How to use the nodejieba.cut 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 alvinhui / machine-learning / 03_naive_bayes / chatbot / app.js View on Github external
listen(function(text) {
  if (text.length) {
    // const words = tokenizer(text);
    const words = nodejieba.cut(text);
    const testVec = words2Vec(vocabList, words);
    console.log(response(classify(testVec, weights, pAbusive)));
  } else {
    console.log('Any help?');
  }
})
github gitbook-plugins / gitbook-plugin-search-pro / main.js View on Github external
"page": function(page){

            // console.log(page);

            // 建立页面内容索引
            pageIndex[pageId] = {
                path : page.path.replace(/readme\.md$/i,'index.html').replace(/\.md$/,'.html'),
                title : page.progress.current.title,
                level : page.progress.current.level
            }

            // 分词
            var words = _.uniq( nodejieba.cut(page.content) );

            // 去重
            _(words).forEach(function(word) {

                // 不索引1个字的词
                //if(word.length > 1){

                    // 转为大写
                    word = word.toUpperCase();

                    // 如果没有这个词的索引空间
                    if(!searchIndexMap[word]) {
                        searchIndexMap[word] = [];
                    }

                    // 搜索词容器推入
github alvinhui / machine-learning / 03_naive_bayes / chatbot / training.js View on Github external
patterns.forEach(function(pattern) {
    // const words = tokenizer(pattern);
    const words = nodejieba.cut(pattern);
    document.push(words);
    classes.push(tag);
  });
  responses[tag] = intent.responses;
github alvinhui / machine-learning / 04_logistic / chatbot_natural / app.js View on Github external
listen(function(text) {
    if (text.length) {
      console.log(classifier.classify(nodejieba.cut(text)));
    } else {
      console.log('Any help?');
    }
  });
});
github ahkimkoo / arex / lib / node-summary.js View on Github external
splitToTerms(content){
		let self = this;
		let terms = [];
		let ps = Array.isArray(content)?content:self.splitToParagraphs(content);
		for(let x of ps){
			let sens = self.splitToSentences(x);
			let parag = [];
			for(let y of sens){
				let sentens = [];
				for(let z of nodejieba.cut(y.trim()))sentens.push(z);
			    if(sentens.length>0){
			    	if(sentens[sentens.length-1]!='。')sentens.push('。');
			    	parag.push(sentens);
			    }
			}
			if(parag.length>0)terms.push(parag);
		}
		return terms;
	}
github feix760 / Chrome_12306 / app / service / ocr.js View on Github external
async function isSimilar({ word, guessWord, simiList }, text) {
  return jieba.cut(text).every(w => {
    return word.indexOf(w) > 0 || guessWord.indexOf(w) > 0 || simiList.every(
      ({ summary, summaryOrig }) => {
        return summary.indexOf(w) > 0 || summaryOrig.indexOf(w) > 0;
      }
    );
  });
}
github alvinhui / machine-learning / 04_logistic / utils.js View on Github external
Classifier.prototype.predict = function(text) {
  const words = nodejieba.cut(text);
  const features = this.textToFeatures(words);
  const results = this.classifier.predict([features]);
  const result = results[0];

  let max = 0;
  let index = 0;
  for(let key in result) {
    const value = result[key];
    if (value > max) {
      max = value;
      index = key;
    }
  }

  return this.classes[index];
};
github feix760 / Chrome_12306 / app / lib / jieba.js View on Github external
exports.cut = function(str) {
  return jieba.cut(str || '')
    .map(function(item) {
      return item.trim();
    })
    .filter(function(item) {
      return !!item;
    });
};
github alvinhui / machine-learning / 04_logistic / utils.js View on Github external
patterns.forEach((pattern) => {
      const words = nodejieba.cut(pattern);
  
      docs.push({
        tag,
        words
      });
      
      for (let i = 0; i < words.length; i++) {
        let token = words[i];
        this.features[token] = (this.features[token] || 0) + 1;
      }
  
      if (this.classes.indexOf(tag) === -1) {
        this.classes.push(tag);
      }
    });
  });
github weather-bot / WxKitty / lib / segment.js View on Github external
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 27 days ago

Package Health Score

78 / 100
Full package analysis