You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to make use the acceptor function for a matcher, and am getting behavior that I would not expect. My assumption is if an acceptor returns a falsy value (I'm using False), then a match should be rejected. The assertion below fails:
import spacy
from spacy.attrs import LOWER, ORTH
nlp = spacy.en.English()
text = u"""The golf club is broken"""
doc = nlp(text)
golf_pattern = [
{ ORTH: "golf"},
{ ORTH: "club"}
]
def return_false(doc, ent_id, label, start, end):
return False
matcher = spacy.matcher.Matcher(nlp.vocab)
matcher.add_entity('Sport_Equipment'
, acceptor=return_false
)
matcher.add_pattern("Sport_Equipment", golf_pattern)
match = matcher(doc)
assert match == []
Inspecting the match, the entity associated with the given ID does indeed have the correct acceptor function registered:
I'm trying to make use the acceptor function for a matcher, and am getting behavior that I would not expect. My assumption is if an acceptor returns a falsy value (I'm using False), then a match should be rejected. The assertion below fails:
Inspecting the match, the entity associated with the given ID does indeed have the correct acceptor function registered:
Your Environment
The text was updated successfully, but these errors were encountered: