Skip to content

Instantly share code, notes, and snippets.

@colinpollock
Created September 20, 2019 23:07
Show Gist options
  • Save colinpollock/6f134437279e1530daf2e030c61ce17d to your computer and use it in GitHub Desktop.
Save colinpollock/6f134437279e1530daf2e030c61ce17d to your computer and use it in GitHub Desktop.
import spacy
from spacy.pipeline import EntityRuler
nlp = spacy.load("en_core_web_sm")
ruler = EntityRuler(nlp, validate=True)
ruler.add_patterns[
{
"label": "PHRASE",
"pattern": [
{"POS": "ADJ", "OP": "*"},
{"POS": "NOUN", "OP": "+"},
]
}
]
ruler.add_patterns(patterns)
nlp.add_pipe(ruler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment