Compare commits

...

2 Commits

Author SHA1 Message Date
mrlan 172727f95f Merge pull request 'Fix Bug 563' (#180) from Bug563-Hui into Alpha-snapshot20240618
Reviewed-on: #180
2024-09-02 15:18:12 +08:00
Lan Hui 46d1793397 Fix Bug 563 2024-09-02 15:16:11 +08:00
2 changed files with 6 additions and 3 deletions

View File

@ -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__':

View File

@ -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'):
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'