class PrefixTrie
package markov.util
An unoptimized prefix trie. A type of ordered tree structure for storing and organizing strings.
See:
Constructor
Variables
Methods
find (word:String):Bool
Attempts to find a word in the trie. If the boolean "word" flag is set on the terminal node of the word in the trie, it returns true, else it returns false.
Parameters:
word | The word to find. |
---|
Returns:
True if the word was found, false if it was not.
getWords ():Array<String>
Builds an array of all the words that have been inserted into the trie. This is only appropriate for debugging or small data sets, it does really slow breadth-first search that works back up to the root every time it reconstructs a word.
Returns:
An array containing the set of the unique words that have been inserted into the trie.
insert (word:String):Int
Inserts a word into the trie. For nodes that already exist, it increments a frequency count. Marks the node that represents the final character in the word with the "word" flag.
Parameters:
word | The word to add to the trie. |
---|
Returns:
The number of times the word exists in the trie.