library(quanteda)
#> Package version: 4.1.0
#> Unicode version: 15.1
#> ICU version: 74.1
#> Parallel computing: 16 of 16 threads used.
#> See https://quanteda.io for tutorials and examples.
toks <- tokens(c("I like apples, but I don't like apple pie. Bananas are OK",
"I like bananas, but I don't like banana fritter."))
dfmat <- dfm(toks)
dict <- dictionary(list(apple = c("apple*"),
banana = c("banana*")))
dfmat1 <- dfm_lookup(dfmat,
dictionary = dict, exclusive = FALSE, capkeys = FALSE)
dfmat2 <- dfm_lookup(dfmat,
dictionary = rev(dict), exclusive = FALSE, capkeys = FALSE)
identical(as.matrix(dfmat1), as.matrix(dfmat2))
#> [1] FALSE
dfmat3 <- dfm(tokens_lookup(toks, dictionary = rev(dict),
exclusive = FALSE, capkeys = FALSE))
identical(as.matrix(dfmat1), as.matrix(dfmat3))
#> [1] TRUE