Package WordUtils :: Module dawg :: Class Node
[show private | hide private]
[frames | no frames]

Type Node

object --+
         |
        Node


Class representing a node in an in-memory trie or dawg.
Method Summary
  __init__(self, key)
Default constructor.
  addChild(self, key)
Adds a child with the given key, or return existing child with same key.
  commonValues(node1, node2)
Return a list of the values that two nodes have in common in their children. (Static method)
  compare(node1, node2)
Compare two nodes. (Static method)
  getChild(self, key)
Returns the child (if any) having the indicated key.
  getChildValues(self)
Returns the values of this node's children.
  hasChild(self, key)
Indicates whether node has a child with the indicated key.
  merge(fromnode, tonode)
Merge one node (fromnode) into another (tonode). (Static method)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Property Summary
  children: Children of this node.
  endpoint: Indicates whether node is a word endpoint.
  value: Value of the node.

Instance Method Details

__init__(self, key=None)
(Constructor)

Default constructor.
Parameters:
key - key to be used to construct this node
           (type=single-character string)
Overrides:
__builtin__.object.__init__

addChild(self, key)

Adds a child with the given key, or return existing child with same key.
Parameters:
key - key to be used to construct this node
           (type=single-character string)
Returns:
the new or existing child as an Node instance

getChild(self, key)

Returns the child (if any) having the indicated key.
Parameters:
key - key used to search for a child.
           (type=single-character string)
Returns:
child as Node instance or None if no child has the indicated key

getChildValues(self)

Returns the values of this node's children.
Returns:
list of children as Node instances

hasChild(self, key)

Indicates whether node has a child with the indicated key.
Parameters:
key - key used to search for a child.
           (type=single-character string)
Returns:
boolean True/False

Static Method Details

commonValues(node1, node2)

Return a list of the values that two nodes have in common in their children.

Note: this is a static method.
Parameters:
node1 - first node
           (type=Node instance)
node2 - second node
           (type=Node instance)
Returns:
list of string values

compare(node1, node2)

Compare two nodes.

The comparison checks whether the two nodes are identical, i.e. have the exact same value, endpoint flag and children (not children with the same values).

Note: this is a static method.
Parameters:
node1 - first node
           (type=Node instance)
node2 - second node
           (type=Node instance)
Returns:
Boolean True/False indicating whether the two nodes are identical.

merge(fromnode, tonode)

Merge one node (fromnode) into another (tonode). The fromnode is not modified.

Note: this is a static method.
Parameters:
fromnode - node to merge from
           (type=Node instance)
tonode - node to merge to
           (type=Node instance)
Returns:
List of Node instances

Property Details

children

Children of this node.

endpoint

Indicates whether node is a word endpoint.

value

Value of the node.

Generated by Epydoc 2.1 on Tue Apr 4 21:55:58 2006 http://epydoc.sf.net