From 6462ef87ccf8c02bc4c58693ca6de385efb2bc01 Mon Sep 17 00:00:00 2001 From: AsWhitale <1838528479@qq.com> Date: Thu, 29 May 2025 14:16:44 +0800 Subject: [PATCH 1/2] vocabulary --- app/static/wordfreqapp.db | Bin 0 -> 20480 bytes app/vocabulary.py | 61 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 app/static/wordfreqapp.db create mode 100644 app/vocabulary.py diff --git a/app/static/wordfreqapp.db b/app/static/wordfreqapp.db new file mode 100644 index 0000000000000000000000000000000000000000..943d6432c08d6911012a9fb19d0d8ab83a62ca8c GIT binary patch literal 20480 zcmeI&L2KJE6u@yQ&Ds)3)=S8s7tNO?vEHdgq>xrjBJJ@e-soH zMla1uz;uyKSK|E(HPM$kS(VCC 0] + return sum(valid_levels) / len(valid_levels) if valid_levels else 0 + +class ArticleVocabularyLevel(VocabularyLevelEstimator): + def __init__(self, content): + self.content = content + words = re.findall(r'\b[\w-]+\b', content.lower()) + word_levels = [self.get_word_level(word) for word in words] + valid_levels = sorted([lvl for lvl in word_levels if lvl > 0], reverse=True) + self.top_levels = valid_levels[:5] # 取前5个最高难度单词 + + @property + def level(self): + if not self.top_levels: + return 0 + return sum(self.top_levels) / len(self.top_levels) \ No newline at end of file -- 2.17.1 From 98e590dc20b3c704fd0e00aae7b2a8ef6472a899 Mon Sep 17 00:00:00 2001 From: AsWhitale <1838528479@qq.com> Date: Thu, 29 May 2025 14:25:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?Bug585=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E8=8B=A5=E5=B9=B2=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/vocabulary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/vocabulary.py b/app/vocabulary.py index 2098d1c..73864d7 100644 --- a/app/vocabulary.py +++ b/app/vocabulary.py @@ -58,4 +58,4 @@ class ArticleVocabularyLevel(VocabularyLevelEstimator): def level(self): if not self.top_levels: return 0 - return sum(self.top_levels) / len(self.top_levels) \ No newline at end of file + return sum(self.top_levels) / len(self.top_levels) -- 2.17.1