194 lines
7.2 KiB
Python
194 lines
7.2 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
import json
|
|||
|
|
import os
|
|||
|
|
from datetime import datetime
|
|||
|
|
|
|||
|
|
# 读取视觉设计岗位简历.json文件
|
|||
|
|
json_file = '网页未导入数据/视觉设计产业/视觉设计岗位简历.json'
|
|||
|
|
mock_file = 'src/mocks/resumeInterviewMock.js'
|
|||
|
|
|
|||
|
|
print("正在读取所有岗位的完整面试题内容(包含答案)...")
|
|||
|
|
with open(json_file, 'r', encoding='utf-8') as f:
|
|||
|
|
positions_data = json.load(f)
|
|||
|
|
|
|||
|
|
# 提取所有岗位的面试题(包含答案)
|
|||
|
|
all_questions_with_answers = {}
|
|||
|
|
|
|||
|
|
for position in positions_data:
|
|||
|
|
position_name = position.get("岗位名称", "")
|
|||
|
|
interview_content = position.get("面试题内容", "")
|
|||
|
|
|
|||
|
|
if position_name and interview_content:
|
|||
|
|
questions_with_answers = []
|
|||
|
|
lines = interview_content.split('\n')
|
|||
|
|
current_question = None
|
|||
|
|
current_answer = ''
|
|||
|
|
collecting_answer = False
|
|||
|
|
|
|||
|
|
for line in lines:
|
|||
|
|
line_stripped = line.strip()
|
|||
|
|
|
|||
|
|
# 检测问题行
|
|||
|
|
if line_stripped and line_stripped[0].isdigit() and '. 问题' in line_stripped:
|
|||
|
|
# 保存上一个问题
|
|||
|
|
if current_question:
|
|||
|
|
questions_with_answers.append({
|
|||
|
|
'question': current_question,
|
|||
|
|
'answer': current_answer.strip() if current_answer.strip() else "请根据您的实际经验和项目情况,结合专业知识进行回答。"
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
# 提取新问题
|
|||
|
|
parts = line_stripped.split('问题:', 1)
|
|||
|
|
if len(parts) > 1:
|
|||
|
|
current_question = parts[1].strip()
|
|||
|
|
else:
|
|||
|
|
parts = line_stripped.split('问题:', 1)
|
|||
|
|
if len(parts) > 1:
|
|||
|
|
current_question = parts[1].strip()
|
|||
|
|
else:
|
|||
|
|
current_question = line_stripped
|
|||
|
|
|
|||
|
|
current_answer = ''
|
|||
|
|
collecting_answer = False
|
|||
|
|
|
|||
|
|
# 检测答案开始
|
|||
|
|
elif '参考回答:' in line or '参考答案:' in line or '答案:' in line:
|
|||
|
|
collecting_answer = True
|
|||
|
|
# 如果答案在同一行
|
|||
|
|
if ':' in line:
|
|||
|
|
answer_part = line.split(':', 1)[1].strip()
|
|||
|
|
if answer_part:
|
|||
|
|
current_answer = answer_part
|
|||
|
|
|
|||
|
|
# 收集答案内容
|
|||
|
|
elif collecting_answer and line.strip():
|
|||
|
|
# 检查是否是新问题或新章节
|
|||
|
|
if (line_stripped and line_stripped[0].isdigit() and '. 问题' in line_stripped) or line_stripped.startswith('#'):
|
|||
|
|
collecting_answer = False
|
|||
|
|
else:
|
|||
|
|
if current_answer:
|
|||
|
|
current_answer += ' '
|
|||
|
|
current_answer += line.strip()
|
|||
|
|
|
|||
|
|
# 保存最后一个问题
|
|||
|
|
if current_question:
|
|||
|
|
questions_with_answers.append({
|
|||
|
|
'question': current_question,
|
|||
|
|
'answer': current_answer.strip() if current_answer.strip() else "请根据您的实际经验和项目情况,结合专业知识进行回答。"
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
all_questions_with_answers[position_name] = questions_with_answers
|
|||
|
|
if questions_with_answers:
|
|||
|
|
print(f" {position_name}: {len(questions_with_answers)} 个问题(含答案)")
|
|||
|
|
|
|||
|
|
print(f"\n共解析 {len(all_questions_with_answers)} 个岗位的面试题")
|
|||
|
|
|
|||
|
|
# 创建备份
|
|||
|
|
backup_file = f"{mock_file}.backup_full_answers_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
|||
|
|
with open(mock_file, 'r', encoding='utf-8') as f:
|
|||
|
|
original_content = f.read()
|
|||
|
|
with open(backup_file, 'w', encoding='utf-8') as f:
|
|||
|
|
f.write(original_content)
|
|||
|
|
print(f"\n已创建备份:{backup_file}")
|
|||
|
|
|
|||
|
|
# 生成UI设计师的完整面试题数据
|
|||
|
|
if "UI设计师" in all_questions_with_answers:
|
|||
|
|
ui_questions = all_questions_with_answers["UI设计师"]
|
|||
|
|
|
|||
|
|
# 构建单卡片格式的面试题
|
|||
|
|
new_questions = [
|
|||
|
|
{
|
|||
|
|
"id": "group_q1",
|
|||
|
|
"question": "# UI设计面试题",
|
|||
|
|
"subQuestions": []
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
for idx, qa in enumerate(ui_questions, 1):
|
|||
|
|
# 清理答案文本,保持可读性
|
|||
|
|
answer_text = qa['answer']
|
|||
|
|
# 限制答案长度,避免太长
|
|||
|
|
if len(answer_text) > 500:
|
|||
|
|
answer_text = answer_text[:500] + "..."
|
|||
|
|
|
|||
|
|
new_questions[0]["subQuestions"].append({
|
|||
|
|
"id": f"q1_{idx}",
|
|||
|
|
"question": qa['question'],
|
|||
|
|
"answer": answer_text
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
# 生成JSON字符串
|
|||
|
|
questions_json = json.dumps(new_questions, ensure_ascii=False, indent=6)
|
|||
|
|
|
|||
|
|
# 保存UI设计的更新数据
|
|||
|
|
with open('ui_questions_with_answers.json', 'w', encoding='utf-8') as f:
|
|||
|
|
f.write(questions_json)
|
|||
|
|
|
|||
|
|
print(f"\nUI设计师的面试题已准备就绪")
|
|||
|
|
print(f"包含 {len(ui_questions)} 个问题,每个都有完整答案")
|
|||
|
|
print("数据已保存到 ui_questions_with_answers.json")
|
|||
|
|
|
|||
|
|
# 显示前两个问题作为示例
|
|||
|
|
print("\n示例(前2个问题):")
|
|||
|
|
for i in range(min(2, len(ui_questions))):
|
|||
|
|
print(f"\n问题 {i+1}: {ui_questions[i]['question']}")
|
|||
|
|
answer_preview = ui_questions[i]['answer'][:150] + "..." if len(ui_questions[i]['answer']) > 150 else ui_questions[i]['answer']
|
|||
|
|
print(f"答案: {answer_preview}")
|
|||
|
|
|
|||
|
|
# 为其他产业也生成完整数据
|
|||
|
|
industry_map = {
|
|||
|
|
"包装设计": "包装设计师",
|
|||
|
|
"插画设计": "插画师",
|
|||
|
|
"灯光": "影视灯光",
|
|||
|
|
"动画设计": "动画师",
|
|||
|
|
"后期特效": "特效设计师",
|
|||
|
|
"剪辑": "剪辑师",
|
|||
|
|
"品牌设计": "品牌视觉内容策划",
|
|||
|
|
"平面设计": "平面设计师",
|
|||
|
|
"三维设计": "3D建模师",
|
|||
|
|
"摄影/摄像": "摄影师",
|
|||
|
|
"室内设计": "室内设计师",
|
|||
|
|
"调色": "调色师",
|
|||
|
|
"新媒体运营": "新媒体运营专员",
|
|||
|
|
"音频处理": "音效设计师",
|
|||
|
|
"影视节目策划": "导演",
|
|||
|
|
"直播": "直播助理"
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
all_updates = []
|
|||
|
|
for industry_name, position_name in industry_map.items():
|
|||
|
|
if position_name in all_questions_with_answers:
|
|||
|
|
questions = all_questions_with_answers[position_name]
|
|||
|
|
if questions:
|
|||
|
|
# 构建单卡片格式
|
|||
|
|
industry_questions = [
|
|||
|
|
{
|
|||
|
|
"id": "group_q1",
|
|||
|
|
"question": f"# {industry_name}面试题",
|
|||
|
|
"subQuestions": []
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
for idx, qa in enumerate(questions, 1):
|
|||
|
|
answer_text = qa['answer']
|
|||
|
|
if len(answer_text) > 500:
|
|||
|
|
answer_text = answer_text[:500] + "..."
|
|||
|
|
|
|||
|
|
industry_questions[0]["subQuestions"].append({
|
|||
|
|
"id": f"q1_{idx}",
|
|||
|
|
"question": qa['question'],
|
|||
|
|
"answer": answer_text
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
all_updates.append({
|
|||
|
|
'industry': industry_name,
|
|||
|
|
'questions': industry_questions,
|
|||
|
|
'count': len(questions)
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
# 保存所有更新数据
|
|||
|
|
with open('all_industries_with_answers.json', 'w', encoding='utf-8') as f:
|
|||
|
|
json.dump(all_updates, f, ensure_ascii=False, indent=2)
|
|||
|
|
|
|||
|
|
print(f"\n所有 {len(all_updates)} 个产业的完整面试题数据已准备就绪")
|
|||
|
|
print("数据已保存到 all_industries_with_answers.json")
|