fieg / markov
Implementation of MarkovChain algorithm in PHP
1.0
2015-05-14 11:53 UTC
Requires (Dev)
- phpunit/phpunit: ~4.1
This package is auto-updated.
Last update: 2024-11-29 05:20:44 UTC
README
Implementation of MarkovChain algorithm in PHP.
Getting started
use Fieg\Markov\MarkovChain; $sentences = [ 'my blue car', 'red and blue flowers', 'his blue car', ]; $chain = new MarkovChain(); foreach ($sentences as $sentence) { $tokens = explode(" ", $sentence); $chain->train($tokens); } $result = $chain->query("blue");
Which would result in:
array(2) {
'car' =>
double(0.66666666666667)
'flowers' =>
double(0.33333333333333)
}