Skip to content

Instantly share code, notes, and snippets.

@chiefastro
Last active November 30, 2020 02:33
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 chiefastro/e187105dd743af32691747bb8c9bd745 to your computer and use it in GitHub Desktop.
Save chiefastro/e187105dd743af32691747bb8c9bd745 to your computer and use it in GitHub Desktop.
Visualizing named entity recognition with spaCy and displaCy
from spacy import displacy
import spacy
# load pre-trained model pipeline
nlp = spacy.load('en_core_web_sm')
# sentence with entities
text = """In 2015, independent researchers from Emory University and Yahoo! Labs showed that spaCy offered the fastest syntactic parser in the world and that its accuracy was within 1% of the best available."""
# apply pipeline
doc = nlp(text)
# visualize
displacy.render(doc, style='ent', jupyter=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment