dshumkov/profanity-filter
基于Swearjar库的脏话过滤器
1.0.1
2015-08-04 23:05 UTC
Requires
- php: >=5.5
This package is not auto-updated.
Last update: 2024-10-02 10:13:59 UTC
README
基于PHP Swearjar库的脏话过滤器
安装
composer require dshumkov/profanity-filter
用法
预定义字典
$tester = new DShumkov\ProfaneFilter\Tester();
if ($tester->profane('son-of-a-bitch'))
{
return 'bad word detected';
}
自定义字典
$dictionary = [
'regex' => ['regex1', 'regex2'],
'word' => ['word1', 'word2'],
'phrase' => ['phrase one', 'phrase two']
];
$tester = new DShumkov\ProfaneFilter\Tester($dictionary);
if ($tester->profane('some string with word1') OR $tester->profane('phrase two'))
{
return 'bad word detected';
}