I want to create a simple text generator with markov chains. I don't understand how the java 'random' routines are used and what datastructures to use?
For example, let's say I have a routine to load a document and then a markov routine to generate a document based on the lone structure. How would I modify/create the generate document routine?
public class MarkovGenerator {
DataStructure wordFreqMapByPos = new DataStructure();
public void train(String doc) {
for (word : doc) {
// Add word to the pos,
// Build a word frequency map AT THE POSITION IN THE DOCUMENT
wordFreqMapByPos.put(thePos, wordsAtThisPos)
}
}
public void generateDocument() {
?????
for (pos : wordFreqMapByPos) {
// Generate a word
// Do I need to weight? generate a word based on how often
// the word occurs at this position?
// How?
}
}
}