I use next pattern on the explosion web site in demos "Rule-based Matcher Explorer"
pattern = [{'LEMMA': 'museum'}]
Text is
museums in madrid
And this is work, Okay. Then i do next in code:
import spacy
from spacy.matcher import Matcher
nlp = spacy.load("en_core_web_sm")
matcher = Matcher(nlp.vocab)
matcher.add("tourism", None, [{'LEMMA': 'museum'}])
doc = nlp("museums in madrid")
matches = matcher(doc)
print(matches)
for match_id, start, end in matches:
string_id = nlp.vocab.strings[match_id]
span = doc[start:end]
print(match_id, string_id, start, end, span.text)
And there is no result! Funny thing is if text is without word "madrid", then it finds a match. Now can anyone explain me what the heck? And why on the web site is everything okay