jieba-js
v1.0.2
Published
jieba-js chinese word segmentation for node in pure javascript.
Downloads
136
Maintainers
Readme
jieba-js
jieba-js A JavaScript Chinese word segmentation tool in pure javascript, based on Python Jieba
install
npm install jieba-js
demo
import jieba, { cut } from 'jieba-js';
const jieba = require("jieba-js");
const jieba = require("jieba-js").jieba;
//------------
const Jieba = require("jieba").Jieba;
const jieba = new Jieba();
console.log(jieba);
jieba.cut("我爸新学会了一项解决日常烦闷的活动,就是把以前的照片抱回办公室扫描保存,弄成电子版的。更无法接受的是,还居然放到网上来,时不时给我两张。\n这些积尘的化石居然突然重现,简直是招架不住。这个怀旧的阀门一旦打开,那就直到意识模糊都没停下来。")
.then(function (ret)
{
//console.log(ret);
})
;
cut('我的中文東西。', function (ret)
{
//console.log(ret);
});
cut('我的中文東西。 2222222222').then(function (ret)
{
console.log(ret);
});
Dict
this method only work before first time call
jieba.cut
orjieba.init
jieba.useDict('path of dict file')
let dict = [
['xxx', 0, 'x'],
];
jieba.useDict(dict)