Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
const jieba = require('nodejieba');
// load dict at first time
jieba.load({
userDict: './scripts/participle/userDict.utf8',
});
const ignoreWordsHash = {};
// const ignoreWords = [
// ',',
// '.',
// ':',
// '。',
// ';',
// ':',
// '(',
// ')',
// '-',
// '*',
// '<',
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;