PHP code example of xu42 / vic-word
1. Go to this page and download the library: Download xu42/vic-word library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
xu42 / vic-word example snippets
// dict file path
$dictPath = '/tmp/dict.igb';
//长度优先分词
(new VicWord($dictPath))->getWord('聚知台是一个及时沟通工具');
//细切分
(new VicWord($dictPath))->getShortWord('聚知台是一个及时沟通工具');
//自动 这种方法最耗时
(new VicWord($dictPath))->getAutoWord('聚知台是一个及时沟通工具');
// dict file path
$dictPath = '/tmp/dict.igb';
// 添加词库
(new VicDict($dictPath))->add('中国', n);