移除敏感词的测试代码
This commit is contained in:
@@ -17,33 +17,6 @@ public class SensitiveFilter {
|
||||
|
||||
private static final String END_FLAG="end";
|
||||
|
||||
public static void main(String[] args) {
|
||||
Set<String> sensitiveWords=new HashSet<>();
|
||||
sensitiveWords.add("你是傻逼");
|
||||
sensitiveWords.add("你是傻逼啊");
|
||||
sensitiveWords.add("你是坏蛋");
|
||||
sensitiveWords.add("你个大笨蛋");
|
||||
sensitiveWords.add("我去年买了个表");
|
||||
sensitiveWords.add("shit");
|
||||
|
||||
SensitiveFilter textFilter=new SensitiveFilter(sensitiveWords);
|
||||
String text="你你你你是傻逼啊你,说你呢,你个大笨蛋。";
|
||||
System.out.println(textFilter.getSensitiveWords(text,MatchType.MAX_MATCH));
|
||||
for (int i = 0; i < 100; i++) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println(textFilter.getSensitiveWords(text,MatchType.MAX_MATCH));
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000 * 100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isContainSensitiveWord(String text){
|
||||
Set<String> sensitiveWords = getSensitiveWords(text, MatchType.MIN_MATCH);
|
||||
if(sensitiveWords!=null&&sensitiveWords.size()>0){
|
||||
|
||||
Reference in New Issue
Block a user