class Model
package markov.namegen
A Markov model built using string training data.
Constructor
new (data:Array<String>, order:UInt, prior:Float, alphabet:Array<String>)
Creates a new Markov model.
Parameters:
data | The training data for the model, an array of words. |
---|---|
order | The order of model to use, models of order "n" will look back "n" characters within their context when determining the next letter. |
prior | The dirichlet prior, an additive smoothing "randomness" factor. Must be in the range 0 to 1. |
alphabet | The alphabet of the training data i.e. the set of unique symbols used in the training data. |
Methods
generate (context:String):String
Attempts to generate the next letter in the word given the context (the previous "order" letters).
Parameters:
context | The previous "order" letters in the word. |
---|
retrain (data:Array<String>):Void
Retrains the model on the newly supplied data, regenerating the Markov chains.
Parameters:
data | The new training data. |
---|