jojoee / leo-profanity
基于 Shutterstock 词典的污言秽语过滤器
v1.2.2
2017-03-31 02:38 UTC
Requires
- php: ~5.6|~7.0
Requires (Dev)
- phpmd/phpmd: ^2.6
- phpunit/phpunit: ^5.7
- squizlabs/php_codesniffer: ^2.8
This package is not auto-updated.
Last update: 2024-09-29 02:23:48 UTC
README
基于 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()
清除所有污言秽语单词
注意
- 来自
jojoee/leo-profanity的过滤器算法 - 测试(使用
composer test) - PSR-2 编码规范(由
composer check-style测试并通过composer fix-style修正。) - 安全性,如果您发现任何与安全性相关的问题,请通过电子邮件 inid3a@gmail.com 而不是使用问题跟踪器。
- 遵循 SemVer v2.0.0
- 连贯的历史(每个单独的提交都很有意义),如果不是,请 合并它们。
待办事项
- 单元测试
- 测试覆盖率
- PHP CodeSniffer
- 支持 PHP 版本 5.6、7.0、hhvm
其他语言
- JavaScript 在 npmjs.com/package/leo-profanity
- PHP 在 packagist.org/packages/jojoee/leo-profanity
- Python 在 PyPI
- Java 在 Maven
- WordPress 在 wordpress.org
贡献
请在提交前运行 composer check 并修复