- 包含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>
141 lines
5.4 KiB
Python
141 lines
5.4 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
|
||
import json
|
||
import re
|
||
|
||
# 读取大健康岗位简历数据
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/网页未导入数据/大健康产业/大健康岗位简历.json', 'r', encoding='utf-8') as f:
|
||
health_data = json.load(f)
|
||
|
||
# 获取药物研发的面试题
|
||
drug_questions = []
|
||
for item in health_data:
|
||
if item.get('简历岗位群') == '药物研发':
|
||
interview_content = item.get('面试题内容', '')
|
||
if interview_content and not drug_questions: # 只取第一个
|
||
# 提取问题
|
||
content = interview_content
|
||
|
||
# 删除"判断题:"前缀
|
||
content = re.sub(r'判断题[::]?\s*', '', content)
|
||
|
||
# 分割成类别
|
||
sections = re.split(r'\n# ([一二三四五六七八九十]+、[^#\n]+)', content)
|
||
|
||
questions = []
|
||
if len(sections) > 1:
|
||
for i in range(1, len(sections), 2):
|
||
if i+1 >= len(sections):
|
||
break
|
||
|
||
category_title = sections[i].strip()
|
||
category_content = sections[i+1]
|
||
|
||
# 提取问题和答案
|
||
sub_questions = []
|
||
lines = category_content.split('\n')
|
||
|
||
current_question = None
|
||
current_answer = []
|
||
in_answer = False
|
||
|
||
for line in lines:
|
||
line = line.strip()
|
||
|
||
# 检查是否是新问题
|
||
question_match = re.match(r'^(\d+)\.\s*(.+)$', line)
|
||
if question_match:
|
||
# 保存上一个问题
|
||
if current_question and current_answer:
|
||
answer_text = ' '.join(current_answer).strip()
|
||
answer_text = re.sub(r'^(示例)?答案[::]?\s*', '', answer_text)
|
||
if answer_text:
|
||
sub_questions.append({
|
||
"question": current_question,
|
||
"answer": answer_text
|
||
})
|
||
|
||
# 开始新问题
|
||
current_question = question_match.group(2).strip()
|
||
current_answer = []
|
||
in_answer = False
|
||
|
||
# 检查是否是答案开始
|
||
elif '答案' in line or '示例答案' in line:
|
||
in_answer = True
|
||
answer_part = re.sub(r'^(示例)?答案[::]?\s*', '', line).strip()
|
||
if answer_part:
|
||
current_answer.append(answer_part)
|
||
|
||
# 收集答案内容
|
||
elif in_answer and line and not re.match(r'^#', line):
|
||
current_answer.append(line)
|
||
|
||
# 保存最后一个问题
|
||
if current_question and current_answer:
|
||
answer_text = ' '.join(current_answer).strip()
|
||
answer_text = re.sub(r'^(示例)?答案[::]?\s*', '', answer_text)
|
||
if answer_text:
|
||
sub_questions.append({
|
||
"question": current_question,
|
||
"answer": answer_text
|
||
})
|
||
|
||
if sub_questions:
|
||
questions.append({
|
||
"category": category_title,
|
||
"questions": sub_questions
|
||
})
|
||
|
||
drug_questions = questions
|
||
break
|
||
|
||
# 转换为前端格式
|
||
questions_array = []
|
||
total_q = 0
|
||
for i, cat in enumerate(drug_questions, 1):
|
||
sub_q_array = []
|
||
for j, q in enumerate(cat['questions'], 1):
|
||
total_q += 1
|
||
sub_q_array.append({
|
||
"id": f"q{total_q}",
|
||
"question": q['question'],
|
||
"answer": q['answer']
|
||
})
|
||
|
||
questions_array.append({
|
||
"id": f"group_q{i}",
|
||
"question": cat['category'],
|
||
"subQuestions": sub_q_array
|
||
})
|
||
|
||
# 生成JSON字符串
|
||
questions_json = json.dumps(questions_array, ensure_ascii=False, indent=2)
|
||
|
||
# 读取Mock文件
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
||
content = f.read()
|
||
|
||
# 在health_11的positions数组后添加questions
|
||
# 找到最后一个position的结束
|
||
pattern = r'("id":\s*"health_11_4"[^}]*?"requirements":\s*\[[^\]]*?\]\s*\}\]\s*\})'
|
||
|
||
match = re.search(pattern, content, re.DOTALL)
|
||
if match:
|
||
end_pos = match.end()
|
||
|
||
# 在这个位置插入questions
|
||
# 先找到']'的位置(positions数组的结束)
|
||
positions_end = content.rfind(']', 0, end_pos)
|
||
|
||
# 构建新的内容
|
||
new_content = content[:positions_end] + '],\n "questions": ' + questions_json + '\n ' + content[end_pos:]
|
||
|
||
# 写回文件
|
||
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
||
f.write(new_content)
|
||
|
||
print(f"✓ 已添加药物研发的 {len(questions_array)} 个分类,共 {total_q} 个面试题")
|
||
else:
|
||
print("未找到health_11的结构") |