- 授权协议: MIT
- 开发语言: JavaScript
- 操作系统: 跨平台
- 软件首页: https://github.com/aszxqw/nodejieba
- 软件文档: http://yanyiwu.com/work/2014/02/22/nodejs-cpp-addon-nodejieba.html
软件介绍
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
王道程序员求职宝典
电子工业出版社 / 2013-11 / 56.00元
本书精选了大量知名企业的程序员笔试、面试题,重点突出、解答翔实。全书共分为四部分,各部分如下:第一部分是程序设计基础及数据结构基础,讨论C/C++基础知识以及数据结构基础知识;第二部分是计算机网络基础,讨论网络模型、套接字编程基本操作、IPv4与IPv6、子网划分、网络常用测试工具等;第三部分是操作系统基础,讨论进程与线程的基本知识、进程间通信与进程同步、内存管理的相关知识等;第四部分是其他计算机......一起来看看 《王道程序员求职宝典》 这本书的介绍吧!
