Documentation
¶
Index ¶
- Variables
- func IsProfane(s string) bool
- func IsProfaneString(s string) string
- type ProfanityDetector
- func (g *ProfanityDetector) IsProfane(s string) bool
- func (g *ProfanityDetector) IsProfaneString(s string) string
- func (g *ProfanityDetector) WithCustomDictionary(profanities, falsePositives, falseNegatives []string) *ProfanityDetector
- func (g *ProfanityDetector) WithExactWord(exact bool) *ProfanityDetector
- func (g *ProfanityDetector) WithSanitizeAccents(sanitize bool) *ProfanityDetector
- func (g *ProfanityDetector) WithSanitizeLeetSpeak(sanitize bool) *ProfanityDetector
- func (g *ProfanityDetector) WithSanitizeSpecialCharacters(sanitize bool) *ProfanityDetector
Constants ¶
This section is empty.
Variables ¶
var DefaultFalseNegatives = []string{
"asshole",
"dumbass",
"nigger",
}
DefaultFalseNegatives is a list of profanities that are checked for before the DefaultFalsePositives are removed
This is reserved for words that may be incorrectly filtered as false positives.
Alternatively, words that are long, or that should mark a string as profane no what the context is or whether the word is part of another word can also be included.
Note that there is a test that prevents words from being in both DefaultProfanities and DefaultFalseNegatives,
var DefaultFalsePositives = []string{
"arsenal",
"assassin",
"assaying",
"assert",
"assign",
"assimil",
"associat",
"assum",
"assur",
"banal",
"basement",
"bass",
"cass",
"butthe",
"canvass",
"circum",
"clitheroe",
"cockburn",
"cumber",
"cumbing",
"cumulat",
"dickvandyke",
"document",
"evaluate",
"exclusive",
"expensive",
"explain",
"expression",
"grape",
"grass",
"harass",
"hass",
"horniman",
"hotwater",
"identit",
"lass",
"leafage",
"libshitz",
"magnacumlaude",
"mass",
"mocha",
"pass",
"penistone",
"phoebe",
"phoenix",
"pushit",
"sassy",
"saturday",
"serfage",
"sexist",
"shoe",
"scunthorpe",
"shitake",
"stitch",
"sussex",
"therapist",
"tysongay",
"wass",
"wharfage",
"button",
}
DefaultFalsePositives is a list of words that may wrongly trigger the DefaultProfanities
var DefaultProfanities = []string{
"anal",
"orgasm",
"xanax",
"valium",
"viagra",
"cialis",
"anus",
"arse",
"ass",
"ballsack",
"balls",
"bastard",
"bitch",
"btch",
"biatch",
"blowjob",
"bollock",
"bollok",
"boner",
"boob",
"bugger",
"butt",
"choad",
"clitoris",
"cock",
"coon",
"crap",
"cum",
"cunt",
"dick",
"dildo",
"douchebag",
"dyke",
"fag",
"feck",
"fellate",
"fellatio",
"felching",
"fuck",
"fudgepacker",
"flange",
"gtfo",
"hoe",
"horny",
"incest",
"jerk",
"jizz",
"labia",
"masturbat",
"muff",
"naked",
"nazi",
"nigga",
"niggu",
"nipple",
"nips",
"nude",
"pedophile",
"penis",
"piss",
"poop",
"porn",
"prick",
"prostitut",
"pube",
"pussie",
"pussy",
"queer",
"rape",
"rapist",
"retard",
"rimjob",
"scrotum",
"sex",
"shit",
"slut",
"spunk",
"stfu",
"suckmy",
"tits",
"tittie",
"titty",
"turd",
"twat",
"vagina",
"wank",
"whore",
}
DefaultProfanities is a list of profanities that are checked after the DefaultFalsePositives are removed
Note that some words that would normally be in this list may be in DefaultFalseNegatives
Functions ¶
func IsProfane ¶
IsProfane checks whether there are any profanities in a given string (word or sentence). Uses the default ProfanityDetector
func IsProfaneString ¶
IsProfaneString checks whether there are any profanities in a given string (word or sentence) and returns the first word that was found. Uses the default ProfanityDetector
Types ¶
type ProfanityDetector ¶
type ProfanityDetector struct {
// contains filtered or unexported fields
}
ProfanityDetector contains the dictionaries as well as the configuration for determining how profanity detection is handled
func NewProfanityDetector ¶
func NewProfanityDetector() *ProfanityDetector
NewProfanityDetector creates a new ProfanityDetector
func (*ProfanityDetector) IsProfane ¶
func (g *ProfanityDetector) IsProfane(s string) bool
IsProfane takes in a string (word or sentence) and look for profanities. Returns a boolean
func (*ProfanityDetector) IsProfaneString ¶
func (g *ProfanityDetector) IsProfaneString(s string) string
IsProfaneString takes in a string (word or sentence) and look for profanities. Returns non-empty string of the first found profanity.
func (*ProfanityDetector) WithCustomDictionary ¶
func (g *ProfanityDetector) WithCustomDictionary(profanities, falsePositives, falseNegatives []string) *ProfanityDetector
WithCustomDictionary allows configuring whether the sanitization process should also take into account custom profanities, false positives and false negatives dictionaries.
func (*ProfanityDetector) WithExactWord ¶ added in v1.2.3
func (g *ProfanityDetector) WithExactWord(exact bool) *ProfanityDetector
func (*ProfanityDetector) WithSanitizeAccents ¶
func (g *ProfanityDetector) WithSanitizeAccents(sanitize bool) *ProfanityDetector
WithSanitizeAccents allows configuring of whether the sanitization process should also take into account accents. By default, this is set to true, but since this adds a bit of overhead, you may disable it if your use case is time-sensitive or if the input doesn't involve accents (i.e. if the input can never contain special characters)
func (*ProfanityDetector) WithSanitizeLeetSpeak ¶
func (g *ProfanityDetector) WithSanitizeLeetSpeak(sanitize bool) *ProfanityDetector
WithSanitizeLeetSpeak allows configuring whether the sanitization process should also take into account leetspeak
func (*ProfanityDetector) WithSanitizeSpecialCharacters ¶
func (g *ProfanityDetector) WithSanitizeSpecialCharacters(sanitize bool) *ProfanityDetector
WithSanitizeSpecialCharacters allows configuring whether the sanitization process should also take into account special characters