1、下载Analysis,创建test.php测试
![](https://img-blog.csdnimg.cn/8e5a814ef58d4d1cba1f1addaa0897da.png)
2、引入Analysis实现中文分词
<?php
include "./Analysis/Analysis.php";$an=new \WordAnalysis\Analysis();
$content="机器学习是一门重要的技术,可以用于数据分析和模式识别。";
//10分词数量
$contents=$an::getKeywords($content,10);
var_dump(explode(',',$contents));
![](https://img-blog.csdnimg.cn/48cbf5ba894544a88276ce3c0b10ad84.png)
3、引入Analysis实现英文分词
<?php
include "./Analysis/Analysis.php";$an=new \WordAnalysis\Analysis();
$content="Machine learning is a branch of AI that enables computers to learn and make predictions without being explicitly programmed.";
//10分词数量
$contents=$an::getKeywords($content,10);
var_dump(explode(',',$contents));
![](https://img-blog.csdnimg.cn/e6646a80b73d4865993017072a329191.png)