filter.go 470 B

123456789101112131415161718192021
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/tal-tech/go-zero/core/stringx"
  5. )
  6. func main() {
  7. filter := stringx.NewTrie([]string{
  8. "AV演员",
  9. "苍井空",
  10. "AV",
  11. "日本AV女优",
  12. "AV演员色情",
  13. }, stringx.WithMask('?'))
  14. safe, keywords, found := filter.Filter("日本AV演员兼电视、电影演员。苍井空AV女优是xx出道, 日本AV女优们最精彩的表演是AV演员色情表演")
  15. fmt.Println(safe)
  16. fmt.Println(keywords)
  17. fmt.Println(found)
  18. }