Created
September 23, 2019 05:16
-
-
Save prateekjoshi565/f7c8850a53c3c118db97539fc12ed6f6 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
# Matcher class object | |
matcher = Matcher(nlp.vocab) | |
#define the pattern | |
pattern = [{'DEP':'amod', 'OP':"?"}, | |
{'POS':'NOUN'}, | |
{'LOWER': 'and', 'OP':"?"}, | |
{'LOWER': 'or', 'OP':"?"}, | |
{'LOWER': 'other'}, | |
{'POS': 'NOUN'}] | |
matcher.add("matching_1", None, pattern) | |
matches = matcher(doc) | |
span = doc[matches[0][1]:matches[0][2]] | |
print(span.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment