ROT.StringGenerator
is an implementation of a high order Markov process. This machine learning technique needs to be trained first (with a set of typical strings); after training, it generates strings similar to those used as a training set.
Read more about the implementation (Dirichlet prior, simplified Katz back-off) in this RogueBasin article. The constructor accepts an optional configuration object with the following keys:
words
– use word mode? (default: false, use letters instead)order
– how many preceding characters are used to generate next characterprior
– default probability weight for all (unexpected) events (Dirichlet prior)There are only two important public methods: observe()
for training and generate()
for producing results. In the following example, we will use all standard Java 7 class names as a training set; let's see what new Java stuff our generator produces.