Datasets:

Modalities:
Text
Formats:
json
ArXiv:
Libraries:
Datasets
pandas
License:
File size: 872 Bytes
07de217
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8fde075
 
07de217
 
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
import json

def extract_unique_strings(input_file_path, output_file_path):
    with open(input_file_path, 'r', encoding='utf-8') as file:
        items = json.load(file)
    
    # 提取item[1],这里假设每个item都至少有两个元素
    strings = [item[1] for item in items if len(item) > 1]
    
    # 去重
    unique_strings = list(set(strings))
    
    # 保存为JSON文件
    with open(output_file_path, 'w', encoding='utf-8') as file:
        json.dump(unique_strings, file, ensure_ascii=False, indent=4)
    
    # 打印去重后的列表长度
    print(f"Number of unique strings: {len(unique_strings)}")

# 替换以下路径为你的输入文件和输出文件路径
input_file_path = 'train/sft/medicalExam_es_dup.json'
output_file_path = 'train/sft/medicalExam_es_dup_question.json'

extract_unique_strings(input_file_path, output_file_path)