linshaoneng/sensitive-word

Using DFA algorithm to check whether sensitive words are included

Installs: 4

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/linshaoneng/sensitive-word

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

This package is auto-updated.

Last update: 2025-09-28 20:54:19 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(

)