sworup/profanityfilter
Composer 安装命令:
composer require sworup/profanityfilter
包简介
Profanity filter package would help you censor some of the bad words users put in your posts and/or comments.
README 文档
README
Profanity Filter takes strings as input and removes any bad curse words that the string might have. It checks the strings for specific blacklist which must match as a separate word to be considered as a curse word. If a curse word is found, then it will replace the curse word with a censor character the user chooses (default is *).
This package is intended to used with Laravel. Tested and working with laravel 5.4.
If you want to override the Package's config file, just copy it and rename it to config/profanity-filter.php, and update as per your needs.
This code is based on Fastwebmedia/Profanity-Filter. A major part of it is taken from there and I added the things that I thought it required.
Install
Via Composer
$ composer require sworup/profanityfilter
###Laravel
Add 'Sworup\ProfanityFilter\ProfanityServiceProvider' to your providers array.
If you wish to use the Facade then add
'Profanity' => 'Sworup\ProfanityFilter\Profanity'
The package will automatically use the config file containing the list of banned words.
Usage
$swear_word = ['dog']; $blacklist = ['puppy']; $replace = ['a' => '(a|a\.|a\-|4|@|Á|á|À|Â|à|Â|â|Ä|ä|Ã|ã|Å|å|α|Δ|Λ|λ)']; $profanity_filter = new sworup\ProfanityFilter($swear_words, $blacklist, $replace); echo $profanity_filter->clean('Dog, puppy badpuppy baddog!', '$');
The above code would return:
array( 'old_string' => 'Dog, puppy badpuppy baddog!', 'new_string' => '$$$, $$$$$ badpuppy bad$$$!', 'clean' => false );
Change log
Please see CHANGELOG for more information about what has changed recently.
Testing
$ phpspec run
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email sworup.shakya@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
sworup/profanityfilter 适用场景与选型建议
sworup/profanityfilter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.49k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2015 年 11 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「censor」 「swear word」 「curse words」 「remove profanity」 「Profanity Filter」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sworup/profanityfilter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sworup/profanityfilter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sworup/profanityfilter 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel Profanity Filter - Powerful PHP package for detecting, filtering, and masking profanity in multiple languages. Supports leet speak, custom word lists, case sensitivity, and seamless Laravel integration.
A content moderation and sentiment analysis library for Laravel 10+
Help search and replace specific texts, such as email address(es).
This is a censor.
Filters through text and cleans the input of bad words found.
A middleware to censor certain words from your pages
统计信息
- 总下载量: 4.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-11-04