class Generator
package markov.namegen
A procedural word generator that uses Markov chains built from a user-provided array of words.
This uses Katz's back-off model, which is an approach that uses high-order models. It looks for the next letter based on the last "n" letters, backing down to lower order models when higher models fail.
This also uses a Dirichlet prior, which acts as an additive smoothing factor, introducing a chance for random letters to be be picked.
See:
Constructor
new (data:Array<String>, order:UInt, prior:Float, backoff:Bool)
Creates a new procedural word Generator.
Parameters:
data | Training data for the generator, an array of words. |
---|---|
order | Highest order of model to use - models of order 1 through order will be generated. |
prior | The dirichlet prior/additive smoothing "randomness" factor. |
backoff | Whether to fall back to lower order models when the highest order model fails to generate a letter. |
Variables
read onlyorder:UInt
The highest order model used by this generator.
Generators own models of order 1 through order "n". Generators of order "n" look back up to "n" characters when choosing the next character.
read onlyprior:Float
Dirichlet prior, acts as an additive smoothing factor.
The prior adds a constant probability that a random letter is picked from the alphabet when generating a new letter.