Merge pull request 'Fix Bug 563' (#180) from Bug563-Hui into Alpha-snapshot20240618
Reviewed-on: #180Bug518-Hui
commit
172727f95f
|
@ -64,7 +64,6 @@ def load_record(pickle_fname):
|
||||||
|
|
||||||
def save_frequency_to_pickle(d, pickle_fname):
|
def save_frequency_to_pickle(d, pickle_fname):
|
||||||
f = open(pickle_fname, 'wb')
|
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 = {}
|
d2 = {}
|
||||||
for k in d:
|
for k in d:
|
||||||
if not k in exclusion_lst and not k.isnumeric() and not len(k) < 2:
|
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()
|
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__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
|
|
@ -178,14 +178,17 @@ def user_mark_word(username):
|
||||||
d = load_freq_history(user_freq_record)
|
d = load_freq_history(user_freq_record)
|
||||||
lst_history = pickle_idea2.dict2lst(d)
|
lst_history = pickle_idea2.dict2lst(d)
|
||||||
lst = []
|
lst = []
|
||||||
|
lst2 = []
|
||||||
for word in request.form.getlist('marked'):
|
for word in request.form.getlist('marked'):
|
||||||
|
if not word in pickle_idea2.exclusion_lst:
|
||||||
lst.append((word, [get_time()]))
|
lst.append((word, [get_time()]))
|
||||||
|
lst2.append(word)
|
||||||
d = pickle_idea2.merge_frequency(lst, lst_history)
|
d = pickle_idea2.merge_frequency(lst, lst_history)
|
||||||
if len(lst_history) > 999:
|
if len(lst_history) > 999:
|
||||||
flash('You have way too many words in your difficult-words book. Delete some first.')
|
flash('You have way too many words in your difficult-words book. Delete some first.')
|
||||||
else:
|
else:
|
||||||
pickle_idea2.save_frequency_to_pickle(d, user_freq_record)
|
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))
|
return redirect(url_for('user_bp.userpage', username=username))
|
||||||
else:
|
else:
|
||||||
return 'Under construction'
|
return 'Under construction'
|
||||||
|
|
Loading…
Reference in New Issue