Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/antlinker/go-dirtyfilter
Golang基于DFA算法实现的敏感词过滤
https://github.com/antlinker/go-dirtyfilter
Last synced: 3 months ago
JSON representation
Golang基于DFA算法实现的敏感词过滤
- Host: GitHub
- URL: https://github.com/antlinker/go-dirtyfilter
- Owner: antlinker
- License: apache-2.0
- Created: 2016-03-25T08:52:11.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-09-23T12:59:08.000Z (about 5 years ago)
- Last Synced: 2024-07-16T13:09:18.587Z (4 months ago)
- Language: Go
- Homepage:
- Size: 574 KB
- Stars: 333
- Watchers: 14
- Forks: 72
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Golang Dirty Filter
[![GoDoc](https://godoc.org/github.com/antlinker/go-dirtyfilter?status.svg)](https://godoc.org/github.com/antlinker/go-dirtyfilter)
> 基于DFA算法;
> 支持动态修改敏感词,同时支持特殊字符的筛选;
> 敏感词的存储支持内存存储及MongoDB存储。## 获取
``` bash
$ go get -v github.com/antlinker/go-dirtyfilter
```## 使用
``` go
package mainimport (
"fmt""github.com/antlinker/go-dirtyfilter"
"github.com/antlinker/go-dirtyfilter/store"
)var (
filterText = `我是需要过滤的内容,内容为:**文@@件,需要过滤。。。`
)func main() {
memStore, err := store.NewMemoryStore(store.MemoryConfig{
DataSource: []string{"文件"},
})
if err != nil {
panic(err)
}
filterManage := filter.NewDirtyManager(memStore)
result, err := filterManage.Filter().Filter(filterText, '*', '@')
if err != nil {
panic(err)
}
fmt.Println(result)
}
```## 输出结果
```
[文件]
```## License
Copyright 2016.All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.