Commit
·
5e6ac7b
1
Parent(s):
62715c2
Fix streaming TAR archive (#1)
Browse files- Fix streaming TAR archive (95b34272712a66e48e0535333f6cd2e2a6fb0171)
- Fix type hint (bdaf5520d4933615eb694fb9fe120428a4e1773a)
Co-authored-by: Albert Villanova <albertvillanova@users.noreply.huggingface.co>
- spl_adr_200db.py +6 -9
spl_adr_200db.py
CHANGED
@@ -57,8 +57,7 @@ https://bionlp.nlm.nih.gov/tac2017adversereactions/
|
|
57 |
import xml.etree.ElementTree as ET
|
58 |
from collections import defaultdict
|
59 |
from itertools import accumulate
|
60 |
-
from
|
61 |
-
from typing import Dict, List, Tuple
|
62 |
|
63 |
import datasets
|
64 |
|
@@ -228,15 +227,13 @@ class SplAdr200DBDataset(datasets.GeneratorBasedBuilder):
|
|
228 |
|
229 |
urls = _URLS[_DATASETNAME][subset_name]
|
230 |
|
231 |
-
data_dir = dl_manager.
|
232 |
-
|
233 |
-
data_files = (Path(data_dir) / f"{subset_name}_xml").glob("*.xml")
|
234 |
|
235 |
return [
|
236 |
datasets.SplitGenerator(
|
237 |
name=datasets.Split.TRAIN,
|
238 |
gen_kwargs={
|
239 |
-
"filepaths":
|
240 |
},
|
241 |
),
|
242 |
]
|
@@ -381,11 +378,11 @@ class SplAdr200DBDataset(datasets.GeneratorBasedBuilder):
|
|
381 |
"coreferences": [],
|
382 |
}
|
383 |
|
384 |
-
def _generate_examples(self, filepaths: Tuple[
|
385 |
"""Yields examples as (key, example) tuples."""
|
386 |
|
387 |
-
for file_index, drug_filename in enumerate(filepaths):
|
388 |
-
element_tree = ET.parse(
|
389 |
|
390 |
if self.config.schema == "source":
|
391 |
features = self._source_features_from_xml(
|
|
|
57 |
import xml.etree.ElementTree as ET
|
58 |
from collections import defaultdict
|
59 |
from itertools import accumulate
|
60 |
+
from typing import BinaryIO, Dict, Iterable, List, Tuple
|
|
|
61 |
|
62 |
import datasets
|
63 |
|
|
|
227 |
|
228 |
urls = _URLS[_DATASETNAME][subset_name]
|
229 |
|
230 |
+
data_dir = dl_manager.download(urls)
|
|
|
|
|
231 |
|
232 |
return [
|
233 |
datasets.SplitGenerator(
|
234 |
name=datasets.Split.TRAIN,
|
235 |
gen_kwargs={
|
236 |
+
"filepaths": dl_manager.iter_archive(data_dir),
|
237 |
},
|
238 |
),
|
239 |
]
|
|
|
378 |
"coreferences": [],
|
379 |
}
|
380 |
|
381 |
+
def _generate_examples(self, filepaths: Iterable[Tuple[str, BinaryIO]]) -> Tuple[int, Dict]:
|
382 |
"""Yields examples as (key, example) tuples."""
|
383 |
|
384 |
+
for file_index, (drug_filename, drug_file) in enumerate(filepaths):
|
385 |
+
element_tree = ET.parse(drug_file)
|
386 |
|
387 |
if self.config.schema == "source":
|
388 |
features = self._source_features_from_xml(
|