Learn R Programming

flashlighttext (version 0.1.0)

Trie: Trie

Description

Trie

Trie

Arguments

Active bindings

rootIdx

the rootIdx.

maxChildren

The maximum number of children for each node. It is usually the size of letters or phonemes.

ptr

set and get the pointer to a Trie instance.

Methods


Method new()

Usage

Trie$new(maxChildren = NULL, rootIdx = NULL)

Arguments

maxChildren

a maxChildren

rootIdx

a rootIdx

Returns

Trie


Method get_root()

Usage

Trie$get_root()

Returns

the root node pointer


Method insert()

Insert a token into trie with label

Usage

Trie$insert(indices, label, score)

Arguments

indices

a indices

label

a label

score

a score

Returns

a TrieNodePtr


Method search()

Get the labels for a given token

Usage

Trie$search(indices)

Arguments

indices

a indices

Returns

a TrieNodePtr


Method 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.

Usage

Trie$smear(smearMode)

Arguments

smearMode

a smearMode (see [SmearingModes] for options)

Returns

invisible(NULL)


Method clone()

The objects of this class are cloneable with this method.

Usage

Trie$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

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.