Closed netyjq closed 1 year ago
public class MyWordDeny implements IWordDeny { @Override public List<String> deny() { return Arrays.asList("舅舅, AA, 双标, fire, 游戏, navicat, QQ, 双规".split(",")); } }
IWordDeny wordDeny = WordDenys.chains(WordDenys.system(), new MyWordDeny()); IWordAllow wordAllow = WordAllows.chains(WordAllows.system(), new MyWordAllow()); SensitiveWordBs sensitiveWordBs = SensitiveWordBs.newInstance() .wordAllow(wordAllow) .wordDeny(wordDeny)// 各种其他配置 .init();// init() 初始化敏感词字典 final String text = "这是一条测试的QQ 猫砂"; // 输出测试结果 System.out.println("敏感词:" + sensitiveWordBs.findAll(text).toString());
output: []
应该不是 null 的问题。
1)【 QQ】这是用逗号分割后的敏感词列表。 2)匹配内容是没有匹配的,因为例子中为【QQ 】
这种问题建议自己 debug 下。
output: []