Module 9.1 closes with structure: after tokens, POS tags, and entities, dependency parsing links words into a tree of grammatical relations (subject, object, modifiers).
This is the last linguistic preprocessing lecture before Module 9.2 turns tokens into vectors—starting with one-hot encoding, then bag-of-words, TF-IDF, and learned embeddings. Parses remain useful for explainable IE even in the embedding era.
Learning Objectives
By the end of this lesson, students should be able to:
- Define dependency parsing and the head–dependent relation.
- Read common Universal Dependencies relation labels (nsubj, obj, amod, …).
- Parse sentences with spaCy and navigate
token.head/token.dep_. - Extract simple subject–verb–object patterns for information extraction.
- Contrast dependency trees with constituency (phrase-structure) parses at a high level.
- State how Module 9.1 feeds Module 9.2 representation learning.
Dependency parsing predicts a directed tree (or DAG in some frameworks) over tokens where each edge connects a head to a dependent and carries a grammatical relation label. The root is usually the main predicate.
Heads, Dependents, and Labels
In “The red cat chased mice,” chased is the root; cat is its nominal subject (nsubj); mice is its object (obj); red adjectivally modifies cat (amod).
| Label | Role | Example |
|---|---|---|
| ROOT | Main predicate | chased |
| nsubj | Nominal subject | cat ← chased |
| obj | Direct object | mice ← chased |
| amod | Adjectival modifier | red ← cat |
| det | Determiner | The ← cat |
| prep / case | Prepositional structure | in ← Berlin |
| aux | Auxiliary | was ← chased |
Parsing with spaCy
Dependency vs Constituency
Dependency
- Word-to-word arcs.
- Directly useful for IE patterns.
- UD standard across languages.
Constituency
- Nested phrases (NP, VP).
- Classic Treebank style.
- Useful for some MT / pedagogy.
Neural NLP today
- Parsers still ship in spaCy.
- LLMs may imply structure.
- Explicit trees aid control & debug.
Strengths
- Transparent grammatical relations.
- Pattern-based relation extraction.
- Cross-lingual UD schemas.
Limitations
- Errors on noisy / informal text.
- Attachment ambiguity (“with binoculars”).
- Not a substitute for embeddings alone.
“The leftmost noun is always the subject.” Word order heuristics fail on passives, questions, and relative clauses. Depend on labeled arcs (nsubj, nsubjpass), not linear position.
Bridge to Module 9.2
You can now turn a raw corpus into cleaned, tokenized, optionally normalized and linguistically annotated text. Module 9.2 starts representing those tokens numerically—from one-hot encoding and bag-of-words to Word2Vec, GloVe, and sentence embeddings—ready for the sequence models you met in Volume 08.
Knowledge Check
- Short Answer: What does dependency parsing predict? Answer: A labeled tree of head–dependent grammatical relations over tokens.
- True/False: In UD-style parses, every token (except the root) has exactly one head in a tree. Answer: True (for standard dependency trees).
- Multiple Choice:
nsubjtypically marks: (a) adjectival modifier, (b) nominal subject, (c) punctuation. Answer: (b). - Short Answer: How do you read a token’s head in spaCy? Answer:
token.head(and relation viatoken.dep_). - True/False: Dependency and constituency parses are identical structures. Answer: False—arcs between words vs nested phrases.
- Multiple Choice: SVO pattern mining uses parses to find: (a) JPEG blocks, (b) subject–verb–object relations, (c) learning rates. Answer: (b).
- Short Answer: Name one hard attachment ambiguity. Answer: e.g., PP-attachment (“saw the man with a telescope”).
- True/False: Linear word order alone reliably finds subjects in English passives. Answer: False.
- Multiple Choice: Module 9.2 begins representation learning with: (a) one-hot encoding, (b) max pooling, (c) k-means. Answer: (a).
- Short Answer: Why keep parsers in an embedding-centric stack? Answer: Explainability, constrained IE patterns, and debugging linguistic errors.
Key Takeaways
- Dependency parses link tokens with labeled grammatical arcs.
- spaCy exposes heads and deps for practical IE patterns.
- Prefer typed relations over naive word-order heuristics.
- Module 9.1 completes linguistic preprocessing for NLP.
- Next module: 9.2 One Hot Encoding begins vector representations.
Hands-on idea: Visualize a spaCy parse (displacy) for an active and passive sentence; extract SVO from both.
Discussion prompt: For relation extraction in contracts, would you trust LLM spans, dependency patterns, or both?
Recap: Dependency parsing exposes who did what to whom—closing NLP Basics before embeddings. Continue to Module 9.2 One Hot Encoding.