Home | Trees | Indices | Help |
|
---|
|
object --+ | list --+ | Tree
A hierarchical structure.
Each Tree
represents a single hierarchical grouping of
leaves and subtrees. For example, each constituent in a syntax tree is
represented by a single Tree
.
A tree's children are encoded as a list
of leaves and
subtrees, where a leaf
is a basic (non-tree) value; and a subtree is a nested Tree
.
Any other properties that a Tree
defines are known as node
properties, and are used to add information about individual
hierarchical groupings. For example, syntax trees use a NODE property to
label syntactic constituents with phrase tags, such as "NP"
and"VP".
Several Tree
methods use tree positions
to specify children or descendants of a tree. Tree positions are defined
as follows:
Tree
's ith child.
()
specifies the Tree
itself.
p
is the tree position of
descendant d, then p+(i)
specifies the
i
th child of d.
I.e., every tree position is either a single index i
, specifying self[i]
; or a sequence (i1,
i2, ..., iN)
, specifying
self[i1][i2]...[iN]
.
|
|||
new list |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
list
|
|
||
Tree
|
|
||
int
|
|
||
|
|||
|
|||
list of Production s
|
|
||
list of tuples
|
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
string
|
|
||
string
|
|
||
|
|||
Inherited from Inherited from |
|
|||
|
|||
Tree
|
|
||
|
|
|||
a new object with type S, a subtype of T |
|
|
|||
Inherited from |
|
|
Construct a new tree. This constructor can be called in one of two ways:
|
x==y
|
x!=y
|
x<y
|
x<=y
|
x>y
|
x>=y
|
x*n
|
n*x
|
x+y
|
x[y]
|
x[i]=y
|
del x[y]
|
|
|
|
|
Generate all the subtrees of this tree, optionally restricted to trees matching the filter function.
|
Generate the productions that correspond to the non-terminal nodes of the tree. For each subtree of the form (P: C1 C2 ... Cn) this produces a production of the form P -> C1 C2 ... Cn.
|
|
|
|
This method can modify a tree in three ways:
|
This method modifies the tree in three ways:
|
Collapse subtrees with a single child (ie. unary productions) into a new non-terminal (Tree node) joined by 'joinChar'. This is useful when working with algorithms that do not allow unary productions, and completely removing the unary productions would require loss of useful information. The Tree is modified directly (since it is passed by reference) and no value is returned.
|
Convert a tree between different subtypes of Tree.
|
Parse a bracketed tree string and return the resulting tree. Trees are represented as nested brackettings, such as: (S (NP (NNP John)) (VP (V runs)))
|
Display a friendly error message when parsing a tree string fails.
|
repr(x)
|
str(x)
|
|
Returns a representation of the tree compatible with the LaTeX qtree
package. This consists of the string For example, the following result was generated from a parse tree of
the sentence \Tree [.I'' [.N'' [.D The ] [.N' [.N announcement ] ] ] [.I' [.V'' [.V' [.V astounded ] [.N'' [.N' [.N us ] ] ] ] ] ] ] See http://www.ling.upenn.edu/advice/latex.html for the LaTeX style file for the qtree package.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Wed Aug 27 15:08:58 2008 | http://epydoc.sourceforge.net |