if (FALSE) {
library(torch)
toks <- tokens(c(doc1 = "a b c d e f g",
doc2 = "a b c g",
doc3 = ""))
as.tensor(toks)
}
# create tokens object from list of characters with custom concatenator
dict <- dictionary(list(country = "United States",
sea = c("Atlantic Ocean", "Pacific Ocean")))
lis <- list(c("The", "United-States", "has", "the", "Atlantic-Ocean",
"and", "the", "Pacific-Ocean", "."))
toks <- as.tokens(lis, concatenator = "-")
tokens_lookup(toks, dict)
Run the code above in your browser using DataLab