Answers for "spacy matcher.add"

1

spacy matcher syntax

import spacy
from spacy.matcher import Matcher
nlp = spacy.load('en-core-web-us')
matcher = Matcher(nlp.vocab)
patterns =[[{'LOWER':'hello'}, {'LOWER':'potato'}], [{'LOWER':'hello'}, {'LOWER':'yam'}], [{'LOWER':'hello'}, {'LOWER':'stupid'}]]
matcher.add('a', patterns, on_match=None)
document = nlp(u'hello potato i am hello yam you are hello stupid')
matcher(document)
Posted by: Guest on February-14-2021

Python Answers by Framework

Browse Popular Code Answers by Language