How to use the nodejieba.load function in nodejieba

To help you get started, we’ve selected a few nodejieba examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ccforward / zhihu / spider / util / tag.js View on Github external
var cheerio = require('cheerio')
var co = require("co");
var ArticleDAO = require('../db/models/article');
var TagDAO = require('../db/models/tag');
var jieba = require("nodejieba");


var articleDAO = new ArticleDAO(),
    tagDAO = new TagDAO();

jieba.load({
    stopWordDict: './dict/stop_words.utf8',
});

var Tag = {
    saveTags: function(aid){
        // var gen = function* (){
        //     var tags = yield tagDAO.search({aid: aid});
        //     if(tags.length<=0){
        //         var result = yield articleDAO.search(aid);
        //         var $ = cheerio.load(result.body, {decodeEntities: false});
        //         var wordsArr = jieba.extract($.root().text(), 10),
        //             tagArr = [];
        //         for(var i=0,len=wordsArr.length;i
github alibaba / ice / scripts / participle / index.js View on Github external
const jieba = require('nodejieba');
// load dict at first time
jieba.load({
  userDict: './scripts/participle/userDict.utf8',
});
const ignoreWordsHash = {};

// const ignoreWords = [
//   ',',
//   '.',
//   ':',
//   '。',
//   ';',
//   ':',
//   '(',
//   ')',
//   '-',
//   '*',
//   '<',
github weather-bot / WxKitty / lib / segment.js View on Github external
const jieba = require("nodejieba");
const trans = require('chinese-conv');
const path = require("path");

jieba.load({
    // User's Words
    userDict: path.join(__dirname, '../data/jieba_userdict.utf8')
});

// nodejieba only support Simplified Chinese, so translate Traditonal to Simplified.
// After segment, translate back to Traditonal Chinese.
const segment = input => {
    const words = jieba.cut(trans.sify(input));
    const results = [];
    words.forEach(w => {
        results.push(trans.tify(w));
    })
    return results;
}
module.exports = segment;

nodejieba

chinese word segmentation for node

MIT
Latest version published 2 years ago

Package Health Score

52 / 100
Full package analysis