jojoee/leo-profanity

基于 Shutterstock 词典的污言秽语过滤器

v1.2.2 2017-03-31 02:38 UTC

This package is not auto-updated.

Last update: 2024-09-29 02:23:48 UTC


README

Latest Version on Packagist Software License Build Status

基于 Shutterstock 词典的污言秽语过滤器

安装

通过 Composer

$ composer require jojoee/leo-profanity
use Jojoee\Library\LeoProfanity as LeoProfanity;

$filter = new LeoProfanity();
$filter->check('I have BoOb');

用法

$filter->getList()

// return all profanity words (string[])
$filter->getList();

$filter->check(string)

查看更多示例,请参阅 clean 方法

// output: true
$filter->clean('I have boob');

$filter->clean(string, [replaceKey=*])

// no bad word
// output: I have 2 eyes
$filter->clean('I have 2 eyes');

// normal case
// output: I have ****, etc.
$filter->clean('I have boob, etc.');

// case sensitive
// output: I have ****
$filter->clean('I have BoOb');

// separated by comma and dot
// output: I have ****.
$filter->clean('I have BoOb.');

// multi occurrence
// output: I have ****,****, ***, and etc.
$filter->clean('I have boob,boob, ass, and etc.');

// should not detect unspaced-word
// output: Buy classic watches online
$filter->clean('Buy classic watches online');

// clean with custom replacement-character
// output: I have ++++
$filter->clean('I have boob', '+');

$filter->add(string|string[])

// add word
$filter->add('b00b');

// add word's array
// check duplication automatically
$filter->add(['b00b', 'b@@b']);

$filter->remove(string|string[])

// remove word
$filter->remove('b00b');

// remove word's array
$filter->remove(['b00b', 'b@@b']);

$filter->reset()

通过使用默认字典重置单词列表(也会移除手动添加的单词)

$filter->clearList()

清除所有污言秽语单词

注意

待办事项

  • 单元测试
  • 测试覆盖率
  • PHP CodeSniffer
  • 支持 PHP 版本 5.6、7.0、hhvm

其他语言

贡献

请在提交前运行 composer check 并修复

参考