wangrongsheng commited on
Commit
4d2c0ed
1 Parent(s): fca17d9

Upload 2 files

Browse files
CMB-test/merge-answer-and-question.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from tqdm import tqdm
3
+
4
+ with open('CMB-test-choice-question-merge.json', 'r', encoding='utf-8') as file1:
5
+ questions = json.load(file1)
6
+
7
+ with open('CMB-test-choice-answer.json', 'r', encoding='utf-8') as file2:
8
+ answers = json.load(file2)
9
+
10
+ results = []
11
+ for i in tqdm(range(len(questions))):
12
+ if questions[i]["id"]==5205 or questions[i]["id"]==5211 or questions[i]["id"]==5219 or questions[i]["id"]==5230 or questions[i]["id"]==5235 or questions[i]["id"]==5236 or questions[i]["id"]==5238 or questions[i]["id"]==5241 or questions[i]["id"]==5287 or questions[i]["id"]==5319 or questions[i]["id"]==5375 or questions[i]["id"]==5376 or questions[i]["id"]==5419 or questions[i]["id"]==5421 or questions[i]["id"]==5424 or questions[i]["id"]==5430 or questions[i]["id"]==5435 or questions[i]["id"]==5452 or questions[i]["id"]==5466 or questions[i]["id"]==5481 or questions[i]["id"]==5482 or questions[i]["id"]==5491 or questions[i]["id"]==5516 or questions[i]["id"]==5522 or questions[i]["id"]==5530 or questions[i]["id"]==5548 or questions[i]["id"]==5555 or questions[i]["id"]==5594 or questions[i]["id"]==5596:
13
+ continue
14
+ if questions[i]["question_type"]=="单项选择题":
15
+ info = {
16
+ "id": str(i+1),
17
+ "book_content": questions[i]["question"].replace("( )。", "").replace("()。", "")+questions[i]["option"][answers[i]["answer"]]+"。"
18
+ }
19
+ results.append(info)
20
+ if questions[i]["question_type"]=="多项选择题":
21
+ answer_list = list(answers[i]["answer"])
22
+ answer_res = ""
23
+ m = 0
24
+ for j in answer_list:
25
+ answer_res = answer_res+questions[i]["option"][j]
26
+ if m < len(answer_list) - 1:
27
+ answer_res += ","
28
+ else:
29
+ answer_res += "。"
30
+ info = {
31
+ "id": str(i+1),
32
+ "book_content": questions[i]["question"].replace("( )。", "").replace("()。", "")+answer_res
33
+ }
34
+ results.append(info)
35
+ m = m+1
36
+
37
+ with open('test-book.json', 'w', encoding="utf-8") as f1:
38
+ json.dump(results, f1, ensure_ascii=False, indent=4)
CMB-test/test-book.json ADDED
The diff for this file is too large to render. See raw diff