-
Notifications
You must be signed in to change notification settings - Fork 1
/
swearjar.go
67 lines (53 loc) · 10.4 KB
/
swearjar.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package swearjar
import (
"encoding/json"
"io/ioutil"
"path/filepath"
"regexp"
)
// Swears type alias to map[string][]string
type Swears map[string][]string
var defaultSwearsJson = `{"anus":["sexual"],"arse":["insult"],"arsehole":["insult"],"ass":["sexual","insult"],"ass-hat":["insult"],"ass-pirate":["discriminatory"],"assbag":["insult"],"assbandit":["discriminatory"],"assbanger":["discriminatory"],"assbite":["insult"],"assclown":["sexual"],"asscock":["insult"],"asscracker":["sexual"],"assface":["sexual"],"assfuck":["sexual"],"assfucker":["discriminatory"],"assgoblin":["discriminatory"],"asshat":["sexual"],"asshead":["insult"],"asshole":["insult"],"asshopper":["discriminatory"],"assjacker":["discriminatory"],"asslick":["insult"],"asslicker":["insult"],"assmonkey":["insult"],"assmunch":["insult"],"assmuncher":["sexual"],"assnigger":["discriminatory"],"asspirate":["discriminatory"],"assshit":["insult"],"assshole":["sexual"],"asssucker":["insult"],"asswad":["sexual"],"asswipe":["sexual"],"bampot":["insult"],"bastard":["insult"],"beaner":["discriminatory"],"beastial":["sexual"],"beastiality":["sexual"],"beastility":["sexual"],"bestial":["sexual"],"bestiality":["sexual"],"bitch":["insult"],"bitchass":["insult"],"bitcher":["insult"],"bitchin":["inappropriate"],"bitching":["inappropriate"],"bitchtit":["discriminatory"],"bitchy":["insult"],"blow job":["sexual"],"blowjob":["sexual"],"bollocks":["sexual"],"bollox":["sexual"],"boner":["sexual"],"bullshit":["inappropriate"],"butt plug":["sexual"],"camel toe":["sexual"],"choad":["sexual"],"chode":["sexual"],"clit":["sexual"],"clitface":["insult"],"clitfuck":["sexual"],"clusterfuck":["inappropriate"],"cock":["sexual"],"cockbite":["insult"],"cockburger":["insult"],"cockface":["insult"],"cockfucker":["insult"],"cockhead":["insult"],"cockmonkey":["insult"],"cocknose":["insult"],"cocknugget":["insult"],"cockshit":["insult"],"cocksuck":["sexual"],"cocksucked":["sexual"],"cocksucker":["discriminatory","sexual"],"cocksucking":["sexual","discriminatory"],"cocksucks":["sexual","discriminatory"],"coochie":["sexual"],"coochy":["sexual"],"cooter":["sexual"],"cum":["sexual"],"cumbubble":["insult"],"cumdumpster":["sexual"],"cummer":["sexual"],"cumming":["sexual"],"cumshot":["sexual"],"cumslut":["sexual","insult"],"cumtart":["insult"],"cunillingus":["sexual"],"cunnie":["sexual"],"cunnilingus":["sexual"],"cunt":["insult","sexual"],"cuntface":["insult"],"cunthole":["sexual"],"cuntlick":["sexual"],"cuntlicker":["sexual","discriminatory"],"cuntlicking":["sexual"],"cuntrag":["insult"],"cuntslut":["insult"],"cyberfuc":["sexual"],"cyberfuck":["sexual"],"cyberfucked":["sexual"],"cyberfucker":["sexual"],"cyberfucking":["sexual"],"dago":["discriminatory"],"damn":["inappropriate"],"deggo":["discriminatory"],"dick":["sexual","insult"],"dickbag":["insult"],"dickbeaters":["sexual"],"dickface":["insult"],"dickfuck":["insult"],"dickhead":["insult"],"dickhole":["sexual"],"dickjuice":["sexual"],"dickmilk":["sexual"],"dickslap":["sexual"],"dickwad":["insult"],"dickweasel":["insult"],"dickweed":["insult"],"dickwod":["insult"],"dildo":["sexual"],"dink":["insult","sexual"],"dipshit":["insult"],"doochbag":["insult"],"dookie":["inappropriate"],"douche":["insult"],"douche-fag":["insult"],"douchebag":["insult"],"douchewaffle":["discriminatory"],"dumass":["insult"],"dumb ass":["insult"],"dumbass":["insult"],"dumbfuck":["insult"],"dumbshit":["insult"],"dumshit":["insult"],"ejaculate":["sexual"],"ejaculated":["sexual"],"ejaculates":["sexual"],"ejaculating":["sexual"],"ejaculation":["sexual"],"fag":["discriminatory"],"fagbag":["discriminatory"],"fagfucker":["discriminatory"],"fagging":["discriminatory"],"faggit":["discriminatory"],"faggot":["discriminatory"],"faggotcock":["discriminatory"],"faggs":["discriminatory"],"fagot":["discriminatory"],"fags":["discriminatory"],"fagtard":["discriminatory"],"fart":["inappropriate"],"farted":["inappropriate"],"farting":["inappropriate"],"farty":["inappropriate"],"fatass":["insult"],"felatio":["sexual"],"fellatio":["sexual"],"feltch":["sexual"],"fingerfuck":["sexual"],"fingerfucked":["sexual"],"fingerfucker":["sexual"],"fingerfucking":["sexual"],"fingerfucks":["sexual"],"fistfuck":["sexual"],"fistfucked":["sexual"],"fistfucker":["sexual"],"fistfucking":["sexual"],"flamer":["discriminatory"],"fuck":["sexual"],"fuckass":["insult"],"fuckbag":["insult"],"fuckboy":["insult"],"fuckbrain":["insult"],"fuckbutt":["sexual"],"fucked":["sexual"],"fucker":["sexual","insult"],"fuckersucker":["insult"],"fuckface":["insult"],"fuckhead":["sexual"],"fuckhole":["insult"],"fuckin":["sexual"],"fucking":["sexual"],"fuckme":["sexual"],"fucknut":["insult"],"fucknutt":["insult"],"fuckoff":["insult"],"fuckstick":["sexual"],"fucktard":["insult"],"fuckup":["insult"],"fuckwad":["insult"],"fuckwit":["insult"],"fuckwitt":["insult"],"fudgepacker":["discriminatory"],"fuk":["sexual"],"gangbang":["sexual"],"gangbanged":["sexual"],"goddamn":["inappropriate","blasphemy"],"goddamnit":["inappropriate","blasphemy"],"gooch":["sexual"],"gook":["discriminatory"],"gringo":["discriminatory"],"guido":["discriminatory"],"handjob":["sexual"],"hardcoresex":["sexual"],"heeb":["discriminatory"],"hell":["inappropriate"],"ho":["discriminatory"],"hoe":["discriminatory"],"homo":["discriminatory"],"homodumbshit":["insult"],"honkey":["discriminatory"],"horniest":["sexual"],"horny":["sexual"],"hotsex":["sexual"],"humping":["sexual"],"jackass":["insult"],"jap":["discriminatory"],"jigaboo":["discriminatory"],"jism":["sexual"],"jiz":["sexual"],"jizm":["sexual"],"jizz":["sexual"],"jungle bunny":["discriminatory"],"junglebunny":["discriminatory"],"kike":["discriminatory"],"kock":["sexual"],"kondum":["sexual"],"kooch":["sexual"],"kootch":["sexual"],"kum":["sexual"],"kumer":["sexual"],"kummer":["sexual"],"kumming":["sexual"],"kums":["sexual"],"kunilingus":["sexual"],"kunt":["sexual"],"kyke":["discriminatory"],"lezzie":["discriminatory"],"lust":["sexual"],"lusting":["sexual"],"mcfagget":["discriminatory"],"mick":["discriminatory"],"minge":["sexual"],"mothafuck":["sexual"],"mothafucka":["sexual","insult"],"mothafuckaz":["sexual"],"mothafucked":["sexual"],"mothafucker":["sexual","insult"],"mothafuckin":["sexual"],"mothafucking":["sexual"],"mothafucks":["sexual"],"motherfuck":["sexual"],"motherfucked":["sexual"],"motherfucker":["sexual","insult"],"motherfuckin":["sexual"],"motherfucking":["sexual"],"muff":["sexual"],"muffdiver":["discriminatory","sexual"],"munging":["sexual"],"negro":["discriminatory"],"nigga":["discriminatory"],"nigger":["discriminatory"],"niglet":["discriminatory"],"nut sack":["sexual"],"nutsack":["sexual"],"orgasim":["sexual"],"orgasm":["sexual"],"paki":["discriminatory"],"panooch":["sexual"],"pecker":["sexual"],"peckerhead":["insult"],"penis":["sexual"],"penisfucker":["discriminatory"],"penispuffer":["discriminatory"],"phonesex":["sexual"],"phuk":["sexual"],"phuked":["sexual"],"phuking":["sexual"],"phukked":["sexual"],"phukking":["sexual"],"phuks":["sexual"],"phuq":["sexual"],"pis":["sexual"],"pises":["sexual"],"pisin":["sexual"],"pising":["sexual"],"pisof":["sexual"],"piss":["inappropriate"],"pissed":["inappropriate"],"pisser":["sexual"],"pisses":["sexual"],"pissflaps":["sexual"],"pissin":["sexual"],"pissing":["sexual"],"pissoff":["sexual"],"polesmoker":["discriminatory"],"pollock":["discriminatory"],"poon":["sexual"],"poonani":["sexual"],"poonany":["sexual"],"poontang":["sexual"],"porch monkey":["discriminatory"],"porchmonkey":["discriminatory"],"porn":["sexual"],"porno":["sexual"],"pornography":["sexual"],"pornos":["sexual"],"prick":["sexual"],"punanny":["sexual"],"punta":["insult"],"pusies":["sexual","insult"],"pussies":["sexual","insult"],"pussy":["sexual","insult"],"pussylicking":["sexual"],"pusy":["sexual"],"puto":["insult"],"renob":["sexual"],"rimjob":["sexual"],"ruski":["discriminatory"],"sandnigger":["discriminatory"],"schlong":["sexual"],"scrote":["sexual"],"shit":["sexual","inappropriate"],"shitass":["insult"],"shitbag":["insult"],"shitbagger":["insult"],"shitbrain":["insult"],"shitbreath":["insult"],"shitcunt":["insult"],"shitdick":["insult"],"shited":["sexual"],"shitface":["insult"],"shitfaced":["inappropriate","insult"],"shitfull":["sexual"],"shithead":["insult"],"shithole":["insult"],"shithouse":["inappropriate"],"shiting":["sexual"],"shitspitter":["sexual"],"shitstain":["inappropriate","insult"],"shitted":["sexual"],"shitter":["sexual"],"shittiest":["inappropriate"],"shitting":["inappropriate"],"shitty":["inappropriate"],"shity":["sexual"],"shiz":["inappropriate"],"shiznit":["inappropriate"],"skank":["insult"],"skeet":["sexual"],"skullfuck":["sexual"],"slut":["discriminatory"],"slutbag":["discriminatory"],"sluts":["sexual"],"smeg":["inappropriate"],"smut":["sexual"],"snatch":["sexual"],"spic":["discriminatory"],"spick":["discriminatory"],"splooge":["sexual"],"spunk":["sexual"],"tard":["discriminatory"],"testicle":["sexual"],"thundercunt":["insult"],"tit":["sexual"],"tits":["sexual"],"titfuck":["sexual"],"tittyfuck":["sexual"],"twat":["sexual"],"twatlips":["insult"],"twatwaffle":["discriminatory"],"unclefucker":["discriminatory"],"va-j-j":["sexual"],"vag":["sexual"],"vagina":["sexual"],"vjayjay":["sexual"],"wank":["sexual"],"wetback":["discriminatory"],"whore":["insult"],"whorebag":["insult"],"whoreface":["insult"]}`
// Load a default set of swears and returns a Swears instance
// or can load a JSON file which will unmarshal to Swears (map[string[]string)
func Load(config ...string) (swears Swears, err error) {
// Make a local copy
defaultSwearsJson := defaultSwearsJson
if config != nil && config[0] != "" {
absPath, err := filepath.Abs(config[0])
if err != nil {
return nil, err
}
swearsJson, err := ioutil.ReadFile(absPath)
if err != nil {
return nil, err
}
defaultSwearsJson = string(swearsJson)
}
err = json.Unmarshal([]byte(defaultSwearsJson), &swears)
if err != nil {
return nil, err
}
return
}
// Profane takes an input word against the swears list and returns bool at an occurrence.
// This calls Scorecard but discards the reason
func (swears Swears) Profane(input string) (bool, error) {
profane, _, err := swears.Scorecard(input)
return profane, err
}
// Scorecard checks input against swear list and returns bool, slice of reasons + error.
// This will return at first occurrence
func (swears Swears) Scorecard(input string) (profane bool, reasons []string, err error) {
for word, reason := range swears {
wordPattern := `\b` + word + `\b`
match, err := regexp.MatchString(wordPattern, input)
if err != nil {
return false, nil, err
}
if match {
return true, reason, nil
}
}
return false, nil, nil
}