dependency — Modeling syntax and semantics

The dependency module defines classes and functions for handling information regarding dependency and grammatical relations based on the %gra tiers in CHAT transcripts. See synsem for usage.

Utilities for dependency grammar and parsing.

class pylangacq.dependency.DependencyGraph(tagged_sent)[source]

A DependencyGraph instance represents a sentence in dependency grammar.

Parameters
tagged_sentlist of tuple(str, str, str, str)

A tagged sentence as a list of (word, pos, mor, rel).

Methods

add_edge(self, node1, node2, **kwargs)

Add an edge between node1 and node2.

edges(self)

Return the edges.

faulty(self)

Determine whether the graph is faulty for dependency information.

number_of_nodes(self)

Return the number of nodes.

to_conll(self)

Return the dependency graph in the CoNLL format.

to_tikz(self)

Return the dependency graph as LaTeX tikz-dependency code.

add_edge(self, node1, node2, **kwargs)[source]

Add an edge between node1 and node2.

If a node doesn’t yet exist, it is added to the graph.

Parameters
node1int
node2int
kwargsdict, optional

Edge attributes

edges(self)[source]

Return the edges.

Returns
dict(int: int)
faulty(self)[source]

Determine whether the graph is faulty for dependency information.

Returns
bool
number_of_nodes(self)[source]

Return the number of nodes.

Returns
int
to_conll(self)[source]

Return the dependency graph in the CoNLL format.

Returns
str

The CoNLL format of the dependency graph

to_tikz(self)[source]

Return the dependency graph as LaTeX tikz-dependency code.

Returns
str

The LaTeX tikz-dependency code for drawing the graph