100 lines
3.9 KiB
Python
100 lines
3.9 KiB
Python
|
|
import json
|
|||
|
|
|
|||
|
|
# 读取食品项目案例数据
|
|||
|
|
with open('网页未导入数据/食品产业/食品项目案例.json', 'r', encoding='utf-8') as f:
|
|||
|
|
food_projects = json.load(f)
|
|||
|
|
|
|||
|
|
# 创建项目列表数据(用于班级项目库)
|
|||
|
|
projects_list = []
|
|||
|
|
|
|||
|
|
# 垂直方向分类映射
|
|||
|
|
direction_map = {
|
|||
|
|
"现代食品工程": "现代食品工程",
|
|||
|
|
"营养配餐与新营养经济店铺经营": "营养配餐与新营养经济店铺经营"
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for idx, project in enumerate(food_projects, 1):
|
|||
|
|
# 创建列表项
|
|||
|
|
list_item = {
|
|||
|
|
"id": idx,
|
|||
|
|
"name": project["案例名称"],
|
|||
|
|
"description": project.get("所属垂直方向", ""),
|
|||
|
|
"positions": project.get("对应个人简历名称", "").split(",") if project.get("对应个人简历名称") else [],
|
|||
|
|
"unit": project.get("对应单元名称(垂直能力课)", "").split(",")[0] if project.get("对应单元名称(垂直能力课)") else "",
|
|||
|
|
"direction": project.get("所属垂直方向", ""),
|
|||
|
|
"category": "食品产业"
|
|||
|
|
}
|
|||
|
|
projects_list.append(list_item)
|
|||
|
|
|
|||
|
|
# 创建详情数据
|
|||
|
|
projects_details = {}
|
|||
|
|
for idx, project in enumerate(food_projects, 1):
|
|||
|
|
# 解析项目内容
|
|||
|
|
content = project.get("项目案例内容", "")
|
|||
|
|
|
|||
|
|
# 提取概述
|
|||
|
|
overview = ""
|
|||
|
|
if "# 一、项目概述" in content:
|
|||
|
|
overview_start = content.find("# 一、项目概述") + len("# 一、项目概述")
|
|||
|
|
overview_end = content.find("# 二、") if "# 二、" in content else len(content)
|
|||
|
|
overview = content[overview_start:overview_end].strip()
|
|||
|
|
|
|||
|
|
# 提取流程
|
|||
|
|
process = ""
|
|||
|
|
if "# 二、项目整体流程介绍" in content:
|
|||
|
|
process_start = content.find("# 二、项目整体流程介绍") + len("# 二、项目整体流程介绍")
|
|||
|
|
process_end = content.find("# 三、") if "# 三、" in content else len(content)
|
|||
|
|
process = content[process_start:process_end].strip()
|
|||
|
|
|
|||
|
|
# 提取关键技术点
|
|||
|
|
keyPoints = ""
|
|||
|
|
if "# 三、项目案例关键技术点" in content:
|
|||
|
|
keyPoints_start = content.find("# 三、项目案例关键技术点") + len("# 三、项目案例关键技术点")
|
|||
|
|
keyPoints = content[keyPoints_start:].strip()
|
|||
|
|
|
|||
|
|
# 处理岗位信息
|
|||
|
|
positions_str = project.get("对应个人简历名称", "")
|
|||
|
|
positions = []
|
|||
|
|
if positions_str:
|
|||
|
|
for pos in positions_str.split(","):
|
|||
|
|
positions.append({
|
|||
|
|
"level": "技术骨干岗",
|
|||
|
|
"position": pos.strip()
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
detail = {
|
|||
|
|
"id": idx,
|
|||
|
|
"name": project["案例名称"],
|
|||
|
|
"positions": positions,
|
|||
|
|
"unit": project.get("对应单元名称(垂直能力课)", "").split(",")[0] if project.get("对应单元名称(垂直能力课)") else "",
|
|||
|
|
"overview": overview[:2000] if overview else "本项目暂无详细概述",
|
|||
|
|
"process": process[:5000] if process else "本项目暂无流程介绍",
|
|||
|
|
"keyPoints": keyPoints[:3000] if keyPoints else "本项目暂无关键技术点"
|
|||
|
|
}
|
|||
|
|
projects_details[idx] = detail
|
|||
|
|
|
|||
|
|
# 输出统计信息
|
|||
|
|
print(f"共处理 {len(food_projects)} 个食品项目案例")
|
|||
|
|
print(f"生成 {len(projects_list)} 个列表项")
|
|||
|
|
print(f"生成 {len(projects_details)} 个详情项")
|
|||
|
|
|
|||
|
|
# 保存处理后的数据
|
|||
|
|
output = {
|
|||
|
|
"projects_list": projects_list,
|
|||
|
|
"projects_details": projects_details
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
with open('food_projects_converted.json', 'w', encoding='utf-8') as f:
|
|||
|
|
json.dump(output, f, ensure_ascii=False, indent=2)
|
|||
|
|
|
|||
|
|
print("数据已保存到 food_projects_converted.json")
|
|||
|
|
|
|||
|
|
# 显示前3个项目作为示例
|
|||
|
|
print("\n前3个项目示例:")
|
|||
|
|
for i in range(min(3, len(projects_list))):
|
|||
|
|
print(f"\n项目 {i+1}:")
|
|||
|
|
print(f" 名称: {projects_list[i]['name']}")
|
|||
|
|
print(f" 方向: {projects_list[i]['direction']}")
|
|||
|
|
print(f" 单元: {projects_list[i]['unit']}")
|
|||
|
|
print(f" 岗位数: {len(projects_list[i]['positions'])}")
|