Home | Trees | Indices | Help |
---|
|
object --+ | ternarytree.TernarySearchTree --+ | WordCollection
Word lookup based on a Patricia tree (a.k.a. Radix Tree, a.k.a. Trie data structure). This data structure is efficiently searchable by the prefix of words. Such a prefix search takes a string prefix, and returns all dictionary words that begin with that prefix.
This class ingests rank/word pair files in a given directory. The ranks are intended to be relative usage frequencies. The class manages these frequency ranks.
Public methods:
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
list |
|
||
|
|||
|
|||
Inherited from Inherited from |
|
|||
DEFAULT_USER_DICT_FILE_NAME =
|
|||
USER_DICT_FILE_PATH = None
|
|
|||
Inherited from Inherited from |
|
Keep track of a Python dict mapping from word to its frequency rank, of the total number of entries, and the number of word files ingested from disk.
|
Goes through the self.dictDir directory on disk, and reads all the files there. Each file must be a list of whitespace-separated frequency-rank / word pairs. Assumes that self.dictDir is set to directory of dictionary files.
|
Given a word, checks whether the word is already in the in-memory dictionary. If so, does nothing and returns False; Else appends the word to dict_files/dictUserRankAndWord.txt with the provided rank; then returns True
|
Insert one word into the word collection.
|
Return the frequency rank of the given word in the collection. I is an error to request the rank of a word that is not in the collection, or of a word whose rank was never specified in an ingestion file or as part of an insert() call.
|
Returns all dictionary entries that begin with the string word. If the optional cutoffRank is specified, it limits the length of the returned list to include only the top cutoffRank words. Example, if cutoffRank=5, only the five most highly ranked dictionary entries are returned. Also, if cutoffRank is specified, the returned list is sorted by decreasing word rank. If cutoffRank is not specified, or is None, the returned list is unsorted.
|
True if word starts with, or is equal to prefix. Else False.
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Feb 21 13:27:59 2013 | http://epydoc.sourceforge.net |