czproject / markov
Simple Markov chains implementation
Fund package maintenance!
Other
v1.0.0
2022-09-25 16:23 UTC
Requires
- php: >=7.2.0
- nette/utils: ^3.2
Requires (Dev)
- nette/tester: ^2.0
This package is auto-updated.
Last update: 2024-10-13 19:55:59 UTC
README
Simple "Markov chains" implementation
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/