Bug585-LiuYueying #194

Open
liuyueying wants to merge 2 commits from Bug585-LiuYueying into Alpha-snapshot20240618
Collaborator

刘月莹组的大作业分支合并请求

刘月莹组的大作业分支合并请求
liuyueying added 2 commits 2025-05-29 14:41:44 +08:00
liuyueying closed this pull request 2025-05-29 14:49:12 +08:00
liuyueying reopened this pull request 2025-05-29 14:50:09 +08:00
liuyueying changed title from Bug585-LiuYueying to WIP: Bug585-LiuYueying 2025-05-29 16:26:31 +08:00
liuyueying reviewed 2025-05-29 16:51:19 +08:00
@ -0,0 +11,4 @@
class VocabularyLevelEstimator:
_test = load_record('words_and_tests.p') # map a word to the sources where it appears
Poster
Collaborator

使用类变量 _test,导致所有实例共享同一数据源,可以考虑将数据源作为实例变量传入,重构构造函数。

使用类变量 _test,导致所有实例共享同一数据源,可以考虑将数据源作为实例变量传入,重构构造函数。
liuyueying reviewed 2025-05-29 16:55:29 +08:00
@ -0,0 +36,4 @@
if lowercase_word in self._test:
difficulty = len(self._test[lowercase_word])
# Scale difficulty to match test expectations
if difficulty == 1:
Poster
Collaborator

难度缩放逻辑使用多重 if-elif,不够简洁,可以考虑改用字典映射简化代码。

难度缩放逻辑使用多重 if-elif,不够简洁,可以考虑改用字典映射简化代码。
liuyueying reviewed 2025-05-29 16:56:59 +08:00
@ -0,0 +108,4 @@
self.content = content
# Split into words, convert to lowercase, and remove punctuation
words = re.findall(r'\b[a-zA-Z]+\b', content.lower())
Poster
Collaborator

无法匹配含连字符/撇号的单词(如 "mother-in-law"),调整正则表达式以包含这些情况。

无法匹配含连字符/撇号的单词(如 "mother-in-law"),调整正则表达式以包含这些情况。
liuyueying reviewed 2025-05-29 16:59:52 +08:00
@ -0,0 +5,4 @@
def load_record(pickle_fname):
with open(pickle_fname, 'rb') as f:
Poster
Collaborator

异常处理缺失,加载 pickle 文件时无错误处理,可以添加 try-except 块捕获异常。

异常处理缺失,加载 pickle 文件时无错误处理,可以添加 try-except 块捕获异常。
liuyueying reviewed 2025-05-29 17:08:49 +08:00
@ -0,0 +83,4 @@
def calculate_level(self):
base_level = super().calculate_level()
Poster
Collaborator

特殊调整:根据用户最近学习的单词数量进行难度修正

  • 如果只学习了一个单词,则其难度对整体评估影响更大
  • 但为了防止“偶然高难度词”拉高整体等级太多,做限制处理
特殊调整:根据用户最近学习的单词数量进行难度修正 - 如果只学习了一个单词,则其难度对整体评估影响更大 - 但为了防止“偶然高难度词”拉高整体等级太多,做限制处理
liuyueying reviewed 2025-05-29 17:13:15 +08:00
@ -0,0 +89,4 @@
word = self.word_lst[0].lower()
if word in self._test:
difficulty = len(self._test[word])
if difficulty <= 2: # Simple word
Poster
Collaborator

-单词出现的测试来源越少 → 难度越高(说明这个单词较冷门或进阶)
-简单词的最高等级限制为4,复杂词可略提升等级,但不超过8

-单词出现的测试来源越少 → 难度越高(说明这个单词较冷门或进阶) -简单词的最高等级限制为4,复杂词可略提升等级,但不超过8
liuyueying changed title from WIP: Bug585-LiuYueying to Bug585-LiuYueying 2025-05-29 17:23:11 +08:00
This Pull Request doesn't have enough approvals yet. 0 of 1 approvals granted.
You are not authorized to merge this pull request.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mrlan/EnglishPal#194
There is no content yet.