4.0.2 • Published 4 years ago

markov-text-gen v4.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

markov-text-gen

A simple library to generate random text using a Markov chain.

Description

markov-text-gen generates a random sentence based on a the source text provided.

It provides two ways to create random text by exposing a build function that gets passed the text to be ingested, the desired nGram size, and boolean flag to build byChars. The build function creates a Markov Chain based on source text and the nGram size passed, and returns a run function that is passed the number of times run should loop for before returning; the default for generating text via characters is 1000, for words the default is 50. The return value is a randomly generatedstring`.

Example

import text from './text';
import build from 'markov-text-gen';

build(text, 3, false) // The text to be ingested, the nGram size, and whether to build byChars
  .then((run) => {
    const result = run(35);
    console.log(result);
  });

Inspiration

The Coding Train YouTube

The Coding Train GitHub

Markov Chains Explained Visually

TODO

In no particular order: tests, linting, general clean-up of code.

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.0.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.1

4 years ago