Reference

Class

RiMarkov

Name

completions

Description If only one array parameter is provided, this function returns all possible next words, ordered by probability, for the given array.
 
If two arrays are provided, it returns an unordered list of possible words w that complete the n-gram consisting of: pre[0]...pre[k], w, post[k+1]...post[n].

result = rm.completions([ "the" ], [ "red", "ball" ]);
will return all the single words that occur between 'the' and 'red ball' in the current model (assuming n > 3),e.g., [ 'round', 'big', 'bouncy']).

Note: For this operation to be valid, (pre.length + post.length) must be less than the model's n-factor, otherwise an error will be thrown.
Example
result = rm.completions([ "the","red"]);
 
result = rm.completions([ "the" ], [ "red", "ball" ]);
Parameters
String[]pre
String[]post (optional)
Returns
String[]an unordered list of possible next tokens
Syntax
completions(preArray);
completions(preArray, postArray);
Platform Java / JavaScript