Package nltk :: Package cluster :: Module util :: Class Dendogram
[hide private]
[frames] | no frames]

Class Dendogram

source code

Represents a dendogram, a tree with a specified branching order. This must be initialised with the leaf items, then iteratively call merge for each branch. This class constructs a tree representing the order of calls to the merge function.

Instance Methods [hide private]
 
__init__(self, items=[]) source code
 
merge(self, *indices)
Merges nodes at given indices in the dendogram.
source code
 
groups(self, n)
Finds the n-groups of items (leaves) reachable from a cut at depth n.
source code
 
show(self)
Print the dendogram in ASCII art to standard out.
source code
 
__repr__(self) source code
Method Details [hide private]

__init__(self, items=[])
(Constructor)

source code 
Parameters:
  • items (sequence of (any)) - the items at the leaves of the dendogram

merge(self, *indices)

source code 

Merges nodes at given indices in the dendogram. The nodes will be combined which then replaces the first node specified. All other nodes involved in the merge will be removed.

Parameters:
  • indices (seq of int) - indices of the items to merge (at least two)

groups(self, n)

source code 

Finds the n-groups of items (leaves) reachable from a cut at depth n.

Parameters:
  • n (int) - number of groups