nelsonkti / sensitive-word
敏感词
Installs: 24 184
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=5.6
Requires (Dev)
- mockery/mockery: dev-master
- phpunit/phpunit: ~4.1
This package is auto-updated.
Last update: 2025-05-07 12:04:36 UTC
README
过滤敏感词,采用 DFA 算法
增加包含词的过滤(如:敏感、敏感词)
Installation
$ composer require nelsonkti/sensitive-word
Laravel
引导服务 config/app.php
'providers' => [
Nelsonkti\SensitiveWord\SensitiveWordServiceProvider::class,
],
'aliases' => [
'SensitiveWord' => Nelsonkti\SensitiveWord\SensitiveWord::class,
],
Usage
基本使用:
use Nelsonkti\SensitiveWord\Facades\SensitiveWord;
$path = './word.txt'
$content = '敏感,敏感词需要过滤'; #检查内容
$filename = '/txt/sensitive-words.txt'; #敏感词文件路径
SensitiveWord::searchWord($content, $filename);
# 返回: array('敏感', '敏感词');
SensitiveWord::filterWord($content, $filename);
# 返回: **,***需要过滤
License
sensitive-word is licensed under The MIT License (MIT).