mirror of
https://github.com/wonli/aqi.git
synced 2026-04-22 23:07:20 +08:00
22 lines
382 B
Go
22 lines
382 B
Go
package utils
|
|
|
|
import (
|
|
"log"
|
|
"testing"
|
|
)
|
|
|
|
func TestSensitive(t *testing.T) {
|
|
sensitiveWords := []string{
|
|
"牛大大", "撒比",
|
|
}
|
|
|
|
trie := NewSensitiveTrie()
|
|
trie.AddWords(sensitiveWords...)
|
|
|
|
content := "今天,牛大大挑战sb灰大大"
|
|
matchSensitiveWords, replaceText := trie.Match(content)
|
|
|
|
log.Printf("%v", trie)
|
|
log.Println(matchSensitiveWords, replaceText)
|
|
}
|