chainy/node_modules/markov/example/qwantz.js

18 lines
408 B
JavaScript
Raw Permalink Normal View History

2020-01-26 19:03:32 +00:00
var util = require('util');
var fs = require('fs');
var markov = require('markov');
var m = markov(1);
var s = fs.createReadStream(__dirname + '/qwantz.txt');
m.seed(s, function () {
var stdin = process.openStdin();
util.print('> ');
stdin.on('data', function (line) {
var res = m.respond(line.toString()).join(' ');
console.log(res);
util.print('> ');
});
});