|
|
2 years ago | |
|---|---|---|
| .. | ||
| DfaFilter | 2 years ago | |
| README.md | 2 years ago | |
php实现基于确定有穷自动机算法的铭感词过滤
curl -sS https://getcomposer.org/installer | php
要检查 Composer 是否正常工作,只需要通过 php 来执行 PHAR
php composer.phar
composer require lustre/php-dfa-sensitive
"minimum-stability": "dev"
require './vendor/autoload.php';
use DfaFilter\SensitiveHelper;
// 获取感词库索引数组
$wordData = array(
'察象蚂',
'拆迁灭',
'车牌隐',
'成人电',
'成人卡通',
......
);
$islegal = SensitiveHelper::init()->setTree($wordData)->islegal($content);
// 敏感词替换为***为例
$filterContent = SensitiveHelper::init()->setTree($wordData)->replace($content, '***');
// 获取内容中所有的敏感词
$sensitiveWordGroup = SensitiveHelper::init()->setTree($wordData)->getBadWord($content);
// 仅且获取一个敏感词
$sensitiveWordGroup = SensitiveHelper::init()->setTree($wordData)->getBadWord($content, 1);
目前已知使用平台:广电云 节目直播页面在线聊天功能支持
如果大家有更好的建议,请大家多多指正,O(∩_∩)O谢谢