Use iter_files
Browse files231 unmodified lines2322332342352362372382392402412422432442452462472482492502514 unmodified lines256257258259260261262231 unmodified linesurl_key += "_wo_scope"urls = _URLS[url_key]data_dir = Path(dl_manager.download_and_extract(urls))return [datasets.SplitGenerator(name=datasets.Split.TRAIN,gen_kwargs={"data_dir": data_dir},)]def _generate_examples(self, data_dir: Path) -> Iterator[Tuple[str, Dict]]:if self.config.schema == "source":fix_offsets = "fixed" in self.config.subset_idfor file in data_dir.iterdir():if not file.name.endswith(".txt"):continue4 unmodified linesyield source_example["id"], source_exampleelif self.config.schema == "bigbio_kb":for file in data_dir.iterdir():if not file.name.endswith(".txt"):continue231 unmodified lines2322332342352362372382392402412422432442452462472482492502512524 unmodified lines257258259260261262263264231 unmodified linesurl_key += "_wo_scope"urls = _URLS[url_key]data_dir = dl_manager.download_and_extract(urls)return [datasets.SplitGenerator(name=datasets.Split.TRAIN,gen_kwargs={"file_paths": dl_manager.iter_files(data_dir)},)]def _generate_examples(self, file_paths: Iterator[str]) -> Iterator[Tuple[str, Dict]]:if self.config.schema == "source":fix_offsets = "fixed" in self.config.subset_idfor file_path in file_paths:file = Path(file_path)if not file.name.endswith(".txt"):continue4 unmodified linesyield source_example["id"], source_exampleelif self.config.schema == "bigbio_kb":for file_path in file_paths:file = Path(file_path)if not file.name.endswith(".txt"):continue
chia.py+7-5