发布版本:
  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) | 阅读(163724)
ทดลองเล่นสล็อต
2021-12-8 12:23
ทดลองเล่นสล็อต     Slots Free Trial Playable Withdrawable Free Trial Playable Withdraw Real Money Free credit to play slots Terms and conditions are as specified by the website.
PG SLOT GAME Email Homepage
2021-12-8 16:15
PG SLOT GAME  It is a new hot new game camp of the year 2021, in which this camp pg 168 is very different from other camps and one of them is clearly Pc game 168.
ฝาก10รับ100 Email Homepage
2021-12-8 16:15
ฝาก10รับ100   is a promotion, online slots, deposit 10, get 100 new Popular for people with small capital, really suitable for investors. With a small budget to play, Web Slots 10 Get 100 is a game that is very popular right now.
PG SLOT wallet Email Homepage
2021-12-8 16:17
PG SLOT wallet online slot games Deposit-withdraw via automatic system It has been ranked number 1 in popularity right now and is the most popular slot website right now.
พีจีสล็อต Email Homepage
2021-12-8 16:17
พีจีสล็อต A very popular game camp that played many years ago. Until now because it's a simple game. The rules are not complicated, the game is played for fun.
ฝาก30รับ100 Email Homepage
2021-12-8 16:18
ฝาก30รับ100   Latest 2021 Promotion Hits Slots Can play all game camps, new members, deposit 30, get 100, give away free credit, no need to deposit, no need to share Promotion deposit 30 get 100 unlimited withdrawal No minimum deposit
PG SLOT GAME Email Homepage
2021-12-9 17:02
PG SLOT GAME  It is a new hot new game camp of the year 2021, in which this camp pg 168 is very different from other camps and one of them is clearly Pc game 168.
ฝาก10รับ100 Email Homepage
2021-12-9 17:09
ฝาก10รับ100   is a promotion, online slots, deposit 10, get 100 new Popular for people with small capital, really suitable for investors. With a small budget to play, Web Slots 10 Get 100 is a game that is very popular right now.
PG SLOT wallet Email Homepage
2021-12-9 17:09
PG SLOT wallet online slot games Deposit-withdraw via automatic system It has been ranked number 1 in popularity right now and is the most popular slot website right now.
pgslot gaming Email Homepage
2021-12-12 16:01
Lots of activities and bonuses You can register for the first time. Get 50% Free Credit pgslot gaming
PG SLOT GAME Homepage
2021-12-15 14:56
PG SLOT GAME  It is a new hot new game camp of the year 2021, in which this camp pg 168 is very different from other camps and one of them is clearly Pc game 168.
ฝาก10รับ100 Email Homepage
2021-12-15 14:56
ฝาก10รับ100   is a promotion, online slots, deposit 10, get 100 new Popular for people with small capital, really suitable for investors. With a small budget to play, Web Slots 10 Get 100 is a game that is very popular right now.
PG SLOT wallet Email Homepage
2021-12-15 14:57
PG SLOT wallet online slot games Deposit-withdraw via automatic system It has been ranked number 1 in popularity right now and is the most popular slot website right now.
พีจีสล็อต Email Homepage
2021-12-15 14:57
พีจีสล็อต A very popular game camp that played many years ago. Until now because it's a simple game. The rules are not complicated, the game is played for fun.
ฝาก30รับ100 Email Homepage
2021-12-15 14:57
ฝาก30รับ100   Latest 2021 Promotion Hits Slots Can play all game camps, new members, deposit 30, get 100, give away free credit, no need to deposit, no need to share Promotion deposit 30 get 100 unlimited withdrawal No minimum deposit
pg45 Email Homepage
2021-12-20 17:26
Thank you! This is good post you.    pg45 pg45 pgbet
เกมยิงปลา Email Homepage
2021-12-23 13:42
เกมยิงปลา   Earn real money without investment 2021 new dimension of making money from online gambling games Play free fish shooting games.
ไฮโล Email Homepage
2021-12-23 13:46
ไฮโล    Slot games from the popular roma xo slots and free roma credit slots 2021 You can try it for free now.
โปรโมชั่นสล็อต Email Homepage
2021-12-23 13:49
โปรโมชั่นสล็อต  Promotion of new web slots 2021 that is becoming popular right now. inevitable promotion New member 100% bonus
分页: 12/21 第一页 上页 7 8 9 10 11 12 13 14 15 16 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]