mt.struct.trie
Classes
Trie
: A simple word trie implemented in C++.
- class mt.struct.trie.Trie
A simple word trie implemented in C++.
Inheritance
digraph inheritanceaaf83ff391 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Trie" [URL="#mt.struct.trie.Trie",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A simple word trie implemented in C++."]; }- cond_prob()
Returns the probability that the word occurs, given that everything except the last character has been given.
- Parameters:
word (str) – The query word.
- Returns:
The probability that the word occurs.
- Return type:
double
- static from_file()
Loads the Trie from a file.
- Parameters:
filepath (str) – path to file to read from
- Returns:
a loaded Trie
- Return type:
- insert()
Inserts a word with frequency/count.
- Parameters:
word (str) – The word to be inserted.
count (int) – The number of times the word occurs.
- num_nodes()
Returns the total number of nodes of the trie.
- prob()
Returns the probability that the word occurs.
- Parameters:
word (str) – The query word.
- Returns:
The probability that the word occurs.
- Return type:
double
- to_file()
Saves the Trie to a file.
- Parameters:
filepath (str) – path to file to save to
- total_count()
Returns the total number of word counts.