File size: 988 Bytes
935dc57 | 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 | import re
from datasets import load_dataset, Dataset, DatasetDict
def main():
datasets = load_dataset('openlifescienceai/medmcqa')
_datasets = {}
for split in ['train','validation']:
data = []
for example in datasets[split]:
question = str(example['question'])
choices = [example['opa'], example['opb'], example['opc'], example['opd']]
answer_index = example['cop']
answer = chr(ord('A') + answer_index)
data.append({
'question': question.strip(),
'choices': choices,
'answer': answer.strip(),
'answer_index': answer_index
})
dataset = Dataset.from_list(data)
_datasets[split] = dataset
datasets = DatasetDict({
'train': _datasets['train'],
'validation': _datasets['validation'],
})
datasets.push_to_hub('extraordinarylab/medmcqa')
if __name__ == '__main__':
main() |