发布版本:
  httpcws 1.0.0 (最新版本:2009-08-10发布)

  程序网址:http://code.google.com/p/httpcws

  安装使用手册:http://blog.zyan.cc/httpcws_v100/

  下载地址(32位版):http://httpcws.googlecode.com/files/httpcws-1.0.0-i386-bin.tar.gz

  下载地址(64位版):http://httpcws.googlecode.com/files/httpcws-1.0.0-x86_64-bin.tar.gz

  中文分词在线演示:http://blog.zyan.cc/demo/httpcws/

  PHP演示程序下载:http://blog.zyan.cc/demo/httpcws/httpcws-php-demo.zip



  httpcws 中文简介
  1、什么是 httpcws ?
  HTTPCWS 是一款基于HTTP协议的开源中文分词系统,目前仅支持Linux系统。HTTPCWS 使用“ICTCLAS 3.0 2009共享版中文分词算法”的API进行分词处理,得出分词结果。HTTPCWS 将取代本人之前开发的 PHPCWS 中文分词扩展

  ICTCLAS(Institute of Computing Technology, Chinese Lexical Analysis System)是中国科学院计算技术研究所在多年研究工作积累的基础上,基于多层隐马模型研制出的汉语词法分析系统,主要功能包括中文分词;词性标注;命名实体识别;新词识别;同时支持用户词典。ICTCLAS经过五年精心打造,内核升级6次,目前已经升级到了ICTCLAS3.0,分词精度98.45%,各种词典数据压缩后不到3M。ICTCLAS在国内973专家组组织的评测中活动获得了第一名,在第一届国际中文处理研究机构SigHan组织的评测中都获得了多项第一名,是当前世界上最好的汉语词法分析器。

  ICTCLAS 3.0 商业版是收费的,而免费提供的 ICTCLAS 3.0 共享版不开源,词库是根据人民日报一个月的语料得出的,很多词语不存在。所以本人补充的一个19万条词语的自定义词库,对ICTCLAS分词结果进行合并处理,输出最终分词结果。

  由于 ICTCLAS 3.0 2009 共享版只支持GBK编码,因此,如果是UTF-8编码的字符串,可以先用iconv函数转换成GBK编码,再用httpcws进行分词处理,最后转换回UTF-8编码。

  HTTPCWS 软件自身(包括httpcws.cpp源文件、dict/httpcws_dict.txt自定义词库)采用NewBSD开源协议,可以自由修改。HTTPCWS 使用的 ICTCLAS 共享版 API 及 dict/Data/ 目录内的语料库,版权及著作权归中国科学院计算技术研究所、ictclas.org所有,使用需遵循其相关协议。



  2、httpcws 中文分词在线演示
  演示网址:http://blog.zyan.cc/demo/httpcws/



  3、httpcws 中文分词下载安装
  32位版:
cd /usr/local/
wget http://httpcws.googlecode.com/files/httpcws-1.0.0-i386-bin.tar.gz
tar zxvf httpcws-1.0.0-i386-bin.tar.gz
rm -f httpcws-1.0.0-i386-bin.tar.gz
cd httpcws-1.0.0-i386-bin/
ulimit -SHn 65535
/usr/local/httpcws-1.0.0-i386-bin/httpcws -d -x /usr/local/httpcws-1.0.0-i386-bin/dict/


  64位版:
cd /usr/local/
wget http://httpcws.googlecode.com/files/httpcws-1.0.0-x86_64-bin.tar.gz
tar zxvf httpcws-1.0.0-x86_64-bin.tar.gz
rm -f httpcws-1.0.0-x86_64-bin.tar.gz
cd httpcws-1.0.0-x86_64-bin/
ulimit -SHn 65535
/usr/local/httpcws-1.0.0-x86_64-bin/httpcws -d -x /usr/local/httpcws-1.0.0-x86_64-bin/dict/


  命令行启动参数:

  点击在新窗口中浏览此图片



  4、httpcws 使用方法
  GET方法(文本长度受URL的长度限制,需要分词的文本为GBK编码,最好采用urlencode对文本进行编码):


  POST方法(文本长度无限制,适用于大文本分词,需要分词的文本为GBK编码,最好采用urlencode对文本进行编码):
curl -d "有人的地方就有江湖" http://192.168.8.42:1985
curl -d "%D3%D0%C8%CB%B5%C4%B5%D8%B7%BD%BE%CD%D3%D0%BD%AD%BA%FE" http://192.168.8.42:1985


  PHP 调用 HTTPCWS 示例:

  ①、对GBK编码的字符串进行中文分词处理(HTTP POST方式):
<?php
@header('Content-Type: text/html; charset=gb2312');
$text = "有人的地方就有江湖";
$text = urlencode($text);
$opts = array(
  'http'=>array(
    'method'=>"POST",
    'header'=>"Content-type: application/x-www-form-urlencoded\r\n".
              "Content-length:".strlen($data)."\r\n" .
              "Cookie: foo=bar\r\n" .
              "\r\n",
    'content' => $text,
  )
);
$context = stream_context_create($opts);
$result = file_get_contents("http://127.0.0.1:1985", false, $context);
echo $result;
?>


  ②、对UTF-8编码的字符串进行中文分词处理(HTTP POST方式):
