fix(Task #1557): 修复单字感叹词被错误合并 + 短句碎片误过滤
问题: 1. OCR把'嘿,php那管理员后台的那个默认密码是多少啊?'拆成两行'嘿'和'php...' 行合并逻辑错误地将'嘿'合并进问句,导致消息变成'嘿;php那管理员后台的那个默认密码是多少啊?' 2. 用户消息'那关于我们'(5字)被短句碎片规则过滤,因为含'那'是口语前缀但原规则未识别 修复: 1. 行合并逻辑:检测单字感叹词(嘿/哈/哦/呃等),若当前行或上一行是单字感叹词则不合并 2. 短句碎片规则:添加口语前缀词(那/这/啥/咋/嗯/哦/嘿/哈)豁免检查,含这些词的短句放行
This commit is contained in:
+11
-2
@@ -3310,9 +3310,15 @@ class MessageMonitor:
|
||||
if _norm_rl and _norm_rl in _known_bot_replies:
|
||||
_is_bot_reply_line = True
|
||||
logger.debug(f"[ocr] 行合并跳过(bot回复): {rl[:60]!r}")
|
||||
# ⭐ Task #1557: 单字感叹词(嘿/哈/哦/呃等)不应与后续问句合并
|
||||
# OCR常把"嘿,php..."拆成两行:"嘿" 和 "php..."
|
||||
# 如果当前行或上一行是单字感叹词,不合并
|
||||
_is_single_excl = len(rl.strip()) == 1 and re.match(r'^[嘿哈哦呃啊哎嗬]$', rl.strip())
|
||||
_prev_is_single_excl = merged_lines and len(merged_lines[-1].strip()) == 1 \
|
||||
and re.match(r'^[嘿哈哦呃啊哎嗬]$', merged_lines[-1].strip())
|
||||
if merged_lines and not _SENT_END.search(merged_lines[-1]) \
|
||||
and not _TS_START.match(rl) and not _TS_START.match(merged_lines[-1]) \
|
||||
and not _is_bot_reply_line:
|
||||
and not _is_bot_reply_line and not _is_single_excl and not _prev_is_single_excl:
|
||||
merged_lines[-1] = merged_lines[-1] + ',' + rl
|
||||
else:
|
||||
merged_lines.append(rl)
|
||||
@@ -4126,10 +4132,13 @@ class MessageMonitor:
|
||||
# 豁免短句检查——否则规则4放行+前缀剥离全白做,消息仍被此规则丢弃。
|
||||
# ⭐ 2026-08-12: 包含括号的消息(如"端0(基岩版)")可能是有效短消息,放行
|
||||
# ⭐ 2026-08-18: 含句末标点(。)或口语确认词(好的/嗯/明白)的短句放行
|
||||
# ⭐ Task #1557: 含疑问词或口语感叹词的短句放行(如"那关于我们"含"那")
|
||||
has_period_end = line.endswith('。') or line.endswith('!')
|
||||
has_confirm = any(w in line for w in ('好的', '嗯', '明白', '收到', '了解', '知道了'))
|
||||
# 口语前缀词(那、这、啥等)提示真实用户消息
|
||||
_spoken_prefix = any(w in line for w in ('那', '这', '啥', '咋', '嗯', '哦', '嘿', '哈'))
|
||||
if not has_q and line not in _ui_prefix_stripped and not re.search(r'[()()]', line) \
|
||||
and not has_period_end and not has_confirm:
|
||||
and not has_period_end and not has_confirm and not _spoken_prefix:
|
||||
logger.debug(f"[{platform}] OCR 过滤: 短句碎片(≤8字无问词) line={line!r}")
|
||||
continue
|
||||
# ★ 以特殊符号(~、`等)开头 → OCR把"一键"识别为"~键"等碎片
|
||||
|
||||
Reference in New Issue
Block a user