fix: 更新 test_lowercase_boolean_detected 断言匹配 R20 re.IGNORECASE 行为
CI / backend (push) Canceled after 0s
CI / frontend (push) Canceled after 0s

P20 R20-3 为 is_pubmed_syntax() 布尔正则添加了 re.IGNORECASE,
小写 and/or/not 现在正确触发 PubMed 语法检测。更新测试断言以匹配新行为,
并在 P1-2 文档中注明 P20 修订。
This commit is contained in:
34047007@qq.com
2026-07-28 16:33:16 +08:00
parent 5dcf639b0b
commit 53cf1d6b70
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -32,8 +32,8 @@ class TestIsPubmedSyntax:
assert not is_pubmed_syntax(None)
def test_lowercase_boolean_detected(self):
"""小写的 and/or/not 识别为 PubMed 语法(P11: 仅大写 AND/OR/NOT 才是 PubMed 布尔符"""
assert not is_pubmed_syntax("cancer and therapy")
"""小写的 and/or/not 识别为 PubMed 语法(P20: 添加 re.IGNORECASE,统一处理大小写"""
assert is_pubmed_syntax("cancer and therapy")
class TestTokenise:
+1
View File
@@ -860,6 +860,7 @@
- **根因**`re.search` 使用 `re.IGNORECASE` 标志。`"diet and exercise in cancer"` 中的 `and` 被识别为 PubMed 布尔符 → 触发 PubMed 路径 → 删除 "and"、"in" 等 stop words → 搜索结果恶化
- **修复**:移除 `re.IGNORECASE`。PubMed 官方仅识别**大写** `AND/OR/NOT` 为布尔符
- **验证**`test_lowercase_boolean_detected` 断言从 `assert is_pubmed_syntax` 改为 `assert not is_pubmed_syntax`
- **P20 修订**`is_pubmed_syntax()` 重新添加 `re.IGNORECASE`R20 Bug-R20-3)。停用词过滤早已移除,不再有退化风险;统一处理大小写可捕获 `cancer and therapy` 等小写 PubMed 查询
### P1-3: `_relevance_query` 对 MeSH-only 查询为空(HIGH