Skip to content

Instantly share code, notes, and snippets.

@prateekjoshi565
Created March 4, 2020 09:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
import spacy
nlp = spacy.load('en_core_web_sm')
# Import spaCy Matcher
from spacy.matcher import Matcher
# Initialize the matcher with the spaCy vocabulary
matcher = Matcher(nlp.vocab)
doc = nlp("Some people start their day with lemon water")
# Define rule
pattern = [{'TEXT': 'lemon'}, {'TEXT': 'water'}]
# Add rule
matcher.add('rule_1', None, pattern)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment