chainy/node_modules/markov/example/qwantz.js
2020-01-26 21:03:32 +02:00

18 lines
408 B
JavaScript

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('> ');
});
});