3.4.3 • Published 3 months ago

nodejieba v3.4.3

Weekly downloads
50,330
License
MIT
Repository
github
Last release
3 months ago

Build Status Financial Contributors on Open Collective Author Platform Performance License NpmDownload Status NPM Version Code Climate


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

介绍

NodeJieba是"结巴"中文分词的 Node.js 版本实现, 由CppJieba提供底层分词算法实现, 是兼具高性能和易用性两者的 Node.js 中文分词组件。

特点

  • 词典载入方式灵活,无需配置词典路径也可使用,需要定制自己的词典路径时也可灵活定制。
  • 底层算法实现是C++,性能高效。
  • 支持多种分词算法,各种分词算法见CppJieba的README.md介绍。
  • 支持动态补充词库。

对实现细节感兴趣的请看如下博文:

下载

npm install nodejieba

用法

var nodejieba = require("nodejieba");
var result = nodejieba.cut("南京市长江大桥");
console.log(result);
//["南京市","长江大桥"]

More Detals in demo

词典载入可灵活配置

如果没有主动调用词典函数时, 则会在第一次调用cut等功能函数时,自动载入默认词典。

如果要主动触发词典载入,则使用以下函数主动触发。

nodejieba.load();

以上用法会自动载入所有默认词典, 如果需要载入自己的词典,而不是默认词典。 比如想要载入自己的用户词典,则使用以下函数:

nodejieba.load({
  userDict: './test/testdata/userdict.utf8',
});

字典载入函数load的参数项都是可选的, 如果没有对应的项则自动填充默认参数。 所以上面这段代码和下面这代代码是等价的。

nodejieba.load({
  dict: nodejieba.DEFAULT_DICT,
  hmmDict: nodejieba.DEFAULT_HMM_DICT,
  userDict: './test/testdata/userdict.utf8',
  idfDict: nodejieba.DEFAULT_IDF_DICT,
  stopWordDict: nodejieba.DEFAULT_STOP_WORD_DICT,
});

词典说明

  • dict: 主词典,带权重和词性标签,建议使用默认词典。
  • hmmDict: 隐式马尔科夫模型,建议使用默认词典。
  • userDict: 用户词典,建议自己根据需要定制。
  • idfDict: 关键词抽取所需的idf信息。
  • stopWordDict: 关键词抽取所需的停用词列表。

词性标注

var nodejieba = require("nodejieba");
console.log(nodejieba.tag("红掌拨清波"));
//[ { word: '红掌', tag: 'n' },
//  { word: '拨', tag: 'v' },
//  { word: '清波', tag: 'n' } ]

More Detals in demo

关键词抽取

var nodejieba = require("nodejieba");
var topN = 4;
console.log(nodejieba.extract("升职加薪,当上CEO,走上人生巅峰。", topN));
//[ { word: 'CEO', weight: 11.739204307083542 },
//  { word: '升职', weight: 10.8561552143 },
//  { word: '加薪', weight: 10.642581114 },
//  { word: '巅峰', weight: 9.49395840471 } ]

console.log(nodejieba.textRankExtract("升职加薪,当上CEO,走上人生巅峰。", topN));
//[ { word: '当上', weight: 1 },
//  { word: '不用', weight: 0.9898479330698993 },
//  { word: '多久', weight: 0.9851260595435759 },
//  { word: '加薪', weight: 0.9830464899847804 },
//  { word: '升职', weight: 0.9802777682279076 } ]

More Detals in demo

Develop NodeJieba

git clone --recurse-submodules https://github.com/yanyiwu/nodejieba.git
cd nodejieba
npm install
npm test

应用

性能评测

应该是目前性能最好的 Node.js 中文分词库 详见: Jieba中文分词系列性能评测

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

transform-pinyin-util@infinitebrahmanuniverse/nolb-nodeji@everything-registry/sub-chunk-2325dolphin-node-text-analyticsweibo-monitorwiki-flowxmmssg_designerwulianseparate-chinese-wordsvisualize-commitpinyin-matenotenode-dolphin-nlphanzi-toolshexo-generator-cloudwordsgitbook-plugin-search-jiebajrjtcsmcccjieba-mecab-tooljiebavhugo-lunr-zhicc-cliloosenjslevi-chinesemoe-pinyinkoishi-plugin-nlphexo-plugin-keywordshugo-algolia2hugo-algolia2-1lunr-languages-cnlunr-languages-zhlunr-zh-cnlunr-chinesemarstochineselsearchnodebb-plugin-dbsearch-for-chinesenodebb-plugin-dbsearch-jiebanodebb-plugin-dbsearch-jieba-newnodebb-plugin-dbsearch-miraiforumnodebb-plugin-dbsearch-nodejiebapinyin-ichinesepinyin-picoworkpinyinifypinyin-browserpinyin-es5node-dolphinnode-article-extractornextprops-lunr-languagesnlp-toolsnode-lda-chinesepicidae-tool-auto-keywordraccinode-synonymsss-chstransform-pinyin-utils@chatopera/ms-message@cerallin/hexo-generator-word-cloud@aam-frontend/pinyinyinglish-nodejsyt-botzhihu-answer-wordcloudzh-classify@hydrooj/better-search@elyse0/hanzi-tools@falconia/lunr-languages@patarapolw/zhlevel@pipcook/pipcook-plugins-text-class-data-process@suziwen/gatsby-theme-sculpting@solar.himalayas/spider@cycjimmy/chinese-sentiment@booxood/lunreasy-create-sharkeasydigemail-bill@tunebond/basefanwiaxlzhjs@veronikya/nodebb-plugin-meilisearch@xiling-bot/wordcloudahwater-prototypeaddress_mapperacfun-article-spider@yuyi-bot/utils-nlpfrequency_and_wordcloudgatsby-remark-extract-keywords-jiebabisheng-plugin-icebisheng-plugin-rax-themearexcjk-readingschinese-search-dhchinese-searchdbhskfafhdfasjfdjjsdhjkdsjkdecode-parse-coredocusaurus-search-local
3.4.3

3 months ago

3.4.0

5 months ago

3.2.0

5 months ago

3.4.2

4 months ago

3.4.1

4 months ago

3.3.1

5 months ago

3.3.0

5 months ago

3.1.1

5 months ago

3.1.0

5 months ago

2.6.0

3 years ago

2.5.2

4 years ago

2.5.1

4 years ago

2.5.0

4 years ago

2.4.2

4 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.5

5 years ago

2.3.3

5 years ago

2.3.2

5 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.7

6 years ago

2.2.6

7 years ago

2.2.5

8 years ago

2.2.4

8 years ago

2.2.3

8 years ago

2.2.2

8 years ago

2.2.1

9 years ago

2.2.0

9 years ago

2.1.0

9 years ago

2.0.0

9 years ago

1.4.11

9 years ago

1.4.10

9 years ago

1.4.9

9 years ago

1.4.8

9 years ago

1.4.7

9 years ago

1.4.6

9 years ago

1.4.5

9 years ago

1.4.4

9 years ago

1.4.3

9 years ago

1.4.2

9 years ago

1.4.1

9 years ago

1.4.0

9 years ago

1.3.0

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.2.13

10 years ago

0.2.12

10 years ago

0.2.11

10 years ago

0.2.10

10 years ago

0.2.9

10 years ago

0.2.8

10 years ago

0.2.7

10 years ago

0.2.6

10 years ago

0.2.5

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago