laravel-敏感词检测
//composer require lustre/php-dfa-sensitive // $wordData = [ // '察象蚂', // '拆迁灭', // '车牌隐', // '成人电', // '成人卡通' // ]; // $handle = SensitiveHelper::init()->setTree($wordData); $wordFilePath = resource_path() . '/file/words.txt'; $handle = SensitiveHelper::init()->setTreeByFile($wordFilePath); $content = '测试语句'; //检查是否含有敏感词 // $islegal = $handle->islegal($content); // 将敏感词替换为* // $filterContent = $handle->replace($content, '*', true); //标记敏感词 // $markedContent = $handle->mark($content, '<mark>', '</mark>'); // 获取内容中所有的敏感词 // $sensitiveWordGroup = $handle->getBadWord($content); // 仅且获取一个敏感词 // $sensitiveWordGroup = $handle->getBadWord($content, 1,1);