Package nltk :: Module tree
[hide private]
[frames] | no frames]

Module tree

source code

Class for representing hierarchical language structures, such as syntax trees and morphological trees.

Classes [hide private]
  ProbabilisticMixIn
A mix-in class to associate probabilities with other classes (trees, rules, etc.).
  Tree
A hierarchical structure.
  ImmutableTree
  AbstractParentedTree
An abstract base class for Trees that automatically maintain pointers to their parents.
  ParentedTree
A Tree that automatically maintains parent pointers for single-parented trees.
  MultiParentedTree
A Tree that automatically maintains parent pointers for multi-parented trees.
  ImmutableParentedTree
  ImmutableMultiParentedTree
  ProbabilisticTree
  ImmutableProbabilisticTree
Functions [hide private]
 
_child_names(tree) source code
tree
bracket_parse(s)
Parse a treebank string and return a tree.
source code
tree
sinica_parse(s)
Parse a Sinica Treebank string and return a tree.
source code
 
demo()
A demonstration showing how Trees and Trees can be used.
source code
Function Details [hide private]

bracket_parse(s)

source code 

Parse a treebank string and return a tree. Trees are represented as nested brackettings, e.g. (S (NP (NNP John)) (VP (V runs))).

Parameters:
  • s (string) - The string to be converted
Returns: tree
A tree corresponding to the string representation.

sinica_parse(s)

source code 

Parse a Sinica Treebank string and return a tree. Trees are represented as nested brackettings, as shown in the following example (X represents a Chinese character): S(goal:NP(Head:Nep:XX)|theme:NP(Head:Nhaa:X)|quantity:Dab:X|Head:VL2:X)#0(PERIODCATEGORY)

Parameters:
  • s (string) - The string to be converted
Returns: tree
A tree corresponding to the string representation.

demo()

source code 

A demonstration showing how Trees and Trees can be used. This demonstration creates a Tree, and loads a Tree from the treebank corpus, and shows the results of calling several of their methods.