nodejieba"结巴"分词的Node.js版本
NodeJieba "结巴"分词的Node.js版本
Introduction
NodeJieba只是CppJieba简单包装而成的node扩展,用来进行中文分词。
Install
npm install nodejieba
因为npm速度很慢而且经常因为墙的原因出现莫名其妙的问题,在此强烈建议使用cnpm,命令如下:
npm --registry=http://r.cnpmjs.org install nodejieba
Usage
默认分词算法
初始化
var segment = require("nodejieba"); segment.loadDict("./node_modules/nodejieba/dict/jieba.dict.utf8", "./node_modules/nodejieba/dict/hmm_model.utf8");
阻塞式调用
var wordList = segment.cutSync("阻塞模式分词"); if (wordList.constructor == Array) // just for tutorial, this is always be true { wordList.forEach(function(word) { console.log(word); }); }
非阻塞式调用
segment.cut("非阻塞模式分词", function(wordList) { wordList.forEach(function(word) { console.log(word); }); });
搜索引擎分词算法
初始化
var segment = require("nodejieba"); segment.queryLoadDict("./node_modules/nodejieba/dict/jieba.dict.utf8", "./node_modules/nodejieba/dict/hmm_model.utf8");
阻塞式调用
var wordList = segment.queryCutSync("阻塞模式分词"); if (wordList.constructor == Array) // just for tutorial, this is always be true { wordList.forEach(function(word) { console.log(word); }); }
非阻塞式调用
segment.queryCut("非阻塞模式分词", function(wordList) { wordList.forEach(function(word) { console.log(word); }); });
具体用法可以参考 test/segment.js test/query_segment.js
Testing
在node v0.10.2下测试通过
Demo
http://cppjieba-webdemo.herokuapp.com/ (chrome is suggested)
Thanks
评论
cppjieba"结巴"中文分词的C++版本
简介CppJieba是"结巴"中文分词的C++版本代码细节详解请见 代码详解特性源代码都写进头文件src/*.hpp里,include即可使用。支持utf-8,gbk编码,但是推荐使用utf-8编码,
cppjieba"结巴"中文分词的C++版本
0
libnodeC++版本的Node.js
libnode是C++语言版的Node.js,和Node.js一样,libnode提供了非堵塞的I/O,可让你用C++开发可伸缩的Web应用,实现了基于shared_ptr或bdw-gc自动的内存管理
libnodeC++版本的Node.js
0
jieba.NET结巴分词 .NET 版
jieba.NET是jieba中文分词的.NET版本(C#实现)。当前版本为0.37.1,基于jieba0.37,目标是提供与jieba一致的功能与接口,但以后可能会在jieba基础上提供其它扩展功能
jieba.NET结巴分词 .NET 版
0
jieba-analysis结巴分词(java版)
首先感谢jieba分词原作者fxsjy,没有他的无私贡献,我们也不会结识到结巴分词,更不会有现在的java版本。结巴分词的原始版本为python编写,目前该项目在github上的关注量为170,打星7
jieba-analysis结巴分词(java版)
0