moderation
is a profanity filter for Go
.
Note: This project is not actively maintained, as I have moved on to working on a Rust version.
- Easy to use
- Minimum possible allocations, processing time, and binary size
- Minimum false negatives (including text like
h3110_w0r!d
) - Minimum false positives
- (Experimental) Provide a way to censor text
- (Future) Other analysis types than inappropriate, profane, offensive, sexual, mean, spam (violence, contact info, etc.)
- (Future) Basic support for languages other than English
package main
import (
"fmt"
"github.com/finnbear/moderation"
)
func main() {
printResult("hello world")
printResult("$#1t")
printResult("a$$")
printResult("assassin")
}
func printResult(phrase string) {
description := "is appropriate"
if moderation.IsInappropriate(phrase) {
description = "is NOT appropriate"
}
fmt.Printf("\"%s\" %s.\n", phrase, description)
}
$ go run hello_world.go
"hello world" is appropriate.
"$#1t" is NOT appropriate.
"a$$" is NOT appropriate.
"assassin" is appropriate.
Accuracy was evaluated based on the first 100,000 items from this dataset of moderated comments.
Package | Time | Accuracy | Comment |
---|---|---|---|
finnbear/moderation | 1.63s | 92.21% | Not stable, nor actively maintained |
TwinProduction/go-away | 2.16s | 82.18% | Many false positives from combined words like "push it" |
- Radix implementation based on https://gitlab.com/caibear/go-boggle/
- Some profanities and test cases are based on https://github.com/TwinProduction/go-away