Created
March 4, 2020 09:42
-
-
Save prateekjoshi565/799e938bbe433d881fd561e17a883622 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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