npm

npm’s 2019 JavaScript ecosystem survey analysis is now available!Get your copy here »

node-composer

0.0.2 • Public • Published

info

Composer - text generator

Example

 
var util = require('util');
var fs = require('fs');
 
var Composer = require('../index.js');
 
// create storage...
var storage = new Composer.Storage();
 
// read some text examples
var text = fs.readFileSync('./test.txt').toString();
 
// generate database
var maker = Composer.Maker(storage, 3);
maker.addDocument(text);
 
// print tree
console.log('STORAGE');
console.log(util.inspect(storage._data,{ showHidden: false, depth: 3 }));
console.log();
 
// print 5 sentences
console.log('TEXT');
var composer = Composer.Composer(storage);
var sentences = [];
while(sentences.length < 5) {
    var sentence = composer.speak();
    if (sentences.indexOf(sentence) === -1) {
        sentences.push(sentence);
    }
}
console.log(sentences.join(' ').toString());
 

Keywords

none

install

npm i node-composer

Downloadsweekly downloads

14

version

0.0.2

license

none

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability