grammar — Modeling syntax and semantics

The grammar 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.

class pylangacq.grammar.DependencyGraph(data, form='CHAT')[source]
DependencyGraph is a class based on the networkx directed graph for
modeling dependency graphs in dependency grammar.
faulty()[source]
Return True or False for whether the graph is faulty for dependency
information.
Returns:True or False
to_conll()[source]

Return the dependency graph in the CoNLL format.

>>> from pylangacq.grammar import (DependencyGraph, chat_graph_data)
>>> graph = DependencyGraph(chat_graph_data)
>>> print(graph.to_conll())
but CONJ 3 LINK
I PRO:SUB 3 SUBJ
thought V 0 ROOT
you PRO 3 OBJ
wanted V 3 JCT
me PRO:OBJ 5 POBJ
to INF 8 INF
turn V 3 XCOMP
it PRO 8 OBJ
. . 3 PUNCT
Returns:The CoNLL format of the dependency graph
Return type:str
to_tikz()[source]

Return the dependency graph as LaTeX tikz-dependency code.

>>> from pylangacq.grammar import (DependencyGraph, chat_graph_data)
>>> graph = DependencyGraph(chat_graph_data)
>>> print(graph.to_tikz())
egin{dependency}[theme = simple]
    egin{deptext}[column sep=1em]
        but \& I \& thought \& you \& wanted \& me \& to \& turn \& it \& . \
    \end{deptext}
    \deproot{3}{ROOT}
    \depedge{1}{3}{LINK}
    \depedge{2}{3}{SUBJ}
    \depedge{3}{0}{ROOT}
    \depedge{4}{3}{OBJ}
    \depedge{5}{3}{JCT}
    \depedge{6}{5}{POBJ}
    \depedge{7}{8}{INF}
    \depedge{8}{3}{XCOMP}
    \depedge{9}{8}{OBJ}
    \depedge{10}{3}{PUNCT}
\end{dependency}
Returns:The LaTeX tikz-dependency code for drawing the graph
Return type:str