A dependency graph represents grammatical relationships among words. Arcs connect dependents to the words that shape their meaning, revealing how a sentence branches and nests. The root is the token with no incoming arrowheads; other words depend on it directly or indirectly. section 2.1.4
Visualizing a sentence with spaCy
Load spaCy's en_core_web_sm model, process a sentence, select its first sentence, and render a dependency diagram with displaCy. The diagram exposes token relationships alongside parts of speech and lemmas, turning an otherwise linear sentence into a navigable structure. section 2.1.4
Dependency graphs also provide a bridge from language processing to knowledge representation. Parsed facts can become connections between entities in a knowledge graph, supporting queries about relationships and grounding language applications in explicit facts. section 11.0
>>> from spacy import displacy
>>> sentence = list(doc.sents)[0] #1
>>> svg = displacy.render(sentence, style="dep",
... jupyter=False) #2
>>> open('sentence_diagram.svg', 'w').write(svg) #3
>>> # displacy.serve(sentence, style="dep") #4
>>> # !firefox 127.0.0.1:5000
>>> displacy.render(sentence, style="dep") #5
Run the displaCy listing to render an interactive or notebook-based dependency diagram, or save the resulting SVG for inspection. section 2.1.4




