1. Go to this page and download the library: Download patrickschur/markov-chain library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
patrickschur / markov-chain example snippets
use MarkovChain\MarkovChain;
use MarkovChain\Tokenizer\WordTokenizer;
$c = new MarkovChain(new WordTokenizer());
$c->learn([
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr.',
'At vero eos et accusam et justo duo dolores et ea rebum.',
]);
print_r($c->classify('et'));
/*
[
'accusam' => 0.33333333333333,
'justo' => 0.33333333333333,
'ea' => 0.33333333333333
]
*/
use MarkovChain\MarkovChain;
use MarkovChain\Tokenizer\CharTokenizer;
$c = new MarkovChain(new CharTokenizer());
$c->learn([
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr.',
'At vero eos et accusam et justo duo dolores et ea rebum.',
]);
print_r($c->classify('a'));
/*
[
'm' => 0.4,
'd' => 0.2,
'c' => 0.2,
'r' => 0.2
]
*/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.