Files
ALL-teach_sys/frontend_化工/scripts/update_mockdata_resume.py

68 lines
2.7 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import re
# 读取个人简历内容.json
with open('/Users/apple/Documents/cursor/教务系统/frontend/网页未导入数据/个人简历内容.json', 'r', encoding='utf-8') as f:
resume_data = json.load(f)
# 读取当前的mockData.js文件
with open('/Users/apple/Documents/cursor/教务系统/frontend/src/data/mockData.js', 'r', encoding='utf-8') as f:
mockdata_content = f.read()
# 创建岗位名称到简历内容的映射
position_map = {}
for item in resume_data:
if '❌岗位名称查询' in item and '简历内容' in item:
position_name = item['❌岗位名称查询']
resume_content = item['简历内容']
# 解析简历内容,提取项目经历、专业技能和个人总结
# 项目经历部分
project_match = re.search(r'# 一、项目经历(.*?)(?=# 二、|$)', resume_content, re.DOTALL)
project_experience = ""
if project_match:
project_text = project_match.group(1).strip()
# 清理markdown格式
project_text = project_text.replace('### ', '')
project_text = project_text.replace('# ', '')
project_experience = project_text
# 专业技能部分
skills_match = re.search(r'# 二、[专业技能|掌握技能](.*?)(?=# 三、|$)', resume_content, re.DOTALL)
skills = ""
if skills_match:
skills_text = skills_match.group(1).strip()
skills_text = skills_text.replace('### ', '')
skills_text = skills_text.replace('# ', '')
skills = skills_text
# 个人总结部分
summary_match = re.search(r'# 三、[个人总结|个人评价](.*?)$', resume_content, re.DOTALL)
summary = ""
if summary_match:
summary_text = summary_match.group(1).strip()
summary = summary_text
position_map[position_name] = {
'projectExperience': project_experience,
'skills': skills,
'personalSummary': summary
}
# 输出找到的岗位数量
print(f"找到 {len(position_map)} 个岗位的简历数据")
# 输出所有岗位名称
print("\n已处理的岗位:")
for position_name in sorted(position_map.keys()):
print(f" - {position_name}")
# 保存映射数据为JSON文件供后续使用
with open('/Users/apple/Documents/cursor/教务系统/frontend/scripts/resume_mapping.json', 'w', encoding='utf-8') as f:
json.dump(position_map, f, ensure_ascii=False, indent=2)
print("\n简历数据映射已保存到 resume_mapping.json")
print("请运行 update_mockdata.py 来更新 mockData.js 文件")