markov-chains-text
Fake text, powered by Markov chains
markov-chains-text
is a simple, Markov chain-based text generator written in
JavaScript, and designed for both Node and the browser. It can be used to
generate random sentences modeled after a large corpus of text.
Table of Contents
Example
;;; const MobyDick = ; // build the generatorconst fakeMobyDick = MobyDick; // generate a sentenceconst sentence = fakeMobyDick; console; // Example output://// And as the Porpoise is the harpooneer might be his immediate purpose,// touching his own kith and kin to noble Benjamin--this day darting the// barbed iron from one to the captain dared not attempt, he snatched the// rope attached to it--for they were humbug.//
Installation & Usage
Requirements
markov-chains-text
relies on Maps and Generators, which are available
natively in Node v4.0 and above, and in modern versions of many browsers.
For a list of JavaScript environments that support these features, see the ECMAScript Compatability Table.
Downloading
npm install --save markov-chains-text
Usage (ES6+)
;const fakeText = /* corpus: string */;
Usage (CommonJS)
var Text = default;var fakeText = /* corpus: string */;
API Reference
Coming Soon
Contributing
Pull requests are always welcome!
Building
The following npm
scripts are available for use during development:
Command | Use to... |
---|---|
npm run clean |
Remove the dist/ files |
npm run lint |
Lint the files in src/ |
npm run build |
Transpile the code with babel |
Tests
markov-chains-text
uses tape
for
testing.
To run the tests, just run npm test
at the command line.
See Also
markovify
- The excellent python library that inspiredmarkov-chains
markovchain-generate
markovchain
general-markov
markov
License
markov-chains-text
is licensed under the MIT License.
For details, please see the LICENSE
file.