From 4ad26f4a2f5ea73eff3b179c3a234d4713c1da6c Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 29 Sep 2020 16:54:53 +0200 Subject: [PATCH] Move reader --- spacy/training/corpus.py | 5 ----- spacy/util.py | 3 +++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/spacy/training/corpus.py b/spacy/training/corpus.py index bd431ab83..12bda486e 100644 --- a/spacy/training/corpus.py +++ b/spacy/training/corpus.py @@ -30,11 +30,6 @@ def create_jsonl_reader( return JsonlTexts(path, min_length=min_length, max_length=max_length, limit=limit) -@util.registry.readers("srsly.read_json.v1") -def _read_json(loc: Path): - return srsly.read_json(loc) - - def walk_corpus(path: Union[str, Path], file_type) -> List[Path]: path = util.ensure_path(path) if not path.is_dir() and path.parts[-1].endswith(file_type): diff --git a/spacy/util.py b/spacy/util.py index 67c577927..948c4ab11 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -97,6 +97,9 @@ class registry(thinc.registry): models = catalogue.create("spacy", "models", entry_points=True) cli = catalogue.create("spacy", "cli", entry_points=True) +# We want json loading in the registry, so manually register srsly.read_json. +registry.readers("srsly.read_json.v0", srsly.read_json) + class SimpleFrozenDict(dict): """Simplified implementation of a frozen dict, mainly used as default