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/6cb13720e92ab8031d2912f333e7785f to your computer and use it in GitHub Desktop.
Save chiefastro/6cb13720e92ab8031d2912f333e7785f to your computer and use it in GitHub Desktop.
Visualize a parsed dependency tree with displaCy
from spacy import displacy
import spacy
# load pre-trained model pipeline
nlp = spacy.load('en_core_web_sm')
# text document
text = 'spaCy is pretty cool.'
# apply pipeline
doc = nlp(text)
# display parsed dependency tree
displacy.render(doc, style='dep', jupyter=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment