Improve the speed of loading the next article further after incorporating Chen Qiuwei et al.'s suggestions.
parent
1b211f107d
commit
83bbd8f600
|
@ -18,6 +18,7 @@ def load_record(pickle_fname):
|
|||
return d
|
||||
|
||||
|
||||
ENGLISH_WORD_DIFFICULTY_DICT = {}
|
||||
def convert_test_type_to_difficulty_level(d):
|
||||
"""
|
||||
对原本的单词库中的单词进行难度评级
|
||||
|
@ -39,8 +40,10 @@ def convert_test_type_to_difficulty_level(d):
|
|||
elif 'BBC' in d[k]:
|
||||
result[k] = 8
|
||||
|
||||
return result # {'apple': 4, ...}
|
||||
global ENGLISH_WORD_DIFFICULTY_DICT
|
||||
ENGLISH_WORD_DIFFICULTY_DICT = result
|
||||
|
||||
return result # {'apple': 4, ...}
|
||||
|
||||
def get_difficulty_level_for_user(d1, d2):
|
||||
"""
|
||||
|
@ -49,7 +52,11 @@ def get_difficulty_level_for_user(d1, d2):
|
|||
在d2的后面添加单词,没有新建一个新的字典
|
||||
"""
|
||||
# TODO: convert_test_type_to_difficulty_level() should not be called every time. Each word's difficulty level should be pre-computed.
|
||||
if ENGLISH_WORD_DIFFICULTY_DICT == {}:
|
||||
d2 = convert_test_type_to_difficulty_level(d2) # 根据d2的标记评级{'apple': 4, 'abandon': 4, ...}
|
||||
else:
|
||||
d2 = ENGLISH_WORD_DIFFICULTY_DICT
|
||||
|
||||
stemmer = snowballstemmer.stemmer('english')
|
||||
|
||||
for k in d1: # 用户的词
|
||||
|
|
Loading…
Reference in New Issue