ngram-natural-language-generator
Takes in text/file(s)/stream(s) and generates random sentences that sound like they could have been in the original text using a bigram generator.
Usage
Commandline
$ ./index.js samples/jaberwocky.txt
Javascript
From file:
var generator = require('ngram-natural-language-generator');
generator({
filename: 'samples/jabberwocky.txt',
model: {
maxLength: 100,
minLength: 50
}
}, function(err, sentence){
console.log(sentence);
});
From text:
var generator = require('ngram-natural-language-generator');
generator({
text: 'Colorless green ideas sleep furiously.',
model: {
maxLength: 100,
minLength: 50
}
}, function(err, sentence){
console.log(sentence);
});
From web url:
var generator = require('ngram-natural-language-generator');
var http = require('http');
http.get('http://www.jabberwocky.com/carroll/jabber/jabberwocky.html', function(res) {
generator({
stream: res
}, function(err, sentence){
console.log(sentence);
});
});