Datasets:

Languages:
English
License:
gabrielaltay commited on
Commit
200f5f2
1 Parent(s): aae2aaa

initial commit

Browse files
Files changed (4) hide show
  1. LICENSE +26 -0
  2. README.md +49 -0
  3. bigbiohub.py +153 -0
  4. bioasq_task_b.py +795 -0
LICENSE ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: National Library of Medicine Terms and Conditions
2
+ short_name: NLM_LICENSE
3
+
4
+
5
+ National Library of Medicine Terms and Conditions
6
+
7
+ INTRODUCTION
8
+
9
+ Downloading data from the National Library of Medicine FTP servers indicates your acceptance of the following Terms and Conditions: No charges, usage fees or royalties are paid to NLM for this data.
10
+
11
+ GENERAL TERMS AND CONDITIONS
12
+
13
+ Users of the data agree to:
14
+ acknowledge NLM as the source of the data by including the phrase "Courtesy of the U.S. National Library of Medicine" in a clear and conspicuous manner,
15
+ properly use registration and/or trademark symbols when referring to NLM products, and
16
+ not indicate or imply that NLM has endorsed its products/services/applications.
17
+
18
+ Users who republish or redistribute the data (services, products or raw data) agree to:
19
+ maintain the most current version of all distributed data, or
20
+ make known in a clear and conspicuous manner that the products/services/applications do not reflect the most current/accurate data available from NLM.
21
+
22
+ These data are produced with a reasonable standard of care, but NLM makes no warranties express or implied, including no warranty of merchantability or fitness for particular purpose, regarding the accuracy or completeness of the data. Users agree to hold NLM and the U.S. Government harmless from any liability resulting from errors in the data. NLM disclaims any liability for any consequences due to use, misuse, or interpretation of information contained or not contained in the data.
23
+
24
+ NLM does not provide legal advice regarding copyright, fair use, or other aspects of intellectual property rights. See the NLM Copyright page.
25
+
26
+ NLM reserves the right to change the type and format of its machine-readable data. NLM will take reasonable steps to inform users of any changes to the format of the data before the data are distributed via the announcement section or subscription to email and RSS updates.
README.md CHANGED
@@ -1,3 +1,52 @@
1
  ---
 
2
  license: other
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language: en
3
  license: other
4
+ multilinguality: monolingual
5
+ pretty_name: BioASQ Task B
6
  ---
