Skip to content

Latest commit

 

History

History
19 lines (17 loc) · 547 Bytes

Sensitive.md

File metadata and controls

19 lines (17 loc) · 547 Bytes

敏感词过滤器 Sensitive

// DFA算法过滤器
$handle = SensitiveHelper::dfa($wordData = []);
$handle->islegal($badWord);
$handle->replace($badWord, '*', true);
$handle->replace($badWord, '***');
$handle->mark($badWord, '<mark>', '</mark>');
$handle->getBadWord($badWord)[0];
文档 https://github.com/FireLustre/php-dfa-sensitive

// AC算法过滤器
$handle = SensitiveHelper::ac($wordData = []);
$handle->add('...');
$handle->finalize();
$found = $handle->search($badWord);
文档 https://github.com/codeplea/ahocorasickphp