<?php
@header('Content-Type: text/html; charset=utf-8');
$text = "有人的地方就有江湖";
$text = iconv("UTF-8", "GBK//IGNORE", $text);
$text = urlencode($text);
$opts = array(
  'http'=>array(
    'method'=>"POST",
    'header'=>"Content-type: application/x-www-form-urlencoded\r\n".
              "Content-length:".strlen($data)."\r\n" .
              "Cookie: foo=bar\r\n" .
              "\r\n",
    'content' => $text,
  )
);
$context = stream_context_create($opts);
$result = file_get_contents("http://127.0.0.1:1985", false, $context);
$result = iconv("GBK", "UTF-8//IGNORE", $result);
echo $result;
?>


  ③、对GBK编码的字符串进行中文分词处理(HTTP GET方式):
<?php
@header('Content-Type: text/html; charset=gb2312');
$text = "有人的地方就有江湖";
$text = urlencode($text);
$result = file_get_contents("http://127.0.0.1:1985/?w=".$text);
echo $result;
?>


  ④、对UTF-8编码的字符串进行中文分词处理(HTTP GET方式):
<?php
@header('Content-Type: text/html; charset=utf-8');
$text = "有人的地方就有江湖";
$text = iconv("UTF-8", "GBK//IGNORE", $text);
$text = urlencode($text);
$result = file_get_contents("http://127.0.0.1:1985/?w=".$text);
$result = iconv("GBK", "UTF-8//IGNORE", $result);
echo $result;
?>




  5、httpcws 分词速度及用途

  局域网内 HTTPCWS 接口中文分词平均处理速度(Wait时间):0.001秒。HTTPCWS 基于 libevent + epoll 网络IO模型开发,经测试,每秒可处理5000~20000次请求。

  点击在新窗口中浏览此图片

  HTTPCWS 属于《[http://blog.zyan.cc/post/385.htm 亿级数据的高并发通用搜索引擎架构设计]》的一部分,用作“搜索查询接口”的关键字分词处理。在此架构中,Sphinx索引引擎对于CJK(中日韩)语言支持一元切分,假设【反恐行动是国产主视角射击网络游戏】这段文字,Sphinx会将其切成【反 恐 行 动 是 国 产 主 视 角 射 击 网 络 游 戏】,然后对每个字建立反向索引。如果用这句话中包含的字组成一个不存在的词语,例如【恐动】,也会被搜索到,所以搜索时,需要加引号,例如搜索【"反恐行动"】,就能完全匹配连在一起的四个字,不连续的【"恐动"】就不会被搜索到。但是,这样还有一个问题,搜索【"反恐行动游戏"】或【"国产网络游戏"】就会搜索不到。所以,我在搜索层写了个PHP中文分词扩展,搜索“反恐行动游戏”、“国产网络游戏”,会被httpcws中文分词函数分别切分为“反恐行动 游戏”、“国产 网络游戏”,这时候,用PHP函数给以空格分隔的词语加上引号,去搜索【"反恐行动" "游戏"】或【"国产" "网络游戏"】,就能搜索到这条记录了。由于httpcws位于搜索层,中文分词词库发生增、删、改,只需重启httpcws进程即可,无需重建搜索索引。

  根据上述情况,对于那些采用二元交叉切分的搜索引擎,httpcws用在前端搜索层对用户输入的搜索关键字、短语进行分词处理,同样适合。httpcws开发的目的正在于此,对于短句、小文本中文分词切分,速度非常之快。



  6、自定义词库
  修改dict/httpcws_dict.txt文件,可以自由增加自己需要的词语。重启httpcws即可生效。





技术大类 » 搜索引擎技术 | 评论(419) | 引用(1) | 阅读(163697)
任我行 Homepage
2011-1-13 15:43
我想问下这对seo有帮助吗?我是做seo的
小覃 Email Homepage
2011-2-22 13:34
我的张宴学长哦,你这么厉害呀,偶们中南民大学子的骄傲啊!呵呵~~
偶对你的中文分词系统很感兴趣哦!
airlifei
2011-4-7 09:09
请问httpcws可以去除标点符号么?
终极梦幻
2011-4-14 16:46
www.sogou.com/labs/resources.html
这里是搜狗实验室的语料库,挺全的,有没有必要把语料库加到你现有的程序中去?
这个绝对不是guanggao!!!!!!!!!!!!!!!!!!!!!!!!!!
sevi
2011-7-30 11:14
uplook 貌似有很长时间没有更新了,不打算升级吗?
yuyi Email Homepage
2011-10-14 13:59
php 例子无法取得结果
wangnan1018
2011-11-8 10:16
我想问一下对于文本的分词如何使用啊?
louis vuitton uk Email Homepage
2011-11-22 17:06
This louis vuitton uk for sale belongs to the sounding just what are termed as Louis Vuitton vintage best sellers, many other products and services for the reason that range appearing companies.You will easily notice the unfold zippers of this coach outlet store online. That is the decoration. There are some inside pockets for you as well. They are easy to match your clothes and to carry.Let us inspire your inner beauty with fine christian louboutin sale. Purse the elegance in bridal wedding. Enjoy the fashion.
armani watches Email Homepage
2011-11-23 10:09
If you are looking for armani Bags, our armani watches Handbags Canada outlet store is your first choice. We promise Original Packing and Best Discount,3-5 Workdays To Your Door!If you buy bags and purses of the latest new designs from the louis vuitton outlet now, you can enjoy special discounts. What else are you waiting for?After you choose the right kind of plants and the size pot for the plant.
dddd
2012-2-8 10:03
[emot]question[/emot][emot]grin[/emot][emot]cool[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]question[/emot][emot]smile[/emot][emot]smoke[/emot][emot]smoke[/emot][emot]smoke[/emot][emot]smoke[/emot][emot]smoke[/emot][emot]smoke[/emot][emot]zan[/emot][emot]zan[/emot][emot]zan[/emot][emot]zan[/emot][emot]zan[/emot][emot]zan[/emot][emot]sleepy[/emot][emot]sleepy[/emot][emot]sweat[/emot][emot]sweat[/emot][emot]sweat[/emot]
Louis Vuitton Neverfull Email Homepage
2012-4-21 19:38
www.lvbagsclassic.com are authorized authentic Louis Vuitton handbags outlet store. All the items at our site are 100% authentic. All our Louis Vuitton handbags will come with the authenticity card, serial Number, dust bag and care booklet. We promise you will be 100% satisfied when you get such cheap authentic Louis Vuitton handbags from us!
Louis Vuitton Neverfull
guo
2012-5-4 14:05
哥们这个主要是使用的中科院的分词组件 只是在外面封装了一层http server噢
Hogan
2012-5-10 18:01
Ci sono diversi motivi principali per cui si può sicuramente trovare sul proprio volere le soluzioni contabili che coinvolgono tutta Stansted, anche se alcune persone potrebbero uomini e donne, probabilmente si dovrà disporre di soluzioni contabili rispetto con la gente. Stai con me per scoprire di più su molti dei motivi per prendere in considerazione l'impiego contabili in tutta Hogan Stansted. Costruire un businessIf vi capita di essere in funzione, è abbastanza possibile che si può fare uso di soluzioni contabili. Non date per scontato tutte le società hanno abbastanza soldi per utilizzare a tempo pieno il personale fiscali, così utilizzando una conditi insieme con l'agenzia affidabile che coinvolge tutta commercialisti Stansted potrebbe rendere meno difficili problemi.
Coach Outlet Store online Email Homepage
2012-6-6 10:40
If women is the stylish carrier, then bag is  the symbol of fashion. And Coach Outlet Store Online bag must be the representative of fashion. If you want to own one stylish enough coach bag, you should have a look at Coach Outlet Store. All the bags in coach outlet online are the real ones with top quality. The most important is that most of those bags are nearly 80% off. It is a good opportunity for coach bags lovers. Come on.
大笨兔 Email Homepage
2012-7-9 11:14
一直不懂中文怎么去分词
自己在脑海里想想都感觉很复杂
绝缘体
2012-8-8 15:04
为什么我centos 上装不上?
能不能做个api接口呢?
还有 你返回结果是 空格分开,为什么不能做成xml  json这种形式的呢
或者 逗号分割也行啊,
lirourou77 Email Homepage
2012-9-5 14:09
Lvjing Hai, the flexibility to delay the basic pension policy, if implemented, will do the elderly occupied by young people to work. In this regard, countries <b>discount designer clothes<b>      
should be to stimulate economic growth, new jobs, to alleviate this problem.

His analysis, private enterprises and foreign enterprises, joint ventures, to attract a large number of employment staff in order to enable flexibility to delay in receiving the basic pension policies can be implemented smoothly, it seems, or should the broad-brush approach to enforce appropriate.

Chu Fu-ling: each year involving tens of millions <b>wholesale designer handbags<b>      
of people

Chu Fu Ling told reporters in the country to implement the flexibility to delay the basic pension policies each year may involve tens of millions of people, and thus lead to the problem of young people unable to enter these positions. This massive amount of posts can not be vacated, may be <b>designer handbags for less<b>      
difficult through the newly developed position, such as to resolve all of a sudden.
Email
2012-9-21 13:47
能用IP访问可以分词,为啥用file_get_contents无法获取到分词内容呢?啥也不显示,怎么回事???将程序放到其他服务器上就能显示分词结果。这是为啥???
知道了,是需要关闭SELINUX
刘建林 Email Homepage
2012-10-12 15:05
支持张宴的大原创开发,二次开发,开发,大力学习中。那些说别人写得没有意思的人有本事自己写去,不要在这侮辱劳动成果。
leo Email
2013-2-2 01:41
请问如何在分词后进行词性标注?词性标注标准可以自定义吗?能不能给个demo代码?谢谢张老师
分页: 4/21 第一页 上页 1 2 3 4 5 6 7 8 9 10 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]