Datasets:
Commit
•
4ba01c7
1
Parent(s):
1bb72c0
Convert dataset to Parquet (#5)
Browse files- Convert dataset to Parquet (0e9e7446210d6a2b3c8466a60576e0c44f31f8e1)
- Add Ade_corpus_v2_drug_ade_relation data files (0e2cdb256773133f88dec09545619dfe8c7d36a2)
- Add Ade_corpus_v2_drug_dosage_relation data files (7ada1679dd325b89ea9e7ce9c03640fdb29e02b7)
- Delete loading script (6066b295f83d8376685b7a7f274e545ef833d079)
Ade_corpus_v2_classification/train-00000-of-00001.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:599e7777b35170c40a7d4cdf5cbb1941fad7d6565f1bd7182b2bf271d30379f5
|
3 |
+
size 1706476
|
Ade_corpus_v2_drug_ade_relation/train-00000-of-00001.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f7c34957a1d9e7c0977df67d490d60422937ecd027336b40b92c419708b038b7
|
3 |
+
size 491362
|
Ade_corpus_v2_drug_dosage_relation/train-00000-of-00001.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:28c17febe1b716cb64b9febab703c40a22826dcc561b3265c0443d6c0109ff2c
|
3 |
+
size 33004
|
README.md
CHANGED
@@ -41,7 +41,7 @@ dataset_info:
|
|
41 |
- name: train
|
42 |
num_bytes: 3403699
|
43 |
num_examples: 23516
|
44 |
-
download_size:
|
45 |
dataset_size: 3403699
|
46 |
- config_name: Ade_corpus_v2_drug_ade_relation
|
47 |
features:
|
@@ -69,7 +69,7 @@ dataset_info:
|
|
69 |
- name: train
|
70 |
num_bytes: 1545993
|
71 |
num_examples: 6821
|
72 |
-
download_size:
|
73 |
dataset_size: 1545993
|
74 |
- config_name: Ade_corpus_v2_drug_dosage_relation
|
75 |
features:
|
@@ -97,8 +97,21 @@ dataset_info:
|
|
97 |
- name: train
|
98 |
num_bytes: 64697
|
99 |
num_examples: 279
|
100 |
-
download_size:
|
101 |
dataset_size: 64697
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
train-eval-index:
|
103 |
- config: Ade_corpus_v2_classification
|
104 |
task: text-classification
|
|
|
41 |
- name: train
|
42 |
num_bytes: 3403699
|
43 |
num_examples: 23516
|
44 |
+
download_size: 1706476
|
45 |
dataset_size: 3403699
|
46 |
- config_name: Ade_corpus_v2_drug_ade_relation
|
47 |
features:
|
|
|
69 |
- name: train
|
70 |
num_bytes: 1545993
|
71 |
num_examples: 6821
|
72 |
+
download_size: 491362
|
73 |
dataset_size: 1545993
|
74 |
- config_name: Ade_corpus_v2_drug_dosage_relation
|
75 |
features:
|
|
|
97 |
- name: train
|
98 |
num_bytes: 64697
|
99 |
num_examples: 279
|
100 |
+
download_size: 33004
|
101 |
dataset_size: 64697
|
102 |
+
configs:
|
103 |
+
- config_name: Ade_corpus_v2_classification
|
104 |
+
data_files:
|
105 |
+
- split: train
|
106 |
+
path: Ade_corpus_v2_classification/train-*
|
107 |
+
- config_name: Ade_corpus_v2_drug_ade_relation
|
108 |
+
data_files:
|
109 |
+
- split: train
|
110 |
+
path: Ade_corpus_v2_drug_ade_relation/train-*
|
111 |
+
- config_name: Ade_corpus_v2_drug_dosage_relation
|
112 |
+
data_files:
|
113 |
+
- split: train
|
114 |
+
path: Ade_corpus_v2_drug_dosage_relation/train-*
|
115 |
train-eval-index:
|
116 |
- config: Ade_corpus_v2_classification
|
117 |
task: text-classification
|
ade_corpus_v2.py
DELETED
@@ -1,267 +0,0 @@
|
|
1 |
-
# coding=utf-8
|
2 |
-
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
|
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 |
-
# Lint as: python3
|
17 |
-
|
18 |
-
""" Adverse Drug Reaction Data: ADE-Corpus-V2 """
|
19 |
-
|
20 |
-
|
21 |
-
import re
|
22 |
-
|
23 |
-
import datasets
|
24 |
-
|
25 |
-
|
26 |
-
_CITATION = """\
|
27 |
-
@article{GURULINGAPPA2012885,
|
28 |
-
title = "Development of a benchmark corpus to support the automatic extraction of drug-related adverse effects from medical case reports",
|
29 |
-
journal = "Journal of Biomedical Informatics",
|
30 |
-
volume = "45",
|
31 |
-
number = "5",
|
32 |
-
pages = "885 - 892",
|
33 |
-
year = "2012",
|
34 |
-
note = "Text Mining and Natural Language Processing in Pharmacogenomics",
|
35 |
-
issn = "1532-0464",
|
36 |
-
doi = "https://doi.org/10.1016/j.jbi.2012.04.008",
|
37 |
-
url = "http://www.sciencedirect.com/science/article/pii/S1532046412000615",
|
38 |
-
author = "Harsha Gurulingappa and Abdul Mateen Rajput and Angus Roberts and Juliane Fluck and Martin Hofmann-Apitius and Luca Toldo",
|
39 |
-
keywords = "Adverse drug effect, Benchmark corpus, Annotation, Harmonization, Sentence classification",
|
40 |
-
abstract = "A significant amount of information about drug-related safety issues such as adverse effects are published in medical case reports that can only be explored by human readers due to their unstructured nature. The work presented here aims at generating a systematically annotated corpus that can support the development and validation of methods for the automatic extraction of drug-related adverse effects from medical case reports. The documents are systematically double annotated in various rounds to ensure consistent annotations. The annotated documents are finally harmonized to generate representative consensus annotations. In order to demonstrate an example use case scenario, the corpus was employed to train and validate models for the classification of informative against the non-informative sentences. A Maximum Entropy classifier trained with simple features and evaluated by 10-fold cross-validation resulted in the F1 score of 0.70 indicating a potential useful application of the corpus."
|
41 |
-
}
|
42 |
-
"""
|
43 |
-
|
44 |
-
_DESCRIPTION = """\
|
45 |
-
ADE-Corpus-V2 Dataset: Adverse Drug Reaction Data.
|
46 |
-
This is a dataset for Classification if a sentence is ADE-related (True) or not (False) and Relation Extraction between Adverse Drug Event and Drug.
|
47 |
-
DRUG-AE.rel provides relations between drugs and adverse effects.
|
48 |
-
DRUG-DOSE.rel provides relations between drugs and dosages.
|
49 |
-
ADE-NEG.txt provides all sentences in the ADE corpus that DO NOT contain any drug-related adverse effects.
|
50 |
-
"""
|
51 |
-
|
52 |
-
_DOWNLOAD_URL = "https://raw.githubusercontent.com/trunghlt/AdverseDrugReaction/master/ADE-Corpus-V2/{}-{}.{}"
|
53 |
-
|
54 |
-
# Different usage configs/
|
55 |
-
configs = {
|
56 |
-
"classification": "Ade_corpus_v2_classification",
|
57 |
-
"RE_ade": "Ade_corpus_v2_drug_ade_relation",
|
58 |
-
"RE_dosage": "Ade_corpus_v2_drug_dosage_relation",
|
59 |
-
}
|
60 |
-
|
61 |
-
|
62 |
-
class ADE_Corpus_V2Config(datasets.BuilderConfig):
|
63 |
-
"""BuilderConfig for ADE_Corpus_V2."""
|
64 |
-
|
65 |
-
def __init__(self, **kwargs):
|
66 |
-
"""BuilderConfig for ADE_Corpus_V2.
|
67 |
-
Args:
|
68 |
-
**kwargs: keyword arguments forwarded to super.
|
69 |
-
"""
|
70 |
-
super(ADE_Corpus_V2Config, self).__init__(**kwargs)
|
71 |
-
|
72 |
-
|
73 |
-
class ADECorpusV2(datasets.GeneratorBasedBuilder):
|
74 |
-
"""ADE_Corpus_V2 Dataset: Adverse Drug Reaction Data for Classification and Relation Extraction tasks ."""
|
75 |
-
|
76 |
-
BUILDER_CONFIGS = [
|
77 |
-
ADE_Corpus_V2Config(
|
78 |
-
name="Ade_corpus_v2_classification",
|
79 |
-
version=datasets.Version("1.0.0"),
|
80 |
-
description="ADE_Corpus_V2 Dataset for Classification if a sentence is ADE-related or not.",
|
81 |
-
),
|
82 |
-
ADE_Corpus_V2Config(
|
83 |
-
name="Ade_corpus_v2_drug_ade_relation",
|
84 |
-
version=datasets.Version("1.0.0"),
|
85 |
-
description="ADE_Corpus_V2 Dataset for Relation Extraction between Adverse Drug Event and Drug.",
|
86 |
-
),
|
87 |
-
ADE_Corpus_V2Config(
|
88 |
-
name="Ade_corpus_v2_drug_dosage_relation",
|
89 |
-
version=datasets.Version("1.0.0"),
|
90 |
-
description="ADE_Corpus_V2 Dataset for Relation Extraction between Drug dosage and Drug.",
|
91 |
-
),
|
92 |
-
]
|
93 |
-
|
94 |
-
def _info(self):
|
95 |
-
|
96 |
-
if self.config.name == configs["classification"]:
|
97 |
-
features = datasets.Features(
|
98 |
-
{
|
99 |
-
"text": datasets.Value("string"),
|
100 |
-
"label": datasets.features.ClassLabel(names=["Not-Related", "Related"]),
|
101 |
-
}
|
102 |
-
)
|
103 |
-
|
104 |
-
if self.config.name == configs["RE_ade"]:
|
105 |
-
features = datasets.Features(
|
106 |
-
{
|
107 |
-
"text": datasets.Value("string"),
|
108 |
-
"drug": datasets.Value("string"),
|
109 |
-
"effect": datasets.Value("string"),
|
110 |
-
"indexes": {
|
111 |
-
"drug": datasets.Sequence(
|
112 |
-
{
|
113 |
-
"start_char": datasets.Value("int32"),
|
114 |
-
"end_char": datasets.Value("int32"),
|
115 |
-
}
|
116 |
-
),
|
117 |
-
"effect": datasets.Sequence(
|
118 |
-
{
|
119 |
-
"start_char": datasets.Value("int32"),
|
120 |
-
"end_char": datasets.Value("int32"),
|
121 |
-
}
|
122 |
-
),
|
123 |
-
},
|
124 |
-
}
|
125 |
-
)
|
126 |
-
|
127 |
-
if self.config.name == configs["RE_dosage"]:
|
128 |
-
features = datasets.Features(
|
129 |
-
{
|
130 |
-
"text": datasets.Value("string"),
|
131 |
-
"drug": datasets.Value("string"),
|
132 |
-
"dosage": datasets.Value("string"),
|
133 |
-
"indexes": {
|
134 |
-
"drug": datasets.Sequence(
|
135 |
-
{
|
136 |
-
"start_char": datasets.Value("int32"),
|
137 |
-
"end_char": datasets.Value("int32"),
|
138 |
-
}
|
139 |
-
),
|
140 |
-
"dosage": datasets.Sequence(
|
141 |
-
{
|
142 |
-
"start_char": datasets.Value("int32"),
|
143 |
-
"end_char": datasets.Value("int32"),
|
144 |
-
}
|
145 |
-
),
|
146 |
-
},
|
147 |
-
}
|
148 |
-
)
|
149 |
-
|
150 |
-
return datasets.DatasetInfo(
|
151 |
-
description=_DESCRIPTION,
|
152 |
-
features=features,
|
153 |
-
supervised_keys=None,
|
154 |
-
homepage="https://www.sciencedirect.com/science/article/pii/S1532046412000615",
|
155 |
-
citation=_CITATION,
|
156 |
-
)
|
157 |
-
|
158 |
-
def _split_generators(self, dl_manager):
|
159 |
-
"""Returns SplitGenerators."""
|
160 |
-
|
161 |
-
DAE_path = dl_manager.download_and_extract(_DOWNLOAD_URL.format("DRUG", "AE", "rel"))
|
162 |
-
DD_path = dl_manager.download_and_extract(_DOWNLOAD_URL.format("DRUG", "DOSE", "rel"))
|
163 |
-
DAE_NEG_path = dl_manager.download_and_extract(_DOWNLOAD_URL.format("ADE", "NEG", "txt"))
|
164 |
-
|
165 |
-
return [
|
166 |
-
datasets.SplitGenerator(
|
167 |
-
name=datasets.Split.TRAIN,
|
168 |
-
gen_kwargs={"DRUG_AE_file": DAE_path, "DRUG_DOSAGE_file": DD_path, "NEG_DRUG_AE_file": DAE_NEG_path},
|
169 |
-
),
|
170 |
-
]
|
171 |
-
|
172 |
-
def _generate_examples(self, DRUG_AE_file, DRUG_DOSAGE_file, NEG_DRUG_AE_file):
|
173 |
-
"""Generate ADE_Corpus_V2 examples."""
|
174 |
-
|
175 |
-
# For Classification task with ade dataset.
|
176 |
-
if self.config.name == configs["classification"]:
|
177 |
-
texts, labels = [], []
|
178 |
-
with open(DRUG_AE_file, encoding="utf-8") as f:
|
179 |
-
for line in f:
|
180 |
-
pubmed_id, text = line.strip().split("|")[:2]
|
181 |
-
texts.append(text)
|
182 |
-
labels.append("Related")
|
183 |
-
|
184 |
-
with open(NEG_DRUG_AE_file, encoding="utf-8") as f:
|
185 |
-
for line in f:
|
186 |
-
pubmed_id, neg = line.strip().split(" ")[:2]
|
187 |
-
text = " ".join(line.strip().split(" ")[2:])
|
188 |
-
texts.append(text)
|
189 |
-
labels.append("Not-Related")
|
190 |
-
|
191 |
-
for i in range(len(labels)):
|
192 |
-
text, label = texts[i], labels[i]
|
193 |
-
yield i, {"text": text, "label": label}
|
194 |
-
|
195 |
-
# For Relation Extraction between drug and its effect.
|
196 |
-
elif self.config.name == configs["RE_ade"]:
|
197 |
-
|
198 |
-
texts, drugs, effects, drug_indexes, effect_indexes = [], [], [], [], []
|
199 |
-
with open(DRUG_AE_file, encoding="utf-8") as f:
|
200 |
-
for line in f:
|
201 |
-
value = line.strip().split("|")
|
202 |
-
text = value[1]
|
203 |
-
effect = value[2]
|
204 |
-
drug = value[5]
|
205 |
-
|
206 |
-
# add index of drug and effect from text
|
207 |
-
effect_matches, drug_matches = [], []
|
208 |
-
for match in re.finditer(effect, text):
|
209 |
-
effect_matches.append({"start_char": match.start(), "end_char": match.end()})
|
210 |
-
effect_indexes.append(effect_matches)
|
211 |
-
|
212 |
-
for match in re.finditer(drug, text):
|
213 |
-
drug_matches.append({"start_char": match.start(), "end_char": match.end()})
|
214 |
-
drug_indexes.append(drug_matches)
|
215 |
-
|
216 |
-
texts.append(text)
|
217 |
-
drugs.append(drug)
|
218 |
-
effects.append(effect)
|
219 |
-
|
220 |
-
for idx, (text, drug, effect, drug_index, effect_index) in enumerate(
|
221 |
-
zip(texts, drugs, effects, drug_indexes, effect_indexes)
|
222 |
-
):
|
223 |
-
|
224 |
-
output = {
|
225 |
-
"text": text,
|
226 |
-
"drug": drug,
|
227 |
-
"effect": effect,
|
228 |
-
"indexes": {"drug": drug_index, "effect": effect_index},
|
229 |
-
}
|
230 |
-
|
231 |
-
yield idx, output
|
232 |
-
|
233 |
-
# For Relation Extraction between drug and its dosage.
|
234 |
-
elif self.config.name == configs["RE_dosage"]:
|
235 |
-
|
236 |
-
texts, drugs, dosages, drug_indexes, dosage_indexes = [], [], [], [], []
|
237 |
-
with open(DRUG_DOSAGE_file, encoding="utf-8") as f:
|
238 |
-
for line in f:
|
239 |
-
value = line.strip().split("|")
|
240 |
-
text = value[1]
|
241 |
-
dosage = value[2]
|
242 |
-
drug = value[5]
|
243 |
-
|
244 |
-
# add index of drug and effect from text
|
245 |
-
dosage_matches, drug_matches = [], []
|
246 |
-
for match in re.finditer(dosage, text):
|
247 |
-
dosage_matches.append({"start_char": match.start(), "end_char": match.end()})
|
248 |
-
dosage_indexes.append(dosage_matches)
|
249 |
-
|
250 |
-
for match in re.finditer(drug, text):
|
251 |
-
drug_matches.append({"start_char": match.start(), "end_char": match.end()})
|
252 |
-
drug_indexes.append(drug_matches)
|
253 |
-
|
254 |
-
texts.append(text)
|
255 |
-
drugs.append(drug)
|
256 |
-
dosages.append(dosage)
|
257 |
-
|
258 |
-
for idx, (text, drug, dosage, drug_index, dosage_index) in enumerate(
|
259 |
-
zip(texts, drugs, dosages, drug_indexes, dosage_indexes)
|
260 |
-
):
|
261 |
-
output = {
|
262 |
-
"text": text,
|
263 |
-
"drug": drug,
|
264 |
-
"dosage": dosage,
|
265 |
-
"indexes": {"drug": drug_index, "dosage": dosage_index},
|
266 |
-
}
|
267 |
-
yield idx, output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|