Support streaming
#1
by albertvillanova HF Staff - opened
28 unmodified lines293031323334353644 unmodified lines81828384858687197 unmodified lines28528628728828929029129229329429529629729829930030130230330430530630730830931031131231331428 unmodified linesRecognition and Relation Extraction."""import osfrom glob import globfrom typing import Dict, List, Tuplefrom xml.etree import ElementTree44 unmodified lines_LICENSE = 'License information unavailable'_URLS = {_DATASETNAME: "https://github.com/metalrt/ppi-dataset/zipball/master",}_SUPPORTED_TASKS = [197 unmodified linesdef _split_generators(self, dl_manager) -> List[datasets.SplitGenerator]:"""Returns SplitGenerators."""urls = _URLS[_DATASETNAME]data_dir = dl_manager.download_and_extract(urls)# Files are actually a few levels down, under this subdirectory, and# intermediate directory names get hashed so this is the easiest way to find it.data_dir = glob(f"{data_dir}/**/csv_output")[0]return [datasets.SplitGenerator(name=datasets.Split.TRAIN,# Whatever you put in gen_kwargs will be passed to _generate_examplesgen_kwargs={"filepath": os.path.join(data_dir, "HPRD50-train.xml"),"split": "train",},),datasets.SplitGenerator(name=datasets.Split.TEST,gen_kwargs={"filepath": os.path.join(data_dir, "HPRD50-test.xml"),"split": "test",},),]def _generate_examples(self, filepath, split: str) -> Tuple[int, Dict]:"""Yields examples as (key, example) tuples."""with open(filepath, "r") as f:28 unmodified lines29303132333444 unmodified lines79808182838485868788197 unmodified lines28628728828929029129229329429529629729829930030130230330430530630730830931028 unmodified linesRecognition and Relation Extraction."""from typing import Dict, List, Tuplefrom xml.etree import ElementTree44 unmodified lines_LICENSE = 'License information unavailable'_URLS = {_DATASETNAME: {"train": "https://github.com/metalrt/ppi-dataset/raw/master/csv_output/HPRD50-train.xml","test": "https://github.com/metalrt/ppi-dataset/raw/master/csv_output/HPRD50-test.xml",},}_SUPPORTED_TASKS = [197 unmodified linesdef _split_generators(self, dl_manager) -> List[datasets.SplitGenerator]:"""Returns SplitGenerators."""urls = _URLS[_DATASETNAME]data_dir = dl_manager.download(urls)return [datasets.SplitGenerator(name=datasets.Split.TRAIN,# Whatever you put in gen_kwargs will be passed to _generate_examplesgen_kwargs={"filepath": data_dir["train"],},),datasets.SplitGenerator(name=datasets.Split.TEST,gen_kwargs={"filepath": data_dir["test"],},),]def _generate_examples(self, filepath) -> Tuple[int, Dict]:"""Yields examples as (key, example) tuples."""with open(filepath, "r") as f:
hprd50.py+8-12