扩展配置文件格式检测,支持多条key:value拼接格式(如'图标: potato 标题:自杀'),忽略大小写/标点差异

This commit is contained in:
youpaishidifu
2026-08-24 16:40:56 +08:00
parent 3c118d3665
commit 5e1ece6076
+13 -4
View File
@@ -7689,12 +7689,21 @@ class MessageMonitor:
_has_subject = any(s in text for s in ('我', '你', '他', '我们', '你们', '他们', '玩家', '用户', '管理员'))
# 无疑问词 + 无动词 或 无疑问词 + 无主语 → 可能是残片
if not _has_question_word and (not _has_verb or not _has_subject):
# ⭐ Task #1591: 配置文件格式检测(如"图标: shield"、"标题: xxx")
# ⭐ Task #1591: 配置文件格式检测(如"图标: shield"、"标题: xxx"、"图标: potato 标题:自杀")
# 特征:key: value格式,无问号/疑问词,不是用户查询
_colon_match = re.match(r'^[\u4e00-\u9fff]{2,10}\s*[::]\s*\S+$', text)
if _colon_match:
logger.debug(f"[ocr] 过滤器2结果: 检测到配置文件格式(key: value),返回True: {text!r}")
# 支持单条和多条拼接格式,忽略大小写/标点差异
_colon_pattern = r'[\u4e00-\u9fff]{2,10}\s*[::]\s*\S+'
_colon_matches = re.findall(_colon_pattern, text)
if len(_colon_matches) >= 2:
# 多条key:value拼接(如"图标: potato 标题:自杀")
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:
logger.debug(f"[ocr] 过滤器2结果: 检测到单条配置文件格式(key: value),返回True: {text!r}")
return True
# ⭐ 核心名词放行:包含核心名词的短文本可能是用户查询词,不视为残片
_core_nouns = {'公告', '更新', '通知', '说明', '规则', '版本', '下载', '安装', '登录', '配置', '设置', '操作', '模式', '列表', '详情', '信息', '内容', '介绍', '功能', '系统', '服务', '玩家', '用户', '管理员', '服务器', '客户端', '插件', '模块', '接口', 'API', 'BUG', '问题', '错误', '异常', '日志', '配置', '文件', '目录', '路径', '地址', '链接', '网址', '网站', '网页', '页面', '界面', '菜单', '按钮', '图标', '图片', '视频', '音频', '文档', '手册', '指南', '教程', '帮助', '支持', '反馈', '建议', '意见', '投诉', '举报', '奖励', '惩罚', '活动', '比赛', '排名', '积分', '等级', '权限', '角色', '职业', '技能', '装备', '道具', '货币', '交易', '市场', '商店', '背包', '仓库', '邮件', '聊天', '组队', '公会', '领地', '地图', '任务', '副本', 'BOSS', '怪物', '掉落', '经验', '属性', '状态', '效果', 'BUFF', 'DEBUFF', '冷却', '消耗', '需求', '条件', '限制'}
if any(noun in text for noun in _core_nouns):