Compare commits
2 Commits
master
...
Bug476-Zha
Author | SHA1 | Date |
---|---|---|
张伟浩 | bd997d1c66 | |
yzj642 | f553c37af2 |
|
@ -75,12 +75,37 @@ def revert_dict(d):
|
||||||
return d2
|
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
|
||||||
|
break
|
||||||
|
return lst1
|
||||||
|
|
||||||
def user_difficulty_level(d_user, d):
|
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
|
d_user2 = revert_dict(d_user) # key is date, and value is a list of words added in that date
|
||||||
count = 0
|
count = 0
|
||||||
geometric = 1
|
geometric = 1
|
||||||
for date in sorted(d_user2.keys(), reverse=True): # most recently added words are more important while determining user's level
|
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
|
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)
|
lst2 = [] # a list of tuples, (word, difficulty level)
|
||||||
for word in lst:
|
for word in lst:
|
||||||
if word in d:
|
if word in d:
|
||||||
|
|
Loading…
Reference in New Issue