From 4d2438f985e1bd12427725fda740829a6460d70a Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Wed, 13 Feb 2019 15:29:08 +0100 Subject: [PATCH] Tidy up and auto-format --- spacy/errors.py | 1 + spacy/lang/kn/__init__.py | 5 ++--- spacy/tests/regression/test_issue3209.py | 21 +++++++++++---------- spacy/tests/regression/test_issue3248.py | 1 - 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/spacy/errors.py b/spacy/errors.py index e97fc49e9..16713d246 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -315,6 +315,7 @@ class Errors(object): "So instead of pickling the span, pickle the Doc it belongs to or " "use Span.as_doc to convert the span to a standalone Doc object.") + @add_codes class TempErrors(object): T001 = ("Max length currently 10 for phrase matching") diff --git a/spacy/lang/kn/__init__.py b/spacy/lang/kn/__init__.py index 5cc33737e..c86354248 100644 --- a/spacy/lang/kn/__init__.py +++ b/spacy/lang/kn/__init__.py @@ -2,14 +2,13 @@ from __future__ import unicode_literals from .stop_words import STOP_WORDS -from .lex_attrs import LEX_ATTRS - -from ..norm_exceptions import BASE_NORMS from ...language import Language from ...attrs import LANG class KannadaDefaults(Language.Defaults): + lex_attr_getters = dict(Language.Defaults.lex_attr_getters) + lex_attr_getters[LANG] = lambda text: "kn" stop_words = STOP_WORDS diff --git a/spacy/tests/regression/test_issue3209.py b/spacy/tests/regression/test_issue3209.py index 2b406b5e0..efa006791 100644 --- a/spacy/tests/regression/test_issue3209.py +++ b/spacy/tests/regression/test_issue3209.py @@ -1,24 +1,25 @@ -'''Test that labels are mapped to classes consistently when loading NER model.''' +# coding: utf8 from __future__ import unicode_literals + from spacy.lang.en import English import pytest + @pytest.mark.xfail def test_issue3209(): - '''Test issue that occurred in spaCy nightly where NER labels were being + """Test issue that occurred in spaCy nightly where NER labels were being mapped to classes incorrectly after loading the model, when the labels were added using ner.add_label(). - ''' + """ nlp = English() - ner = nlp.create_pipe('ner') + ner = nlp.create_pipe("ner") nlp.add_pipe(ner) - - ner.add_label('ANIMAL') + + ner.add_label("ANIMAL") nlp.begin_training() - move_names = ['O', 'B-ANIMAL', 'I-ANIMAL', 'L-ANIMAL', 'U-ANIMAL'] + move_names = ["O", "B-ANIMAL", "I-ANIMAL", "L-ANIMAL", "U-ANIMAL"] assert ner.move_names == move_names nlp2 = English() - nlp2.add_pipe(nlp2.create_pipe('ner')) + nlp2.add_pipe(nlp2.create_pipe("ner")) nlp2.from_bytes(nlp.to_bytes()) - assert nlp2.get_pipe('ner').move_names == move_names - + assert nlp2.get_pipe("ner").move_names == move_names diff --git a/spacy/tests/regression/test_issue3248.py b/spacy/tests/regression/test_issue3248.py index 8df45bdc0..c4b592f3c 100644 --- a/spacy/tests/regression/test_issue3248.py +++ b/spacy/tests/regression/test_issue3248.py @@ -1,7 +1,6 @@ # coding: utf-8 from __future__ import unicode_literals -import pytest from spacy.matcher import PhraseMatcher from spacy.lang.en import English from spacy.compat import pickle