From ad09b0d6f39b221be413143cbfa99b9ac0aab205 Mon Sep 17 00:00:00 2001 From: Sofie Van Landeghem Date: Mon, 5 Aug 2019 23:51:04 +0200 Subject: [PATCH] fetch norm from lex if necessary for matching (#4080) --- spacy/tests/regression/test_issue4002.py | 1 - spacy/tokens/doc.pyx | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/spacy/tests/regression/test_issue4002.py b/spacy/tests/regression/test_issue4002.py index d9b509a30..d5d7bc86c 100644 --- a/spacy/tests/regression/test_issue4002.py +++ b/spacy/tests/regression/test_issue4002.py @@ -6,7 +6,6 @@ from spacy.matcher import PhraseMatcher from spacy.tokens import Doc -@pytest.mark.xfail def test_issue4002(en_vocab): """Test that the PhraseMatcher can match on overwritten NORM attributes. """ diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index 7ab1563e9..e9c5a0f1d 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -49,6 +49,10 @@ cdef int bounds_check(int i, int length, int padding) except -1: cdef attr_t get_token_attr(const TokenC* token, attr_id_t feat_name) nogil: if feat_name == LEMMA: return token.lemma + elif feat_name == NORM: + if not token.norm: + return token.lex.norm + return token.norm elif feat_name == POS: return token.pos elif feat_name == TAG: