How to use php to extract keywords from articles? PHP uses Analysis Chinese and English word segmentation to extract keywords

1. Download Analysis and create test.php test

2. Introduce Analysis to realize Chinese word segmentation
<?php
include "./Analysis/Analysis.php";

$an=new \WordAnalysis\Analysis();
$content="机器学习是一门重要的技术,可以用于数据分析和模式识别。";
//10分词数量
$contents=$an::getKeywords($content,10);
var_dump(explode(',',$contents));

3. Introduce Analysis to realize English word segmentation 
<?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));

Guess you like

Origin blog.csdn.net/weixin_39934453/article/details/133198284