| 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() |