A sentence can name several people, organizations, and places without making their relationships obvious. Dependency parsing identifies how words relate to one another, producing a tree that helps an information-extraction pipeline find relationships between named entities. Those relationships can become edges in a knowledge graph, but a grammatical link is not, by itself, a verified fact. section 11.6 section 11.0
The tree connects words according to their roles in a sentence. Part-of-speech tags help identify nouns and verbs; dependency labels describe roles such as a subject or a modifier. This differs from constituency parsing, which groups words into phrases such as noun phrases and verb phrases. Dependency trees are the practical focus here because constituency results are slower to compute and harder to interpret. section 11.4.2 section 11.6
Inspect the words around a verb
Run `doc = nlp("Gebru was unethically fired from her Ethical AI team.")`, then inspect each token’s `pos_`, `ent_type_`, `dep_`, and `children`. In the resulting parse, `fired` is `ROOT`; its children include `Gebru`, `was`, `unethically`, and `from`. `Gebru` has the passive-subject label `nsubjpass`, while `from` leads toward `team`. Read these links as evidence about the sentence’s structure, not as independent confirmation of its claim. section 11.6
>>> def doc2df(doc):
... df = pd.DataFrame([token_dict2(t) for t in doc])
... return df.set_index('TOK')
>>> doc2df(doc)
POS TAG ENT_TYPE DEP children
TOK
Gebru PROPN NNP PERSON nsubjpass []
was AUX VBD auxpass []
unethically ADV RB advmod []
fired VERB VBN ROOT [Gebru, was, une...
from ADP IN prep [team]
her PRON PRP$ poss []
Ethical PROPN NNP ORG compound []
AI PROPN NNP ORG compound [Ethical]
team NOUN NN pobj [her, AI]
. PUNCT . punct []
The token table places part-of-speech tags, entity types, dependency labels, and children side by side, making the tree inspectable one word at a time. section 11.6
For a visual check, spaCy’s `displacy.render` can write the parsed sentence to an HTML file. Inspecting the tree is useful before turning token relationships into entity relationships: an entity may span multiple tokens, and entity labels can differ across spaCy models. The parser also has a processing cost. Its dependency structure helps spaCy segment sentences with ambiguous punctuation, but a simpler regular-expression segmenter can be much faster at the expense of downstream accuracy. section 11.6 section 11.4.2 section 11.2.2
