{"id":13462457,"url":"https://github.com/yanyiwu/nodejieba","last_synced_at":"2026-03-06T02:57:38.286Z","repository":{"id":13484997,"uuid":"16175350","full_name":"yanyiwu/nodejieba","owner":"yanyiwu","description":"\"结巴\"中文分词的Node.js版本","archived":false,"fork":false,"pushed_at":"2025-03-08T09:34:10.000Z","size":4749,"stargazers_count":3127,"open_issues_count":7,"forks_count":279,"subscribers_count":72,"default_branch":"master","last_synced_at":"2025-05-07T06:59:45.067Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yanyiwu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"yanyiwu","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2014-01-23T14:52:01.000Z","updated_at":"2025-05-06T12:41:57.000Z","dependencies_parsed_at":"2024-08-07T04:38:34.377Z","dependency_job_id":"972a52e2-9af9-49c7-9cc4-12d4010c7207","html_url":"https://github.com/yanyiwu/nodejieba","commit_stats":{"total_commits":359,"total_committers":35,"mean_commits":"10.257142857142858","dds":"0.21727019498607247","last_synced_commit":"20bd5e3329b3fdd4f32678ea17dba37636b35c99"},"previous_names":["yanyiwu/nodejieba","luckykaiyi/nodejieba"],"tags_count":75,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanyiwu%2Fnodejieba","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanyiwu%2Fnodejieba/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanyiwu%2Fnodejieba/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanyiwu%2Fnodejieba/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yanyiwu","download_url":"https://codeload.github.com/yanyiwu/nodejieba/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252996341,"owners_count":21837622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T12:00:48.272Z","updated_at":"2026-03-06T02:57:38.188Z","avatar_url":"https://github.com/yanyiwu.png","language":"JavaScript","funding_links":["https://github.com/sponsors/yanyiwu","https://opencollective.com/nodejieba","https://opencollective.com/nodejieba/contribute","https://opencollective.com/nodejieba/organization/0/website","https://opencollective.com/nodejieba/organization/1/website","https://opencollective.com/nodejieba/organization/2/website","https://opencollective.com/nodejieba/organization/3/website","https://opencollective.com/nodejieba/organization/4/website","https://opencollective.com/nodejieba/organization/5/website","https://opencollective.com/nodejieba/organization/6/website","https://opencollective.com/nodejieba/organization/7/website","https://opencollective.com/nodejieba/organization/8/website","https://opencollective.com/nodejieba/organization/9/website"],"categories":["Repository","JavaScript","TypeScript","Uncategorized","Node.js","6. 其他"],"sub_categories":["Search Engine/Word Segmentation","Uncategorized","Algorithm","6.6 NLP"],"readme":"[![Build Status](https://github.com/yanyiwu/nodejieba/actions/workflows/test.yml/badge.svg)](https://github.com/yanyiwu/nodejieba/actions/workflows/test.yml)\n[![Financial Contributors on Open Collective](https://opencollective.com/nodejieba/all/badge.svg?label=financial+contributors)](https://opencollective.com/nodejieba) [![Author](https://img.shields.io/badge/author-@yanyiwu-blue.svg?style=flat)](https://github.com/yanyiwu/) \n[![Platform](https://img.shields.io/badge/platform-Linux,macOS,Windows-green.svg?style=flat)](https://github.com/yanyiwu/nodejieba)\n[![Performance](https://img.shields.io/badge/performance-excellent-brightgreen.svg?style=flat)](https://github.com/yanyiwu/blog/blob/posts2023archive/_posts/2015-06-14-jieba-series-performance-test.md) \n[![License](https://img.shields.io/badge/license-MIT-yellow.svg?style=flat)](http://yanyiwu.mit-license.org)\n[![NpmDownload Status](http://img.shields.io/npm/dm/nodejieba.svg)](https://www.npmjs.org/package/nodejieba)\n[![NPM Version](https://img.shields.io/npm/v/nodejieba.svg?style=flat)](https://www.npmjs.org/package/nodejieba)\n[![Code Climate](https://codeclimate.com/github/yanyiwu/nodejieba/badges/gpa.svg)](https://codeclimate.com/github/yanyiwu/nodejieba)\n\n- - -\n\n# NodeJieba \"结巴\"分词的Node.js版本\n\n## 介绍 \n\n`NodeJieba`是\"结巴\"中文分词的 Node.js 版本实现，\n由[CppJieba]提供底层分词算法实现，\n是兼具高性能和易用性两者的 Node.js 中文分词组件。\n\n## 特点\n\n+ 词典载入方式灵活，无需配置词典路径也可使用，需要定制自己的词典路径时也可灵活定制。\n+ 底层算法实现是C++，性能高效。\n+ 支持多种分词算法，各种分词算法见[CppJieba]的README.md介绍。\n+ 支持动态补充词库。\n\n对实现细节感兴趣的请看如下博文：\n\n+ [Node.js的C++扩展初体验之NodeJieba] \n+ [由NodeJieba谈谈Node.js异步实现] \n\n## 下载\n\n```sh\nnpm install nodejieba\n```\n\n## 用法\n\n```js\nvar nodejieba = require(\"nodejieba\");\nvar result = nodejieba.cut(\"南京市长江大桥\");\nconsole.log(result);\n//[\"南京市\",\"长江大桥\"]\n```\n\nMore Detals in [demo](https://github.com/yanyiwu/nodejieba-demo)\n\n### 词典载入可灵活配置\n\n如果没有主动调用词典函数时，\n则会在第一次调用cut等功能函数时，自动载入默认词典。\n\n如果要主动触发词典载入，则使用以下函数主动触发。\n\n```js\nnodejieba.load();\n```\n\n以上用法会自动载入所有默认词典，\n如果需要载入自己的词典，而不是默认词典。\n比如想要载入自己的用户词典，则使用以下函数：\n\n```js\nnodejieba.load({\n  userDict: './test/testdata/userdict.utf8',\n});\n```\n\n字典载入函数load的参数项都是可选的，\n如果没有对应的项则自动填充默认参数。\n所以上面这段代码和下面这代代码是等价的。\n\n```js\nnodejieba.load({\n  dict: nodejieba.DEFAULT_DICT,\n  hmmDict: nodejieba.DEFAULT_HMM_DICT,\n  userDict: './test/testdata/userdict.utf8',\n  idfDict: nodejieba.DEFAULT_IDF_DICT,\n  stopWordDict: nodejieba.DEFAULT_STOP_WORD_DICT,\n});\n```\n\n#### 词典说明\n\n+ dict: 主词典，带权重和词性标签，建议使用默认词典。\n+ hmmDict: 隐式马尔科夫模型，建议使用默认词典。\n+ userDict: 用户词典，建议自己根据需要定制。\n+ idfDict: 关键词抽取所需的idf信息。\n+ stopWordDict: 关键词抽取所需的停用词列表。\n\n### 词性标注\n\n```js\nvar nodejieba = require(\"nodejieba\");\nconsole.log(nodejieba.tag(\"红掌拨清波\"));\n//[ { word: '红掌', tag: 'n' },\n//  { word: '拨', tag: 'v' },\n//  { word: '清波', tag: 'n' } ]\n```\n\nMore Detals in [demo](https://github.com/yanyiwu/nodejieba-demo)\n\n### 关键词抽取\n\n```js\nvar nodejieba = require(\"nodejieba\");\nvar topN = 4;\nconsole.log(nodejieba.extract(\"升职加薪，当上CEO，走上人生巅峰。\", topN));\n//[ { word: 'CEO', weight: 11.739204307083542 },\n//  { word: '升职', weight: 10.8561552143 },\n//  { word: '加薪', weight: 10.642581114 },\n//  { word: '巅峰', weight: 9.49395840471 } ]\n\nconsole.log(nodejieba.textRankExtract(\"升职加薪，当上CEO，走上人生巅峰。\", topN));\n//[ { word: '当上', weight: 1 },\n//  { word: '不用', weight: 0.9898479330698993 },\n//  { word: '多久', weight: 0.9851260595435759 },\n//  { word: '加薪', weight: 0.9830464899847804 },\n//  { word: '升职', weight: 0.9802777682279076 } ]\n```\n\nMore Detals in [demo](https://github.com/yanyiwu/nodejieba-demo)\n\n## Develop NodeJieba\n\n```sh\ngit clone --recurse-submodules https://github.com/yanyiwu/nodejieba.git\ncd nodejieba\nnpm install\nnpm test\n```\n\n## 应用\n\n+ 支持中文搜索的 gitbook 插件: [gitbook-plugin-search-pro]\n+ 汉字拼音转换工具: [pinyin]\n\n## 性能评测\n\n应该是目前性能最好的 Node.js 中文分词库\n详见: [Jieba中文分词系列性能评测]\n\n\n[由NodeJieba谈谈Node.js异步实现]:https://github.com/yanyiwu/blog/blob/posts2023archive/_posts/2015-03-21-nodejs-asynchronous-insight.md\n[Node.js的C++扩展初体验之NodeJieba]:https://github.com/yanyiwu/blog/blob/posts2023archive/_posts/2014-02-22-nodejs-cpp-addon-nodejieba.md\n[CppJieba]:https://github.com/yanyiwu/cppjieba.git\n[cnpm]:http://cnpmjs.org\n[Jieba中文分词]:https://github.com/fxsjy/jieba\n\n[Jieba中文分词系列性能评测]:https://github.com/yanyiwu/blog/blob/posts2023archive/_posts/2015-06-14-jieba-series-performance-test.md\n[contributors]:https://github.com/yanyiwu/nodejieba/graphs/contributors\n[YanyiWu]:http://github.com/yanyiwu\n[gitbook-plugin-search-pro]:https://plugins.gitbook.com/plugin/search-pro\n[pinyin]:https://github.com/hotoo/pinyin\n\n## Contributors\n\n### Code Contributors\n\nThis project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].\n\u003ca href=\"https://github.com/yanyiwu/nodejieba/graphs/contributors\"\u003e\u003cimg src=\"https://opencollective.com/nodejieba/contributors.svg?width=890\u0026button=false\" /\u003e\u003c/a\u003e\n\n### Financial Contributors\n\nBecome a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/nodejieba/contribute)]\n\n#### Individuals\n\n\u003ca href=\"https://opencollective.com/nodejieba\"\u003e\u003cimg src=\"https://opencollective.com/nodejieba/individuals.svg?width=890\"\u003e\u003c/a\u003e\n\n#### Organizations\n\nSupport this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/nodejieba/contribute)]\n\n\u003ca href=\"https://opencollective.com/nodejieba/organization/0/website\"\u003e\u003cimg src=\"https://opencollective.com/nodejieba/organization/0/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nodejieba/organization/1/website\"\u003e\u003cimg src=\"https://opencollective.com/nodejieba/organization/1/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nodejieba/organization/2/website\"\u003e\u003cimg src=\"https://opencollective.com/nodejieba/organization/2/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nodejieba/organization/3/website\"\u003e\u003cimg src=\"https://opencollective.com/nodejieba/organization/3/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nodejieba/organization/4/website\"\u003e\u003cimg src=\"https://opencollective.com/nodejieba/organization/4/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nodejieba/organization/5/website\"\u003e\u003cimg src=\"https://opencollective.com/nodejieba/organization/5/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nodejieba/organization/6/website\"\u003e\u003cimg src=\"https://opencollective.com/nodejieba/organization/6/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nodejieba/organization/7/website\"\u003e\u003cimg src=\"https://opencollective.com/nodejieba/organization/7/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nodejieba/organization/8/website\"\u003e\u003cimg src=\"https://opencollective.com/nodejieba/organization/8/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nodejieba/organization/9/website\"\u003e\u003cimg src=\"https://opencollective.com/nodejieba/organization/9/avatar.svg\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyanyiwu%2Fnodejieba","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyanyiwu%2Fnodejieba","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyanyiwu%2Fnodejieba/lists"}