Dependency Reader

The dependency reader displays the dependency relations between the words in a sentence.

A dependency represents a relation from a word that has a complex CCG type to a word that fulfils an argument of that type.

For example, in the sentence “John resigned”, the verb “resigned” has type S\NP with one argument. This argument is fulfilled by the noun “John” which has type NP. Therefore, this sentence contains one dependency relation from “resigned” to “John”:

[1]:
from lambeq import DependencyReader

reader = DependencyReader()
reader.sentence2diagram('John resigned').draw()
../_images/examples_dependency-reader_1_0.png

In the more interesting case of the sentence “Money that I give them”, the derivation can capture long-range word dependencies, like the one between “money” and “give”:

[2]:
sentence = 'Money that I give them'

print('CCG parse:')
reader.ccg_parser.sentence2diagram(sentence).draw(figsize=(8, 3))

print('\nDependency graph:')
reader.sentence2diagram(sentence).draw(figsize=(8, 3))
CCG parse:
../_images/examples_dependency-reader_3_1.png

Dependency graph:
../_images/examples_dependency-reader_3_3.png