R/predict_sbo_predictor.R
predict.sbo_predictor.Rd
Predictive text based on Stupid Back-off N-gram model.
# S3 method for sbo_predictor predict(object, input, ...)
object | a |
---|---|
input | a character vector, containing the input for next-word prediction. |
... | further arguments passed to or from other methods. |
A character vector if length(input) == 1
, otherwise a
character matrix.
This method returns the top L
next-word predictions from a
text predictor trained with Stupid Back-Off.
Trying to predict from a sbo_predtable
results into an error. Instead,
one should load a sbo_predictor
object and use this one to predict(),
as shown in the example below.
Valerio Gherardi
#> [1] "you" "it" "my"#> [1] "<EOS>" "me" "the"#N.B. the top predictions here are x[1], followed by x[2] and x[3]. predict(p, c("i love", "you love")) # Behaviour with length()>1 input.#> [,1] [,2] [,3] #> [1,] "you" "it" "my" #> [2,] "<EOS>" "me" "the"