scripturadesign / markov
马尔可夫链
v2.0.0
2021-12-15 00:09 UTC
Requires
- php: ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.4.0
- phpunit/phpunit: ^9.5
- vimeo/psalm: ^4.15.0
README
马尔可夫链实现。
您可以通过提供标记数组来训练它。然后您可以得到给定标记后的标记出现次数和概率。
安装
您可以通过composer安装此包
$ composer require scripturadesign/markov
用法
!!! 已过时,目前请查看测试部分 !!!
/* Create a new first order Markov Chain object */ $chain = new Chain(1); /* Learn from arrays of tokens */ $chain->learn(['the', 'falcon', 'likes', 'the', 'snake']); /* Get all the history of the training */ $chain->history(); // [ // [ // 0 => [''], // 1 => ['the'], // 2 => ['falcon'], // 3 => ['likes'], // 4 => ['snake'], // ], // [ // 0 => ['the' => 1], // 1 => ['falcon' => 1, 'snake' => 1], // 2 => ['likes' => 1], // 3 => ['the' => 1], // 4 => ['' => 1], // ], // ]
/* Create a new second order Markov Chain object */ $chain = new Chain(2); /* Learn from arrays of tokens */ $chain->learn(['the', 'falcon', 'likes', 'the', 'snake']); /* Get all the history of the training */ $chain->history(); // [ // [ // 0 => ['', ''], // 1 => ['', 'the'], // 2 => ['the', 'falcon'], // 3 => ['falcon', 'likes'], // 4 => ['likes', 'the'], // 5 => ['the', 'snake'], // ], // [ // 0 => ['the' => 1], // 1 => ['falcon' => 1], // 2 => ['likes' => 1], // 3 => ['the' => 1], // 4 => ['snake' => 1], // 5 => ['' => 1], // ], // ]
测试
$ composer test
变更日志
请查看变更日志以获取最近更改的更多信息。
贡献
请查看贡献指南以获取详细信息。
安全性
如果您发现任何与安全相关的问题,请通过电子邮件martindilling@gmail.com而不是使用问题跟踪器来报告。
致谢
许可
MIT许可(MIT)。请查看许可文件以获取更多信息。