diff --git a/backend/tests/test_pubmed_query_parser.py b/backend/tests/test_pubmed_query_parser.py index 0678e9d..b0c87ab 100644 --- a/backend/tests/test_pubmed_query_parser.py +++ b/backend/tests/test_pubmed_query_parser.py @@ -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: diff --git a/docs/13-搜索修复全记录.md b/docs/13-搜索修复全记录.md index da6bb8b..86bb73f 100644 --- a/docs/13-搜索修复全记录.md +++ b/docs/13-搜索修复全记录.md @@ -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)