fix: 忽略OCR末尾不完整括号噪声,避免误判为括号不匹配

This commit is contained in:
youpaishidifu
2026-08-10 00:56:18 +08:00
parent 88d0db1aec
commit a11741fa69
+4 -2
View File
@@ -5380,9 +5380,11 @@ class MessageMonitor:
logger.debug(f"[ocr] 过滤器2结果: 检测到短截断片段,返回True")
return True
# 括号不匹配(可能OCR截断)
if text.count('[') != text.count(']') or text.count('(') != text.count(')') or text.count('(') != text.count(')'):
# 清理末尾的不完整括号(OCR噪声),如"消息内容['"
text_clean = re.sub(r'[\[((]+$', '', text)
if text_clean.count('[') != text_clean.count(']') or text_clean.count('(') != text_clean.count(')') or text_clean.count('(') != text_clean.count(')'):
# 仅当文本较短时才判定为病句(避免误杀正常聊天)
if len(text) < 30:
if len(text_clean) < 30:
logger.debug(f"[ocr] 过滤器2结果: 检测到括号不匹配,返回True")
return True
# ⭐ 用户协议/服务条款文档内容检测(牛头不对马嘴修复)