greedy_match accepts a trie and a character vector
and returns the values associated with any key that is "greedily" (read: fuzzily)
matched against one of the character vector entries.
greedy_match(trie, to_match, include_keys = FALSE)a trie object, created with trie
a character vector containing the strings to check against the trie's keys.
a logical value indicating whether to include the keys in the returned results or not. If TRUE (not the default) the returned object will be a list of data.frames, rather than of vectors.
a list, the length of to_match, with each entry containing any trie values
where the to_match element greedily matches the associated key. In the case that
nothing was found, the entry will contain NA. In the case that include_keys
is TRUE, the matching keys will also be included
longest_match and prefix_match
for longest and prefix matching, respectively.
trie <- trie(keys = c("afford", "affair", "available", "binary", "bind", "blind"),
values = c("afford", "affair", "available", "binary", "bind", "blind"))
greedy_match(trie, c("avoid", "bring", "attack"))
#> [[1]]
#> [1] "available"
#>
#> [[2]]
#> [1] "binary" "bind" "blind"
#>
#> [[3]]
#> [1] "affair" "afford" "available"
#>