1.1.2 • Published 8 years ago

twaddle v1.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

Twaddle

A never ending stream of nonsense using Markov chains and speeches of famous people.

This module is an extension to the excellent Markoff module, that comes pre-packaged with data to quickly generate filler text from profiles of various speeches.

Using a supplied data pack

See the data directory for a full list of what data comes supplied with this module.

var twaddle = require('twaddle');

console.log( twaddle.generate('politics-us-kennedy-f-john', {sentences: 1}) ); // Ask not what your country...

Combining data packs

You can also supply twaddle.generate() with an array of ID's which will merge these data packs together:

var twaddle = require('twaddle');

console.log( twaddle.generate(['politics-us-trump-j-donald', 'politics-de-hitler-adolph'], {paragraphs: 5}) );

Using your own data

var twaddle = require('twaddle');

twaddle.register('lincoln', __dirname + '/test/data/gettysburg.txt'))

console.log( twaddle.generate({words: 10}) ); // Four score and eleven...

See the test directory for more complex examples.

API

twaddle.register(id, path)

Register a file of text against the ID to use later

twaddle.compile(id)

Compile the given ID into a chain. This is done automatically if generate(id) is called without the chain being present.

twaddle.generate(options={words:20})

Generate the specified amount of text.

The options parameter can be constructed of the following keys:

KeyDefaultDescription
words20Generate at minimum this number of words
sentencesnullGenerate at minimum this number of sentences
paragraphsnullGenerate at minimum this number of paragraphs (this can override sentences to produce its output
minSentencesPerParagraph1The smallest number of sentences that can constitute a paragraph
maxSentencesPerParagraph5The largest number of sentences that can constitute a paragraph
paragraphJoiner"\n\n"The joining characters used between paragraphs
paragraphStructure[]An array of the sentence length of each paragraph. If omitted this is calculated and randomized from the above settings
fixTrimtrueTrim all paragraph content before output
fixCapitalFirsttrueCheck that all sentences have a capital letter first

Credits

1.1.2

8 years ago

1.1.1

9 years ago

1.1.0

9 years ago

0.0.0

9 years ago