trie_create: Create the finite state automaton.

Description Usage Arguments Value Examples

View source: R/trie.R

Description

AKA the trie with failure attributes built in. This will need to be run one time and then can be used for both find and replace functions.

Usage

1
trie_create(keys, values, to_lower = TRUE, whole_words_only = TRUE)

Arguments

keys

these are the words that you want to search for in the trie

values

these are optional, but if you will need to supply them if you want to use the replace method.

to_lower

are your keys case sensitive? If so, this should be false.

whole_words_only

do you want to pad your keys with whitespace to find only those that are whole words? If so select this should be true

Value

a reference class object of class node from the data.tree package.

Examples

1
2
3
4
5
keys <- c("a", "ab", "bab", "bc", "bca", "c", "caa", "abc")
values <- c("foo", "bar", "foo", "bar", "foo", "bar", "foo", "bar")
example_trie <- trie_create(keys, value = values)
example_trie
example_trie$a$b$fail

lmkirvan/textTries documentation built on May 25, 2019, 9:32 p.m.