sensitive-words-filter
sensitive words filter.
Installing
$ composer require xiaobinqt/sensitive-words-filter -vvv
Usage
use Xiaobinqt\SensitiveWordsFilter\SensitiveWordsFilter;
$haystack = "** | ? [] sdfs0221。?!,、;:「」『』“”‘’()【】《》〈〉 电影";
$obj = new SensitiveWordsFilter();
try {
$ret = $obj->filter($haystack);
var_dump($ret);
} catch (Exception $exception) {
// TODO
}
Return Resource
array(
'costTimeMs' => 21571.157217026,
'sensitiveWords' => "**电影"
);
Advanced usage
- 自定义敏感词文件
$senPath = __DIR__ . DIRECTORY_SEPARATOR . 'mysen.txt';
$obj = new SensitiveWordsFilter($senPath);
- 自定义敏感词数组
$obj = new SensitiveWordsFilter(null, array("**独立建国"));
Contributing
You can contribute in one of three ways:
- File bug reports using the issue tracker.
- Answer questions or fix bugs on the issue tracker.
- Contribute new features or update the wiki.
The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.
License
MIT