Commit
·
d46f506
1
Parent(s):
c89e40b
Support streaming (#2)
Browse files- Add data files (e464ca58284c63d1cd8e9d13af4d8ced6be39591)
- Update loading script (37e51f357048083e8f0340dcd07c9c4bc4a91232)
- Fix style (d42e878fa55cfbcfa3e3b321e0b04acdb1c1d08c)
Co-authored-by: Albert Villanova <albertvillanova@users.noreply.huggingface.co>
- bionlp_st_2011_epi.py +26 -27
- data/devel.zip +3 -0
- data/test.zip +3 -0
- data/train.zip +3 -0
bionlp_st_2011_epi.py
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
|
16 |
|
17 |
from pathlib import Path
|
18 |
-
from typing import List
|
19 |
|
20 |
import datasets
|
21 |
|
@@ -32,7 +32,7 @@ _DISPLAYNAME = "BioNLP 2011 EPI"
|
|
32 |
_SOURCE_VIEW_NAME = "source"
|
33 |
_UNIFIED_VIEW_NAME = "bigbio"
|
34 |
|
35 |
-
_LANGUAGES = [
|
36 |
_PUBMED = True
|
37 |
_LOCAL = False
|
38 |
_CITATION = """\
|
@@ -59,11 +59,12 @@ of BioNLP Shared Task 2011.
|
|
59 |
|
60 |
_HOMEPAGE = "https://github.com/openbiocorpora/bionlp-st-2011-epi"
|
61 |
|
62 |
-
_LICENSE =
|
63 |
|
64 |
_URLs = {
|
65 |
-
"
|
66 |
-
"
|
|
|
67 |
}
|
68 |
|
69 |
_SUPPORTED_TASKS = [
|
@@ -198,46 +199,44 @@ class bionlp_st_2011_epi(datasets.GeneratorBasedBuilder):
|
|
198 |
self, dl_manager: datasets.DownloadManager
|
199 |
) -> List[datasets.SplitGenerator]:
|
200 |
|
201 |
-
|
202 |
-
data_dir = Path(dl_manager.download_and_extract(my_urls))
|
203 |
-
data_files = {
|
204 |
-
"train": data_dir
|
205 |
-
/ f"bionlp-st-2011-epi-master"
|
206 |
-
/ "original-data"
|
207 |
-
/ "train",
|
208 |
-
"dev": data_dir / f"bionlp-st-2011-epi-master" / "original-data" / "devel",
|
209 |
-
"test": data_dir / f"bionlp-st-2011-epi-master" / "original-data" / "test",
|
210 |
-
}
|
211 |
-
|
212 |
return [
|
213 |
datasets.SplitGenerator(
|
214 |
name=datasets.Split.TRAIN,
|
215 |
-
gen_kwargs={"data_files": data_files["train"]},
|
216 |
),
|
217 |
datasets.SplitGenerator(
|
218 |
name=datasets.Split.VALIDATION,
|
219 |
-
gen_kwargs={
|
|
|
|
|
220 |
),
|
221 |
datasets.SplitGenerator(
|
222 |
name=datasets.Split.TEST,
|
223 |
-
gen_kwargs={"data_files": data_files["test"]},
|
224 |
),
|
225 |
]
|
226 |
|
227 |
-
def _generate_examples(self, data_files:
|
228 |
if self.config.schema == "source":
|
229 |
-
|
230 |
-
for
|
|
|
|
|
|
|
231 |
example = parse_brat_file(txt_file)
|
232 |
example["id"] = str(guid)
|
233 |
yield guid, example
|
|
|
234 |
elif self.config.schema == "bigbio_kb":
|
235 |
-
|
236 |
-
for
|
237 |
-
|
238 |
-
|
239 |
-
|
|
|
240 |
example["id"] = str(guid)
|
241 |
yield guid, example
|
|
|
242 |
else:
|
243 |
raise ValueError(f"Invalid config: {self.config.name}")
|
|
|
15 |
|
16 |
|
17 |
from pathlib import Path
|
18 |
+
from typing import Iterable, List
|
19 |
|
20 |
import datasets
|
21 |
|
|
|
32 |
_SOURCE_VIEW_NAME = "source"
|
33 |
_UNIFIED_VIEW_NAME = "bigbio"
|
34 |
|
35 |
+
_LANGUAGES = ["English"]
|
36 |
_PUBMED = True
|
37 |
_LOCAL = False
|
38 |
_CITATION = """\
|
|
|
59 |
|
60 |
_HOMEPAGE = "https://github.com/openbiocorpora/bionlp-st-2011-epi"
|
61 |
|
62 |
+
_LICENSE = "GENIA Project License for Annotated Corpora"
|
63 |
|
64 |
_URLs = {
|
65 |
+
"train": "data/train.zip",
|
66 |
+
"validation": "data/devel.zip",
|
67 |
+
"test": "data/test.zip",
|
68 |
}
|
69 |
|
70 |
_SUPPORTED_TASKS = [
|
|
|
199 |
self, dl_manager: datasets.DownloadManager
|
200 |
) -> List[datasets.SplitGenerator]:
|
201 |
|
202 |
+
data_files = dl_manager.download_and_extract(_URLs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
return [
|
204 |
datasets.SplitGenerator(
|
205 |
name=datasets.Split.TRAIN,
|
206 |
+
gen_kwargs={"data_files": dl_manager.iter_files(data_files["train"])},
|
207 |
),
|
208 |
datasets.SplitGenerator(
|
209 |
name=datasets.Split.VALIDATION,
|
210 |
+
gen_kwargs={
|
211 |
+
"data_files": dl_manager.iter_files(data_files["validation"])
|
212 |
+
},
|
213 |
),
|
214 |
datasets.SplitGenerator(
|
215 |
name=datasets.Split.TEST,
|
216 |
+
gen_kwargs={"data_files": dl_manager.iter_files(data_files["test"])},
|
217 |
),
|
218 |
]
|
219 |
|
220 |
+
def _generate_examples(self, data_files: Iterable[str]):
|
221 |
if self.config.schema == "source":
|
222 |
+
guid = 0
|
223 |
+
for data_file in data_files:
|
224 |
+
txt_file = Path(data_file)
|
225 |
+
if txt_file.suffix != ".txt":
|
226 |
+
continue
|
227 |
example = parse_brat_file(txt_file)
|
228 |
example["id"] = str(guid)
|
229 |
yield guid, example
|
230 |
+
guid += 1
|
231 |
elif self.config.schema == "bigbio_kb":
|
232 |
+
guid = 0
|
233 |
+
for data_file in data_files:
|
234 |
+
txt_file = Path(data_file)
|
235 |
+
if txt_file.suffix != ".txt":
|
236 |
+
continue
|
237 |
+
example = brat_parse_to_bigbio_kb(parse_brat_file(txt_file))
|
238 |
example["id"] = str(guid)
|
239 |
yield guid, example
|
240 |
+
guid += 1
|
241 |
else:
|
242 |
raise ValueError(f"Invalid config: {self.config.name}")
|
data/devel.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4f439291f13c6f04f1c669dce40f5abfd539a82529e0e99cc7164462ed775738
|
3 |
+
size 318525
|
data/test.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5f1d5d6b552661be4e3c7988db8c1e534e00a9c5afbb12838af36b9f6c597ed3
|
3 |
+
size 646940
|
data/train.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b10532f594a23c5ff0a66e88cdb5f731814c529a282701746df44edd72c182f2
|
3 |
+
size 942875
|