- Common bug: getting random text very similar to but not quite the same as the random text from the correct output.
Common cause: Copying a previous version of
.getRandomText()
and forgetting to modify the call toRandom.nextInt()
for the order of markov model. Think about what you need to account for when you randomly generateindex
to make the first key. - Common bug: getting the wrong size for the largest value in the
HashMap
inEfficientMarkovWord
.
Common causes:
- Using the old
.getFollows()
method to build theHashMap
. You should not call.getFollows()
to build the map or add to the map in.getFollows()
. You should first build the map and then use the completedHashMap
in.getFollows()
. - Make sure you are using the correct conditions to stop the loop over the training text to build the
HashMap
(make sure you are not stopping too early and missing some of the text).
- Using the old
- Why is my
EfficientMarkovWord
taking longer than myMarkovWord
?
Make sure you are only passing over the training text once to build the map. Don’t call your old
.getFollows()
method in.buildMap()
, or add to yourHashMap
in.getFollows()
. You should first build theHashMap
, and use the completedHashMap
in.getFollows()
rather than searching the training text again.