https://github.com/hash-bang/twaddle
A never ending stream of nonsense using Markov chains and speaches of famous people
https://github.com/hash-bang/twaddle
Last synced: 3 months ago
JSON representation
A never ending stream of nonsense using Markov chains and speaches of famous people
- Host: GitHub
- URL: https://github.com/hash-bang/twaddle
- Owner: hash-bang
- License: mit
- Created: 2016-05-14T03:43:14.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-05-30T07:05:46.000Z (almost 9 years ago)
- Last Synced: 2025-02-03T04:42:24.076Z (4 months ago)
- Language: JavaScript
- Size: 364 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Twaddle
=======
A never ending stream of nonsense using Markov chains and speeches of famous people.This module is an extension to the excellent [Markoff](https://github.com/jcorbin/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](./data) directory for a full list of what data comes supplied with this module.```javascript
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:```javascript
var twaddle = require('twaddle');console.log( twaddle.generate(['politics-us-trump-j-donald', 'politics-de-hitler-adolph'], {paragraphs: 5}) );
```Using your own data
-------------------```javascript
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](./test) directory for more complex examples.
API
===twaddle.register(id, path)
--------------------------
Register a file of text against the ID to use latertwaddle.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:
| Key | Default | Description |
|----------------------------|-------------|-------------------------------------------------------------------------------------------------------------------------|
| `words` | `20` | Generate at minimum this number of words |
| `sentences` | `null` | Generate at minimum this number of sentences |
| `paragraphs` | `null` | Generate at minimum this number of paragraphs (this can override `sentences` to produce its output |
| `minSentencesPerParagraph` | `1` | The smallest number of sentences that can constitute a paragraph |
| `maxSentencesPerParagraph` | `5` | The 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 |
| `fixTrim` | `true` | Trim all paragraph content before output |
| `fixCapitalFirst` | `true` | Check that all sentences have a capital letter first |Credits
=======
* [American Rhetoric](http://www.americanrhetoric.com)
* [History Place](http://www.historyplace.com/speeches/previous.htm)
* [Jewish Virtual Library](http://www.jewishvirtuallibrary.org/jsource/Holocaust/hitlertoc.html)
* [Presidential Rhetoric](http://www.presidentialrhetoric.com/historicspeeches/index.html)