predict.sbo_predictor: Predict method for Stupid Back-off text predictor

Description Usage Arguments Details Value Author(s) Examples

View source: R/predict_sbo_predictor.R

Description

Predictive text based on Stupid Back-off N-gram model.

Usage

1
2
## S3 method for class 'sbo_predictor'
predict(object, input, ...)

Arguments

object

a sbo_predictor object.

input

a character vector, containing the input for next-word prediction.

...

further arguments passed to or from other methods.

Details

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.

Value

A character vector if length(input) == 1, otherwise a character matrix.

Author(s)

Valerio Gherardi

Examples

1
2
3
4
5
6
7
p <- sbo_predictor(twitter_predtable)
x <- predict(p, "i love")
x
x <- predict(p, "you love")
x
#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.

sbo documentation built on Dec. 6, 2020, 1:06 a.m.