结巴中文分词之PHP扩展
https://github.com/jonnywang/...
functions
array jieba(string $text, bool use_extract = false, long extract_limit = 10)
install
git clone https://github.com/jonnywang/phpjieba.git cd phpjieba/cjieba make cd .. phpize ./configure make make install
jieba more detail please visit https://github.com/yanyiwu/cp...
php.ini
extension=jieba.so jieba.enable=1 jieba.dict_path=/Users/xingqiba/data/softs/jz/cjieba/dict #指向jieba库dict目录
example
$result = jieba('小明硕士毕业于中国科学院计算所,后在日本京都大学深造');
echo implode('/', $result) . PHP_EOL;
//小明/硕士/毕业/于/中国/科学/学院/科学院/中国科学院/计算/计算所/,/后/在/日本/京都/大学/京都大学/深造
$result = jieba('小明硕士毕业于中国科学院计算所,后在日本京都大学深造', true, 6);
echo implode('/', $result) . PHP_EOL;
//计算所/小明/京都大学/深造/硕士/中国科学院
$result = jieba('他心理健康');
echo implode('/', $result) . PHP_EOL;
//他/心理/健康/心理健康
$result = jieba('this is a demo, my name is jony', true, 10);
echo implode('/', $result) . PHP_EOL;
//demo/jony
$result = jieba('this is a demo, my name is jony');
echo implode('/', $result) . PHP_EOL;
//this/ /is/ /a/ /demo/,/ /my/ /name/ /is/ /jony欢迎您加入我们的专属QQ讨论群组① 233415606 ② 233415756
相关推荐
fkyyly 2019-08-16
xiaocao0 2020-06-25
fkyyly 2020-05-31
chongtianfeiyu 2020-04-10
小发猫 2020-02-02
fkyyly 2020-01-28
spylyt 2020-09-11
天才幻想家 2020-08-03
vtnews 2020-07-29
算法改变人生 2020-06-25
winxcoder 2020-04-19
tigercn 2020-04-18
athrenzala 2020-04-17
houhow 2020-02-18
李玉志 2020-01-17
mengyue 2020-01-01
CYJ0go 2020-01-01