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

The extension = jieba. So jieba. Enable = 1 jieba. Dict_path = / Users/xingqiba/data/softs jz cjieba/dict # to dict jieba library directory

example

$result = jieba(' Xiao Ming graduated from Institute of Computer Science, Chinese Academy of Sciences, and then studied in Kyoto University '); echo implode('/', $result) . PHP_EOL; $result = jieba(' Xiao Ming received his master's degree from the Institute of Computer Science, Chinese Academy of Sciences, Institute of Computing, Chinese Academy of Sciences ', true, 6); $result = jieba(' Xiao Ming received his master's degree from the Institute of Computer Science, Chinese Academy of Sciences, Institute of Computer Science, Chinese Academy of Sciences, Institute of Computer Science, Japan, and then went for further study in Kyoto University, Japan ', true, 6); echo implode('/', $result) . PHP_EOL; $result = jieba($result = jieba($result = jieba($result = jieba)); echo implode('/', $result) . PHP_EOL; $result = jieba('this is a demo, my name is jony', true, 10); $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

Welcome to join our exclusive QQ discussion group ① 233415606 ② 233415756