Skip to content

Latest commit

 

History

History
49 lines (35 loc) · 897 Bytes

README.md

File metadata and controls

49 lines (35 loc) · 897 Bytes

lemonade

A sensitive word filter service based on DFA

Install

go get -u -v github.com/killtw/lemonade

Usage

package main

import (
	"fmt"
	"github.com/killtw/lemonade/lemonade"
	"log"
)

func main() {
	if err := lemonade.InitTrie(); err != nil {
		log.Fatalln(err)
	}

	lemonade.Add("test")

	f1, m1 := lemonade.Replace("123test321")
	fmt.Printf("filtered: %s, matches: %s\n", f1, m1)

	f2, m2 := lemonade.Replace("123te!@#$%st321")
	fmt.Printf("filtered: %s, matches: %s\n", f2, m2)
}

Output

filtered: 123****321, matches: [test]
filtered: 123*********321, matches: [te!@#$%st]

Credits

License

The MIT License (MIT). Please see License File for more information.