<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          nodejieba"結(jié)巴"分詞的Node.js版本

          聯(lián)合創(chuàng)作 · 2023-09-29 05:17

          NodeJieba "結(jié)巴"分詞的Node.js版本

          Introduction

          NodeJieba只是CppJieba簡單包裝而成的node擴展,用來進(jìn)行中文分詞。

          詳見NodeJiebaBlog

          Install

          npm install nodejieba

          因為npm速度很慢而且經(jīng)常因為墻的原因出現(xiàn)莫名其妙的問題,在此強烈建議使用cnpm,命令如下:

          npm --registry=http://r.cnpmjs.org install nodejieba

          Usage

          默認(rèn)分詞算法

          初始化

          var segment = require("nodejieba");
          segment.loadDict("./node_modules/nodejieba/dict/jieba.dict.utf8", "./node_modules/nodejieba/dict/hmm_model.utf8");

          阻塞式調(diào)用

          var wordList = segment.cutSync("阻塞模式分詞"); if (wordList.constructor == Array) // just for tutorial, this is always be true  {
              wordList.forEach(function(word) { console.log(word);     
              });
          }

          非阻塞式調(diào)用

          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");

          阻塞式調(diào)用

          var wordList = segment.queryCutSync("阻塞模式分詞"); if (wordList.constructor == Array) // just for tutorial, this is always be true  {
              wordList.forEach(function(word) { console.log(word);     
              });
          }

          非阻塞式調(diào)用

          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中文分詞

          瀏覽 15
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  日本无码色情三级播放免费看电影 | 美女自慰在线观看 | 亚洲入口 | 牛牛精品视频 | 国产91娱乐乱伦视频 |