https://github.com/syyongx/go-wordsfilter
A high performance sensitive word filter.
https://github.com/syyongx/go-wordsfilter
go words-filter
Last synced: 12 months ago
JSON representation
A high performance sensitive word filter.
- Host: GitHub
- URL: https://github.com/syyongx/go-wordsfilter
- Owner: syyongx
- License: mit
- Created: 2018-04-13T02:33:16.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-19T08:30:23.000Z (about 6 years ago)
- Last Synced: 2025-06-05T22:09:13.078Z (about 1 year ago)
- Topics: go, words-filter
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 124
- Watchers: 4
- Forks: 31
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-wordsfilter
A high performance text filter.
## Download & Install
```shell
go get github.com/syyongx/go-wordsfilter
```
## Quick Start
```go
import (
"github.com/syyongx/go-wordsfilter"
)
func main() {
texts := []string{
"Miyamoto Musashi",
"妲己",
"アンジェラ",
"ความรุ่งโรจน์",
}
wf := wordsfilter.New()
// Generate
root := wf.Generate(texts)
// Generate with file
// root := wf.GenerateWithFile(path)
// Contains
c1 := wf.Contains("アン", root)
// c1: false
c2 := wf.Contains("アンジェラ", root)
// c2: true
// Remove
wf.Remove("アンジェラ", root)
c3 := wf.Contains("アンジェラ", root)
// c3: false
// Replace
r1 := wf.Replace("Game ความรุ่งโรจน์ i like 妲己 heroMiyamotoMusashi", root)
// r1: Game*************ilike**hero***************
}
```
## Apis
```go
New() *WordsFilter
Generate(texts []string) map[string]*Node
GenerateWithFile(path string) (map[string]*Node, error)
Add(text string, root map[string]*Node)
Replace(text string, root map[string]*Node) string
Contains(text string, root map[string]*Node) bool
Remove(text string, root map[string]*Node)
```
## LICENSE
go-wordsfilter source code is licensed under the [MIT](https://github.com/syyongx/go-wordsfilter/blob/master/LICENSE) Licence.