UNPKG

node-ac

Version:

A nodejs implementation of the aho corasick pattern search algorithm

24 lines (17 loc) 642 B
var nac = require('.'); //添加检查词汇, nac.addCheckItem('aa','bb','cc'); //添加检查词汇字典,必须utf8格式 nac.addDictionary('../dictionary'); //构建检查器,只可调用一次,调用后,再次调用addCheckItem和addDictionary无效。 nac.buildChecker(); //reset后,模块重新初始化,需要重新addCheckItem和addDictionary,并buildChecker nac.reset(); //检查文本 nac.checkText('aavbnasdfsaacasdf',function(data){ console.log(JSON.stringify(data)); }); //检查文本文件,必须utf8格式。 nac.checkTextFile('../textfile.txt',function(data){ console.log(JSON.stringify(data)); });