liveBook · Manning

Dependency relation

As explained in Natural Language Processing in Action, Second Edition

A dependency relation is a labeled grammatical link between a head word and a dependent word in a dependency parse.

A dependency relation labels a grammatical link between a head word and a dependent word. In a dependency tree, every word except the root depends on another word; the relation labels describe links such as passive subjects, modifiers, and objects. section 11.6

Reading a dependency parse

In “Gebru was unethically fired from her Ethical AI team,” fired is the ROOT, while Gebru has the nsubjpass relation. Inspecting each token’s children reveals which words depend on it; these links can support extracting a fact for a knowledge graph. section 11.6

>>> text = "Gebru was unethically fired from her Ethical AI team."
>>> doc = nlp(text)
>>> doc2df(doc)
           TOK    POS   TAG ENT_TYPE        DEP
0        Gebru  PROPN   NNP   PERSON  nsubjpass
1          was    AUX   VBD             auxpass
2  unethically    ADV    RB              advmod
3        fired   VERB   VBN                ROOT
4         from    ADP    IN                prep
5          her   PRON  PRP$                poss
6      Ethical  PROPN   NNP      ORG   compound
7           AI  PROPN   NNP      ORG   compound
8         team   NOUN    NN                pobj
9            .  PUNCT     .               punct

Inspect token text, part of speech, entity type, and dependency label for the example sentence. section 11.6

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Explains heads, dependents, roots, labels, children, tables, and visual diagrams through a runnable sentence example.
Examples
Uses a sentence about Gebru being fired, token tables, child lists, and a rendered dependency diagram.
What you can do after
Apply spaCy to inspect dependency labels and children, then use relations to construct extracted facts.
How it connects
Connects dependency parsing with natural language grammar, spaCy, dependency trees, and knowledge graphs.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.