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
on_match functions that are supplied to Matcher are not firing for matched of patterns that use * and +OP constraints. ? seems to be ok. This behaviour is present in both the spacy-nightly and also 2.0.12.
How to reproduce the behaviour
importspacyfromspacy.matcherimportMatchernlp=spacy.load('en_core_web_sm')
defon_match(matcher, doc, id, matches):
print('Matched!', matches)
matcher=Matcher(nlp.vocab)
matcher.add('JOHN', on_match, [{'LEMMA': 'invest'}, {'OP': '*'}, {'LOWER': 'china'}])
doc=nlp("John Doe invests in one more stock in China.")
formatchinmatcher(doc):
print(match)
The above snipped does successfully find a match, printing this:
(10603582739829208913, 2, 9)
However the on_match function does not fire, as nothing is printed.
The following snippet on the other hand, which has the greedy wildcard removed (and an updated string which matches) does cause the on_match function to fire:
This has the same root cause as #2671 --- which I've just fixed. Nice timing!
The problem was that the entity ID was being returned incorrectly in some situations, and it's the entity ID that is used to key the on_match callbacks. With the wrong ID matching, the callback was not called. This should now be fixed.
on_match functions that are supplied to
Matcher
are not firing for matched of patterns that use*
and+
OP
constraints.?
seems to be ok. This behaviour is present in both the spacy-nightly and also 2.0.12.How to reproduce the behaviour
The above snipped does successfully find a match, printing this:
However the
on_match
function does not fire, as nothing is printed.The following snippet on the other hand, which has the greedy wildcard removed (and an updated string which matches) does cause the
on_match
function to fire:Outputting this:
Your Environment
The text was updated successfully, but these errors were encountered: