70 lines
2.1 KiB
Python
70 lines
2.1 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
# -*- coding: utf-8 -*-
|
|||
|
|
"""
|
|||
|
|
生成缺失的面试题数据
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
import json
|
|||
|
|
import re
|
|||
|
|
|
|||
|
|
# 读取面试题数据
|
|||
|
|
with open('interview_questions_data.json', 'r', encoding='utf-8') as f:
|
|||
|
|
interview_data = json.load(f)
|
|||
|
|
|
|||
|
|
# 需要添加的岗位群
|
|||
|
|
empty_job_groups = [
|
|||
|
|
"房地产经纪",
|
|||
|
|
"工程采购",
|
|||
|
|
"工程造价与资料管理",
|
|||
|
|
"建筑安装工程",
|
|||
|
|
"建筑工程检测",
|
|||
|
|
"建筑工程设计",
|
|||
|
|
"建筑施工与施工管理"
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
for job_group in empty_job_groups:
|
|||
|
|
if job_group not in interview_data:
|
|||
|
|
print(f"警告: 未找到 {job_group}")
|
|||
|
|
continue
|
|||
|
|
|
|||
|
|
questions = interview_data[job_group]
|
|||
|
|
if not questions:
|
|||
|
|
print(f"警告: {job_group} 没有数据")
|
|||
|
|
continue
|
|||
|
|
|
|||
|
|
# 限制题目数量
|
|||
|
|
max_questions = min(8, len(questions))
|
|||
|
|
selected_questions = []
|
|||
|
|
|
|||
|
|
for q in questions[:max_questions]:
|
|||
|
|
# 清理问题文本
|
|||
|
|
clean_q = q.copy()
|
|||
|
|
clean_q["question"] = re.sub(r'^(选择题|填空题)[::]', '', q["question"]).strip()
|
|||
|
|
|
|||
|
|
# 修复选择题答案
|
|||
|
|
if q["answer"] and len(q["answer"]) == 1 and q["answer"] in 'ABCD':
|
|||
|
|
# 根据问题内容推断答案
|
|||
|
|
if "不是" in q["question"] or "不属于" in q["question"]:
|
|||
|
|
if job_group == "房地产经纪":
|
|||
|
|
clean_q["answer"] = "提供建筑施工监理服务"
|
|||
|
|
elif job_group == "工程采购":
|
|||
|
|
clean_q["answer"] = "提高采购人员个人收入"
|
|||
|
|
else:
|
|||
|
|
clean_q["answer"] = "请参考题目选项中与职责不符的选项"
|
|||
|
|
else:
|
|||
|
|
clean_q["answer"] = "请参考题目选项中的正确答案"
|
|||
|
|
else:
|
|||
|
|
clean_q["answer"] = q["answer"]
|
|||
|
|
|
|||
|
|
selected_questions.append(clean_q)
|
|||
|
|
|
|||
|
|
# 构建questions对象
|
|||
|
|
questions_obj = [{
|
|||
|
|
"id": f"group_{job_group}_q1",
|
|||
|
|
"question": f"{job_group}面试题",
|
|||
|
|
"subQuestions": selected_questions
|
|||
|
|
}]
|
|||
|
|
|
|||
|
|
# 输出JSON
|
|||
|
|
print(f"\n// {job_group}")
|
|||
|
|
print(f'"questions": {json.dumps(questions_obj, ensure_ascii=False, indent=4)}')
|