PHP code example of xiaobinqt / sensitive-words-filter
1. Go to this page and download the library: Download xiaobinqt/sensitive-words-filter library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
xiaobinqt / sensitive-words-filter example snippets
use Xiaobinqt\SensitiveWordsFilter\SensitiveWordsFilter;
$haystack = "淫色 | ? [] sdfs0221。?!,、;:「」『』“”‘’()【】《》〈〉 电影";
$obj = new SensitiveWordsFilter();
try {
$ret = $obj->filter($haystack);
var_dump($ret);
} catch (Exception $exception) {
// TODO
}
array(
'costTimeMs' => 21571.157217026,
'sensitiveWords' => "淫色电影"
);
$senPath = __DIR__ . DIRECTORY_SEPARATOR . 'mysen.txt';
$obj = new SensitiveWordsFilter($senPath);