Created
August 23, 2022 21:44
-
-
Save ahmedbesbes/d541a28bbaab1668d39db620241a50c6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from spacy.matcher import Matcher | |
nlp = spacy.load("en_core_web_sm") | |
doc = nlp("You should definitely buy Bitcoin") | |
pattern = [ | |
{"LEMMA": {"IN": ["buy", "sell"]}}, | |
{"LOWER": {"IN": ["bitcoin", "dogecoin"]}}, | |
] | |
matcher = Matcher(nlp.vocab) | |
matcher.add("HelloWorld", [pattern]) | |
matcher(doc) | |
# [(15578876784678163569, 3, 5)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment