purpl-markov-chain
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.3 • Public • Published

    Markov Chain

    A simple Marvkov chain class supporting different n-grams, back and forth generation and serializable to JSON or string in order to save them and reload them later.

    Documentation

    The documentation is available here.

    Installation

    • For use in npm, run the command:

    npm install --save purpl-markov-chain.

    • For use in the browser, you can include the library from a CDN:
    <script src="https://unpkg.com/purpl-markov-chain/index.js"></script>
    <script>
      const chain = new MarkovChain();
    </script> 

    Usage

    // No need to include the file if working in the browser
    const MarkovChain = require('purpl-markov-chain');
     
    const chain = new MarkovChain(); // Create a Markov chain
     
    // Teach the chain some text.
    chain.update('Adding some sentences');
    chain.update('And more uwu');
     
    // Generate a new sentence.
    console.log(chain.generate());

    Install

    npm i purpl-markov-chain

    DownloadsWeekly Downloads

    1

    Version

    2.0.3

    License

    MIT

    Unpacked Size

    12 kB

    Total Files

    5

    Last publish

    Collaborators

    • nayuwu