词库可以上这个网站找:https://www.heywhale.com/mw/dataset/5ecf6214162df90036ddfcff/file
按行处理文件:
let fs = require('fs');
const readline = require('readline');
let path = "./politics.txt";
const r1 = readline.createInterface({
input: fs.createReadStream("politics_sensitive_words.txt")
});
r1.on('line', line => { //事件监听
fs.writeFile(path, '"' + line + '"' + ',' + '\r\n', { flag: 'a', encoding: 'utf-8' }, (err) => {
console.log(err);
});
})
网友评论