Skip to content

Instantly share code, notes, and snippets.

@prateekjoshi565
Created September 23, 2019 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prateekjoshi565/ead4882a0c53f4370fc4ae300333a261 to your computer and use it in GitHub Desktop.
Save prateekjoshi565/ead4882a0c53f4370fc4ae300333a261 to your computer and use it in GitHub Desktop.
# Matcher class object
matcher = Matcher(nlp.vocab)
#define the pattern
pattern = [{'DEP':'nummod','OP':"?"},
{'DEP':'amod','OP':"?"},
{'POS':'NOUN'},
{'IS_PUNCT':True},
{'LOWER': 'especially'},
{'DEP':'nummod','OP':"?"},
{'DEP':'amod','OP':"?"},
{'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