Reference

Class

RiMarkov

Name

generate

Description Generates one or more sentences from the model.
 
Note: multiple sentences generated by this method will follow the model across sentence boundaries; thus the following two calls are not equivalent:
 
results = markov.generate(10);
    and

for (int i = 0; i < 10; i++) { 
results[i] = markov.generate(1);
}

The latter will create 10 sentences with no explicit relationship between one and the next; while the former will follow probabilities from one sentence to the next.

Example
rm = new RiMarkov(3);
rm.addText(sentences);
sents = rm.generate(10);
Parameters
intthe number of sentences (optional, default=1)
Object
(or Map in Java)

the options for generation (all optional)

{float} options.temperature:
The temperature parameter acts as a knob to adjust the probability that input elements will be selected for the output. At higher values, infrequent words are more likely to be chosen, while at lower values the most frequent inputs are more likely to be output. If no value is provided, then tokens are chosen according to their relative frequency in the input.

Range: between 0 and positive infinity (excluding both)
Default: exactly mapped to frequencies in the input
Lower values move the highest-weighted output toward a probability of 1.0.
Higher values tend to even out all probabilities (toward random selection).

The temperature parameter function similarly to its use with softmax in neural networks. See this page for a more in-depth explanation.

{int} options.minLength:
minimal length of the sentences, default=5

{int} options.maxLength:
maximum length of the sentences, default=35

{boolean} options.allowDuplicates:
if true, allows the result to contain duplicate sentences

{String or Array} options.seed:
text from which the generation should start.
Returns
String[]the result
Syntax
generate(num);
Platform Java / JavaScript