Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { DetectLeetSpeak bool `json:"detectLeetSpeak"` DetectObfuscated bool `json:"detectObfuscated"` ReplacementCharacter string `json:"replacementCharacter"` ObfuscationLength int32 `json:"obfuscationLength,default=3"` Profanities []WordMatcher `json:"profanities"` FalsePositives []string `json:"falsePositives"` FalseNegatives []WordMatcher `json:"falseNegatives"` }
Config is a struct that contains the configuration for the profanity sanitizer.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig is the default configuration for the profanity sanitizer.
type DetectedConcern ¶
type DetectedConcern struct { Word string MatchedText string StartIndex int32 EndIndex int32 Level int32 }
DetectedConcern contains details about detected profanity (matched text, base word, start, end index and optional level).
func List ¶
func List(str string) []DetectedConcern
List takes in a string (word or sentence) and returns list of DetectedConcern.
Uses the default ProfanitySanitizer
type ProfanitySanitizer ¶
type ProfanitySanitizer struct {
// contains filtered or unexported fields
}
ProfanitySanitizer contains the dictionaries as well as the configuration for determining how profanity detection is handled
func NewProfanitySanitizer ¶
func NewProfanitySanitizer(c *Config) ProfanitySanitizer
NewProfanitySanitizer creates a new ProfanitySanitizer with the provided Config.
func (*ProfanitySanitizer) IsProfane ¶
func (gc *ProfanitySanitizer) IsProfane(str string) bool
IsProfane checks whether there are any profanities in a given string (word or sentence).
func (*ProfanitySanitizer) List ¶
func (gc *ProfanitySanitizer) List(message string) []DetectedConcern
List takes in a string (word or sentence) and returns list of DetectedConcern.
func (*ProfanitySanitizer) Redact ¶
func (gc *ProfanitySanitizer) Redact(str string) string
Redact takes in a string (word or sentence) and tries to censor all profanities found.