Node.js-中文分词【1】-node-segment

node-segment是基于盘古分词写的Node.js中文分词模块,鉴于盘古分词给我留下的好印象,我们在Node.js上选择了它

一、安装node-segment

npm install -g segment

二、使用

var Segment = require('segment');
var segment = new Segment();
segment.useDefault();

console.log((segment.doSegment('科技处女干事每月经过下属科室都要亲口交代24口交换机等技术性器件的安装工作。', { simple: true })).join('/'));

三、输出

科技/处女/干事/每月/经过/下属/科室/都/要/亲口/交代/24口/交换机/等/技术性/器件//安装/工作/。

备注:初始化的时候花了大概5s钟,后面就非常快了,输出结果按理说应该是科技处/女干事/...这样,事实上这不是什么问题,编辑下词库就轻松搞定

 

引用:https://github.com/leizongmin/node-segment

转载于:https://www.cnblogs.com/godcity/p/5663726.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
NodeJieba "结巴"分词的Node.js版本Introduction NodeJieba只是CppJieba简单包装而成的node扩展,用来进行中文分词。 详见NodeJiebaBlogInstallnpm 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.jsTesting 在node v0.10.2下测试通过http://cppjieba-webdemo.herokuapp.com/ (chrome is suggested)ThanksJieba中文分词 标签:nodejieba
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值