From 750e67ef6bea6791764cec73b59ddec33053bfe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=AA=E5=91=A8=E6=8C=BA?= <2778919974@qq.com> Date: Fri, 28 Jun 2024 20:47:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=AE=80=E5=8D=95?= =?UTF-8?q?=E5=8D=95=E8=AF=8D=E6=9C=AA=E6=88=90=E5=8A=9F=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E7=94=9F=E8=AF=8D=E7=B0=BF=EF=BC=8C=E4=BD=86=E4=BE=9D=E6=97=A7?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E2=80=9Cadded=20****.=E2=80=9D=E7=9A=84?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/pickle_idea2.py | 3 +-- app/user_service.py | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/pickle_idea2.py b/app/pickle_idea2.py index 0da55bc..4c93985 100644 --- a/app/pickle_idea2.py +++ b/app/pickle_idea2.py @@ -64,10 +64,9 @@ 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: + if not k.isnumeric() and not len(k) < 2: d2[k] = list(sorted(d[k])) # 原先这里是d2[k] = list(sorted(set(d[k]))) pickle.dump(d2, f) f.close() diff --git a/app/user_service.py b/app/user_service.py index 27323b8..7f09f5b 100644 --- a/app/user_service.py +++ b/app/user_service.py @@ -178,14 +178,27 @@ def user_mark_word(username): d = load_freq_history(user_freq_record) lst_history = pickle_idea2.dict2lst(d) lst = [] - for word in request.form.getlist('marked'): - lst.append((word, [get_time()])) - 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.') + # pickle_idea2.save_frequency_to_pickle中设置的较为简单的无法加入生词簿的单词,虽然生词簿未添加但添加后顶部依然会显示"Added ***"的信息 + 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'] + add = request.form.getlist('marked') + trueadd = [] + for word in add: + if word not in exclusion_lst: + trueadd.append(word) + lst.append((word, [get_time()])) + if len(trueadd) > 0: # 如果有单词被添加 + 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(trueadd))) # 显示添加的单词 else: - pickle_idea2.save_frequency_to_pickle(d, user_freq_record) - flash('Added %s.' % (', '.join(request.form.getlist('marked')))) + flash('No new words were added. All words were either too simple or already in your list.') # 没有单词被添加 return redirect(url_for('user_bp.userpage', username=username)) else: return 'Under construction' -- 2.17.1 From 706ee48a7d7bc3782aac9faef1c584b5ecaaffa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=AA=E5=91=A8=E6=8C=BA?= <2778919974@qq.com> Date: Fri, 28 Jun 2024 20:57:30 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=AE=80=E5=8D=95?= =?UTF-8?q?=E5=8D=95=E8=AF=8D=E6=9C=AA=E6=88=90=E5=8A=9F=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E7=94=9F=E8=AF=8D=E7=B0=BF=EF=BC=8C=E4=BD=86=E4=BE=9D=E6=97=A7?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E2=80=9Cadded=20****.=E2=80=9D=E7=9A=84?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/user_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/user_service.py b/app/user_service.py index 7f09f5b..eeca743 100644 --- a/app/user_service.py +++ b/app/user_service.py @@ -198,7 +198,7 @@ def user_mark_word(username): pickle_idea2.save_frequency_to_pickle(d, user_freq_record) flash('Added %s.' % (', '.join(trueadd))) # 显示添加的单词 else: - flash('No new words were added. All words were either too simple or already in your list.') # 没有单词被添加 + flash('No new words were added.') # 没有单词被添加 return redirect(url_for('user_bp.userpage', username=username)) else: return 'Under construction' -- 2.17.1 From a08c25a78b8f1274ce465db3dd6883f1fcac5756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=AA=E5=91=A8=E6=8C=BA?= <2778919974@qq.com> Date: Fri, 28 Jun 2024 23:32:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=AE=80=E5=8D=95?= =?UTF-8?q?=E5=8D=95=E8=AF=8D=E6=9C=AA=E6=88=90=E5=8A=9F=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E7=94=9F=E8=AF=8D=E7=B0=BF=EF=BC=8C=E4=BD=86=E4=BE=9D=E6=97=A7?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=98=BE=E7=A4=BA=E2=80=9Cadded=20****.?= =?UTF-8?q?=E2=80=9D=E7=9A=84=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/test/test_bug###_nizhouting.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 app/test/test_bug###_nizhouting.py diff --git a/app/test/test_bug###_nizhouting.py b/app/test/test_bug###_nizhouting.py new file mode 100644 index 0000000..3303348 --- /dev/null +++ b/app/test/test_bug###_nizhouting.py @@ -0,0 +1,2 @@ +def test_add_simple_word_to_vocabulary(driver, URL): + return \ No newline at end of file -- 2.17.1