Generate random text based on Stupid Back-off language model.

babble(model, input = NA, n_max = 100L, L = attr(model, "L"))

Arguments

model

a sbo_predictor object.

input

a length one character vector. Starting point for babbling! If NA, as by default, a random word is sampled from the model's dictionary.

n_max

a length one integer. Maximum number of words to generate.

L

a length one integer. Number of next-word suggestions from which to sample (see details).

Value

A character vector of length one.

Details

This function generates random text from a Stupid Back-off language model. babble randomly samples one of the top L next word predictions. Text generation stops when an End-Of-Sentence token is encountered, or when the number of generated words exceeds n_max.

Author

Valerio Gherardi

Examples

# Babble! p <- sbo_predictor(twitter_predtable) set.seed(840) # Set seed for reproducibility babble(p)
#> [1] "mine too many."