Package nltk :: Module containers :: Class Trie
[hide private]
[frames] | no frames]

Class Trie

source code

A Trie is like a dictionary in that it maps keys to values. However, because of the way keys are stored, it allows look up based on the longest prefix that matches. Keys must be strings.

Instance Methods [hide private]
 
__init__(self, trie=None) source code
 
clear(self) source code
 
isleaf(self, key)
Return True if the key is present and it's a leaf of the Trie, False otherwise.
source code
 
find_prefix(self, key)
Find as much of the key as one can, by using the longest prefix that has a value.
source code
 
subtrie(self, key) source code
 
__len__(self) source code
 
__eq__(self, other) source code
 
__ne__(self, other) source code
 
__setitem__(self, key, value) source code
 
__getitem__(self, key)
Return the value for the given key if it is present, raises a KeyError if key not found, and return None if it is present a key2 that starts with key.
source code
 
__contains__(self, key)
Return True if the key is present or if it is present a key2 string that starts with key.
source code
 
__str__(self) source code
 
__repr__(self) source code
Method Details [hide private]

find_prefix(self, key)

source code 

Find as much of the key as one can, by using the longest prefix that has a value. Return (value, remainder) where remainder is the rest of the given string.