#!/usr/bin/env python3 # -*- coding: utf-8 -*- import json import re # 读取数据 with open('resume_updates.json', 'r', encoding='utf-8') as f: updates = json.load(f) # 读取当前的resumeInterviewMock.js文件 with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f: content = f.read() # 定义需要更新的岗位和其所属行业 position_mapping = { '露营地运营专员': '露营地运营', # 需要创建新行业 '文创产品设计师': '文旅产品设计', '文创产品策划师': '文旅产品设计', '文创产品设计师助理': '文旅产品设计', '品牌策划运营专员': '品牌运营', '品牌公关': '品牌运营', '品牌推广专员': '品牌运营', 'ip运营': '品牌运营', 'ip运营总监助理': '品牌运营', '品牌公关管培生': '品牌运营' } # 生成更新代码 for update in updates: position = update['position'] student_info = update['studentInfo'] # 清理数据中的额外空格和错误文本 if student_info['project_experience']['project_name']: student_info['project_experience']['project_name'] = student_info['project_experience']['project_name'].strip() if student_info['project_experience']['position']: student_info['project_experience']['position'] = student_info['project_experience']['position'].strip() if student_info['project_experience']['time_period']: student_info['project_experience']['time_period'] = student_info['project_experience']['time_period'].strip() if student_info['project_experience']['company']: student_info['project_experience']['company'] = student_info['project_experience']['company'].strip() # 清理core_skills中的错误文本 cleaned_core_skills = [] for skill in student_info['core_skills']: # 移除开头的"chubu "等错误文本 skill = re.sub(r'^chubu\s+', '', skill) skill = skill.strip() if skill: cleaned_core_skills.append(skill) student_info['core_skills'] = cleaned_core_skills # 清理compound_skills cleaned_compound_skills = [] for skill in student_info['compound_skills']: skill = skill.strip() if skill: cleaned_compound_skills.append(skill) student_info['compound_skills'] = cleaned_compound_skills print(f"\n处理岗位: {position}") print(f" - 项目名称: {student_info['project_experience']['project_name']}") print(f" - 核心技能数: {len(student_info['core_skills'])}") print(f" - 复合技能数: {len(student_info['compound_skills'])}") print(f" - 个人总结长度: {len(student_info['personal_summary'])}") # 保存清理后的数据 with open('resume_updates_cleaned.json', 'w', encoding='utf-8') as f: json.dump(updates, f, ensure_ascii=False, indent=2) print("\n数据清理完成,保存到 resume_updates_cleaned.json")