summaryrefslogtreecommitdiff
path: root/app/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/main.py')
-rw-r--r--app/main.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/app/main.py b/app/main.py
index 38250b3..cccb46a 100644
--- a/app/main.py
+++ b/app/main.py
@@ -87,10 +87,11 @@ def get_today_article(user_word_list):
d3 = get_difficulty_level(d1, d2)
d = {}
- no_match = 0
d_user = load_freq_history(user_word_list)
user_level = user_difficulty_level(d_user, d3) # more consideration as user's behaviour is dynamic. Time factor should be considered.
- random.shuffle(result) # shuffle list
+ random.shuffle(result) # shuffle list
+ d = random.choice(result)
+ text_level = text_difficulty_level(d['text'], d3)
for reading in result:
text_level = text_difficulty_level(reading['text'], d3)
#print('TEXT_LEVEL %4.2f' % (text_level))
@@ -98,12 +99,7 @@ def get_today_article(user_word_list):
d = reading
break
- if len(d) == 0:
- no_match = 1
- d = random.choice(result)
- text_level = text_difficulty_level(d['text'], d3)
-
- s = '<p><i>According to your word list, your level is %4.2f and we have chosen an article with a difficulty level of %4.2f for you.</i></p>' % (user_level, text_level)
+ s = '<p><i>According to your word list, your level is <b>%4.2f</b> and we have chosen an article with a difficulty level of <b>%4.2f</b> for you.</i></p>' % (user_level, text_level)
s += '<p><b>%s</b></p>' % (d['date'])
s += '<p>%s</p>' % (d['text'])
s += '<p><i>%s</i></p>' % (d['source'])