GithubHelp home page GithubHelp logo

abelzhou / php-trietree Goto Github PK

View Code? Open in Web Editor NEW
224.0 15.0 59.0 2.04 MB

Make a trie tree with php language.使用场景为中文|英文 敏感词过滤/关键词过滤字典树,前缀树,内链建设,搜索提示。

License: MIT License

PHP 100.00%
wordfilter textfilter text-filter string-matching filter trietree

php-trietree's People

Contributors

abelzhou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-trietree's Issues

求指教,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

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

Hi!

您好,看了您的代码感觉受益匪浅,现在想把代码稍微改造一下,当做我们开源项目的一个组件来使用,完成后会注明来源,保证不以盈利为目的,想征求一下您的同意。

有的字符串调search直接挂掉了

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小时全天激情热舞公务员的工资奸夫淫妇淫糜妹妹的阴户喷"));

关键词用的你的

不是很懂append方法中ascii处理那段的意图,能解释一下吗

                       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;
			}

php8 支持

Required parameter $is_py follows optional parameter $end

TrieTree.php:192

有些词会命中不了

比如 "爱他妈的你好你好" 他妈的 命中不了, 敏感词是三个字的情况下, 有时候命中不了, 有时候敏感词在英文标点之后命中不了,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.