Compare commits
	
		
			1 Commits 
		
	
	
		
			master
			...
			Bug344-Jia
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | cb224fe3ab | 
|  | @ -21,12 +21,11 @@ def difficulty_level_from_frequency(word, d): | ||||||
|     level = 1 |     level = 1 | ||||||
|     if not word in d: |     if not word in d: | ||||||
|         return level |         return level | ||||||
|      |     else: | ||||||
|     if 'what' in d: |         if(len(word)<5): #calculate the difficulty level based on length | ||||||
|         ratio = (d['what']+1)/(d[word]+1) # what is a frequent word |         level = math.log(len(word),math.pow(d[word],2)) | ||||||
|         level = math.log( max(ratio, 1), 2) |         else: | ||||||
| 
 |         level = math.log(len[word],d[word]) | ||||||
|     level = min(level, 8)  |  | ||||||
|     return level |     return level | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -44,8 +43,8 @@ def get_difficulty_level(d1, d2): | ||||||
|                 d[k] = 6 |                 d[k] = 6 | ||||||
|             elif 'BBC' in d2[k]: |             elif 'BBC' in d2[k]: | ||||||
|                 d[k] = 8 |                 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. |                 if k in d1:  | ||||||
|                     d[k] = min(difficulty_level_from_frequency(k, d1), d[k]) |                     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: |         elif k in d1: | ||||||
|             d[k] = difficulty_level_from_frequency(k, d1) |             d[k] = difficulty_level_from_frequency(k, d1) | ||||||
| 
 | 
 | ||||||
|  | @ -86,7 +85,7 @@ def user_difficulty_level(d_user, d): | ||||||
|             if word in d: |             if word in d: | ||||||
|                 lst2.append((word, d[word])) |                 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) |         #print(lst3) | ||||||
|         for t in lst3: |         for t in lst3: | ||||||
|             word = t[0] |             word = t[0] | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue