linshaoneng / sensitive-word
Using DFA algorithm to check whether sensitive words are included
v0.1
2020-05-28 09:07 UTC
Requires
- php: >=7.0.0
This package is auto-updated.
Last update: 2024-10-28 18:49:45 UTC
README
使用dfa算法检查是否包含敏感词/Using DFA algorithm to check whether sensitive words are included
安装/Installation
$ composer require linshaoneng/sensitive-word
使用方法 $badWords 为需要检查的敏感词/Basic Usage
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( )