# import json # # 读取JSON文件 # with open('./output/cot/cot/deepseek-ai/DeepSeek-V3_f.json', 'r', encoding='utf-8') as file: # data = json.load(file) # # 处理每个条目,提取Yes或No作为新的answer值 # for item in data: # if "answer" in item: # # 提取Yes或No # answer = item["answer"].split('\n\n')[0] # 取第一个句号前的部分 # # answer = answer.split(',')[0] # # answer = answer.split('.')[0] # # answer = answer.split(',')[0] # item["answer"] = answer # # 保存修改后的数据 # with open('./output/cot/cot/deepseek-ai/DeepSeek-V3_f_modified.json', 'w', encoding='utf-8') as file: # json.dump(data, file, ensure_ascii=False, indent=4) # 导入json模块 import json # 读取JSON文件 with open('F:/GeoLLM/Task2/output/cot1/cot/gpt-3.5-turbo_待处理1.json', 'r', encoding='utf-8') as file: data = json.load(file) # 处理每个条目,提取Yes或No作为新的answer值 for item in data: if "answer" in item: # 提取Yes或No answer = item["answer"].split('\n\n')[0] # 取第一个句号前的部分 # answer = answer.split('\n')[0] # answer = answer.split('.')[0] # answer = answer.split(',')[0] item["answer"] = answer # 保存修改后的数据 with open('F:/GeoLLM/Task2/output/cot1/cot/gpt-3.5-turbo_model.json', 'w', encoding='utf-8') as file: json.dump(data, file, ensure_ascii=False, indent=4)