Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

markov-chains-text

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markov-chains-text

Fake text, powered by Markov chains

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
increased by36.36%
Maintainers
1
Weekly downloads
 
Created
Source

markov-chains-text

Fake text, powered by Markov chains

npm version


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

import { readFileSync } from 'fs';
import path from 'path';
import Text from 'markov-chains-text';

const MobyDick = readFileSync(path.join(__dirname, 'moby-dick.txt'));

// build the generator
const fakeMobyDick = new Text(MobyDick);

// generate a sentence
const sentence = fakeMobyDick.makeSentence();

console.log(sentence);

// 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.
//

Back to Top ↑


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+)

import Text from 'markov-chains-text';
const fakeText = new Text(/* corpus: string */);

Usage (CommonJS)

var Text = require('markov-chains-text').default;
var fakeText = new Text(/* corpus: string */);

Back to Top ↑


API Reference

Coming Soon

Back to Top ↑


Contributing

Pull requests are always welcome!

Building

The following npm scripts are available for use during development:

CommandUse to...
npm run cleanRemove the dist/ files
npm run lintLint the files in src/
npm run buildTranspile the code with babel

Tests

markov-chains-text uses tape for testing.

To run the tests, just run npm test at the command line.

Back to Top ↑


See Also

Back to Top ↑


License

markov-chains-text is licensed under the MIT License.

For details, please see the LICENSE file.

Back to Top ↑

Keywords

FAQs

Package last updated on 07 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc