forked from zongzibinbin/MallChat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f15e1f
commit 0eec325
Showing
14 changed files
with
122 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
mallchat-chat-server/src/test/java/com/abin/mallchat/common/SensitiveTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.abin.mallchat.common; | ||
|
||
import com.abin.mallchat.common.common.utils.sensitiveWord.ACFilter; | ||
import com.abin.mallchat.common.common.utils.sensitiveWord.DFAFilter; | ||
import org.junit.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* Description: | ||
* Author: <a href="https://github.com/zongzibinbin">abin</a> | ||
* Date: 2023-10-08 | ||
*/ | ||
public class SensitiveTest { | ||
@Test | ||
public void DFA() { | ||
List<String> sensitiveList = Arrays.asList("abcd", "abcbba", "adabca"); | ||
DFAFilter instance = DFAFilter.getInstance(); | ||
instance.loadWord(sensitiveList); | ||
System.out.println(instance.hasSensitiveWord("adabcd")); | ||
} | ||
|
||
@Test | ||
public void AC() { | ||
List<String> sensitiveList = Arrays.asList("abcd", "abcbba", "adabca"); | ||
ACFilter instance = new ACFilter(); | ||
instance.loadWord(sensitiveList); | ||
instance.hasSensitiveWord("adabcd"); | ||
} | ||
|
||
@Test | ||
public void DFAMulti() { | ||
List<String> sensitiveList = Arrays.asList("白痴", "你是白痴", "白痴吗"); | ||
DFAFilter instance = DFAFilter.getInstance(); | ||
instance.loadWord(sensitiveList); | ||
System.out.println(instance.filter("你是白痴吗")); | ||
} | ||
|
||
@Test | ||
public void ACMulti() { | ||
List<String> sensitiveList = Arrays.asList("白痴", "你是白痴", "白痴吗"); | ||
ACFilter instance = new ACFilter(); | ||
instance.loadWord(sensitiveList); | ||
System.out.println(instance.filter("你是白痴吗")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters