Related Natural Language Processing Links
Learn Dependency Natural Language Processing Tutorial, validate concepts with Dependency Natural Language Processing MCQ Questions, and prepare interviews through Dependency Natural Language Processing Interview Questions and Answers.
Dependency Parsing
Understand how to map direct grammatical relationships between words without hierarchical phrasing.
Dependency Parsing
Unlike Constituency Parsing (which builds nested phrase boxes), Dependency Parsing directly draws directional linkages between the words themselves. It maps out which word is the grammatical "Head" and which word is its "Dependent".
Dependency parsing is much more popular than constituency parsing in modern NLP (especially through spaCy) because it is faster, lighter, and easier to use for Information Extraction.
Head vs Dependent
Dependency links are directional (). In the phrase "clever dog":
- "dog" is the Head word (ROOT concept).
- "clever" is the Dependent word (it modifies the dog).
- Link type:
amod(Adjectival Modifier).
Visualizing Dependencies
det
amod
nsubj
det
dobj
Universal Dependency Tags
| Tag | Meaning | Example Relation |
|---|---|---|
| nsubj | Nominal Subject | Provides the subject to the verb. (dog → chased) |
| dobj | Direct Object | The entity acted upon. (chased → ball) |
| amod | Adjectival Modifier | Modifies the noun. (clever → dog) |
| prep | Prepositional Modifier | Links preposition to its head. (sat → on) |
| ROOT | Root of Sentence | The central active verb. (chased) |
import spacy
nlp = spacy.load("en_core_web_sm")
doc = nlp("The clever dog chased the ball.")
# Print Subject-Verb-Object relationships!
print(f"{'Text':<10} | {'Dependent Tag':<15} | {'Head Word':<10}")
print("-" * 40)
for token in doc:
print(f"{token.text:<10} | {token.dep_:<15} | {token.head.text:<10}")
'''
Output:
Text | Dependent Tag | Head Word
----------------------------------------
The | det | dog
clever | amod | dog
dog | nsubj | chased <-- We found the subject!
chased | ROOT | chased <-- Core verb of sentence
the | det | ball
ball | dobj | chased <-- We found the object!
. | punct | chased
'''