mirror of
https://github.com/houbb/sensitive-word.git
synced 2026-03-22 08:27:36 +08:00
[Feature] add for new
This commit is contained in:
@@ -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("三三九乘元功", "一军两策");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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("一军两策"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user