From f553c37af25d5c385c92a2e5e72abefc2a348ca9 Mon Sep 17 00:00:00 2001 From: yzj642 Date: Mon, 13 Jun 2022 19:35:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E8=AF=84=E7=BA=A7?= =?UTF-8?q?=E7=94=A8=E6=88=B7level?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/difficulty.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/difficulty.py b/app/difficulty.py index 50aa179..d6ba6af 100644 --- a/app/difficulty.py +++ b/app/difficulty.py @@ -75,12 +75,36 @@ def revert_dict(d): return d2 +def combine_words_through_grammar(lst,d): #通过语法合并同一单词的不同形式 + lst1=lst + for index,word in enumerate(lst): + change_word='' + if word.endswith('ies'): #语法条件匹配 + change_word=word[:-3]+'y' + elif word.endswith('es'): + change_word=word[:-2] + elif word.endswith('s'): + change_word=word[:-1] + elif word.endswith('ed'): + change_word=word[:-2] + elif word.endswith('en'): + change_word=word[:-2] + 'an' + else: + pass + for word2 in d: + if change_word==word2: + lst1[index]=change_word + return lst1 + def user_difficulty_level(d_user, d): d_user2 = revert_dict(d_user) # key is date, and value is a list of words added in that date count = 0 geometric = 1 for date in sorted(d_user2.keys(), reverse=True): # most recently added words are more important while determining user's level lst = d_user2[date] # a list of words + #print(lst) + lst=combine_words_through_grammar(lst,d) #合并单词的不同形式 + #print(lst) lst2 = [] # a list of tuples, (word, difficulty level) for word in lst: if word in d: From bd997d1c66956d29e7f46e0950e05e7b3cdc17fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BC=9F=E6=B5=A9?= <3449275448@qq.com> Date: Mon, 13 Jun 2022 20:39:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'app/difficulty.py'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/difficulty.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/difficulty.py b/app/difficulty.py index d6ba6af..f79ca35 100644 --- a/app/difficulty.py +++ b/app/difficulty.py @@ -94,6 +94,7 @@ def combine_words_through_grammar(lst,d): #通过语法合并同一单词的不 for word2 in d: if change_word==word2: lst1[index]=change_word + break return lst1 def user_difficulty_level(d_user, d):