Created
February 11, 2015 11:51
-
-
Save samplereality/d4ec9b3184956afce74a to your computer and use it in GitHub Desktop.
Moby Dick in Markov Chains
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<canvas id="canvas" width=1200 height=400 style="border: 0px dashed #000000; display: block; margin:0 auto;"></canvas> | |
<script src="rita.js"></script> | |
<script> | |
RiTa.p5Compatible(true); | |
RiText.defaultFont("Georgia",18); | |
var rm = new RiMarkov(RiTa.random(2,5)); | |
rm.minSentenceLength = 2; | |
rm.maxSentenceLength = 15; | |
RiTa.loadString('moby-dick.txt', function(text) { | |
rm.loadText(text); | |
var sentenceOne = rm.generateSentences(1); | |
var sentenceTwo = rm.generateSentences(1); | |
var output = sentenceOne + " " + sentenceTwo + " (" + rm.getN().toFixed(0) + "-gram)"; | |
console.log(rm.getN()); | |
RiText(output).draw(); | |
}); | |
</script> | |
</head> | |
<body> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment