From 4cbb954281ad47148667de130e5c4eb23e579edf Mon Sep 17 00:00:00 2001 From: Elijah Rippeth Date: Wed, 30 Sep 2020 07:26:06 -0400 Subject: [PATCH] reorder so tagmap is replaced only if a custom file is provided. (#6164) * reorder so tagmap is replaced only if a custom file is provided. * Remove unneeded variable initialization Co-authored-by: Adriane Boyd --- spacy/cli/debug_data.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spacy/cli/debug_data.py b/spacy/cli/debug_data.py index 22540c779..7e6c99c06 100644 --- a/spacy/cli/debug_data.py +++ b/spacy/cli/debug_data.py @@ -59,10 +59,6 @@ def debug_data( if not dev_path.exists(): msg.fail("Development data not found", dev_path, exits=1) - tag_map = {} - if tag_map_path is not None: - tag_map = srsly.read_json(tag_map_path) - # Initialize the model and pipeline pipeline = [p.strip() for p in pipeline.split(",")] if base_model: @@ -70,8 +66,11 @@ def debug_data( else: lang_cls = get_lang_class(lang) nlp = lang_cls() - # Replace tag map with provided mapping - nlp.vocab.morphology.load_tag_map(tag_map) + + if tag_map_path is not None: + tag_map = srsly.read_json(tag_map_path) + # Replace tag map with provided mapping + nlp.vocab.morphology.load_tag_map(tag_map) msg.divider("Data format validation")