yangwang825 commited on
Commit
b39323c
·
verified ·
1 Parent(s): 5ff6dab

Create prepare.py

Browse files
Files changed (1) hide show
  1. prepare.py +33 -0
prepare.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ from datasets import load_dataset, Dataset, DatasetDict
3
+
4
+
5
+ def main():
6
+ datasets = load_dataset('kg-rag/BiomixQA', 'mcq')
7
+
8
+ _datasets = {}
9
+ for split in ['train']:
10
+ data = []
11
+ for example in datasets[split]:
12
+ question = str(example['text'])
13
+ question = question.split('Given list is:')[0]
14
+ choices = [example['option_A'],example['option_B'], example['option_C'], example['option_D'], example['option_E']]
15
+ answer_index = choices.index(example['correct_answer'])
16
+ answer = chr(ord('A') + answer_index)
17
+ data.append({
18
+ 'question': question.strip(),
19
+ 'choices': choices,
20
+ 'answer': answer.strip(),
21
+ 'answer_index': answer_index
22
+ })
23
+ dataset = Dataset.from_list(data)
24
+ _datasets[split] = dataset
25
+
26
+ datasets = DatasetDict({
27
+ 'test': _datasets['train'],
28
+ })
29
+ datasets.push_to_hub('extraordinarylab/biomix-qa')
30
+
31
+
32
+ if __name__ == '__main__':
33
+ main()