From 868104da6c126371a0082a81994506f18b8c644d Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Mon, 30 Aug 2021 07:43:41 +0800 Subject: [PATCH 1/2] main.py: let the range be more flexible. --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index d23c272..c2129d4 100644 --- a/app/main.py +++ b/app/main.py @@ -115,7 +115,7 @@ def get_today_article(user_word_list, articleID): for reading in result: text_level = text_difficulty_level(reading['text'], d3) #print('TEXT_LEVEL %4.2f' % (text_level)) - if within_range(text_level, user_level, 0.5): + if within_range(text_level, user_level, (8.0 - user_level)*0.1): d = reading break From baf333678a3ba21b7781df8d411692b1314c6767 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Mon, 30 Aug 2021 08:18:47 +0800 Subject: [PATCH 2/2] main.py and build.sh: shuffle the articles first before select one, relax selection range, keep the database main.py: - shuffle the articles first before select one - relax selection range (see the function call within_range) build.sh: - keep the database wordfreqapp.db so that the user could login again next time after the program is rebuilt. Hui --- app/main.py | 4 ++-- build.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/main.py b/app/main.py index c2129d4..9e78216 100644 --- a/app/main.py +++ b/app/main.py @@ -99,6 +99,7 @@ def get_today_article(user_word_list, articleID): rq.instructions('SELECT * FROM article WHERE article_id=%d' % (articleID)) rq.do() result = rq.get_results() + random.shuffle(result) # Choose article according to reader's level d1 = load_freq_history(path_prefix + 'static/frequency/frequency.p') @@ -114,8 +115,7 @@ def get_today_article(user_word_list, articleID): if articleID == None: for reading in result: text_level = text_difficulty_level(reading['text'], d3) - #print('TEXT_LEVEL %4.2f' % (text_level)) - if within_range(text_level, user_level, (8.0 - user_level)*0.1): + if within_range(text_level, user_level, (8.0 - user_level)*0.8): d = reading break diff --git a/build.sh b/build.sh index 9ac3f1a..89d6543 100755 --- a/build.sh +++ b/build.sh @@ -10,7 +10,7 @@ sudo docker rm EnglishPal sudo docker build -t englishpal . # Run the application -sudo docker run -d --name EnglishPal -p 90:80 -v /home/lanhui/englishpal/app/static/frequency:/app/static/frequency -t englishpal # for permanently saving data +sudo docker run -d --name EnglishPal -p 90:80 -v /home/lanhui/englishpal/app/static/frequency:/app/static/frequency -v /home/lanhui/englishpal/app/static/:/app/static/ -t englishpal # for permanently saving data # Save space. Run it after sudo docker run sudo docker system prune -a -f