Delete frenchmedmcqa.py
Browse files- frenchmedmcqa.py +0 -125
frenchmedmcqa.py
DELETED
|
@@ -1,125 +0,0 @@
|
|
| 1 |
-
# coding=utf-8
|
| 2 |
-
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 3 |
-
#
|
| 4 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
-
# you may not use this file except in compliance with the License.
|
| 6 |
-
# You may obtain a copy of the License at
|
| 7 |
-
#
|
| 8 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
-
#
|
| 10 |
-
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
-
# See the License for the specific language governing permissions and
|
| 14 |
-
# limitations under the License.
|
| 15 |
-
"""FrenchMedMCQA : A French Multiple-Choice Question Answering Corpus for Medical domain"""
|
| 16 |
-
|
| 17 |
-
import os
|
| 18 |
-
import json
|
| 19 |
-
|
| 20 |
-
import datasets
|
| 21 |
-
|
| 22 |
-
_DESCRIPTION = """\
|
| 23 |
-
FrenchMedMCQA
|
| 24 |
-
"""
|
| 25 |
-
|
| 26 |
-
_HOMEPAGE = "https://frenchmedmcqa.github.io"
|
| 27 |
-
|
| 28 |
-
_LICENSE = "Apache License 2.0"
|
| 29 |
-
|
| 30 |
-
_URL = "https://drive.google.com/uc?export=download&id=1uH5RvDQnEhfgwC6oXE_xfK63N6Q7slIZ"
|
| 31 |
-
|
| 32 |
-
_CITATION = """\
|
| 33 |
-
@unpublished{labrak:hal-03824241,
|
| 34 |
-
TITLE = {{FrenchMedMCQA: A French Multiple-Choice Question Answering Dataset for Medical domain}},
|
| 35 |
-
AUTHOR = {Labrak, Yanis and Bazoge, Adrien and Dufour, Richard and Daille, Béatrice and Gourraud, Pierre-Antoine and Morin, Emmanuel and Rouvier, Mickael},
|
| 36 |
-
URL = {https://hal.archives-ouvertes.fr/hal-03824241},
|
| 37 |
-
NOTE = {working paper or preprint},
|
| 38 |
-
YEAR = {2022},
|
| 39 |
-
MONTH = Oct,
|
| 40 |
-
PDF = {https://hal.archives-ouvertes.fr/hal-03824241/file/LOUHI_2022___QA-3.pdf},
|
| 41 |
-
HAL_ID = {hal-03824241},
|
| 42 |
-
HAL_VERSION = {v1},
|
| 43 |
-
}
|
| 44 |
-
"""
|
| 45 |
-
|
| 46 |
-
class FrenchMedMCQA(datasets.GeneratorBasedBuilder):
|
| 47 |
-
"""FrenchMedMCQA : A French Multi-Choice Question Answering Corpus for Medical domain"""
|
| 48 |
-
|
| 49 |
-
VERSION = datasets.Version("1.0.0")
|
| 50 |
-
|
| 51 |
-
def _info(self):
|
| 52 |
-
|
| 53 |
-
features = datasets.Features(
|
| 54 |
-
{
|
| 55 |
-
"id": datasets.Value("string"),
|
| 56 |
-
"question": datasets.Value("string"),
|
| 57 |
-
"answer_a": datasets.Value("string"),
|
| 58 |
-
"answer_b": datasets.Value("string"),
|
| 59 |
-
"answer_c": datasets.Value("string"),
|
| 60 |
-
"answer_d": datasets.Value("string"),
|
| 61 |
-
"answer_e": datasets.Value("string"),
|
| 62 |
-
"correct_answers": datasets.Sequence(
|
| 63 |
-
datasets.features.ClassLabel(names=["a", "b", "c", "d", "e"]),
|
| 64 |
-
),
|
| 65 |
-
"type": datasets.Value("string"),
|
| 66 |
-
"subject_name": datasets.Value("string"),
|
| 67 |
-
"number_correct_answers": datasets.features.ClassLabel(names=["1","2","3","4","5"]),
|
| 68 |
-
}
|
| 69 |
-
)
|
| 70 |
-
|
| 71 |
-
return datasets.DatasetInfo(
|
| 72 |
-
description=_DESCRIPTION,
|
| 73 |
-
features=features,
|
| 74 |
-
homepage=_HOMEPAGE,
|
| 75 |
-
license=_LICENSE,
|
| 76 |
-
citation=_CITATION,
|
| 77 |
-
)
|
| 78 |
-
|
| 79 |
-
def _split_generators(self, dl_manager):
|
| 80 |
-
"""Returns SplitGenerators."""
|
| 81 |
-
|
| 82 |
-
data_dir = dl_manager.download_and_extract(_URL) + "/HuggingFace-Train-Dev-Archive-JSON/"
|
| 83 |
-
|
| 84 |
-
return [
|
| 85 |
-
datasets.SplitGenerator(
|
| 86 |
-
name=datasets.Split.TRAIN,
|
| 87 |
-
gen_kwargs={
|
| 88 |
-
"filepath": os.path.join(data_dir, "train.json"),
|
| 89 |
-
},
|
| 90 |
-
),
|
| 91 |
-
datasets.SplitGenerator(
|
| 92 |
-
name=datasets.Split.VALIDATION,
|
| 93 |
-
gen_kwargs={
|
| 94 |
-
"filepath": os.path.join(data_dir, "dev.json"),
|
| 95 |
-
},
|
| 96 |
-
),
|
| 97 |
-
# datasets.SplitGenerator(
|
| 98 |
-
# name=datasets.Split.TEST,
|
| 99 |
-
# gen_kwargs={
|
| 100 |
-
# "filepath": os.path.join(data_dir, "test.json"),
|
| 101 |
-
# },
|
| 102 |
-
# ),
|
| 103 |
-
]
|
| 104 |
-
|
| 105 |
-
def _generate_examples(self, filepath):
|
| 106 |
-
|
| 107 |
-
with open(filepath, encoding="utf-8") as f:
|
| 108 |
-
|
| 109 |
-
data = json.load(f)
|
| 110 |
-
|
| 111 |
-
for key, d in enumerate(data):
|
| 112 |
-
|
| 113 |
-
yield key, {
|
| 114 |
-
"id": d["id"],
|
| 115 |
-
"question": d["question"],
|
| 116 |
-
"answer_a": d["answers"]["a"],
|
| 117 |
-
"answer_b": d["answers"]["b"],
|
| 118 |
-
"answer_c": d["answers"]["c"],
|
| 119 |
-
"answer_d": d["answers"]["d"],
|
| 120 |
-
"answer_e": d["answers"]["e"],
|
| 121 |
-
"correct_answers": d["correct_answers"],
|
| 122 |
-
"number_correct_answers": str(len(d["correct_answers"])),
|
| 123 |
-
"type": d["type"],
|
| 124 |
-
"subject_name": d["subject_name"],
|
| 125 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|