Reference

Class

RiMarkov

Name

getCompletions

Description If only one array parameter is provided, this function returns all possible next words (or tokens), 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.getCompletions([ "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.
Syntax
getCompletions(preArray);
getCompletions(preArray, postArray);
Parameters
String[]pre
String[]post (optional)
Returns
String[]an unordered list of possible next tokens
Example
result = rm.getCompletions([ "the","red"]);
 
result = rm.getCompletions([ "the" ], [ "red", "ball" ]);
Platform Java / Javascript