Trie
Trie
rootIdxthe rootIdx.
maxChildrenThe maximum number of children for each node. It is usually the size of letters or phonemes.
ptrset and get the pointer to a Trie instance.
new()Trie$new(maxChildren = NULL, rootIdx = NULL)maxChildrena maxChildren
rootIdxa rootIdx
Trie
get_root()Trie$get_root()the root node pointer
insert()Insert a token into trie with label
Trie$insert(indices, label, score)indicesa indices
labela label
scorea score
a TrieNodePtr
indicesa indices
a TrieNodePtr
smear()Smearing the trie using the valid labels inserted in the trie so as to get score on each node (incompleted token). For example, if smear_mode is MAX, then for node "a" in path "c"->"a", we will select the maximum score from all its children like "c"->"a"->"t", "c"->"a"->"n", "c"->"a"->"r"->"e" and so on. This process will be carry out recursively on all the nodes.
Trie$smear(smearMode)smearModea smearMode (see [SmearingModes] for options)
invisible(NULL)
clone()The objects of this class are cloneable with this method.
Trie$clone(deep = FALSE)deepWhether to make a deep clone.
Trie is used to store the lexicon in language model. We use it to limit the search space in decoder and quickly look up scores for a given token (completed word) or make prediction for incompleted ones based on smearing.