Datasets:

Modalities:
Text
Formats:
json
ArXiv:
Libraries:
Datasets
pandas
License:
File size: 1,956 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import json

def filter_items_based_on_questions(questions_file_path, items_file_path, output_filtered_path, output_removed_path):
    
    with open(questions_file_path, 'r', encoding='utf-8') as file:
        questions = json.load(file)
    
    
    with open(items_file_path, 'r', encoding='utf-8') as file:
        items = json.load(file)

    initial_count = len(items)
    removed_items = []
    
    
    print("Starting filtering process...")
    filtered_items = []
    for index, item in enumerate(items):
        if index % 100 == 0:  # 每处理100个项目,打印一次进度
            print(f"Processed {index}/{initial_count} items...")
        sameFlag = False
        i_question = item[0].split('\n')[1][10:]
        for question in questions:
            if question in item[0]:
                if len(question) >= 64 or i_question == question: 
                    removed_items.append([item, question])
                    sameFlag = True
                    break
        if not sameFlag:
            filtered_items.append(item)
            
    
    final_count = len(filtered_items)
    
    
    with open(output_filtered_path, 'w', encoding='utf-8') as file:
        json.dump(filtered_items, file, ensure_ascii=False, indent=4)
        
   
    with open(output_removed_path, 'w', encoding='utf-8') as file:
        json.dump(removed_items, file, ensure_ascii=False, indent=4)
        
    print(f"Initial item count: {initial_count}")
    print(f"Final item count: {final_count}")
    print(f"Removed item count: {len(removed_items)}")
    print("Filtering process completed.")


questions_file_path = "./questions/fr_question.json"
items_file_path = "../train/sft/medicalExam_fr.json"
output_filtered_path = "../train/sft/medicalExam_fr_clean.json"
output_removed_path = "../train/sft/medicalExam_fr_dup.json"

filter_items_based_on_questions(questions_file_path, items_file_path, output_filtered_path, output_removed_path)