Reference

Class

RiTa

Name

markov

Description Creates a new RiMarkov object with functions for text-generation, as well as a range of other probabilistic functions.

This object uses Markov chains (aka n-grams) with options to process words or arbitrary regular expressions.
Example
txt = "This is a two sentence example. This is the second one."

rm = RiTa.markov(3);
rm.addText(txt);
sentences = rm.generate(2);

Parameters
intn-factor - the length of each n-gram stored in the model
Object
(or Map in Java)
options for creating the model (optional)

{int} options.maxLengthMatch:
# of words allowed in result to match a sequence in the input, default=∞

{boolean} options.disableInputChecks:
if true, allow result to be present in the input, default=false

{Function} options.tokenize:
a custom tokenize function to use, default=RiTa.tokenize

{Function} options.untokenize [JS only]:
a custom tokenize function to use, default=RiTa.untokenize

{boolean} options.trace:
if true, output debug log to console, default=false

{int} options.maxAttempts:
max attempts before throwing a generation error, default=999

{String or String[]} options.text:
text to be added to the model (same as via model.addText()

Returns
RiMarkova RiMarkov object
Syntax
// Constructs a RiMarkov object and set its n-factor.

RiTa.markov(nFactor);


// Create an object and specify one or more options

RiTa.markov(nFactor, optionsObject);

Platform Java / JavaScript