修复语法错误:else后不能直接跟elif
- 问题:Task #1685修复引入语法错误,else:后直接跟elif导致SyntaxError - 修复:调整代码结构,将elif正确嵌套在if not _has_table_structure:块内
This commit is contained in:
+25
-25
@@ -8631,33 +8631,33 @@ class MessageMonitor:
|
||||
# 纯配置文本,丢弃
|
||||
logger.debug(f"[ocr] 过滤器2结果: 检测到多条配置文件格式({len(_colon_matches)}条key:value),返回True: {text!r}")
|
||||
return True
|
||||
elif len(_colon_matches) == 1:
|
||||
# 单条key:value,检查是否为完整的一条(无多余字符)
|
||||
_colon_match = re.match(r'^[\u4e00-\u9fff]{2,10}\s*[::]\s*\S+$', text)
|
||||
if _colon_match:
|
||||
# ⭐ Task #1671: 检查用户消息特征,避免误判正常用户消息
|
||||
# 如"使用第三方作弊软件:脚本。外挂。模拟器。群控设备等非正常手段批量注册或刷取数据"
|
||||
_has_user_msg_feature = False
|
||||
# 特征1: @提及(用户@他人或@机器人)
|
||||
if '@' in text and re.search(r'@\w+', text):
|
||||
_has_user_msg_feature = True
|
||||
# 特征2: 疑问词(吗呢多少怎么如何哪什么几)
|
||||
if any(q in text for q in ['?', '?', '吗', '呢', '多少', '怎么', '如何', '哪', '什么', '几']):
|
||||
_has_user_msg_feature = True
|
||||
# 特征3: 明确的查询意图词(查/问/看/有/在哪/如何/怎么)
|
||||
if re.search(r'[查问看].*(?:插件|功能|命令|模式|系统|公告|信息)', text):
|
||||
_has_user_msg_feature = True
|
||||
# 特征4: 长度超过20字的中文文本(可能是用户消息而非配置)
|
||||
if len(text) > 20:
|
||||
_has_user_msg_feature = True
|
||||
if _has_user_msg_feature:
|
||||
# 包含用户消息特征,不丢弃,继续后续检查
|
||||
logger.debug(f"[ocr] 过滤器2结果: 检测到单条key:value但含用户消息特征,继续检查: {text[:80]!r}")
|
||||
else:
|
||||
logger.debug(f"[ocr] 过滤器2结果: 检测到单条配置文件格式(key: value),返回True: {text!r}")
|
||||
return True
|
||||
else:
|
||||
logger.debug(f"[ocr] 过滤器2结果: 检测到表格结构,跳过key:value配置文件检测: {text[:80]!r}")
|
||||
elif len(_colon_matches) == 1:
|
||||
# 单条key:value,检查是否为完整的一条(无多余字符)
|
||||
_colon_match = re.match(r'^[\u4e00-\u9fff]{2,10}\s*[::]\s*\S+$', text)
|
||||
if _colon_match:
|
||||
# ⭐ Task #1671: 检查用户消息特征,避免误判正常用户消息
|
||||
# 如"使用第三方作弊软件:脚本。外挂。模拟器。群控设备等非正常手段批量注册或刷取数据"
|
||||
_has_user_msg_feature = False
|
||||
# 特征1: @提及(用户@他人或@机器人)
|
||||
if '@' in text and re.search(r'@\w+', text):
|
||||
_has_user_msg_feature = True
|
||||
# 特征2: 疑问词(吗呢多少怎么如何哪什么几)
|
||||
if any(q in text for q in ['?', '?', '吗', '呢', '多少', '怎么', '如何', '哪', '什么', '几']):
|
||||
_has_user_msg_feature = True
|
||||
# 特征3: 明确的查询意图词(查/问/看/有/在哪/如何/怎么)
|
||||
if re.search(r'[查问看].*(?:插件|功能|命令|模式|系统|公告|信息)', text):
|
||||
_has_user_msg_feature = True
|
||||
# 特征4: 长度超过20字的中文文本(可能是用户消息而非配置)
|
||||
if len(text) > 20:
|
||||
_has_user_msg_feature = True
|
||||
if _has_user_msg_feature:
|
||||
# 包含用户消息特征,不丢弃,继续后续检查
|
||||
logger.debug(f"[ocr] 过滤器2结果: 检测到单条key:value但含用户消息特征,继续检查: {text[:80]!r}")
|
||||
else:
|
||||
logger.debug(f"[ocr] 过滤器2结果: 检测到单条配置文件格式(key: value),返回True: {text!r}")
|
||||
return True
|
||||
# 3. 检测其他配置文件格式:等号分隔的键值对(如key=value)
|
||||
# ⭐ Task #1685: 跳过表格结构内容
|
||||
if not _has_table_structure:
|
||||
|
||||
Reference in New Issue
Block a user