7
+
8
+
9
+ # Dataset Card for BioASQ Task B
10
+
11
+ ## Dataset Description
12
+
13
+ - **Homepage:** http://participants-area.bioasq.org/datasets/
14
+ - **Pubmed:** True
15
+ - **Public:** False
16
+ - **Tasks:** Question Answering
17
+
18
+
19
+ The BioASQ corpus contains multiple question
20
+ answering tasks annotated by biomedical experts, including yes/no, factoid, list,
21
+ and summary questions. Pertaining to our objective of comparing neural language
22
+ models, we focus on the the yes/no questions (Task 7b), and leave the inclusion
23
+ of other tasks to future work. Each question is paired with a reference text
24
+ containing multiple sentences from a PubMed abstract and a yes/no answer. We use
25
+ the official train/dev/test split of 670/75/140 questions.
26
+
27
+ See 'Domain-Specific Language Model Pretraining for Biomedical
28
+ Natural Language Processing'
29
+
30
+
31
+ ## Citation Information
32
+
33
+ ```
34
+ @article{tsatsaronis2015overview,
35
+ title = {
36
+ An overview of the BIOASQ large-scale biomedical semantic indexing and
37
+ question answering competition
38
+ },
39
+ author = {
40
+ Tsatsaronis, George and Balikas, Georgios and Malakasiotis, Prodromos
41
+ and Partalas, Ioannis and Zschunke, Matthias and Alvers, Michael R and
42
+ Weissenborn, Dirk and Krithara, Anastasia and Petridis, Sergios and
43
+ Polychronopoulos, Dimitris and others
44
+ },
45
+ year = 2015,
46
+ journal = {BMC bioinformatics},
47
+ publisher = {BioMed Central Ltd},
48
+ volume = 16,
49
+ number = 1,
50
+ pages = 138
51
+ }
52
+ ```
bigbiohub.py ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass
2
+ from enum import Enum
3
+ import datasets
4
+ from types import SimpleNamespace
5
+
6
+
7
+ BigBioValues = SimpleNamespace(NULL="<BB_NULL_STR>")
8
+
9
+
10
+ @dataclass
11
+ class BigBioConfig(datasets.BuilderConfig):
12
+ """BuilderConfig for BigBio."""
13
+
14
+ name: str = None
15
+ version: datasets.Version = None
16
+ description: str = None
17
+ schema: str = None
18
+ subset_id: str = None
19
+
20
+
21
+ class Tasks(Enum):
22
+ NAMED_ENTITY_RECOGNITION = "NER"
23
+ NAMED_ENTITY_DISAMBIGUATION = "NED"
24
+ EVENT_EXTRACTION = "EE"
25
+ RELATION_EXTRACTION = "RE"
26
+ COREFERENCE_RESOLUTION = "COREF"
27
+ QUESTION_ANSWERING = "QA"
28
+ TEXTUAL_ENTAILMENT = "TE"
29
+ SEMANTIC_SIMILARITY = "STS"
30
+ TEXT_PAIRS_CLASSIFICATION = "TXT2CLASS"
31
+ PARAPHRASING = "PARA"
32
+ TRANSLATION = "TRANSL"
33
+ SUMMARIZATION = "SUM"
34
+ TEXT_CLASSIFICATION = "TXTCLASS"
35
+
36
+
37
+ entailment_features = datasets.Features(
38
+ {
39
+ "id": datasets.Value("string"),
40
+ "premise": datasets.Value("string"),
41
+ "hypothesis": datasets.Value("string"),
42
+ "label": datasets.Value("string"),
43
+ }
44
+ )
45
+
46
+ pairs_features = datasets.Features(
47
+ {
48
+ "id": datasets.Value("string"),
49
+ "document_id": datasets.Value("string"),
50
+ "text_1": datasets.Value("string"),
51
+ "text_2": datasets.Value("string"),
52
+ "label": datasets.Value("string"),
53
+ }
54
+ )
55
+
56
+ qa_features = datasets.Features(
57
+ {
58
+ "id": datasets.Value("string"),
59
+ "question_id": datasets.Value("string"),
60
+ "document_id": datasets.Value("string"),
61
+ "question": datasets.Value("string"),
62
+ "type": datasets.Value("string"),
63
+ "choices": [datasets.Value("string")],
64
+ "context": datasets.Value("string"),
65
+ "answer": datasets.Sequence(datasets.Value("string")),
66
+ }
67
+ )
68
+
69
+ text_features = datasets.Features(
70
+ {
71
+ "id": datasets.Value("string"),
72
+ "document_id": datasets.Value("string"),
73
+ "text": datasets.Value("string"),
74
+ "labels": [datasets.Value("string")],
75
+ }
76
+ )
77
+
78
+ text2text_features = datasets.Features(
79
+ {
80
+ "id": datasets.Value("string"),
81
+ "document_id": datasets.Value("string"),
82
+ "text_1": datasets.Value("string"),
83
+ "text_2": datasets.Value("string"),
84
+ "text_1_name": datasets.Value("string"),
85
+ "text_2_name": datasets.Value("string"),
86
+ }
87
+ )
88
+
89
+ kb_features = datasets.Features(
90
+ {
91
+ "id": datasets.Value("string"),
92
+ "document_id": datasets.Value("string"),
93
+ "passages": [
94
+ {
95
+ "id": datasets.Value("string"),
96
+ "type": datasets.Value("string"),
97
+ "text": datasets.Sequence(datasets.Value("string")),
98
+ "offsets": datasets.Sequence([datasets.Value("int32")]),
99
+ }
100
+ ],
101
+ "entities": [
102
+ {
103
+ "id": datasets.Value("string"),
104
+ "type": datasets.Value("string"),
105
+ "text": datasets.Sequence(datasets.Value("string")),
106
+ "offsets": datasets.Sequence([datasets.Value("int32")]),
107
+ "normalized": [
108
+ {
109
+ "db_name": datasets.Value("string"),
110
+ "db_id": datasets.Value("string"),
111
+ }
112
+ ],
113
+ }
114
+ ],
115
+ "events": [
116
+ {
117
+ "id": datasets.Value("string"),
118
+ "type": datasets.Value("string"),
119
+ # refers to the text_bound_annotation of the trigger
120
+ "trigger": {
121
+ "text": datasets.Sequence(datasets.Value("string")),
122
+ "offsets": datasets.Sequence([datasets.Value("int32")]),
123
+ },
124
+ "arguments": [
125
+ {
126
+ "role": datasets.Value("string"),
127
+ "ref_id": datasets.Value("string"),
128
+ }
129
+ ],
130
+ }
131
+ ],
132
+ "coreferences": [
133
+ {
134
+ "id": datasets.Value("string"),
135
+ "entity_ids": datasets.Sequence(datasets.Value("string")),
136
+ }
137
+ ],
138
+ "relations": [
139
+ {
140
+ "id": datasets.Value("string"),
141
+ "type": datasets.Value("string"),
142
+ "arg1_id": datasets.Value("string"),
143
+ "arg2_id": datasets.Value("string"),
144
+ "normalized": [
145
+ {
146
+ "db_name": datasets.Value("string"),
147
+ "db_id": datasets.Value("string"),
148
+ }
149
+ ],
150
+ }
151
+ ],
152
+ }
153
+ )
bioasq_task_b.py ADDED
@@ -0,0 +1,795 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 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
+ """
16
+ BioASQ Task B On Biomedical Semantic QA (Involves IR, QA, Summarization qnd
17
+ More). This task uses benchmark datasets containing development and test
18
+ questions, in English, along with gold standard (reference) answers constructed
19
+ by a team of biomedical experts. The participants have to respond with relevant
20
+ concepts, articles, snippets and RDF triples, from designated resources, as well
21
+ as exact and 'ideal' answers.
22
+
23
+ Fore more information about the challenge, the organisers and the relevant
24
+ publications please visit: http://bioasq.org/
25
+ """
26
+ import glob
27
+ import json
28
+ import os
29
+ import re
30
+
31
+ import datasets
32
+
33
+ from .bigbiohub import qa_features
34
+ from .bigbiohub import BigBioConfig
35
+ from .bigbiohub import Tasks
36
+
37
+ _LANGUAGES = ["English"]
38
+ _PUBMED = True
39
+ _LOCAL = True
40
+ _CITATION = """\
41
+ @article{tsatsaronis2015overview,
42
+ title = {
43
+ An overview of the BIOASQ large-scale biomedical semantic indexing and
44
+ question answering competition
45
+ },
46
+ author = {
47
+ Tsatsaronis, George and Balikas, Georgios and Malakasiotis, Prodromos
48
+ and Partalas, Ioannis and Zschunke, Matthias and Alvers, Michael R and
49
+ Weissenborn, Dirk and Krithara, Anastasia and Petridis, Sergios and
50
+ Polychronopoulos, Dimitris and others
51
+ },
52
+ year = 2015,
53
+ journal = {BMC bioinformatics},
54
+ publisher = {BioMed Central Ltd},
55
+ volume = 16,
56
+ number = 1,
57
+ pages = 138
58
+ }
59
+ """
60
+
61
+ _DATASETNAME = "bioasq_task_b"
62
+ _DISPLAYNAME = "BioASQ Task B"
63
+
64
+ _BIOASQ_10B_DESCRIPTION = """\
65
+ The data are intended to be used as training and development data for BioASQ
66
+ 10, which will take place during 2022. There is one file containing the data:
67
+ - training10b.json
68
+
69
+ The file contains the data of the first nine editions of the challenge: 4234
70
+ questions [1] with their relevant documents, snippets, concepts and RDF
71
+ triples, exact and ideal answers.
72
+
73
+ Differences with BioASQ-training9b.json
74
+ - 492 new questions added from BioASQ9
75
+ - The question with id 56c1f01eef6e394741000046 had identical body with
76
+ 602498cb1cb411341a00009e. All relevant elements from both questions
77
+ are available in the merged question with id 602498cb1cb411341a00009e.
78
+ - The question with id 5c7039207c78d69471000065 had identical body with
79
+ 601c317a1cb411341a000014. All relevant elements from both questions
80
+ are available in the merged question with id 601c317a1cb411341a000014.
81
+ - The question with id 5e4b540b6d0a27794100001c had identical body with
82
+ 602828b11cb411341a0000fc. All relevant elements from both questions
83
+ are available in the merged question with id 602828b11cb411341a0000fc.
84
+ - The question with id 5fdb42fba43ad31278000027 had identical body with
85
+ 5d35eb01b3a638076300000f. All relevant elements from both questions
86
+ are available in the merged question with id 5d35eb01b3a638076300000f.
87
+ - The question with id 601d76311cb411341a000045 had identical body with
88
+ 6060732b94d57fd87900003d. All relevant elements from both questions
89
+ are available in the merged question with id 6060732b94d57fd87900003d.
90
+
91
+ [1] 4234 questions : 1252 factoid, 1148 yesno, 1018 summary, 816 list
92
+ """
93
+
94
+ _BIOASQ_9B_DESCRIPTION = """\
95
+ The data are intended to be used as training and development data for BioASQ 9,
96
+ which will take place during 2021. There is one file containing the data:
97
+ - training9b.json
98
+
99
+ The file contains the data of the first seven editions of the challenge: 3742
100
+ questions [1] with their relevant documents, snippets, concepts and RDF triples,
101
+ exact and ideal answers.
102
+
103
+ Differences with BioASQ-training8b.json
104
+ - 499 new questions added from BioASQ8
105
+ - The question with id 5e30e689fbd6abf43b00003a had identical body with
106
+ 5880e417713cbdfd3d000001. All relevant elements from both questions
107
+ are available in the merged question with id 5880e417713cbdfd3d000001.
108
+
109
+ [1] 3742 questions : 1091 factoid, 1033 yesno, 899 summary, 719 list
110
+ """
111
+
112
+ _BIOASQ_8B_DESCRIPTION = """\
113
+ The data are intended to be used as training and development data for BioASQ 8,
114
+ which will take place during 2020. There is one file containing the data:
115
+ - training8b.json
116
+
117
+ The file contains the data of the first seven editions of the challenge: 3243
118
+ questions [1] with their relevant documents, snippets, concepts and RDF triples,
119
+ exact and ideal answers.
120
+
121
+ Differences with BioASQ-training7b.json
122
+ - 500 new questions added from BioASQ7
123
+ - 4 questions were removed
124
+ - The question with id 5717fb557de986d80d000009 had identical body with
125
+ 571e06447de986d80d000016. All relevant elements from both questions
126
+ are available in the merged question with id 571e06447de986d80d000016.
127
+ - The question with id 5c589ddb86df2b917400000b had identical body with
128
+ 5c6b7a9e7c78d69471000029. All relevant elements from both questions
129
+ are available in the merged question with id 5c6b7a9e7c78d69471000029.
130
+ - The question with id 52ffb5d12059c6d71c00007c had identical body with
131
+ 52e7870a98d023950500001a. All relevant elements from both questions
132
+ are available in the merged question with id 52e7870a98d023950500001a.
133
+ - The question with id 53359338d6d3ac6a3400004f had identical body with
134
+ 589a246878275d0c4a000030. All relevant elements from both questions
135
+ are available in the merged question with id 589a246878275d0c4a000030.
136
+
137
+ **** UPDATE 25/02/2020 *****
138
+ The previous version of the dataset contained an inconsistency on question with
139
+ id "5c9904eaecadf2e73f00002e", where the "ideal_answer" field was missing.
140
+ This has been fixed.
141
+ """
142
+
143
+ _BIOASQ_7B_DESCRIPTION = """\
144
+ The data are intended to be used as training and development data for BioASQ 7,
145
+ which will take place during 2019. There is one file containing the data:
146
+ - BioASQ-trainingDataset7b.json
147
+
148
+ The file contains the data of the first six editions of the challenge: 2747
149
+ questions [1] with their relevant documents, snippets, concepts and RDF triples,
150
+ exact and ideal answers.
151
+
152
+ Differences with BioASQ-trainingDataset6b.json
153
+ - 500 new questions added from BioASQ6
154
+ - 4 questions were removed
155
+ - The question with id 569ed752ceceede94d000004 had identical body with
156
+ a new question from BioASQ6. All relevant elements from both questions
157
+ are available in the merged question with id 5abd31e0fcf456587200002c
158
+ - 3 questions were removed as incomplete: 54d643023706e89528000007,
159
+ 532819afd6d3ac6a3400000f, 517545168ed59a060a00002b
160
+ - 4 questions were revised for various confusions that have been identified
161
+ - In 2 questions the ideal answer has been revised :
162
+ 51406e6223fec90375000009, 5172f8118ed59a060a000019
163
+ - In 4 questions the snippets and documents list has been revised :
164
+ 51406e6223fec90375000009, 5172f8118ed59a060a000019,
165
+ 51593dc8d24251bc05000099, 5158a5b8d24251bc05000097
166
+ - In 198 questions the documents list has updated with missing
167
+ documents from the relevant snippets list. [2]
168
+
169
+ [1] 2747 questions : 779 factoid, 745 yesno, 667 summary, 556 list
170
+ [2] 55031181e9bde69634000014, 51406e6223fec90375000009, 54d643023706e89528000007,
171
+ 52bf1b0a03868f1b06000009, 52bf19c503868f1b06000001, 51593dc8d24251bc05000099,
172
+ 530a5117970c65fa6b000007, 553a8d78f321868558000003, 531a3fe3b166e2b806000038,
173
+ 532819afd6d3ac6a3400000f, 5158a5b8d24251bc05000097, 553653a5bc4f83e828000007,
174
+ 535d2cf09a4572de6f000004, 53386282d6d3ac6a3400005a, 517a8ce98ed59a060a000045,
175
+ 55391ce8bc4f83e828000018, 5547d700f35db75526000007, 5713bf261174fb1755000011,
176
+ 6f15c5a2ac5ed1459000012, 52b2e498f828ad283c000010, 570a7594cf1c325851000026,
177
+ 530cefaaad0bf1360c000012, 530f685c329f5fcf1e000002, 550c4011a103b78016000009,
178
+ 552faababc4f83e828000005, 54cf48acf693c3b16b00000b, 550313aae9bde6963400001f,
179
+ 551177626a8cde6b72000005, 54eded8c94afd6150400000c, 550c3754a103b78016000007,
180
+ 56f555b609dd18d46b000007, 54c26e29f693c3b16b000003, 54da0c524b1fd0d33c00000b,
181
+ 52bf1d3c03868f1b0600000d, 5343bdd6aeec6fbd07000001, 52cb9b9b03868f1b0600002d,
182
+ 55423875ec76f5e50c000002, 571366ba1174fb1755000005, 56c4d14ab04e159d0e000003,
183
+ 550c44d1a103b7801600000a, 5547a01cf35db75526000005, 55422640ccca0ce74b000004,
184
+ 54ecb66d445c3b5a5f000002, 553656c4bc4f83e828000009, 5172f8118ed59a060a000019,
185
+ 513711055274a5fb0700000e, 54d892ee014675820d000005, 52e6c92598d0239505000019,
186
+ 5353aedb288f4dae47000006, 52bf1f1303868f1b06000014, 5519113b622b19434500000f,
187
+ 52b2f1724003448f5500000b, 5525317687ecba3764000007, 554a0cadf35db7552600000f,
188
+ 55152bd246478f2f2c000002, 516c3960298dcd4e51000073, 571e417bbb137a4b0c00000a,
189
+ 551910d3622b194345000008, 54dc8ed6c0bb8dce23000002, 511a4ec01159fa8212000004,
190
+ 54d8ea2c4b1fd0d33c000002, 5148e1d6d24251bc0500003a, 515dbb3b298dcd4e51000018,
191
+ 56f7c15a09dd18d46b000012, 51475d5cd24251bc0500001b, 54db7c4ac0bb8dce23000001,
192
+ 57152ebbcb4ef8864c000002, 57134d511174fb1755000002, 55149f156a8cde6b72000013,
193
+ 56bcd422d36b5da378000005, 54ede5c394afd61504000006, 517545168ed59a060a00002b,
194
+ 5710ed19a5ed216440000003, 53442472aeec6fbd07000008, 55088e412e93f0133a000001,
195
+ 54d762653706e89528000014, 550aef0ec2af5d5b7000000a, 552435602c8b63434a000009,
196
+ 552446612c8b63434a00000c, 54d901ec4b1fd0d33c000006, 54cf45e7f693c3b16b00000a,
197
+ 52fc8b772059c6d71c00006e, 5314d05adae131f84700000d, 5512c91b6a8cde6b7200000b,
198
+ 56c5a7605795f9a73e000002, 55030a6ce9bde6963400000f, 553fac39c6a5098552000001,
199
+ 531a3a58b166e2b806000037, 5509bd6a1180f13250000002, 54f9c40ddd3fc62544000001,
200
+ 553c8fd1f32186855800000a, 56bce51cd36b5da37800000a, 550316a6e9bde69634000029,
201
+ 55031286e9bde6963400001b, 536e46f27d100faa09000012, 5502abd1e9bde69634000008,
202
+ 551af9106b348bb82c000002, 54edeb4394afd6150400000b, 5717cdd2070aa3d072000001,
203
+ 56c5ade15795f9a73e000003, 531464a6e3eabad021000014, 58a0d87a78275d0c4a000053,
204
+ 58a3160d60087bc10a00000a, 58a5d54860087bc10a000025, 58a0da5278275d0c4a000054,
205
+ 58a3264e60087bc10a00000d, 589c8ef878275d0c4a000042, 58a3428d60087bc10a00001b,
206
+ 58a3196360087bc10a00000b, 58a341eb60087bc10a000018, 58a3275960087bc10a00000f,
207
+ 58a342e760087bc10a00001c, 58bd645702b8c60953000010, 58bc8e5002b8c60953000006,
208
+ 58bc8e7a02b8c60953000007, 58a1da4e78275d0c4a000059, 58bcb83d02b8c6095300000f,
209
+ 58bc9a5002b8c60953000008, 589dee3778275d0c4a000050, 58a32efe60087bc10a000013,
210
+ 58a327bf60087bc10a000011, 58bca08702b8c6095300000a, 58bc9dbb02b8c60953000009,
211
+ 58c99fcc02b8c60953000029, 58bca2f302b8c6095300000c, 58cbf1f402b8c60953000036,
212
+ 58cdb41302b8c60953000042, 58cdb80302b8c60953000043, 58cdbaf302b8c60953000044,
213
+ 58cb305c02b8c60953000032, 58caf86f02b8c60953000030, 58c1b2f702b8c6095300001e,
214
+ 58bde18b02b8c60953000014, 58eb7898eda5a57672000006, 58caf88c02b8c60953000031,
215
+ 58e11bf76fddd3e83e00000c, 58cdbbd102b8c60953000045, 58df779d6fddd3e83e000001,
216
+ 58dbb4f08acda3452900001a, 58dbb8968acda3452900001b, 58add7699ef3c34033000009,
217
+ 58dbbbf08acda3452900001d, 58dbba438acda3452900001c, 58dd2cb08acda34529000029,
218
+ 58eb9542eda5a57672000007, 58f3ca5c70f9fc6f0f00000d, 58e9e7aa3e8b6dc87c00000d,
219
+ 58e3d9ab3e8b6dc87c000002, 58eb4ce7eda5a57672000004, 58f3c8f470f9fc6f0f00000c,
220
+ 58f3c62970f9fc6f0f00000b, 58adca6d9ef3c34033000007, 58f4b3ee70f9fc6f0f000013,
221
+ 593ff22b70f9fc6f0f000023, 5a679875b750ff4455000004, 5a774585faa1ab7d2e000005,
222
+ 5a6f7245b750ff4455000050, 5a787544faa1ab7d2e00000b, 5a74d9980384be9551000008,
223
+ 5a6a02a3b750ff4455000021, 5a6e47b1b750ff4455000049, 5a87124561bb38fb24000001,
224
+ 5a6e42f1b750ff4455000046, 5a8b1264fcd1d6a10c00001d, 5a981e66fcd1d6a10c00002f,
225
+ 5a8718c861bb38fb24000008, 5a7615af83b0d9ea6600001f, 5a87140a61bb38fb24000003,
226
+ 5a77072c9e632bc06600000a, 5a897601fcd1d6a10c000008, 5a871a6861bb38fb24000009,
227
+ 5a74e9ad0384be955100000a, 5a79d25dfaa1ab7d2e00000f, 5a6900ebb750ff445500001d,
228
+ 5a87145861bb38fb24000004, 5a871b8d61bb38fb2400000a, 5a897a06fcd1d6a10c00000b,
229
+ 5a8dc6b4fcd1d6a10c000026, 5a8712af61bb38fb24000002, 5a8714e261bb38fb24000005,
230
+ 5aa304f1d6d6b54f79000004, 5a981bcffcd1d6a10c00002d, 5aa3fa73d6d6b54f79000008,
231
+ 5aa55b45d6d6b54f7900000d, 5a981dd0fcd1d6a10c00002e, 5a9700adfcd1d6a10c00002c,
232
+ 5a9d8ffe1d1251d03b000022, 5a96c74cfcd1d6a10c000029, 5aa50086d6d6b54f7900000c,
233
+ 5a95765bfcd1d6a10c000028, 5a96f40cfcd1d6a10c00002b, 5ab144fefcf4565872000012,
234
+ 5aa67b4fd6d6b54f7900000f, 5abd5a62fcf4565872000031, 5abbe429fcf456587200001c,
235
+ 5aaef38dfcf456587200000f, 5abce6acfcf4565872000022, 5aae6499fcf456587200000c
236
+ """
237
+
238
+ _BIOASQ_6B_DESCRIPTION = """\
239
+ The data are intended to be used as training and development data for BioASQ 6,
240
+ which will take place during 2018. There is one file containing the data:
241
+ - BioASQ-trainingDataset6b.json
242
+
243
+ Differences with BioASQ-trainingDataset5b.json
244
+ - 500 new questions added from BioASQ5
245
+ - 48 pairs of questions with identical bodies have been merged into one
246
+ question having only one question-id, but all the documents, snippets,
247
+ concepts, RDF triples and answers of both questions of the pair.
248
+ - This normalization lead to the removal of 48 deprecated question
249
+ ids [2] from the dataset and to the update of the 48 remaining
250
+ questions [3].
251
+ - In cases where a pair of questions with identical bodies had some
252
+ inconsistency (e.g. different question type), the inconsistency has
253
+ been solved merging the pair manually consulting the BioASQ expert team.
254
+ - 12 questions were revised for various confusions that have been
255
+ identified
256
+ - In 8 questions the question type has been changed to better suit to
257
+ the question body. The change of type lead to corresponding changes
258
+ in exact answers existence and format : 54fc4e2e6ea36a810c000003,
259
+ 530b01a6970c65fa6b000008, 530cf54dab4de4de0c000009,
260
+ 531b2fc3b166e2b80600003c, 532819afd6d3ac6a3400000f,
261
+ 532aad53d6d3ac6a34000010, 5710ade4cf1c32585100002c,
262
+ 52f65f372059c6d71c000027
263
+ - In 6 questions the ideal answer has been revised :
264
+ 532aad53d6d3ac6a34000010, 5710ade4cf1c32585100002c,
265
+ 53147b52e3eabad021000015, 5147c8a6d24251bc05000027,
266
+ 5509bd6a1180f13250000002, 58bbb71f22d3005309000016
267
+ - In 5 questions the exact answer has been revised :
268
+ 5314bd7ddae131f847000006, 53130a77e3eabad02100000f,
269
+ 53148a07dae131f847000002, 53147b52e3eabad021000015,
270
+ 5147c8a6d24251bc05000027
271
+ - In 2 questions the question body has been revised :
272
+ 52f65f372059c6d71c000027, 5503145ee9bde69634000022
273
+ - In lists of ideal answers, documents, snippets, concepts and RDF triples
274
+ any duplicate identical elements have been removed.
275
+ - Ideal answers in format of one string have been converted to a list with
276
+ one element for consistency with cases where more than one golden ideal
277
+ answers are available. (i.e. "ideal_ans1" converted to ["ideal_ans1"])
278
+ - For yesno questions: All exact answers have been normalized to "yes" or
279
+ "no" (replacing "Yes", "YES" and "No")
280
+ - For factoid questions: The format of the exact answer was normalized to a
281
+ list of strings for each question, representing a set of synonyms
282
+ answering the question (i.e. [`ans1`, `syn11`, ... ]).
283
+ - For list questions: The format of the exact answer was normalized to a
284
+ list of lists. Each internal list represents one element of the answer
285
+ as a set of synonyms
286
+ (i.e. [[`ans1`, `syn11`, `syn12`], [`ans2`], [`ans3`, `syn31`] ...]).
287
+ - Empty elements, e.g. empty lists of documents have been removed.
288
+
289
+ [1] 2251 questions : 619 factoid, 616 yesno, 531 summary, 485 list
290
+ [2] The 48 deprecated question ids are : 52f8b2902059c6d71c000053,
291
+ 52f11bf22059c6d71c000005, 52f77edb2059c6d71c000028, 52ed795098d0239505000032,
292
+ 56d1a9baab2fed4a47000002, 52f7d3472059c6d71c00002f, 52fbe2bf2059c6d71c00006c,
293
+ 52ec961098d023950500002a, 52e8e98298d0239505000020, 56cae5125795f9a73e000024,
294
+ 530cefaaad0bf1360c000007, 530cefaaad0bf1360c000005, 52d63b2803868f1b0600003a,
295
+ 530cefaaad0bf1360c00000a, 516425ff298dcd4e51000051, 55191149622b194345000010,
296
+ 52fa70142059c6d71c000056, 52f77f4d2059c6d71c00002a, 52efc016c8da89891000001a,
297
+ 52efc001c8da898910000019, 52f896ae2059c6d71c000045, 52eceada98d023950500002d,
298
+ 52efc05cc8da89891000001c, 515e078e298dcd4e51000031, 52fe54252059c6d71c000079,
299
+ 514217a6d24251bc05000005, 52d1389303868f1b06000032, 530cf4d5e2bfff940c000003,
300
+ 52fc946d2059c6d71c000071, 52e8e99e98d0239505000021, 52ef7786c8da898910000015,
301
+ 52d8494698d0239505000007, 530cf51d5610acba0c000001, 52f637972059c6d71c000025,
302
+ 52e9f99798d0239505000025, 515de572298dcd4e51000021, 52fe4ad52059c6d71c000077,
303
+ 52f65bf02059c6d71c000026, 52e8e9d298d0239505000022, 52fa74052059c6d71c00005a,
304
+ 52ffbddf2059c6d71c00007d, 56bc932aac7ad1001900001c, 56c02883ef6e394741000017,
305
+ 52d2b75403868f1b06000035, 52f118aa2059c6d71c000003, 52e929eb98d0239505000023,
306
+ 532c12f2d6d3ac6a3400001d, 52d8466298d0239505000006'
307
+ [3] The 48 questions resulting from merging with their pair have the
308
+ following ids: 5149aafcd24251bc05000045, 515db020298dcd4e51000011,
309
+ 515db54c298dcd4e51000016, 51680a49298dcd4e51000062, 52b06a68f828ad283c000005,
310
+ 52bf1aa503868f1b06000006, 52bf1af803868f1b06000008, 52bf1d6003868f1b0600000e,
311
+ 52cb9b9b03868f1b0600002d, 52d2818403868f1b06000033, 52df887498d023950500000c,
312
+ 52e0c9a298d0239505000010, 52e203bc98d0239505000011, 52e62bae98d0239505000015,
313
+ 52e6c92598d0239505000019, 52e7bbf698d023950500001d, 52ea605098d0239505000028,
314
+ 52ece29f98d023950500002c, 52ecf2dd98d023950500002e, 52ef7754c8da898910000014,
315
+ 52f112bb2059c6d71c000002, 52f65f372059c6d71c000027, 52f77f752059c6d71c00002b,
316
+ 52f77f892059c6d71c00002c, 52f89ee42059c6d71c00004d, 52f89f4f2059c6d71c00004e,
317
+ 52f89fba2059c6d71c00004f, 52f89fc62059c6d71c000050, 52f89fd32059c6d71c000051,
318
+ 52fa6ac72059c6d71c000055, 52fa73c62059c6d71c000058, 52fa73e82059c6d71c000059,
319
+ 52fa74252059c6d71c00005b, 52fc8b772059c6d71c00006e, 52fc94572059c6d71c000070,
320
+ 52fc94ae2059c6d71c000073, 52fc94db2059c6d71c000074, 52fe52702059c6d71c000078,
321
+ 52fe58f82059c6d71c00007a, 530cefaaad0bf1360c000008, 530cefaaad0bf1360c000010,
322
+ 533ba218fd9a95ea0d000007, 534bb147aeec6fbd07000014, 55167dec46478f2f2c00000a,
323
+ 56c04412ef6e39474100001b, 56c1f01eef6e394741000046, 56c81fd15795f9a73e00000c,
324
+ 587d016ed673c3eb14000002
325
+ """
326
+
327
+ _BIOASQ_5B_DESCRIPTION = """\
328
+ The data are intended to be used as training and development data for BioASQ 5,
329
+ which will take place during 2017. There is one file containing the data:
330
+ - BioASQ-trainingDataset5b.json
331
+
332
+ The file contains the data of the first four editions of the challenge: 1799
333
+ questions with their relevant documents, snippets, concepts and rdf triples,
334
+ exact and ideal answers.
335
+ """
336
+
337
+ _BIOASQ_4B_DESCRIPTION = """\
338
+ The data are intended to be used as training and development data for BioASQ 4,
339
+ which will take place during 2016. There is one file containing the data:
340
+ - BioASQ-trainingDataset4b.json
341
+
342
+ The file contains the data of the first three editions of the challenge: 1307
343
+ questions with their relevant documents, snippets, concepts and rdf triples,
344
+ exact and ideal answers from the first two editions and 497 questions with
345
+ similar annotations from the third editions of the challenge.
346
+ """
347
+
348
+ _BIOASQ_3B_DESCRIPTION = """No README provided."""
349
+
350
+ _BIOASQ_2B_DESCRIPTION = """No README provided."""
351
+
352
+ _BIOASQ_BLURB_DESCRIPTION = """The BioASQ corpus contains multiple question
353
+ answering tasks annotated by biomedical experts, including yes/no, factoid, list,
354
+ and summary questions. Pertaining to our objective of comparing neural language
355
+ models, we focus on the the yes/no questions (Task 7b), and leave the inclusion
356
+ of other tasks to future work. Each question is paired with a reference text
357
+ containing multiple sentences from a PubMed abstract and a yes/no answer. We use
358
+ the official train/dev/test split of 670/75/140 questions.
359
+
360
+ See 'Domain-Specific Language Model Pretraining for Biomedical
361
+ Natural Language Processing' """
362
+
363
+ _DESCRIPTION = {
364
+ "bioasq_10b": _BIOASQ_10B_DESCRIPTION,
365
+ "bioasq_9b": _BIOASQ_9B_DESCRIPTION,
366
+ "bioasq_8b": _BIOASQ_8B_DESCRIPTION,
367
+ "bioasq_7b": _BIOASQ_7B_DESCRIPTION,
368
+ "bioasq_6b": _BIOASQ_6B_DESCRIPTION,
369
+ "bioasq_5b": _BIOASQ_5B_DESCRIPTION,
370
+ "bioasq_4b": _BIOASQ_4B_DESCRIPTION,
371
+ "bioasq_3b": _BIOASQ_3B_DESCRIPTION,
372
+ "bioasq_2b": _BIOASQ_2B_DESCRIPTION,
373
+ "bioasq_blurb": _BIOASQ_BLURB_DESCRIPTION,
374
+ }
375
+
376
+ _HOMEPAGE = "http://participants-area.bioasq.org/datasets/"
377
+
378
+ # Data access reqires registering with BioASQ.
379
+ # See http://participants-area.bioasq.org/accounts/register/
380
+ _LICENSE = "NLM_LICENSE"
381
+
382
+ _URLs = {
383
+ "bioasq_10b": ["BioASQ-training10b.zip", None],
384
+ "bioasq_9b": ["BioASQ-training9b.zip", "Task9BGoldenEnriched.zip"],
385
+ "bioasq_8b": ["BioASQ-training8b.zip", "Task8BGoldenEnriched.zip"],
386
+ "bioasq_7b": ["BioASQ-training7b.zip", "Task7BGoldenEnriched.zip"],
387
+ "bioasq_6b": ["BioASQ-training6b.zip", "Task6BGoldenEnriched.zip"],
388
+ "bioasq_5b": ["BioASQ-training5b.zip", "Task5BGoldenEnriched.zip"],
389
+ "bioasq_4b": ["BioASQ-training4b.zip", "Task4BGoldenEnriched.zip"],
390
+ "bioasq_3b": ["BioASQ-trainingDataset3b.zip", "Task3BGoldenEnriched.zip"],
391
+ "bioasq_2b": ["BioASQ-trainingDataset2b.zip", "Task2BGoldenEnriched.zip"],
392
+ "bioasq_blurb": ["BioASQ-training7b.zip", "Task7BGoldenEnriched.zip"],
393
+ }
394
+
395
+ # BLURB train and dev contain all yesno questions from the offical training split
396
+ # test is all yesno question from the official test split
397
+ _BLURB_SPLITS = {
398
+ "dev": {
399
+ "5313b049e3eabad021000013",
400
+ "553a8d78f321868558000003",
401
+ "5158a5b8d24251bc05000097",
402
+ "571e3d42bb137a4b0c000007",
403
+ "5175b97a8ed59a060a00002f",
404
+ "56c9e9d15795f9a73e00001d",
405
+ "56d19ffaab2fed4a47000001",
406
+ "518ccac0310faafe0800000b",
407
+ "56f12ca92ac5ed145900000e",
408
+ "51680a49298dcd4e51000062",
409
+ "5339ed7bd6d3ac6a34000060",
410
+ "516e5f33298dcd4e5100007e",
411
+ "5327139ad6d3ac6a3400000d",
412
+ "54e12ae3ae9738404b000004",
413
+ "5321b8579b2d7acc7e000008",
414
+ "514a4679d24251bc0500005b",
415
+ "54c12fd1f693c3b16b000001",
416
+ "52df887498d023950500000c",
417
+ "52f20d802059c6d71c00000a",
418
+ "532f0c4ed6d3ac6a3400002e",
419
+ "52b2f3b74003448f5500000c",
420
+ "52b2f1724003448f5500000b",
421
+ "515d9a42298dcd4e5100000d",
422
+ "5159b990d24251bc050000a3",
423
+ "54e12c30ae9738404b000005",
424
+ "553a6a9fbc4f83e82800001c",
425
+ "5509ec41c2af5d5b70000006",
426
+ "56cae40b5795f9a73e000022",
427
+ "51680b0e298dcd4e51000065",
428
+ "515df89e298dcd4e5100002f",
429
+ "54f49e56d0d681a040000004",
430
+ "571e3e2abb137a4b0c000008",
431
+ "515debe7298dcd4e51000026",
432
+ "56f6ab7009dd18d46b00000d",
433
+ "53302bced6d3ac6a34000039",
434
+ "5322de919b2d7acc7e000012",
435
+ "5709f212cf1c325851000020",
436
+ "5502abd1e9bde69634000008",
437
+ "516c220e298dcd4e51000071",
438
+ "5894597e7d9090f353000004",
439
+ "5895ec5e7d9090f353000015",
440
+ "58bbb8ae22d3005309000018",
441
+ "58bc58c302b8c60953000001",
442
+ "58c276bc02b8c60953000020",
443
+ "58c0825502b8c6095300001b",
444
+ "58ab1f6c9ef3c34033000002",
445
+ "58adbe999ef3c34033000005",
446
+ "58df3e408acda3452900002d",
447
+ "58dfec676fddd3e83e000006",
448
+ "58d8d0cc8acda34529000008",
449
+ "58b67fae22d3005309000009",
450
+ "58dbbbf08acda3452900001d",
451
+ "58dbba438acda3452900001c",
452
+ "58dbbdac8acda3452900001e",
453
+ "58dcbb8c8acda34529000021",
454
+ "5a468785966455904c00000d",
455
+ "5a70de5199e2c3af26000005",
456
+ "5a67a550b750ff4455000009",
457
+ "5a679875b750ff4455000004",
458
+ "5a7a44b4faa1ab7d2e000010",
459
+ "5a67ade5b750ff445500000c",
460
+ "5a8881118cb19eca6b000006",
461
+ "5a67b48cb750ff4455000010",
462
+ "5a679be1b750ff4455000005",
463
+ "5a7340962dc08e987e000017",
464
+ "5a737e233b9d13c70800000d",
465
+ "5a8dc57ffcd1d6a10c000025",
466
+ "5a6d186db750ff4455000031",
467
+ "5a70d43b99e2c3af26000003",
468
+ "5a70ec6899e2c3af2600000c",
469
+ "5a9ac4161d1251d03b000010",
470
+ "5a733d2a2dc08e987e000015",
471
+ "5a74acd80384be9551000006",
472
+ "5aa6800ad6d6b54f79000011",
473
+ "5a9d9ab94e03427e73000003",
474
+ }
475
+ }
476
+
477
+ _SUPPORTED_TASKS = [Tasks.QUESTION_ANSWERING]
478
+ _SOURCE_VERSION = "1.0.0"
479
+ _BIGBIO_VERSION = "1.0.0"
480
+
481
+
482
+ class BioasqTaskBDataset(datasets.GeneratorBasedBuilder):
483
+ """
484
+ BioASQ Task B On Biomedical Semantic QA.
485
+ Creates configs for BioASQ2 through BioASQ10.
486
+ """
487
+
488
+ DEFAULT_CONFIG_NAME = "bioasq_9b_source"
489
+ SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
490
+ BIGBIO_VERSION = datasets.Version(_BIGBIO_VERSION)
491
+
492
+ # BioASQ2 through BioASQ10
493
+ BUILDER_CONFIGS = []
494
+ for version in range(2, 11):
495
+ BUILDER_CONFIGS.append(
496
+ BigBioConfig(
497
+ name=f"bioasq_{version}b_source",
498
+ version=SOURCE_VERSION,
499
+ description=f"bioasq{version} Task B source schema",
500
+ schema="source",
501
+ subset_id=f"bioasq_{version}b",
502
+ )
503
+ )
504
+
505
+ BUILDER_CONFIGS.append(
506
+ BigBioConfig(
507
+ name=f"bioasq_{version}b_bigbio_qa",
508
+ version=BIGBIO_VERSION,
509
+ description=f"bioasq{version} Task B in simplified BigBio schema",
510
+ schema="bigbio_qa",
511
+ subset_id=f"bioasq_{version}b",
512
+ )
513
+ )
514
+
515
+ # BLURB Benchmark config https://microsoft.github.io/BLURB/
516
+ BUILDER_CONFIGS.append(
517
+ BigBioConfig(
518
+ name=f"bioasq_blurb_bigbio_qa",
519
+ version=BIGBIO_VERSION,
520
+ description=f"BLURB benchmark in simplified BigBio schema",
521
+ schema="bigbio_qa",
522
+ subset_id=f"bioasq_blurb",
523
+ )
524
+ )
525
+
526
+ def _info(self):
527
+
528
+ # BioASQ Task B source schema
529
+ if self.config.schema == "source":
530
+ features = datasets.Features(
531
+ {
532
+ "id": datasets.Value("string"),
533
+ "type": datasets.Value("string"),
534
+ "body": datasets.Value("string"),
535
+ "documents": datasets.Sequence(datasets.Value("string")),
536
+ "concepts": datasets.Sequence(datasets.Value("string")),
537
+ "ideal_answer": datasets.Sequence(datasets.Value("string")),
538
+ "exact_answer": datasets.Sequence(datasets.Value("string")),
539
+ "triples": [
540
+ {
541
+ "p": datasets.Value("string"),
542
+ "s": datasets.Value("string"),
543
+ "o": datasets.Value("string"),
544
+ }
545
+ ],
546
+ "snippets": [
547
+ {
548
+ "offsetInBeginSection": datasets.Value("int32"),
549
+ "offsetInEndSection": datasets.Value("int32"),
550
+ "text": datasets.Value("string"),
551
+ "beginSection": datasets.Value("string"),
552
+ "endSection": datasets.Value("string"),
553
+ "document": datasets.Value("string"),
554
+ }
555
+ ],
556
+ }
557
+ )
558
+ # simplified schema for QA tasks
559
+ elif self.config.schema == "bigbio_qa":
560
+ features = qa_features
561
+
562
+ return datasets.DatasetInfo(
563
+ description=_DESCRIPTION[self.config.subset_id],
564
+ features=features,
565
+ supervised_keys=None,
566
+ homepage=_HOMEPAGE,
567
+ license=str(_LICENSE),
568
+ citation=_CITATION,
569
+ )
570
+
571
+ def _dump_gold_json(self, data_dir):
572
+ """
573
+ BioASQ test data is split into multiple records {9B1_golden.json,...,9B5_golden.json}
574
+ We combine these files into a single test set file 9Bx_golden.json
575
+ """
576
+ # BLURB is based on version 7
577
+ version = (
578
+ re.search(r"bioasq_([0-9]+)b", self.config.subset_id).group(1)
579
+ if "blurb" not in self.config.name
580
+ else "7"
581
+ )
582
+ gold_fpath = os.path.join(
583
+ data_dir, f"Task{version}BGoldenEnriched/bx_golden.json"
584
+ )
585
+
586
+ if not os.path.exists(gold_fpath):
587
+ # combine all gold json files
588
+ filelist = glob.glob(os.path.join(data_dir, "*/*.json"))
589
+ data = {"questions": []}
590
+ for fname in sorted(filelist):
591
+ with open(fname, "rt", encoding="utf-8") as file:
592
+ data["questions"].extend(json.load(file)["questions"])
593
+ # dump gold to json
594
+ with open(gold_fpath, "wt", encoding="utf-8") as file:
595
+ json.dump(data, file, indent=2)
596
+
597
+ return f"Task{version}BGoldenEnriched/bx_golden.json"
598
+
599
+ def _blurb_split_generator(self, train_dir, test_dir):
600
+ """
601
+ Create splits for BLURB Benchmark
602
+ """
603
+ gold_fpath = self._dump_gold_json(test_dir)
604
+
605
+ # create train/dev splits from yesno questions
606
+ train_fpath = os.path.join(train_dir, "blurb_bioasq_train.json")
607
+ dev_fpath = os.path.join(train_dir, "blurb_bioasq_dev.json")
608
+
609
+ blurb_splits = {
610
+ "train": {"questions": []},
611
+ "dev": {"questions": []},
612
+ "test": {"questions": []},
613
+ }
614
+
615
+ if not os.path.exists(train_fpath):
616
+ data_fpath = os.path.join(train_dir, "BioASQ-training7b/trainining7b.json")
617
+ with open(data_fpath, "rt", encoding="utf-8") as file:
618
+ data = json.load(file)
619
+
620
+ for record in data["questions"]:
621
+ if record["type"] != "yesno":
622
+ continue
623
+ if record["id"] in _BLURB_SPLITS["dev"]:
624
+ blurb_splits["dev"]["questions"].append(record)
625
+ else:
626
+ blurb_splits["train"]["questions"].append(record)
627
+
628
+ with open(train_fpath, "wt", encoding="utf-8") as file:
629
+ json.dump(blurb_splits["train"], file, indent=2)
630
+
631
+ with open(dev_fpath, "wt", encoding="utf-8") as file:
632
+ json.dump(blurb_splits["dev"], file, indent=2)
633
+
634
+ # create test split from yesno questions
635
+ with open(os.path.join(test_dir, gold_fpath), "rt", encoding="utf-8") as file:
636
+ data = json.load(file)
637
+
638
+ for record in data["questions"]:
639
+ if record["type"] != "yesno":
640
+ continue
641
+ blurb_splits["test"]["questions"].append(record)
642
+
643
+ test_fpath = os.path.join(test_dir, "blurb_bioasq_test.json")
644
+ with open(test_fpath, "wt", encoding="utf-8") as file:
645
+ json.dump(blurb_splits["test"], file, indent=2)
646
+
647
+ return [
648
+ datasets.SplitGenerator(
649
+ name=datasets.Split.TRAIN,
650
+ gen_kwargs={
651
+ "filepath": train_fpath,
652
+ "split": "train",
653
+ },
654
+ ),
655
+ datasets.SplitGenerator(
656
+ name=datasets.Split.VALIDATION,
657
+ gen_kwargs={
658
+ "filepath": dev_fpath,
659
+ "split": "dev",
660
+ },
661
+ ),
662
+ datasets.SplitGenerator(
663
+ name=datasets.Split.TEST,
664
+ gen_kwargs={
665
+ "filepath": test_fpath,
666
+ "split": "test",
667
+ },
668
+ ),
669
+ ]
670
+
671
+ def _split_generators(self, dl_manager):
672
+ """Returns SplitGenerators."""
673
+
674
+ if self.config.data_dir is None:
675
+ raise ValueError(
676
+ "This is a local dataset. Please pass the data_dir kwarg to load_dataset."
677
+ )
678
+
679
+ train_dir, test_dir = dl_manager.download_and_extract(
680
+ [
681
+ os.path.join(self.config.data_dir, _url)
682
+ for _url in _URLs[self.config.subset_id]
683
+ ]
684
+ )
685
+ # create gold dump and get path
686
+ gold_fpath = self._dump_gold_json(test_dir)
687
+
688
+ # older versions of bioasq have different folder formats
689
+ train_fpaths = {
690
+ "bioasq_2b": "BioASQ_2013_TaskB/BioASQ-trainingDataset2b.json",
691
+ "bioasq_3b": "BioASQ-trainingDataset3b.json",
692
+ "bioasq_4b": "BioASQ-training4b/BioASQ-trainingDataset4b.json",
693
+ "bioasq_5b": "BioASQ-training5b/BioASQ-trainingDataset5b.json",
694
+ "bioasq_6b": "BioASQ-training6b/BioASQ-trainingDataset6b.json",
695
+ "bioasq_7b": "BioASQ-training7b/trainining7b.json",
696
+ "bioasq_8b": "training8b.json", # HACK - this zipfile strips the dirname
697
+ "bioasq_9b": "BioASQ-training9b/training9b.json",
698
+ "bioasq_10b": "BioASQ-training10b/training10b.json",
699
+ }
700
+
701
+ # BLURB has custom train/dev/test splits based on Task 7B
702
+ if "blurb" in self.config.name:
703
+ return self._blurb_split_generator(train_dir, test_dir)
704
+
705
+ return [
706
+ datasets.SplitGenerator(
707
+ name=datasets.Split.TRAIN,
708
+ gen_kwargs={
709
+ "filepath": os.path.join(
710
+ train_dir, train_fpaths[self.config.subset_id]
711
+ ),
712
+ "split": "train",
713
+ },
714
+ ),
715
+ datasets.SplitGenerator(
716
+ name=datasets.Split.TEST,
717
+ gen_kwargs={
718
+ "filepath": os.path.join(test_dir, gold_fpath),
719
+ "split": "test",
720
+ },
721
+ ),
722
+ ]
723
+
724
+ def _get_exact_answer(self, record):
725
+ """The value exact_answer can be in different formats based on question type."""
726
+ if record["type"] == "yesno":
727
+ exact_answer = [record["exact_answer"]]
728
+ elif record["type"] == "summary":
729
+ exact_answer = []
730
+ # summary question types only have an ideal answer, so use that for bigbio
731
+ if self.config.schema == "bigbio_qa":
732
+ exact_answer = (
733
+ record["ideal_answer"]
734
+ if isinstance(record["ideal_answer"], list)
735
+ else [record["ideal_answer"]]
736
+ )
737
+
738
+ elif record["type"] == "list":
739
+ exact_answer = record["exact_answer"]
740
+ elif record["type"] == "factoid":
741
+ # older version of bioasq sometimes represent this as as string
742
+ exact_answer = (
743
+ record["exact_answer"]
744
+ if isinstance(record["exact_answer"], list)
745
+ else [record["exact_answer"]]
746
+ )
747
+ return exact_answer
748
+
749
+ def _generate_examples(self, filepath, split):
750
+ """Yields examples as (key, example) tuples."""
751
+
752
+ if self.config.schema == "source":
753
+ with open(filepath, encoding="utf-8") as file:
754
+ data = json.load(file)
755
+ for i, record in enumerate(data["questions"]):
756
+ yield i, {
757
+ "id": record["id"],
758
+ "type": record["type"],
759
+ "body": record["body"],
760
+ "documents": record["documents"],
761
+ "concepts": record["concepts"] if "concepts" in record else [],
762
+ "triples": record["triples"] if "triples" in record else [],
763
+ "ideal_answer": record["ideal_answer"]
764
+ if isinstance(record["ideal_answer"], list)
765
+ else [record["ideal_answer"]],
766
+ "exact_answer": self._get_exact_answer(record),
767
+ "snippets": record["snippets"] if "snippets" in record else [],
768
+ }
769
+
770
+ elif self.config.schema == "bigbio_qa":
771
+ # NOTE: Years 2014-2016 (BioASQ2-BioASQ4) have duplicate records
772
+ cache = set()
773
+ with open(filepath, encoding="utf-8") as file:
774
+ uid = 0
775
+ data = json.load(file)
776
+ for record in data["questions"]:
777
+ # for questions that do not have snippets, skip
778
+ if "snippets" not in record:
779
+ continue
780
+ for i, snippet in enumerate(record["snippets"]):
781
+ key = f'{record["id"]}_{i}'
782
+ # ignore duplicate records
783
+ if key not in cache:
784
+ cache.add(key)
785
+ yield uid, {
786
+ "id": key,
787
+ "document_id": snippet["document"],
788
+ "question_id": record["id"],
789
+ "question": record["body"],
790
+ "type": record["type"],
791
+ "choices": [],
792
+ "context": snippet["text"],
793
+ "answer": self._get_exact_answer(record),
794
+ }
795
+ uid += 1