[Feature] add for new

This commit is contained in:
binbin.hou
2023-06-06 16:11:20 +08:00
parent 7614d53775
commit b1ed3249d0
2 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
package com.github.houbb.sensitive.word.bugs.b32;
import com.github.houbb.sensitive.word.api.IWordDeny;
import java.util.Arrays;
import java.util.List;
public class MyWordDenyChineseNum implements IWordDeny {
@Override
public List<String> deny() {
return Arrays.asList("三三九乘元功", "一军两策");
}
}

View File

@@ -0,0 +1,26 @@
package com.github.houbb.sensitive.word.bugs.b32;
import com.github.houbb.sensitive.word.api.IWordDeny;
import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
import com.github.houbb.sensitive.word.support.deny.WordDenys;
import org.junit.Assert;
import org.junit.Test;
public class MyWordDenyChineseTest {
@Test
public void test() {
IWordDeny wordDeny = WordDenys.chains(WordDenys.system(), new MyWordDenyChineseNum());
SensitiveWordBs sensitiveWordBs = SensitiveWordBs.newInstance()
.wordDeny(wordDeny)// 各种其他配置
.init();// init() 初始化敏感词字典
final String text = "和我练习三三九乘元功、一军两策";
//输出测试结果
Assert.assertEquals("[三三九乘元功, 一军两策]", sensitiveWordBs.findAll(text).toString());
Assert.assertTrue(sensitiveWordBs.contains("三三九乘元功"));
Assert.assertTrue(sensitiveWordBs.contains("一军两策"));
}
}