- 后端 API(Flask + Gunicorn) - RAG 引擎(混合检索 + 云端 Reranker + 引用溯源) - 文档解析(MinerU + 多格式支持) - Docker 生产部署配置 - 排除前端项目、敏感配置、模型文件
27 lines
842 B
Python
27 lines
842 B
Python
"""
|
|
查询分类工具
|
|
|
|
当前仅保留枚举查询检测函数(被生产管线使用)。
|
|
原有的 QueryClassifier 类和 classify() 方法未被生产路径调用,已清理。
|
|
|
|
使用方式:
|
|
from core.query_classifier import is_enumeration_query
|
|
|
|
if is_enumeration_query(query):
|
|
# 枚举类查询需要连续上下文
|
|
...
|
|
"""
|
|
import re
|
|
|
|
|
|
def is_enumeration_query(query: str) -> bool:
|
|
"""Return True for list/numbered-clause questions that need contiguous context."""
|
|
if not query:
|
|
return False
|
|
|
|
strong_markers = ("哪些", "有哪些", "列出", "严禁", "禁止", "不得", "包括", "要求")
|
|
if any(marker in query for marker in strong_markers):
|
|
return True
|
|
|
|
return bool(re.search(r"(哪几|几类|几种|多少项|第[一二三四五六七八九十\d]+条)", query))
|