Compare commits

..

No commits in common. "172727f95f965210e9b8651a76bd0e48e26192ae" and "74186df29249c41089a6853f3e1f686d3157fbcb" have entirely different histories.

2 changed files with 3 additions and 6 deletions

View File

@ -64,6 +64,7 @@ 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:
@ -72,7 +73,6 @@ 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__':

View File

@ -178,17 +178,14 @@ 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(lst2)) flash('Added %s.' % (', '.join(request.form.getlist('marked'))))
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'