0Pricing
NLP Academy · Lesson

Dependency Parsing Basics

See how words connect in a sentence.

Dependency Parsing Basics is a free NLP Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the NLP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Beyond Single Tags

POS tags name each word's job, but not how words connect. Dependency parsing reveals which word depends on which, building a sentence map. 🔗

Sentences as Trees

A parser arranges words into a tree. One word becomes the root, and every other word hangs off it through a labeled link.

The Root Verb

The root is usually the main verb that anchors the sentence. In The cat chased the mouse, the root is chased.

Heads and Children

Every word has a head, the word it attaches to. The words attached to it are its children, forming the branches of the tree.

Read the Relation

Each link has a label, the dependency relation. A subject is tagged nsubj, while a direct object is tagged dobj.

spaCy Parses Free

The same model that tags words also parses them. After nlp(), every token already carries its dependency information, ready to read.

doc = nlp("The cat chased the mouse")

Read dep_ and head

Use token.dep_ for the relation and token.head for the word it attaches to. Together they describe the token's place in the tree.

for t in doc:
    print(t.text, t.dep_, t.head.text)

Find the Subject

To get who does the action, look for the token whose dep_ equals nsubj. That word is the grammatical subject of the verb.

subj = [t.text for t in doc if t.dep_ == "nsubj"]

Explain a Relation

Unsure what a label means? Pass it to spacy.explain() and get a clear description, just like you did for POS tags.

print(spacy.explain("dobj"))

Visualize the Tree

Render the parse with displacy. Set the style to dep and it draws labeled arrows from each head to its children.

from spacy import displacy
displacy.render(doc, style="dep")

Why Parsing Matters

Dependencies unlock real meaning, like linking an action to its actor and target. This structure powers extraction, search, and question answering.

Quick Check

Recall how subjects are marked in a parse.

Recap

You saw sentences as trees of heads and children, read dep_ in spaCy, and drew the parse with displacy. Now you can map how words relate. 🎉

Frequently asked questions

Is the “Dependency Parsing Basics” lesson free?

Yes — the full text of “Dependency Parsing Basics” is free to read here on the web, and the NLP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the NLP Academy course, upgrade to CoddyKit PRO.

What will I learn in “Dependency Parsing Basics”?

See how words connect in a sentence. You practise NLP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start NLP Academy?

No prior experience is required. NLP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Dependency Parsing Basics” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this NLP Academy lesson?

Yes. Every NLP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Nouns, Verbs, and Why Tags Matter
  2. Tagging Words With spaCy
  3. Extracting Phrases by Tag Pattern
  4. Dependency Parsing Basics
← Back to NLP Academy