From f4a7d1a423964876208f0caccf0ba7a19d4832a0 Mon Sep 17 00:00:00 2001 From: Motoki Wu Date: Tue, 30 Jan 2018 18:29:54 -0800 Subject: [PATCH 1/2] make to sure pass in **cfg to each component when training --- spacy/language.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacy/language.py b/spacy/language.py index ae62f918a..a2b945c49 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -461,7 +461,8 @@ class Language(object): if hasattr(proc, 'begin_training'): proc.begin_training(get_gold_tuples(), pipeline=self.pipeline, - sgd=self._optimizer) + sgd=self._optimizer, + **cfg) return self._optimizer def evaluate(self, docs_golds, verbose=False): From 54062b7326b998c0fe3015ae9d78816762d52c25 Mon Sep 17 00:00:00 2001 From: Motoki Wu Date: Tue, 30 Jan 2018 18:30:19 -0800 Subject: [PATCH 2/2] added tests for issue #1915 --- spacy/tests/regression/test_issue1915.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 spacy/tests/regression/test_issue1915.py diff --git a/spacy/tests/regression/test_issue1915.py b/spacy/tests/regression/test_issue1915.py new file mode 100644 index 000000000..23cf6dc73 --- /dev/null +++ b/spacy/tests/regression/test_issue1915.py @@ -0,0 +1,19 @@ +# coding: utf8 + +from __future__ import unicode_literals +from ...language import Language + + +def test_simple_ner(): + cfg = { + 'hidden_depth': 2, # should error out + } + + nlp = Language() + nlp.add_pipe(nlp.create_pipe('ner')) + nlp.get_pipe('ner').add_label('answer') + try: + nlp.begin_training(**cfg) + assert False # should error out + except ValueError: + assert True