File size: 1,515 Bytes
badcf3c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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)