albertvillanova HF staff commited on
Commit
ceec078
1 Parent(s): b26034a

Delete loading script

Browse files
Files changed (1) hide show
  1. covid_qa_deepset.py +0 -127
covid_qa_deepset.py DELETED
@@ -1,127 +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
- """COVID-QA: A Question Answering Dataset for COVID-19."""
16
-
17
-
18
- import json
19
-
20
- import datasets
21
- from datasets.tasks import QuestionAnsweringExtractive
22
-
23
-
24
- logger = datasets.logging.get_logger(__name__)
25
-
26
-
27
- _CITATION = """\
28
- @inproceedings{moller2020covid,
29
- title={COVID-QA: A Question Answering Dataset for COVID-19},
30
- author={M{\"o}ller, Timo and Reina, Anthony and Jayakumar, Raghavan and Pietsch, Malte},
31
- booktitle={Proceedings of the 1st Workshop on NLP for COVID-19 at ACL 2020},
32
- year={2020}
33
- }
34
- """
35
-
36
- # You can copy an official description
37
- _DESCRIPTION = """\
38
- COVID-QA is a Question Answering dataset consisting of 2,019 question/answer pairs annotated by volunteer biomedical \
39
- experts on scientific articles related to COVID-19.
40
- """
41
-
42
- _HOMEPAGE = "https://github.com/deepset-ai/COVID-QA"
43
-
44
- _LICENSE = "Apache License 2.0"
45
-
46
- _URL = "https://raw.githubusercontent.com/deepset-ai/COVID-QA/master/data/question-answering/"
47
- _URLs = {"covid_qa_deepset": _URL + "COVID-QA.json"}
48
-
49
-
50
- class CovidQADeepset(datasets.GeneratorBasedBuilder):
51
- VERSION = datasets.Version("1.0.0")
52
-
53
- BUILDER_CONFIGS = [
54
- datasets.BuilderConfig(name="covid_qa_deepset", version=VERSION, description="COVID-QA deepset"),
55
- ]
56
-
57
- def _info(self):
58
- features = datasets.Features(
59
- {
60
- "document_id": datasets.Value("int32"),
61
- "context": datasets.Value("string"),
62
- "question": datasets.Value("string"),
63
- "is_impossible": datasets.Value("bool"),
64
- "id": datasets.Value("int32"),
65
- "answers": datasets.features.Sequence(
66
- {
67
- "text": datasets.Value("string"),
68
- "answer_start": datasets.Value("int32"),
69
- }
70
- ),
71
- }
72
- )
73
- return datasets.DatasetInfo(
74
- description=_DESCRIPTION,
75
- features=features,
76
- supervised_keys=None,
77
- homepage=_HOMEPAGE,
78
- license=_LICENSE,
79
- citation=_CITATION,
80
- task_templates=[
81
- QuestionAnsweringExtractive(
82
- question_column="question", context_column="context", answers_column="answers"
83
- )
84
- ],
85
- )
86
-
87
- def _split_generators(self, dl_manager):
88
- url = _URLs[self.config.name]
89
- downloaded_filepath = dl_manager.download_and_extract(url)
90
-
91
- return [
92
- datasets.SplitGenerator(
93
- name=datasets.Split.TRAIN,
94
- gen_kwargs={"filepath": downloaded_filepath},
95
- ),
96
- ]
97
-
98
- def _generate_examples(self, filepath):
99
- """This function returns the examples in the raw (text) form."""
100
- logger.info("generating examples from = %s", filepath)
101
- with open(filepath, encoding="utf-8") as f:
102
- covid_qa = json.load(f)
103
- for article in covid_qa["data"]:
104
- for paragraph in article["paragraphs"]:
105
- context = paragraph["context"].strip()
106
- document_id = paragraph["document_id"]
107
- for qa in paragraph["qas"]:
108
- question = qa["question"].strip()
109
- is_impossible = qa["is_impossible"]
110
- id_ = qa["id"]
111
-
112
- answer_starts = [answer["answer_start"] for answer in qa["answers"]]
113
- answers = [answer["text"].strip() for answer in qa["answers"]]
114
-
115
- # Features currently used are "context", "question", and "answers".
116
- # Others are extracted here for the ease of future expansions.
117
- yield id_, {
118
- "document_id": document_id,
119
- "context": context,
120
- "question": question,
121
- "is_impossible": is_impossible,
122
- "id": id_,
123
- "answers": {
124
- "answer_start": answer_starts,
125
- "text": answers,
126
- },
127
- }