Implementation method of putting PHP word segmentation into MVC framework

小云云
Release: 2023-03-21 09:36:01
Original
1118 people have browsed it


This article mainly shares with you the implementation method of putting PHP word segmentation into the MVC framework. It is placed directly in the root directory of the website for testing, and in the thinkphp directory, and the class is compressed [ Util.rar】Extract to \ThinkPHP\Library\Org\Util

Code block

The code block syntax follows the standard markdown code, for example:

\n"; $ntime = $cutime; } header('Content-Type: text/html; charset=utf-8'); $memory_info = ''; print_memory('没任何操作', $memory_info); require_once '/ThinkPHP/Library/Org/Util/Phpanalysis.class.php'; $str = (isset($_POST['source']) ? $_POST['source'] : ''); $loadtime = $endtime1 = $endtime2 = $slen = 0; $do_fork = $do_unit = true; $do_multi = $do_prop = $pri_dict = false;if($str != '') { //岐义处理 $do_fork = empty($_POST['do_fork']) ? false : true; //新词识别 $do_unit = empty($_POST['do_unit']) ? false : true; //多元切分 $do_multi = empty($_POST['do_multi']) ? false : true; //词性标注 $do_prop = empty($_POST['do_prop']) ? false : true; //是否预载全部词条 $pri_dict = empty($_POST['pri_dict']) ? false : true; $tall = microtime(true); //初始化类 PhpAnalysis::$loadInit = false; $pa = new PhpAnalysis('utf-8', 'utf-8', $pri_dict); print_memory('初始化对象', $memory_info); //载入词典 $pa->LoadDict(); print_memory('载入基本词典', $memory_info); //执行分词 $pa->SetSource($str); $pa->differMax = $do_multi; $pa->unitWord = $do_unit; $pa->StartAnalysis( $do_fork ); print_memory('执行分词', $memory_info); $okresult = $pa->GetFinallyResult(' ', $do_prop); print_memory('输出分词结果', $memory_info); $pa_foundWordStr = $pa->foundWordStr; $t2 = microtime(true); $endtime = sprintf('%0.4f', $t2 - $t1); $slen = strlen($str); $slen = sprintf('%0.2f', $slen/1024); $pa = ''; } $teststr = "2010年1月,美国国际消费电子展 (CES)上,联想将展出一款基于ARM架构的新产品,这有可能是传统四大PC厂商首次推出的基于ARM架构的消费电子产品,也意味着在移动互联网和产业融合趋势下,传统的PC芯片霸主英特尔正在遭遇挑战。 11月12日,联想集团副总裁兼中国区总裁夏立向本报证实,联想基于ARM架构的新产品正在筹备中。 英特尔新闻发言人孟轶嘉表示,对第三方合作伙伴信息不便评论。 正面交锋 ARM内部人士透露,11月5日,ARM高级副总裁lanDrew参观了联想研究院,拜访了联想负责消费产品的负责人,进一步商讨基于ARM架构的新产品。ARM是英国芯片设计厂商,全球几乎95%的手机都采用ARM设计的芯片。 据悉,这是一款采用高通芯片(基于ARM架构)的新产品,高通产品市场总监钱志军表示,联想对此次项目很谨慎,对于产品细节不方便透露。 夏立告诉记者,联想研究院正在考虑多种方案,此款基于ARM架构的新产品应用邻域多样化,并不是替代传统的PC,而是更丰富的满足用户的需求。目前,客户调研还没有完成,“设计、研发更前瞻一些,最终还要看市场、用户接受程度。”"; ?>     分词测试 

源文本: [更新词典]

/>岐义处理 />新词识别 />多元切分 />词性标注 />预载全部词条



调试信息:
字串长度:K 自动识别词:

内存占用及执行时间:(表示完成某个动作后正在占用的内存)
总用时:
Copy after login

Baidu download【Word segmentation .rar】

The above is the detailed content of Implementation method of putting PHP word segmentation into MVC framework. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!