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 RiMarkov chains (aka n-grams) with options to process single characters, words, sentences, 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);

for (i = 0; i < sentences.length; i ++ ){
println(sentences[i]);
}
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.maxAttempts:
max attempts before throwing an error in generation, default=99

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

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

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

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

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

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

RiTa.markov(nFactor);


// Create an object and specify options

RiTa.markov(nFactor, options);

Platform Java / JavaScript