From 6e809e9b8b3c961bc4c7c4565edef699717c0919 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 15 Jul 2019 11:42:50 +0200 Subject: [PATCH] proper error for missing cfg arguments --- spacy/_ml.py | 5 ++--- spacy/errors.py | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spacy/_ml.py b/spacy/_ml.py index 4d9bb4c2b..d71b8d56c 100644 --- a/spacy/_ml.py +++ b/spacy/_ml.py @@ -663,11 +663,10 @@ def build_simple_cnn_text_classifier(tok2vec, nr_class, exclusive_classes=False, def build_nel_encoder(embed_width, hidden_width, ner_types, **cfg): - # TODO proper error if "entity_width" not in cfg: - raise ValueError("entity_width not found") + raise ValueError(Errors.E144.format(param="entity_width")) if "context_width" not in cfg: - raise ValueError("context_width not found") + raise ValueError(Errors.E144.format(param="context_width")) conv_depth = cfg.get("conv_depth", 2) cnn_maxout_pieces = cfg.get("cnn_maxout_pieces", 3) diff --git a/spacy/errors.py b/spacy/errors.py index ed3d6afb9..cb8bb44b4 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -406,6 +406,7 @@ class Errors(object): E141 = ("Entity vectors should be of length {required} instead of the provided {found}.") E142 = ("Unsupported loss_function '{loss_func}'. Use either 'L2' or 'cosine'") E143 = ("Labels for component '{name}' not initialized. Did you forget to call add_label()?") + E144 = ("Could not find parameter `{param}` when building the entity linker model.") @add_codes