Data structures

Trees

ImmutableMultiParentedTree

ImmutableParentedTree

ImmutableProbabilisticTree

ImmutableTree

MultiParentedTree

A Tree that automatically maintains parent pointers for multi-parented trees.

ParentedTree

A Tree that automatically maintains parent pointers for single-parented trees.

bracket_parse(s)

Use Tree.read(s, remove_empty_top_bracketing=True) instead.

sinica_parse(s)

Parse a Sinica Treebank string and return a tree.

TreePrettyPrinter

Pretty-print a tree in text format, either as ASCII or Unicode.

ProbabilisticTree

chomsky_normal_form(tree[, factor, ...])

collapse_unary(tree[, collapsePOS, ...])

Collapse subtrees with a single child (ie.

un_chomsky_normal_form(tree[, expandUnary, ...])

Tree

A Tree represents a hierarchical grouping of leaves and subtrees.

Feature structures

FeatStruct

A mapping from feature identifiers to feature values, where each feature value is either a basic value (such as a string or an integer), or a nested feature structure.

FeatDict

A feature structure that acts like a Python dictionary.

FeatList

A list of feature values, where each feature value is either a basic value (such as a string or an integer), or a nested feature structure.

unify(fstruct1, fstruct2[, bindings, trace, ...])

Unify fstruct1 with fstruct2, and return the resulting feature structure.

subsumes(fstruct1, fstruct2)

Return True if fstruct1 subsumes fstruct2.

conflicts(fstruct1, fstruct2[, trace])

Return a list of the feature paths of all features which are assigned incompatible values by fstruct1 and fstruct2.

Feature

A feature identifier that's specialized to put additional constraints, default values, etc.

SlashFeature

RangeFeature

SLASH

TYPE

A feature identifier that's specialized to put additional constraints, default values, etc.

FeatStructReader

Dependency graphs

DependencyGraph

A container for the nodes and labelled edges of a dependency structure.

Grammars

Nonterminal

A non-terminal symbol for a context free grammar.

nonterminals(symbols)

Given a string containing a list of symbol names, return a list of Nonterminals constructed from those symbols.

CFG

A context-free grammar.

Production

A grammar production.

PCFG

A probabilistic context-free grammar.

ProbabilisticProduction

A probabilistic context free grammar production.

DependencyGrammar

A dependency grammar.

DependencyProduction

A dependency grammar production.

ProbabilisticDependencyGrammar

induce_pcfg(start, productions)

Induce a PCFG grammar from a list of productions.

read_grammar(input, nonterm_parser[, ...])

Return a pair consisting of a starting category and a list of Productions.

Visualizations

ProductionList

CFGEditor

A dialog window for creating and editing context free grammars.

CFGDemo

TreeView

draw_trees(*trees)

Open a new window containing a graphical diagram of the given trees.