Files
ALL-teach_sys/frontend_视觉设计/update_all_to_single_card.py

106 lines
3.6 KiB
Python
Raw Normal View History

#!/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 = {}
for position in positions_data:
position_name = position.get("岗位名称", "")
interview_content = position.get("面试题内容", "")
if position_name and interview_content:
questions = []
lines = interview_content.split('\n')
for line in lines:
line = line.strip()
if line and line[0].isdigit() and '. 问题' in line:
parts = line.split('问题:', 1)
if len(parts) > 1:
question_text = parts[1].strip()
questions.append(question_text)
all_questions[position_name] = questions
print(f"共解析 {len(all_questions)} 个岗位的面试题")
# 为每个岗位创建单卡片格式的面试题
def generate_single_card_questions(industry_name, questions):
"""生成单卡片格式的面试题JSON"""
result = [
{
"id": "group_q1",
"question": f"# {industry_name}面试题",
"subQuestions": []
}
]
for idx, q in enumerate(questions, 1):
result[0]["subQuestions"].append({
"id": f"q1_{idx}",
"question": q,
"answer": "请根据您的实际经验和项目情况,结合专业知识进行回答。"
})
return json.dumps(result, ensure_ascii=False, indent=6)
# 定义要更新的产业和对应岗位
industry_updates = [
("包装设计", "包装设计师"),
("插画设计", "插画师"),
("灯光", "影视灯光"),
("动画设计", "动画师"),
("后期特效", "特效设计师"),
("剪辑", "剪辑师"),
("品牌设计", "品牌视觉内容策划"),
("平面设计", "平面设计师"),
("三维设计", "3D建模师"),
("摄影/摄像", "摄影师"),
("室内设计", "室内设计师"),
("调色", "调色师"),
("新媒体运营", "新媒体运营专员"),
("音频处理", "音效设计师"),
("影视节目策划", "导演"),
("直播", "直播助理")
]
# 生成所有更新
print("\n生成所有产业的单卡片格式面试题...")
updates_ready = []
for industry_name, position_name in industry_updates:
if position_name in all_questions:
questions = all_questions[position_name]
if questions:
questions_json = generate_single_card_questions(industry_name, questions)
updates_ready.append({
'industry': industry_name,
'questions_json': questions_json,
'count': len(questions)
})
print(f" {industry_name}: {len(questions)} 个问题")
# 保存到文件供手动更新
output_file = 'single_card_questions_updates.json'
with open(output_file, 'w', encoding='utf-8') as f:
json.dump(updates_ready, f, ensure_ascii=False, indent=2)
print(f"\n生成了 {len(updates_ready)} 个产业的单卡片格式面试题")
print(f"数据已保存到 {output_file}")
# 为包装设计生成示例更新代码
if len(updates_ready) > 0:
first_update = updates_ready[0]
print(f"\n包装设计的面试题更新示例:")
print(f"产业:{first_update['industry']}")
print(f"问题数:{first_update['count']}")
print("JSON预览前200字符")
print(first_update['questions_json'][:200] + "...")