Skip to content

Implementation of "Markov chains" in PHP

License

Notifications You must be signed in to change notification settings

czproject/markov

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CzProject\Markov

Build Status Downloads this Month Latest Stable Version License

Simple "Markov chains" implementation

Donate

Installation

Download a latest package or use Composer:

composer require czproject/markov

CzProject\Markov requires PHP 7.2.0 or later.

Usage

use CzProject\Markov\WordAnalyzer;
use CzProject\Markov\MemoryStorage;
use CzProject\Markov\SentenceGenerator;
use CzProject\Markov\RandomNextStateChooser;

$analyzer = new WordAnalyzer;
$analyzer->analyze(['Hello', 'world', 'and', 'everyone']);
$analyzer->analyze(['I', 'love', 'you']);

$storage = new MemoryStorage;
$storage->persistAll($analyzer->getStates());

$generator = new SentenceGenerator($storage, new RandomNextStateChooser);
echo $generator->generateRandom();

License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/

About

Implementation of "Markov chains" in PHP

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published