PHP code example of linshaoneng / sensitive-word
1. Go to this page and download the library: Download linshaoneng/sensitive-word 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/ */
linshaoneng / sensitive-word example snippets
use linshaoneng\Sensitive\SensitiveWordTree;
$Sensitive = new SensitiveWordTree();
$badWords = ['发票','口罩'];
$Sensitive->addWordstoTree( $badWords );
$text1 = '发票,发票要吗?口罩也有';
$text2 = '团结友善';
print_r( $Sensitive->checkBadWords($text1));
print_r( $Sensitive->checkBadWords($text2));
包含敏感词信息:
Array
(
[0] => 发票
[1] => 口罩
)
并无敏感词信息
Array(
)