cledilsonweb/badwords
Composer 安装命令:
composer require cledilsonweb/badwords
包简介
Badwords PHP is a small lightweight PHP library for detecting 'bad' words, e.g. profanity, in content.
关键字:
README 文档
README
Badwords PHP is small lightweight PHP library for detecting "bad" words, e.g. profanity, in content. This is a fork from mioga-technik/badwords to customize.
Aside from the obvious matching if a word is present in a string, the filter also tries to detect words similar to those in the list, e.g. gl@d and glad.
The library is designed to be highly configurable, from the word lists used to the character replacement configuration at the heart of the filter.
Note: At present the default configuration provided is not a bulletproof/catch-all solution, but it will catch most variations. This will become more robust over time.
Requirements
- The library is only supported on PHP 5.6 and up.
- Composer is required.
Installation
To install include it in your projects's composer.json.
$ composer require cledilsonweb/badwords
$ composer update
There are no additional dependencies required for this package to work.
Usage
File Method:
The simplest way to use the library is as follows,
$dictionary = new \Badword\Dictionary\Php('path/to/dictionary_list.php'); $config = new \Badword\Filter\Config\Standard(); $filter = new \Badword\Filter($dictionary, $config); $result = $filter->filter('My content...'); $result->getRiskLevel(); $result->getMatches(); $result->getMatchesAndRiskLevels(); $result->getHighlightedContent();
Explained,
- First load your list of "bad" words using the
Dictionaryobjects, or create your own and implement theDictionaryinterface. - Define a configuration for the filter to use (a default
Standardconfiguration is provided). - Create the
Filterpassing your dictionary(s) and config. - Filter your content using the
filter()method. - Use the
Resultobject to analyse your content.
Array Method:
// An example moderate dictionary. $dictionaryWords = array( 'some', 'bad', 'words' ); $dictionary = new \Badword\Dictionary\PhpArray($dictionaryWords, 1); $config = new \Badword\Filter\Config\Standard(); $filter = new \Badword\Filter($dictionary, $config); $result = $filter->filter('My content...'); $result->getRiskLevel(); $result->getMatches(); $result->getMatchesAndRiskLevels(); $result->getHighlightedContent();
Object Layer Method [new]:
$dictionaryWords = array( 'reject' => array( 'maecenas', 'mauris', 'luctus' ), 'moderate' => array( 'consectetur', 'neque', 'velit' ) ); $Badwords = new \Badword\Badwords($dictionaryWords); $result = $Badwords->Filter()->filter('My content...')); $result->getRiskLevel(); $result->getMatches(); $result->getMatchesAndRiskLevels(); $result->getHighlightedContent();
Testing
To run the unit tests on this package, simply run vendor/bin/phpunit from the package directory.
Credits
- This repository is maintained by Cledilson Nascimento
Previous authors:
- Update Repository and push it to packagist by Brian Schäffner.
- Written and developed by Stephen Melrose.
- Original concept by Paul Lemon.
cledilsonweb/badwords 适用场景与选型建议
cledilsonweb/badwords 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 09 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「badwords」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cledilsonweb/badwords 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cledilsonweb/badwords 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cledilsonweb/badwords 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Filtro para censura de palavrões/palavras inapropriadas
Laravel badwords filter package (multi-language, production-ready)
PHP Slang Detection Library for Web Applications
Italian profanity and spam filter for PHP. Three-level detection: regex, substring, compound phrases.
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-16