mirror of https://github.com/explosion/spaCy.git
fetch norm from lex if necessary for matching (#4080)
This commit is contained in:
parent
7f3212e2f5
commit
ad09b0d6f3
|
@ -6,7 +6,6 @@ from spacy.matcher import PhraseMatcher
|
||||||
from spacy.tokens import Doc
|
from spacy.tokens import Doc
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail
|
|
||||||
def test_issue4002(en_vocab):
|
def test_issue4002(en_vocab):
|
||||||
"""Test that the PhraseMatcher can match on overwritten NORM attributes.
|
"""Test that the PhraseMatcher can match on overwritten NORM attributes.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -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:
|
cdef attr_t get_token_attr(const TokenC* token, attr_id_t feat_name) nogil:
|
||||||
if feat_name == LEMMA:
|
if feat_name == LEMMA:
|
||||||
return token.lemma
|
return token.lemma
|
||||||
|
elif feat_name == NORM:
|
||||||
|
if not token.norm:
|
||||||
|
return token.lex.norm
|
||||||
|
return token.norm
|
||||||
elif feat_name == POS:
|
elif feat_name == POS:
|
||||||
return token.pos
|
return token.pos
|
||||||
elif feat_name == TAG:
|
elif feat_name == TAG:
|
||||||
|
|
Loading…
Reference in New Issue