fetch norm from lex if necessary for matching (#4080)

This commit is contained in:
Sofie Van Landeghem 2019-08-05 23:51:04 +02:00 committed by Matthew Honnibal
parent 7f3212e2f5
commit ad09b0d6f3
2 changed files with 4 additions and 1 deletions

View File

@ -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.
"""

View File

@ -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: