Commit
•
caa903b
1
Parent(s):
b7d5818
Support streaming (#1)
Browse files- Download only required data files (cc09f106da421dba4f66151d3d9c8cbeebaa6204)
Co-authored-by: Albert Villanova <albertvillanova@users.noreply.huggingface.co>
hprd50.py
CHANGED
@@ -29,8 +29,6 @@ Because the dataset contains entities and relations, it is suitable for Named En
|
|
29 |
Recognition and Relation Extraction.
|
30 |
"""
|
31 |
|
32 |
-
import os
|
33 |
-
from glob import glob
|
34 |
from typing import Dict, List, Tuple
|
35 |
from xml.etree import ElementTree
|
36 |
|
@@ -81,7 +79,10 @@ _HOMEPAGE = ""
|
|
81 |
_LICENSE = 'License information unavailable'
|
82 |
|
83 |
_URLS = {
|
84 |
-
_DATASETNAME:
|
|
|
|
|
|
|
85 |
}
|
86 |
|
87 |
_SUPPORTED_TASKS = [
|
@@ -285,30 +286,25 @@ class HPRD50Dataset(datasets.GeneratorBasedBuilder):
|
|
285 |
def _split_generators(self, dl_manager) -> List[datasets.SplitGenerator]:
|
286 |
"""Returns SplitGenerators."""
|
287 |
urls = _URLS[_DATASETNAME]
|
288 |
-
data_dir = dl_manager.
|
289 |
-
# Files are actually a few levels down, under this subdirectory, and
|
290 |
-
# intermediate directory names get hashed so this is the easiest way to find it.
|
291 |
-
data_dir = glob(f"{data_dir}/**/csv_output")[0]
|
292 |
|
293 |
return [
|
294 |
datasets.SplitGenerator(
|
295 |
name=datasets.Split.TRAIN,
|
296 |
# Whatever you put in gen_kwargs will be passed to _generate_examples
|
297 |
gen_kwargs={
|
298 |
-
"filepath":
|
299 |
-
"split": "train",
|
300 |
},
|
301 |
),
|
302 |
datasets.SplitGenerator(
|
303 |
name=datasets.Split.TEST,
|
304 |
gen_kwargs={
|
305 |
-
"filepath":
|
306 |
-
"split": "test",
|
307 |
},
|
308 |
),
|
309 |
]
|
310 |
|
311 |
-
def _generate_examples(self, filepath
|
312 |
"""Yields examples as (key, example) tuples."""
|
313 |
|
314 |
with open(filepath, "r") as f:
|
|
|
29 |
Recognition and Relation Extraction.
|
30 |
"""
|
31 |
|
|
|
|
|
32 |
from typing import Dict, List, Tuple
|
33 |
from xml.etree import ElementTree
|
34 |
|
|
|
79 |
_LICENSE = 'License information unavailable'
|
80 |
|
81 |
_URLS = {
|
82 |
+
_DATASETNAME: {
|
83 |
+
"train": "https://github.com/metalrt/ppi-dataset/raw/master/csv_output/HPRD50-train.xml",
|
84 |
+
"test": "https://github.com/metalrt/ppi-dataset/raw/master/csv_output/HPRD50-test.xml",
|
85 |
+
},
|
86 |
}
|
87 |
|
88 |
_SUPPORTED_TASKS = [
|
|
|
286 |
def _split_generators(self, dl_manager) -> List[datasets.SplitGenerator]:
|
287 |
"""Returns SplitGenerators."""
|
288 |
urls = _URLS[_DATASETNAME]
|
289 |
+
data_dir = dl_manager.download(urls)
|
|
|
|
|
|
|
290 |
|
291 |
return [
|
292 |
datasets.SplitGenerator(
|
293 |
name=datasets.Split.TRAIN,
|
294 |
# Whatever you put in gen_kwargs will be passed to _generate_examples
|
295 |
gen_kwargs={
|
296 |
+
"filepath": data_dir["train"],
|
|
|
297 |
},
|
298 |
),
|
299 |
datasets.SplitGenerator(
|
300 |
name=datasets.Split.TEST,
|
301 |
gen_kwargs={
|
302 |
+
"filepath": data_dir["test"],
|
|
|
303 |
},
|
304 |
),
|
305 |
]
|
306 |
|
307 |
+
def _generate_examples(self, filepath) -> Tuple[int, Dict]:
|
308 |
"""Yields examples as (key, example) tuples."""
|
309 |
|
310 |
with open(filepath, "r") as f:
|