Bug476-ZhangWeiHao-YuHuangtao
parent
541f78c7ea
commit
fc515a7b08
|
@ -7,7 +7,7 @@ import random, glob
|
|||
import hashlib
|
||||
from datetime import datetime
|
||||
from flask import Flask, request, redirect, render_template, url_for, session, abort, flash, get_flashed_messages
|
||||
from difficulty import get_difficulty_level, text_difficulty_level, user_difficulty_level
|
||||
from difficulty import get_difficulty_level_for_user, text_difficulty_level, user_difficulty_level
|
||||
|
||||
|
||||
path_prefix = '/var/www/wordfreq/wordfreq/'
|
||||
|
@ -45,7 +45,7 @@ def get_today_article(user_word_list, articleID):
|
|||
# Choose article according to reader's level
|
||||
d1 = load_freq_history(path_prefix + 'static/frequency/frequency.p')
|
||||
d2 = load_freq_history(path_prefix + 'static/words_and_tests.p')
|
||||
d3 = get_difficulty_level(d1, d2)
|
||||
d3 = get_difficulty_level_for_user(d1, d2)
|
||||
|
||||
d = {}
|
||||
d_user = load_freq_history(user_word_list)
|
||||
|
|
|
@ -37,7 +37,7 @@ def difficulty_level_from_frequency(word, d):
|
|||
return level
|
||||
|
||||
|
||||
def get_difficulty_level_for_words_and_tests(d):
|
||||
def convert_test_type_to_difficulty_level(d):
|
||||
"""
|
||||
对原本的单词库中的单词进行难度评级
|
||||
:param d: 存储了单词库pickle文件中的单词的字典
|
||||
|
@ -51,12 +51,12 @@ def get_difficulty_level_for_words_and_tests(d):
|
|||
result[k] = 4 # CET4 word has level 4
|
||||
elif 'CET6' in d[k] or 'GRADUATE' in d[k]:
|
||||
result[k] = 6
|
||||
elif 'IELTS' in d[k]: # 雅思或研究生英语
|
||||
elif 'IELTS' in d[k]: # 雅思
|
||||
result[k] = 7
|
||||
elif 'BBC' in d[k]:
|
||||
result[k] = 8
|
||||
# elif 'EnWords' in d[k]: # 除基础词汇外的绝大多数词,包括一些犄角旮旯的专业词汇,近九万个,定级不太好处理,绝大多数我是真不认识
|
||||
# result[k] = 7
|
||||
elif 'EnWords' in d[k]: # 除基础词汇外的绝大多数词,包括一些犄角旮旯的专业词汇,近九万个,定级不太好处理,绝大多数我是真不认识
|
||||
result[k] = 3
|
||||
|
||||
return result # {'apple': 4, ...}
|
||||
|
||||
|
@ -78,13 +78,13 @@ def simplify_the_words_dict(d):
|
|||
return result
|
||||
|
||||
|
||||
def get_difficulty_level(d1, d2):
|
||||
def get_difficulty_level_for_user(d1, d2):
|
||||
"""
|
||||
d2 来自于词库的27000个已标记单词
|
||||
d1 用户不会的词
|
||||
在d2的后面添加单词,没有新建一个新的字典
|
||||
"""
|
||||
d2 = get_difficulty_level_for_words_and_tests(d2) # 根据d2的标记评级{'apple': 4, 'abandon': 4, ...}
|
||||
d2 = convert_test_type_to_difficulty_level(d2) # 根据d2的标记评级{'apple': 4, 'abandon': 4, ...}
|
||||
d2_simplified = simplify_the_words_dict(d2) # 提取d2的词根 {'appl': 4, 'abandon': 4, ...}
|
||||
stem = snowballstemmer.stemmer('english')
|
||||
|
||||
|
@ -181,7 +181,7 @@ if __name__ == '__main__':
|
|||
#print(d2)
|
||||
|
||||
|
||||
d3 = get_difficulty_level(d1, d2)
|
||||
d3 = get_difficulty_level_for_user(d1, d2)
|
||||
|
||||
s = '''
|
||||
South Lawn
|
||||
|
|
Loading…
Reference in New Issue