Skip to content

Instantly share code, notes, and snippets.

@ahmedbesbes
Created August 23, 2022 21:43
Show Gist options
  • Save ahmedbesbes/222b5efa912c30f42e60dfdc323479b7 to your computer and use it in GitHub Desktop.
Save ahmedbesbes/222b5efa912c30f42e60dfdc323479b7 to your computer and use it in GitHub Desktop.
from spacy.matcher import Matcher
nlp = spacy.load("en_core_web_sm")
doc = nlp("Hello my friend!")
pattern = [
{"TEXT": "Hello"}
]
matcher = Matcher(nlp.vocab)
matcher.add("HelloPattern", [pattern])
matcher(doc)
[(10496072603676489703, 0, 1)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment