Compare commits
1 Commits
master
...
Bug344-Jia
Author | SHA1 | Date |
---|---|---|
姜雪虹 | cb224fe3ab |
|
@ -21,12 +21,11 @@ def difficulty_level_from_frequency(word, d):
|
|||
level = 1
|
||||
if not word in d:
|
||||
return level
|
||||
|
||||
if 'what' in d:
|
||||
ratio = (d['what']+1)/(d[word]+1) # what is a frequent word
|
||||
level = math.log( max(ratio, 1), 2)
|
||||
|
||||
level = min(level, 8)
|
||||
else:
|
||||
if(len(word)<5): #calculate the difficulty level based on length
|
||||
level = math.log(len(word),math.pow(d[word],2))
|
||||
else:
|
||||
level = math.log(len[word],d[word])
|
||||
return level
|
||||
|
||||
|
||||
|
@ -44,8 +43,8 @@ def get_difficulty_level(d1, d2):
|
|||
d[k] = 6
|
||||
elif 'BBC' in d2[k]:
|
||||
d[k] = 8
|
||||
if k in d1: # BBC could contain easy words that are not in CET4 or CET6. So 4 is not reasonable. Recompute difficulty level.
|
||||
d[k] = min(difficulty_level_from_frequency(k, d1), d[k])
|
||||
if k in d1:
|
||||
d[k] = difficulty_level_from_frequency(k, d1)# BBC word rating 8 is too high,it is based on word fre
|
||||
elif k in d1:
|
||||
d[k] = difficulty_level_from_frequency(k, d1)
|
||||
|
||||
|
@ -86,7 +85,7 @@ def user_difficulty_level(d_user, d):
|
|||
if word in d:
|
||||
lst2.append((word, d[word]))
|
||||
|
||||
lst3 = sort_in_ascending_order(lst2) # easiest tuple first
|
||||
lst3 = sort_in_descending_order(lst2) # easiest tuple first
|
||||
#print(lst3)
|
||||
for t in lst3:
|
||||
word = t[0]
|
||||
|
|
Loading…
Reference in New Issue