代码拉取完成,页面将自动刷新
NodeJieba
只是CppJieba简单包装而成的node
扩展,用来进行中文分词。
npm install nodejieba
因为npm
速度很慢而且经常因为墙的原因出现莫名其妙的问题,在此强烈建议使用cnpm,命令如下:
npm --registry=http://r.cnpmjs.org install nodejieba
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
在node v0.10.2
下测试通过
http://cppjieba-webdemo.herokuapp.com/ (chrome is suggested)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型