- 包含4个产业方向的前端项目:智能开发、智能制造、大健康、财经商贸 - 已清理node_modules、.yoyo等大文件,项目大小从2.6GB优化至631MB - 配置完善的.gitignore文件 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
150 lines
5.8 KiB
Python
150 lines
5.8 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
|
||
import json
|
||
import re
|
||
|
||
def parse_interview_questions(content):
|
||
"""解析面试题内容为结构化数据"""
|
||
questions = []
|
||
|
||
# 分割成不同的问题类别
|
||
sections = re.split(r'\n# ([一二三四五六七八九十]+、[^#\n]+)', content)
|
||
|
||
question_id = 1
|
||
for i in range(1, len(sections), 2):
|
||
if i >= len(sections):
|
||
break
|
||
|
||
section_title = sections[i].strip()
|
||
section_content = sections[i + 1] if i + 1 < len(sections) else ""
|
||
|
||
# 提取每个问题
|
||
question_blocks = re.split(r'\n\d+\.\s+', section_content)
|
||
|
||
for j, block in enumerate(question_blocks[1:], 1): # 跳过第一个空块
|
||
lines = block.strip().split('\n')
|
||
if not lines:
|
||
continue
|
||
|
||
question_text = lines[0].strip()
|
||
|
||
# 查找答案
|
||
answer_text = ""
|
||
for k, line in enumerate(lines):
|
||
if '示例答案' in line or '答案' in line:
|
||
# 获取答案内容
|
||
answer_lines = []
|
||
for answer_line in lines[k+1:]:
|
||
answer_line = answer_line.strip()
|
||
if answer_line and not answer_line.startswith('示例答案'):
|
||
if re.match(r'^\d+\.', answer_line):
|
||
break
|
||
answer_lines.append(answer_line)
|
||
answer_text = ' '.join(answer_lines)
|
||
break
|
||
|
||
if question_text and answer_text:
|
||
questions.append({
|
||
"id": f"q{question_id}",
|
||
"question": question_text,
|
||
"answer": answer_text
|
||
})
|
||
question_id += 1
|
||
|
||
return questions
|
||
|
||
def main():
|
||
# 读取大健康岗位简历数据
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/网页未导入数据/大健康产业/大健康岗位简历.json', 'r', encoding='utf-8') as f:
|
||
health_data = json.load(f)
|
||
|
||
# 读取Mock文件
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
||
content = f.read()
|
||
|
||
# 创建岗位群到面试题的映射
|
||
industry_questions = {}
|
||
for item in health_data:
|
||
industry = item.get('简历岗位群', '')
|
||
interview_content = item.get('面试题内容', '')
|
||
|
||
if industry and interview_content and industry not in industry_questions:
|
||
questions = parse_interview_questions(interview_content)
|
||
if questions:
|
||
# 按类别分组
|
||
category_questions = {}
|
||
current_category = "综合面试题"
|
||
|
||
for q in questions:
|
||
if '岗位理解' in q['question']:
|
||
current_category = "岗位理解类问题"
|
||
elif '实践经验' in q['question'] or '案例' in q['question']:
|
||
current_category = "实践经验类问题"
|
||
elif '客户服务' in q['question'] or '客户' in q['question']:
|
||
current_category = "客户服务类问题"
|
||
elif '市场' in q['question'] or '趋势' in q['question']:
|
||
current_category = "市场与未来趋势类问题"
|
||
|
||
if current_category not in category_questions:
|
||
category_questions[current_category] = []
|
||
category_questions[current_category].append(q)
|
||
|
||
# 构建questions数组
|
||
questions_array = []
|
||
cat_id = 1
|
||
for category, cat_questions in category_questions.items():
|
||
questions_array.append({
|
||
"id": f"group_q{cat_id}",
|
||
"question": category,
|
||
"subQuestions": cat_questions
|
||
})
|
||
cat_id += 1
|
||
|
||
industry_questions[industry] = questions_array
|
||
|
||
# 映射岗位群名称到ID
|
||
industry_mapping = {
|
||
'健康管理': 'health_1',
|
||
'健康检查': 'health_2',
|
||
'康复治疗': 'health_3',
|
||
'慢性病管理': 'health_4',
|
||
'轻医美': 'health_5',
|
||
'心理健康': 'health_6',
|
||
'社群运营': 'health_7',
|
||
'药品供应链管理': 'health_8',
|
||
'药品生产': 'health_9',
|
||
'药品质量检测': 'health_10',
|
||
'药物研发': 'health_11'
|
||
}
|
||
|
||
# 为每个岗位群添加questions字段
|
||
updates = 0
|
||
for orig_name, industry_id in industry_mapping.items():
|
||
if orig_name in industry_questions:
|
||
questions = industry_questions[orig_name]
|
||
|
||
# 生成questions的JSON字符串
|
||
questions_json = json.dumps(questions, ensure_ascii=False, indent=2)
|
||
|
||
# 查找对应的岗位群并添加questions字段
|
||
# 使用更精确的模式:在positions数组结束后添加questions
|
||
pattern = rf'("id":\s*"{industry_id}"[^{{]*?"positions":\s*\[[^\]]*?\])\s*(\}})'
|
||
|
||
# 添加questions字段
|
||
replacement = rf'\1,\n "questions": {questions_json}\n \2'
|
||
|
||
new_content, count = re.subn(pattern, replacement, content, flags=re.DOTALL)
|
||
if count > 0:
|
||
content = new_content
|
||
updates += 1
|
||
print(f"✓ 为 {orig_name} ({industry_id}) 添加了 {len(questions)} 个问题分类")
|
||
|
||
# 写回文件
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
||
f.write(content)
|
||
|
||
print(f"\n完成!更新了 {updates} 个岗位群的面试题")
|
||
|
||
if __name__ == "__main__":
|
||
main() |