"结巴"分词的Node.js版本 nodejieba

码农软件 · 软件分类 · 中文分词库 · 2019-08-28 21:43:10

软件介绍

NodeJieba "结巴"分词的Node.js版本

Introduction

NodeJieba只是CppJieba简单包装而成的node扩展,用来进行中文分词。

详见NodeJiebaBlog

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

Jieba中文分词

本文地址:https://codercto.com/soft/d/13387.html

暗网

暗网

杰米·巴特利特 / 刘丹丹 / 北京时代华文书局 / 2018-7 / 59.00

全面深入揭秘“黑暗版淘宝”暗网的幕后世界和操纵者 现实中所有的罪恶,在暗网中,都是明码标价的商品。 暗杀、色情、恋童癖、比特币犯罪、毒品交易…… TED演讲、谷歌特邀专家、英国智库网络专家杰米•巴特利特代表作! 1、 被大家戏称为“黑暗版淘宝”的暗网究竟是什么?微信猎奇 文不能告诉你的真相都在这里了! 2、 因章莹颖一案、Facebook信息泄露危机而被国人所知的暗网......一起来看看 《暗网》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具