linshaoneng/sensitive-word

使用DFA算法检查是否包含敏感词

v0.1 2020-05-28 09:07 UTC

This package is auto-updated.

Last update: 2024-09-28 18:42:38 UTC


README

使用dfa算法检查是否包含敏感词/使用DFA算法检查是否包含敏感词

安装/安装

$ composer require linshaoneng/sensitive-word

基本用法 $badWords 为需要检查的敏感词/基本用法 $badWords 为需要检查的敏感词

require_once "./vendor/autoload.php";

use linshaoneng\Sensitive\SensitiveWordTree;

$Sensitive = new SensitiveWordTree();

$badWords = ['发票','口罩'];
$Sensitive->addWordstoTree( $badWords );
$text1 = '发票,发票要吗?口罩也有';
$text2 = '团结友善';
print_r( $Sensitive->checkBadWords($text1));
print_r( $Sensitive->checkBadWords($text2));

## 返回如下

包含敏感词信息:
Array
(
    [0] => 发票
    [1] => 口罩
)
并无敏感词信息
Array(

)