From 21ce86d2052f461ae4548c6894ff8eaa3a5ca915 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Thu, 13 Aug 2020 09:55:23 +0800 Subject: main.py and wordfreqWEB.py: do not show word frequency if it is 1. --- app/README.md | 2 +- app/main.py | 5 ++++- app/wordfreqWEB.py | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/README.md b/app/README.md index ab7c217..124afa2 100644 --- a/app/README.md +++ b/app/README.md @@ -48,4 +48,4 @@ sudo docker ps -a sudo docker logs image_name, where image name could be obtained from sudo docker ps. -build.sh contains all the above commands. Run sudo ./build.sh to rebuild the web application. +build.sh contains all the above commands. Run "sudo ./build.sh" to rebuild the web application. diff --git a/app/main.py b/app/main.py index 52954fc..3368612 100644 --- a/app/main.py +++ b/app/main.py @@ -305,7 +305,10 @@ def userpage(username): word = x[0] freq = x[1] if isinstance(d[word], list): # d[word] is a list of dates - page += '%s (%d)\n' % (youdao_link(word), word, '; '.join(d[word]), freq) + if freq > 1: + page += '%s (%d)\n' % (youdao_link(word), word, '; '.join(d[word]), freq) + else: + page += '%s\n' % (youdao_link(word), word) elif isinstance(d[word], int): # d[word] is a frequency. to migrate from old format. page += '%s%d\n' % (youdao_link(word), word, freq) diff --git a/app/wordfreqWEB.py b/app/wordfreqWEB.py index 7107791..2c0e4be 100644 --- a/app/wordfreqWEB.py +++ b/app/wordfreqWEB.py @@ -269,7 +269,10 @@ def userpage(username): word = x[0] freq = x[1] if isinstance(d[word], list): # d[word] is a list of dates - page += '%s (%d)\n' % (youdao_link(word), word, '; '.join(d[word]), freq) + if freq > 1: + page += '%s (%d)\n' % (youdao_link(word), word, '; '.join(d[word]), freq) + else: + page += '%s\n' % (youdao_link(word), word) elif isinstance(d[word], int): # d[word] is a frequency. to migrate from old format. page += '%s%d\n' % (youdao_link(word), word, freq) -- cgit v1.2.1