## ------------------------------------------------
## Method `KenLM$new`
## ------------------------------------------------
library(flashlighttext)
sys_file <- function(file) system.file(file, package = "flashlighttext")
read_bin <- function(file, type, size) readBin(sys_file(file), size = size, type, n = 10000)
lexicon <- load_words(sys_file("words.lst"))
word_dict <- create_word_dict(lexicon)
lm <- KenLM$new(sys_file("lm.arpa"), word_dict)
lm_state <- lm$start(FALSE)
c(lm_state, lm_score) %<-% lm$score(lm_state, 0)
Run the code above in your browser using DataLab