#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 验证清理后的答案 """ import re print("=== 验证清理后的答案 ===\n") # 读取文件 with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f: content = f.read() # 统计总答案数 total_answers = len(re.findall(r'"answer":\s*"[^"]*"', content)) print(f"总答案数: {total_answers}") # 检查是否还有选项格式 option_patterns = [ (r'"answer":\s*"[^"]*[A-D][\.、][^"]*"', "包含 A. B. C. D. 格式"), (r'"answer":\s*"选项[::][^"]*"', "以'选项:'开头"), (r'"answer":\s*"[A-D]\s+[^"]*"', "以单个字母开头"), ] print("\n检查剩余的选项格式:") has_options = False for pattern, description in option_patterns: matches = re.findall(pattern, content) if matches: print(f"\n{description}: {len(matches)} 个") for match in matches[:3]: # 显示前3个示例 # 提取答案内容 answer_text = re.search(r'"answer":\s*"([^"]*)"', match) if answer_text: print(f" - {answer_text.group(1)[:80]}...") has_options = True if not has_options: print("✅ 没有发现明显的选项格式") # 显示一些成功清理的例子 print("\n\n成功清理的示例:") examples = [ "示教器操作时,必须佩戴", "机器人运行时,人员应", "安全围栏的作用是", "工具标定不准确会导致", "每日交接班必须做的是" ] for question in examples: pattern = f'"question":\s*"{question}",\s*\n\s*"answer":\s*"([^"]*)"' match = re.search(pattern, content) if match: print(f"问题: {question}") print(f"答案: {match.group(1)}") print("-" * 40) print("\n✅ 验证完成!")