abelzhou / php-trietree Goto Github PK
View Code? Open in Web Editor NEWMake a trie tree with php language.使用场景为中文|英文 敏感词过滤/关键词过滤字典树,前缀树,内链建设,搜索提示。
License: MIT License
Make a trie tree with php language.使用场景为中文|英文 敏感词过滤/关键词过滤字典树,前缀树,内链建设,搜索提示。
License: MIT License
Fatal error: Uncaught Error: Class 'swoole_http_server' not found in /opt/lampp/htdocs/vendor/abelzhou/php-trie-tree/demo/swoole_server.php:13 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/vendor/abelzhou/php-trie-tree/demo/swoole_server.php on line 13
您好,看了您的代码感觉受益匪浅,现在想把代码稍微改造一下,当做我们开源项目的一个组件来使用,完成后会注明来源,保证不以盈利为目的,想征求一下您的同意。
require "../src/TrieTree.php";
$str = file_get_contents("./dict.txt");
$words_arr = explode("\n", $str);
$tree = new \AbelZhou\Tree\TrieTree();
foreach ($words_arr as $str) {
$tree->append($str);
}
var_dump($tree->search('法伦功'));
var_dump($tree->search("据警方调查和“善心汇”部分骨干成员介绍,“张天师”的形象是张天明对自己极力包装的结果。pp点点通法伦功切七哲民护士小穴空姐小穴QQ堂昏药saohuao操**好爽meinv主持26小时全天激情热舞公务员的工资奸夫淫妇淫糜妹妹的阴户喷"));
关键词用的你的
if (($ascii_code >> 7) == 0) {
$code = dechex(ord($str[$i]));
$word = $str[$i];
} else if (($ascii_code >> 4) == 15) { //1111 xxxx, 四字节
if ($i < $len - 3) {
$code = dechex(ord($str[$i])) . dechex(ord($str[$i + 1])) . dechex(ord($str[$i + 2])) . dechex(
ord($str[$i + 3])
);
$word = $str[$i] . $str[$i + 1] . $str[$i + 2] . $str[$i + 3];
$i += 3;
}
} else if (($ascii_code >> 5) == 7) { //111x xxxx, 三字节
if ($i < $len - 2) {
$code = dechex(ord($str[$i])) . dechex(ord($str[$i + 1])) . dechex(ord($str[$i + 2]));
$word = $str[$i] . $str[$i + 1] . $str[$i + 2];
$i += 2;
}
} else if (($ascii_code >> 6) == 3) { //11xx xxxx, 2字节
if ($i < $len - 1) {
$code = dechex(ord($str[$i])) . dechex(ord($str[$i + 1]));
$word = $str[$i] . $str[$i + 1];
$i++;
}
}
if ($i == ($len - 1)) {
$is_end = true;
}
请问想把内容里违禁的关键词替换成*号怎么操作?不太会使用组件的替换这个方法
Required parameter $is_py follows optional parameter $end
TrieTree.php:192
比如 "爱他妈的你好你好" 他妈的 命中不了, 敏感词是三个字的情况下, 有时候命中不了, 有时候敏感词在英文标点之后命中不了,
你试试 "胡***你好你好圣诞节" 我用的是demo里面14000的字典
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.