Last active
August 29, 2015 13:57
-
-
Save samplereality/9783636 to your computer and use it in GitHub Desktop.
Markov Chains using Moby-Dick
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
var rita = require('rita'); | |
var fs = require('fs'); | |
rm = new rita.RiMarkov(2), file = 'moby-dick.txt'; | |
rm.minSentenceLength = 5; | |
rm.maxSentenceLength = 20; | |
fs.readFile(__dirname + '/' + file, function(e, data) { | |
if (e) throw e; | |
loadMarkov(data.toString()); | |
}); | |
function loadMarkov(text) { | |
rm.loadText(text); | |
var sentenceOne = rm.generateSentences(1); | |
var whale = sentenceOne; | |
console.log(whale); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also download the Moby-Dick text file and save it in the same directory: https://www.dropbox.com/s/xtduz02rivpcpev/moby-dick.txt