forked from mrlan/EnglishPal
				
			Refactoring parameter names and partial function names to make them more reasonable
							parent
							
								
									f741f84b4d
								
							
						
					
					
						commit
						ffd2d516fa
					
				| 
						 | 
					@ -22,12 +22,12 @@ def total_number_of_essays():
 | 
				
			||||||
    return len(result)
 | 
					    return len(result)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_article_title(article):
 | 
					def get_article_title(s):
 | 
				
			||||||
    return article.split('\n')[0]
 | 
					    return s.split('\n')[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_article_body(article):
 | 
					def get_article_body(s):
 | 
				
			||||||
    lst = article.split('\n')
 | 
					    lst = s.split('\n')
 | 
				
			||||||
    lst.pop(0)  # remove the first line
 | 
					    lst.pop(0)  # remove the first line
 | 
				
			||||||
    return '\n'.join(lst)
 | 
					    return '\n'.join(lst)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -111,11 +111,11 @@ def within_range(x, y, r):
 | 
				
			||||||
    return x > y and abs(x - y) <= r
 | 
					    return x > y and abs(x - y) <= r
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_question_part(article):
 | 
					def get_question_part(s):
 | 
				
			||||||
    article = article.strip()
 | 
					    s = s.strip()
 | 
				
			||||||
    result = []
 | 
					    result = []
 | 
				
			||||||
    flag = 0
 | 
					    flag = 0
 | 
				
			||||||
    for line in article.split('\n'):
 | 
					    for line in s.split('\n'):
 | 
				
			||||||
        line = line.strip()
 | 
					        line = line.strip()
 | 
				
			||||||
        if line == 'QUESTION':
 | 
					        if line == 'QUESTION':
 | 
				
			||||||
            result.append(line)
 | 
					            result.append(line)
 | 
				
			||||||
| 
						 | 
					@ -127,11 +127,11 @@ def get_question_part(article):
 | 
				
			||||||
    return '\n'.join(result)
 | 
					    return '\n'.join(result)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_answer_part(article):
 | 
					def get_answer_part(s):
 | 
				
			||||||
    article = article.strip()
 | 
					    s = s.strip()
 | 
				
			||||||
    result = []
 | 
					    result = []
 | 
				
			||||||
    flag = 0
 | 
					    flag = 0
 | 
				
			||||||
    for line in article.split('\n'):
 | 
					    for line in s.split('\n'):
 | 
				
			||||||
        line = line.strip()
 | 
					        line = line.strip()
 | 
				
			||||||
        if line == 'ANSWER':
 | 
					        if line == 'ANSWER':
 | 
				
			||||||
            flag = 1
 | 
					            flag = 1
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,6 @@ import string
 | 
				
			||||||
from datetime import datetime, timedelta
 | 
					from datetime import datetime, timedelta
 | 
				
			||||||
from UseSqlite import InsertQuery, RecordQuery
 | 
					from UseSqlite import InsertQuery, RecordQuery
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
def md5(s):
 | 
					def md5(s):
 | 
				
			||||||
    '''
 | 
					    '''
 | 
				
			||||||
    MD5摘要
 | 
					    MD5摘要
 | 
				
			||||||
| 
						 | 
					@ -13,16 +12,14 @@ def md5(s):
 | 
				
			||||||
    h = hashlib.md5(s.encode(encoding='utf-8'))
 | 
					    h = hashlib.md5(s.encode(encoding='utf-8'))
 | 
				
			||||||
    return h.hexdigest()
 | 
					    return h.hexdigest()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
# import model.user after the defination of md5(s) to avoid circular import
 | 
					# import model.user after the defination of md5(s) to avoid circular import
 | 
				
			||||||
from model.user import get_user_by_username, insert_user, update_password_by_username
 | 
					from model.user import get_user_by_username, insert_user, update_password_by_username
 | 
				
			||||||
 | 
					
 | 
				
			||||||
path_prefix = '/var/www/wordfreq/wordfreq/'
 | 
					path_prefix = '/var/www/wordfreq/wordfreq/'
 | 
				
			||||||
path_prefix = './'  # comment this line in deployment
 | 
					path_prefix = './'  # comment this line in deployment
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def verify_pass(newpass,oldpass):
 | 
				
			||||||
def verify_pass(new_password, old_password):
 | 
					    if(newpass==oldpass):
 | 
				
			||||||
    if new_password == old_password:
 | 
					 | 
				
			||||||
        return True
 | 
					        return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,6 +43,7 @@ def signup():
 | 
				
			||||||
                return jsonify({'status': '1'})
 | 
					                return jsonify({'status': '1'})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@accountService.route("/login", methods=['GET', 'POST'])
 | 
					@accountService.route("/login", methods=['GET', 'POST'])
 | 
				
			||||||
def login():
 | 
					def login():
 | 
				
			||||||
    '''
 | 
					    '''
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,25 +18,25 @@ def load_record(pickle_fname):
 | 
				
			||||||
    return d
 | 
					    return d
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def convert_test_type_to_difficulty_level(words_dict):
 | 
					def convert_test_type_to_difficulty_level(d):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    对原本的单词库中的单词进行难度评级
 | 
					    对原本的单词库中的单词进行难度评级
 | 
				
			||||||
    :param words_dict: 存储了单词库pickle文件中的单词的字典
 | 
					    :param d: 存储了单词库pickle文件中的单词的字典
 | 
				
			||||||
    :return:
 | 
					    :return:
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    result = {}
 | 
					    result = {}
 | 
				
			||||||
    words_lst = list(words_dict.keys())  # in words_dict, we have test types (e.g., CET4,CET6,BBC) for each word
 | 
					    L = list(d.keys())  # in d, we have test types (e.g., CET4,CET6,BBC) for each word
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for k in words_lst:
 | 
					    for k in L:
 | 
				
			||||||
        if 'CET4' in words_dict[k]:
 | 
					        if 'CET4' in d[k]:
 | 
				
			||||||
            result[k] = 4  # CET4 word has level 4
 | 
					            result[k] = 4  # CET4 word has level 4
 | 
				
			||||||
        elif 'OXFORD3000' in words_dict[k]:
 | 
					        elif 'OXFORD3000' in d[k]:
 | 
				
			||||||
            result[k] = 5
 | 
					            result[k] = 5
 | 
				
			||||||
        elif 'CET6' in words_dict[k] or 'GRADUATE' in words_dict[k]:
 | 
					        elif 'CET6' in d[k] or 'GRADUATE' in d[k]:
 | 
				
			||||||
            result[k] = 6
 | 
					            result[k] = 6
 | 
				
			||||||
        elif 'OXFORD5000' in words_dict[k] or 'IELTS' in words_dict[k]:
 | 
					        elif 'OXFORD5000' in d[k] or 'IELTS' in d[k]:
 | 
				
			||||||
            result[k] = 7
 | 
					            result[k] = 7
 | 
				
			||||||
        elif 'BBC' in words_dict[k]:
 | 
					        elif 'BBC' in d[k]:
 | 
				
			||||||
            result[k] = 8
 | 
					            result[k] = 8
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return result  # {'apple': 4, ...}
 | 
					    return result  # {'apple': 4, ...}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,7 +63,7 @@ def mark_word():
 | 
				
			||||||
    '''
 | 
					    '''
 | 
				
			||||||
    if request.method == 'POST':
 | 
					    if request.method == 'POST':
 | 
				
			||||||
        d = load_freq_history(path_prefix + 'static/frequency/frequency.p')
 | 
					        d = load_freq_history(path_prefix + 'static/frequency/frequency.p')
 | 
				
			||||||
        lst_history = pickle_idea.dict_to_lst(d)
 | 
					        lst_history = pickle_idea.dict2lst(d)
 | 
				
			||||||
        lst = []
 | 
					        lst = []
 | 
				
			||||||
        for word in request.form.getlist('marked'):
 | 
					        for word in request.form.getlist('marked'):
 | 
				
			||||||
            lst.append((word, 1))
 | 
					            lst.append((word, 1))
 | 
				
			||||||
| 
						 | 
					@ -86,7 +86,7 @@ def mainpage():
 | 
				
			||||||
        lst = f.get_freq()
 | 
					        lst = f.get_freq()
 | 
				
			||||||
        # save history
 | 
					        # save history
 | 
				
			||||||
        d = load_freq_history(path_prefix + 'static/frequency/frequency.p')
 | 
					        d = load_freq_history(path_prefix + 'static/frequency/frequency.p')
 | 
				
			||||||
        lst_history = pickle_idea.dict_to_lst(d)
 | 
					        lst_history = pickle_idea.dict2lst(d)
 | 
				
			||||||
        d = pickle_idea.merge_frequency(lst, lst_history)
 | 
					        d = pickle_idea.merge_frequency(lst, lst_history)
 | 
				
			||||||
        pickle_idea.save_frequency_to_pickle(d, path_prefix + 'static/frequency/frequency.p')
 | 
					        pickle_idea.save_frequency_to_pickle(d, path_prefix + 'static/frequency/frequency.p')
 | 
				
			||||||
        return render_template('mainpage_post.html', lst=lst, yml=Yaml.yml)
 | 
					        return render_template('mainpage_post.html', lst=lst, yml=Yaml.yml)
 | 
				
			||||||
| 
						 | 
					@ -96,7 +96,7 @@ def mainpage():
 | 
				
			||||||
        number_of_essays = total_number_of_essays()
 | 
					        number_of_essays = total_number_of_essays()
 | 
				
			||||||
        d = load_freq_history(path_prefix + 'static/frequency/frequency.p')
 | 
					        d = load_freq_history(path_prefix + 'static/frequency/frequency.p')
 | 
				
			||||||
        d_len = len(d)
 | 
					        d_len = len(d)
 | 
				
			||||||
        lst = sort_in_descending_order(pickle_idea.dict_to_lst(d))
 | 
					        lst = sort_in_descending_order(pickle_idea.dict2lst(d))
 | 
				
			||||||
        return render_template('mainpage_get.html', 
 | 
					        return render_template('mainpage_get.html', 
 | 
				
			||||||
                               admin_name=ADMIN_NAME,
 | 
					                               admin_name=ADMIN_NAME,
 | 
				
			||||||
                               random_ads=random_ads,
 | 
					                               random_ads=random_ads,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,7 @@ import pickle
 | 
				
			||||||
from datetime import datetime
 | 
					from datetime import datetime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def lst_to_dict(lst, d):
 | 
					def lst2dict(lst, d):
 | 
				
			||||||
    ''' 
 | 
					    ''' 
 | 
				
			||||||
    Store the information in list lst to dictionary d. 
 | 
					    Store the information in list lst to dictionary d. 
 | 
				
			||||||
    Note: nothing is returned.
 | 
					    Note: nothing is returned.
 | 
				
			||||||
| 
						 | 
					@ -25,14 +25,14 @@ def lst_to_dict(lst, d):
 | 
				
			||||||
            d[word] += freq
 | 
					            d[word] += freq
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def dict_to_lst(d):
 | 
					def dict2lst(d):
 | 
				
			||||||
    return list(d.items()) # a list of (key, value) pairs
 | 
					    return list(d.items()) # a list of (key, value) pairs
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def merge_frequency(list1, list2):
 | 
					def merge_frequency(lst1, lst2):
 | 
				
			||||||
    d = {}
 | 
					    d = {}
 | 
				
			||||||
    lst_to_dict(list1, d)
 | 
					    lst2dict(lst1, d)
 | 
				
			||||||
    lst_to_dict(list2, d)
 | 
					    lst2dict(lst2, d)
 | 
				
			||||||
    return d
 | 
					    return d
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,7 +54,6 @@ def save_frequency_to_pickle(d, pickle_fname):
 | 
				
			||||||
    pickle.dump(d2, f)
 | 
					    pickle.dump(d2, f)
 | 
				
			||||||
    f.close()
 | 
					    f.close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
def unfamiliar(path,word):
 | 
					def unfamiliar(path,word):
 | 
				
			||||||
    f = open(path,"rb")
 | 
					    f = open(path,"rb")
 | 
				
			||||||
    dic = pickle.load(f)
 | 
					    dic = pickle.load(f)
 | 
				
			||||||
| 
						 | 
					@ -62,7 +61,6 @@ def unfamiliar(path, word):
 | 
				
			||||||
    fp = open(path,"wb")
 | 
					    fp = open(path,"wb")
 | 
				
			||||||
    pickle.dump(dic,fp)
 | 
					    pickle.dump(dic,fp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
def familiar(path,word):
 | 
					def familiar(path,word):
 | 
				
			||||||
    f = open(path,"rb")
 | 
					    f = open(path,"rb")
 | 
				
			||||||
    dic = pickle.load(f)
 | 
					    dic = pickle.load(f)
 | 
				
			||||||
| 
						 | 
					@ -77,12 +75,12 @@ if __name__ == '__main__':
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    lst1 = [('apple',2),  ('banana',1)]
 | 
					    lst1 = [('apple',2),  ('banana',1)]
 | 
				
			||||||
    d = {}
 | 
					    d = {}
 | 
				
			||||||
    lst_to_dict(lst1, d) # d will change
 | 
					    lst2dict(lst1, d) # d will change
 | 
				
			||||||
    save_frequency_to_pickle(d, 'frequency.p') # frequency.p is our database
 | 
					    save_frequency_to_pickle(d, 'frequency.p') # frequency.p is our database
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    lst2 = [('banana',2), ('orange', 4)]
 | 
					    lst2 = [('banana',2), ('orange', 4)]
 | 
				
			||||||
    d = load_record('frequency.p')
 | 
					    d = load_record('frequency.p')
 | 
				
			||||||
    lst1 = dict_to_lst(d)
 | 
					    lst1 = dict2lst(d)
 | 
				
			||||||
    d = merge_frequency(lst2, lst1)
 | 
					    d = merge_frequency(lst2, lst1)
 | 
				
			||||||
    print(d)
 | 
					    print(d)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,6 @@
 | 
				
			||||||
import pickle
 | 
					import pickle
 | 
				
			||||||
from datetime import datetime
 | 
					from datetime import datetime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
def lst2dict(lst, d):
 | 
					def lst2dict(lst, d):
 | 
				
			||||||
    ''' 
 | 
					    ''' 
 | 
				
			||||||
    Store the information in list lst to dictionary d. 
 | 
					    Store the information in list lst to dictionary d. 
 | 
				
			||||||
| 
						 | 
					@ -26,7 +25,6 @@ def lst2dict(lst, d):
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            d[word] += dates
 | 
					            d[word] += dates
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
def deleteRecord(path,word):
 | 
					def deleteRecord(path,word):
 | 
				
			||||||
    with open(path, 'rb') as f:
 | 
					    with open(path, 'rb') as f:
 | 
				
			||||||
        db = pickle.load(f)
 | 
					        db = pickle.load(f)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -93,7 +93,7 @@ def familiar(username, word):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@userService.route("/<username>/<word>/del", methods=['GET', 'POST'])
 | 
					@userService.route("/<username>/<word>/del", methods=['GET', 'POST'])
 | 
				
			||||||
def delete_word(username, word):
 | 
					def deleteword(username, word):
 | 
				
			||||||
    '''
 | 
					    '''
 | 
				
			||||||
    删除单词
 | 
					    删除单词
 | 
				
			||||||
    :param username: 用户名
 | 
					    :param username: 用户名
 | 
				
			||||||
| 
						 | 
					@ -181,7 +181,6 @@ def user_mark_word(username):
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        return 'Under construction'
 | 
					        return 'Under construction'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
def get_time():
 | 
					def get_time():
 | 
				
			||||||
    '''
 | 
					    '''
 | 
				
			||||||
    获取当前时间
 | 
					    获取当前时间
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,8 +9,7 @@ import operator
 | 
				
			||||||
import os, sys # 引入模块sys,因为我要用里面的sys.argv列表中的信息来读取命令行参数。
 | 
					import os, sys # 引入模块sys,因为我要用里面的sys.argv列表中的信息来读取命令行参数。
 | 
				
			||||||
import pickle_idea
 | 
					import pickle_idea
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def freq(fruit):
 | 
				
			||||||
def freq(s):
 | 
					 | 
				
			||||||
    '''
 | 
					    '''
 | 
				
			||||||
    功能: 把字符串转成列表。 目的是得到每个单词的频率。
 | 
					    功能: 把字符串转成列表。 目的是得到每个单词的频率。
 | 
				
			||||||
    输入: 字符串
 | 
					    输入: 字符串
 | 
				
			||||||
| 
						 | 
					@ -19,26 +18,27 @@ def freq(s):
 | 
				
			||||||
    '''
 | 
					    '''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    result = []
 | 
					    result = []
 | 
				
			||||||
    s = s.lower()  # 字母转小写
 | 
					    
 | 
				
			||||||
    word_lst = s.split()  # 字符串转成list
 | 
					    fruit = fruit.lower() # 字母转小写
 | 
				
			||||||
    c = collections.Counter(word_lst)
 | 
					    flst = fruit.split()  # 字符串转成list
 | 
				
			||||||
 | 
					    c = collections.Counter(flst)
 | 
				
			||||||
    result = c.most_common()
 | 
					    result = c.most_common()
 | 
				
			||||||
    return result
 | 
					    return result
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def youdao_link(word):  # 有道链接
 | 
					def youdao_link(s): # 有道链接
 | 
				
			||||||
    link = 'http://youdao.com/w/eng/' + word + '/#keyfrom=dict2.index'  # 网址
 | 
					    link = 'http://youdao.com/w/eng/' + s + '/#keyfrom=dict2.index'# 网址
 | 
				
			||||||
    return link
 | 
					    return link
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def file_to_str(f_name):  # 文件转字符
 | 
					def file2str(fname):#文件转字符
 | 
				
			||||||
    f = open(f_name)  # 打开
 | 
					    f = open(fname) #打开
 | 
				
			||||||
    f_str = f.read()  # 读取
 | 
					    s = f.read()    #读取
 | 
				
			||||||
    f.close()       #关闭
 | 
					    f.close()       #关闭
 | 
				
			||||||
    return f_str
 | 
					    return s
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def remove_punctuation(s):  # 这里是words_text是形参 (parameter)。函数被调用时才给words_text赋值。
 | 
					def remove_punctuation(s): # 这里是s是形参 (parameter)。函数被调用时才给s赋值。
 | 
				
			||||||
    special_characters = '\_©~<=>+-/[]*&$%^@.,?!:;#()"“”—‘’{}|' # 把里面的字符都去掉
 | 
					    special_characters = '\_©~<=>+-/[]*&$%^@.,?!:;#()"“”—‘’{}|' # 把里面的字符都去掉
 | 
				
			||||||
    for c in special_characters:
 | 
					    for c in special_characters:
 | 
				
			||||||
        s = s.replace(c, ' ') # 防止出现把 apple,apple 移掉逗号后变成 appleapple 情况
 | 
					        s = s.replace(c, ' ') # 防止出现把 apple,apple 移掉逗号后变成 appleapple 情况
 | 
				
			||||||
| 
						 | 
					@ -47,15 +47,15 @@ def remove_punctuation(s):  # 这里是words_text是形参 (parameter)。函数
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    if '\'' in s:
 | 
					    if '\'' in s:
 | 
				
			||||||
        n = len(s)
 | 
					        n = len(s)
 | 
				
			||||||
        characters = ''  # 用来收集我需要保留的字符
 | 
					        t = '' # 用来收集我需要保留的字符
 | 
				
			||||||
        for i in range(n): # 只有单引号前后都有英文字符,才保留
 | 
					        for i in range(n): # 只有单引号前后都有英文字符,才保留
 | 
				
			||||||
            if s[i] == '\'':
 | 
					            if s[i] == '\'':
 | 
				
			||||||
                i_is_ok = i - 1 >= 0 and i + 1 < n
 | 
					                i_is_ok = i - 1 >= 0 and i + 1 < n
 | 
				
			||||||
                if i_is_ok and s[i-1] in string.ascii_letters and s[i+1] in string.ascii_letters:
 | 
					                if i_is_ok and s[i-1] in string.ascii_letters and s[i+1] in string.ascii_letters:
 | 
				
			||||||
                    characters += s[i]
 | 
					                    t += s[i]
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                characters += s[i]
 | 
					                t += s[i]
 | 
				
			||||||
        return characters
 | 
					        return t
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        return s
 | 
					        return s
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -93,7 +93,7 @@ if __name__ == '__main__':
 | 
				
			||||||
        s = input()
 | 
					        s = input()
 | 
				
			||||||
    elif num == 2: # 从文件读入字符串
 | 
					    elif num == 2: # 从文件读入字符串
 | 
				
			||||||
        fname = sys.argv[1]
 | 
					        fname = sys.argv[1]
 | 
				
			||||||
        s = file_to_str(fname)
 | 
					        s = file2str(fname)
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        print('I can accept at most 2 arguments.')
 | 
					        print('I can accept at most 2 arguments.')
 | 
				
			||||||
        sys.exit()# 结束程序运行, 下面的代码不会被执行了。
 | 
					        sys.exit()# 结束程序运行, 下面的代码不会被执行了。
 | 
				
			||||||
| 
						 | 
					@ -112,9 +112,12 @@ if __name__ == '__main__':
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        d = {}
 | 
					        d = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    print(sort_in_descending_order(pickle_idea.dict_to_lst(d)))
 | 
					    print(sort_in_descending_order(pickle_idea.dict2lst(d)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # 合并频率
 | 
					    # 合并频率
 | 
				
			||||||
    lst_history = pickle_idea.dict_to_lst(d)
 | 
					    lst_history = pickle_idea.dict2lst(d)
 | 
				
			||||||
    d = pickle_idea.merge_frequency(L, lst_history)
 | 
					    d = pickle_idea.merge_frequency(L, lst_history)
 | 
				
			||||||
    pickle_idea.save_frequency_to_pickle(d, 'frequency.p')
 | 
					    pickle_idea.save_frequency_to_pickle(d, 'frequency.p')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
Flask==2.2.3
 | 
					Flask==1.1.2
 | 
				
			||||||
selenium==3.141.0
 | 
					selenium==3.141.0
 | 
				
			||||||
PyYAML~=6.0
 | 
					PyYAML~=6.0
 | 
				
			||||||
pony==0.7.16
 | 
					pony==0.7.16
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue