Fix Bug 563
parent
74186df292
commit
46d1793397
|
@ -64,7 +64,6 @@ def load_record(pickle_fname):
|
|||
|
||||
def save_frequency_to_pickle(d, pickle_fname):
|
||||
f = open(pickle_fname, 'wb')
|
||||
exclusion_lst = ['one', 'no', 'has', 'had', 'do', 'that', 'have', 'by', 'not', 'but', 'we', 'this', 'my', 'him', 'so', 'or', 'as', 'are', 'it', 'from', 'with', 'be', 'can', 'for', 'an', 'if', 'who', 'whom', 'whose', 'which', 'the', 'to', 'a', 'of', 'and', 'you', 'i', 'he', 'she', 'they', 'me', 'was', 'were', 'is', 'in', 'at', 'on', 'their', 'his', 'her', 's', 'said', 'all', 'did', 'been', 'w']
|
||||
d2 = {}
|
||||
for k in d:
|
||||
if not k in exclusion_lst and not k.isnumeric() and not len(k) < 2:
|
||||
|
@ -73,6 +72,7 @@ def save_frequency_to_pickle(d, pickle_fname):
|
|||
f.close()
|
||||
|
||||
|
||||
exclusion_lst = ['one', 'no', 'has', 'had', 'do', 'that', 'have', 'by', 'not', 'but', 'we', 'this', 'my', 'him', 'so', 'or', 'as', 'are', 'it', 'from', 'with', 'be', 'can', 'for', 'an', 'if', 'who', 'whom', 'whose', 'which', 'the', 'to', 'a', 'of', 'and', 'you', 'i', 'he', 'she', 'they', 'me', 'was', 'were', 'is', 'in', 'at', 'on', 'their', 'his', 'her', 's', 'said', 'all', 'did', 'been', 'w']
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
|
|
|
@ -178,14 +178,17 @@ def user_mark_word(username):
|
|||
d = load_freq_history(user_freq_record)
|
||||
lst_history = pickle_idea2.dict2lst(d)
|
||||
lst = []
|
||||
lst2 = []
|
||||
for word in request.form.getlist('marked'):
|
||||
lst.append((word, [get_time()]))
|
||||
if not word in pickle_idea2.exclusion_lst:
|
||||
lst.append((word, [get_time()]))
|
||||
lst2.append(word)
|
||||
d = pickle_idea2.merge_frequency(lst, lst_history)
|
||||
if len(lst_history) > 999:
|
||||
flash('You have way too many words in your difficult-words book. Delete some first.')
|
||||
else:
|
||||
pickle_idea2.save_frequency_to_pickle(d, user_freq_record)
|
||||
flash('Added %s.' % (', '.join(request.form.getlist('marked'))))
|
||||
flash('Added %s.' % ', '.join(lst2))
|
||||
return redirect(url_for('user_bp.userpage', username=username))
|
||||
else:
|
||||
return 'Under construction'
|
||||
|
|
Loading…
Reference in New Issue