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 Syntax and semantics 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_sent : list of tuple(str, str, str, str)

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

Methods

add_edge(node1, node2, **kwargs) Add an edge between node1 and node2.
edges() Return the edges.
faulty() Determine whether the graph is faulty for dependency information.
number_of_nodes() Return the number of nodes.
to_conll() Return the dependency graph in the CoNLL format.
to_tikz() Return the dependency graph as LaTeX tikz-dependency code.
add_edge(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:

node1 : int

node2 : int

kwargs : dict, optional

Edge attributes

edges()[source]

Return the edges.

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

Determine whether the graph is faulty for dependency information.

Returns:bool
number_of_nodes()[source]

Return the number of nodes.

Returns:int
to_conll()[source]

Return the dependency graph in the CoNLL format.

Returns:

str

The CoNLL format of the dependency graph

to_tikz()[source]

Return the dependency graph as LaTeX tikz-dependency code.

Returns:

str

The LaTeX tikz-dependency code for drawing the graph