评审后的修改(words_and_tests.p文件没有提交,为防止版本的控制)
parent
ddbce62089
commit
541f78c7ea
|
@ -37,26 +37,28 @@ def difficulty_level_from_frequency(word, d):
|
||||||
return level
|
return level
|
||||||
|
|
||||||
|
|
||||||
def get_difficulty_level_for_words_and_tests(d_in):
|
def get_difficulty_level_for_words_and_tests(d):
|
||||||
"""
|
"""
|
||||||
对原本的单词库中的单词进行难度评级
|
对原本的单词库中的单词进行难度评级
|
||||||
:param d_in: 存储了单词库pickle文件中的单词的字典
|
:param d: 存储了单词库pickle文件中的单词的字典
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
d = {}
|
result = {}
|
||||||
L = list(d_in.keys()) # in dic, we have test types (e.g., CET4,CET6,BBC) for each word
|
L = list(d.keys()) # in dic, we have test types (e.g., CET4,CET6,BBC) for each word
|
||||||
|
|
||||||
for k in L:
|
for k in L:
|
||||||
if 'CET4' in d_in[k]:
|
if 'CET4' in d[k]:
|
||||||
d[k] = 4 # CET4 word has level 4
|
result[k] = 4 # CET4 word has level 4
|
||||||
elif 'CET6' in d_in[k]:
|
elif 'CET6' in d[k] or 'GRADUATE' in d[k]:
|
||||||
d[k] = 6
|
result[k] = 6
|
||||||
elif 'IELTS' in d_in[k] or 'GRADUATE' in d_in[k]: # 雅思或研究生英语
|
elif 'IELTS' in d[k]: # 雅思或研究生英语
|
||||||
d[k] = 8
|
result[k] = 7
|
||||||
elif 'EnWords' in d_in[k]: # 除基础词汇外的绝大多数词,包括一些犄角旮旯的专业词汇,近九万个,绝大多数我是真不认识
|
elif 'BBC' in d[k]:
|
||||||
d[k] = 7
|
result[k] = 8
|
||||||
|
# elif 'EnWords' in d[k]: # 除基础词汇外的绝大多数词,包括一些犄角旮旯的专业词汇,近九万个,定级不太好处理,绝大多数我是真不认识
|
||||||
|
# result[k] = 7
|
||||||
|
|
||||||
return d # {'apple': 4, ...}
|
return result # {'apple': 4, ...}
|
||||||
|
|
||||||
def simplify_the_words_dict(d):
|
def simplify_the_words_dict(d):
|
||||||
"""
|
"""
|
||||||
|
@ -65,13 +67,13 @@ def simplify_the_words_dict(d):
|
||||||
stem = snowballstemmer.stemmer('english')
|
stem = snowballstemmer.stemmer('english')
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
for j in d: # j 在字典中
|
for k in d: # j 在字典中
|
||||||
temp = stem.stemWord(j) # 提取j得词根
|
temp = stem.stemWord(k) # 提取j得词根
|
||||||
if not temp in result: # 如果这个词根不在结果字典中,则以词根为键、以dic中的等级作为值添加
|
if temp not in result: # 如果这个词根不在结果字典中,则以词根为键、以dic中的等级作为值添加
|
||||||
result[temp] = d[j]
|
result[temp] = d[k]
|
||||||
else: # 如果这个词在结果词典中,则比较一下单词的难度等级是否最小
|
else: # 如果这个词在结果词典中,则比较一下单词的难度等级是否最小
|
||||||
if result[temp] > d[j]:
|
if result[temp] > d[k]:
|
||||||
result[temp] = d[j]
|
result[temp] = d[k]
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue