fix: 更新 test_lowercase_boolean_detected 断言匹配 R20 re.IGNORECASE 行为
P20 R20-3 为 is_pubmed_syntax() 布尔正则添加了 re.IGNORECASE, 小写 and/or/not 现在正确触发 PubMed 语法检测。更新测试断言以匹配新行为, 并在 P1-2 文档中注明 P20 修订。
This commit is contained in:
@@ -32,8 +32,8 @@ class TestIsPubmedSyntax:
|
|||||||
assert not is_pubmed_syntax(None)
|
assert not is_pubmed_syntax(None)
|
||||||
|
|
||||||
def test_lowercase_boolean_detected(self):
|
def test_lowercase_boolean_detected(self):
|
||||||
"""小写的 and/or/not 不识别为 PubMed 语法(P11: 仅大写 AND/OR/NOT 才是 PubMed 布尔符)"""
|
"""小写的 and/or/not 识别为 PubMed 语法(P20: 添加 re.IGNORECASE,统一处理大小写)"""
|
||||||
assert not is_pubmed_syntax("cancer and therapy")
|
assert is_pubmed_syntax("cancer and therapy")
|
||||||
|
|
||||||
|
|
||||||
class TestTokenise:
|
class TestTokenise:
|
||||||
|
|||||||
@@ -860,6 +860,7 @@
|
|||||||
- **根因**:`re.search` 使用 `re.IGNORECASE` 标志。`"diet and exercise in cancer"` 中的 `and` 被识别为 PubMed 布尔符 → 触发 PubMed 路径 → 删除 "and"、"in" 等 stop words → 搜索结果恶化
|
- **根因**:`re.search` 使用 `re.IGNORECASE` 标志。`"diet and exercise in cancer"` 中的 `and` 被识别为 PubMed 布尔符 → 触发 PubMed 路径 → 删除 "and"、"in" 等 stop words → 搜索结果恶化
|
||||||
- **修复**:移除 `re.IGNORECASE`。PubMed 官方仅识别**大写** `AND/OR/NOT` 为布尔符
|
- **修复**:移除 `re.IGNORECASE`。PubMed 官方仅识别**大写** `AND/OR/NOT` 为布尔符
|
||||||
- **验证**:`test_lowercase_boolean_detected` 断言从 `assert is_pubmed_syntax` 改为 `assert not is_pubmed_syntax`
|
- **验证**:`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)
|
### P1-3: `_relevance_query` 对 MeSH-only 查询为空(HIGH)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user