PHP code example of guda / php-dfa
1. Go to this page and download the library: Download guda/php-dfa 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/ */
guda / php-dfa example snippets
composer
$path = __DIR__;
$raw = $path.'/storage/logs/raw'; // 词库目录
$map = $path.'/storage/logs/map'; // 映射文件目录
(new InitWordsMap($raw, $map))->initMap();
$path = __DIR__;
$raw = $path.'/storage/logs/raw'; // 词库目录
$map = $path.'/storage/logs/map'; // 映射文件目录
$obj = (new CheckWords($raw, $map));
$obj->setMap('illegal'); // 词库名称(取自词库文件名)
var_dump($obj->check('我是测试字段'));