• this is another method for information extraction
  • each words are first converted into tokens
  • dependency parse links tokens directly to other tokens
  • each link has three parts:
    1. head - the word that governs, each token has exactly 1 head, unless its the ROOT of the sentence (main verb, etc)
    2. dependent/modifier - the word that modifies the head
    3. label - the grammatical relation such as (nsubj, det, amod, ...)

Each link/arc joins exactly 2 tokens. The dependency depends on the head, so the direction is from head to dependency. In displacy, the arrowhead points at the dependent.

A dependent is a general term, and modifier is a subtype of dependent.

nlp = spacy.load("en_core_web_sm")
sentence = "I saw a kitten eating chicken in the kitchen."
 
doc = nlp(sentence)
 
print('{:<15}|{:<8}|{:<15}|{:<20}'.format('Token','Relation','Head','Children'))
print('-'*70)
 
for token in doc:
	#Print the token, dependency nature, head and all dependents of the token
	print("{:<15} | {:<18} | {:<15} | {:<20}"
		.format(str(token.text), str(token.dep_), str(token.head.text), \
		str([child for child in token.children])))

displacy.render(doc, style='dep', jupyter=True, options={'distance':120})

Core arguments

LabelMeaningExample (head in italics)
ROOTHead of the whole sentence, depends on nothingThe drone transmits signals
nsubjNominal subject (subject performing the action)The drone transmits
nsubjpassPassive nominal subject (subject receiving the action)The signal was jammed
csubjClausal subject (clause contains a subject and a verb)What he said matters
csubjpassClausal passive subjectWhether it flew was disputed
dobjDirect objecttransmits signals
dativeIndirect object (spaCy's name for iobj)gave him the data
pobjObject of a prepositionin the sky
attrAttribute: complement of a copulait is a drone
oprdObject predicateconsidered it useless
agentThe "by" marking the agent in a passivejammed by the operator

Dependency parsing links words directly to each other, and the other view of sentence structure builds phrases from rules, which is Context-free Grammar (CFG).