-
Notifications
You must be signed in to change notification settings - Fork 0
/
profanity_check.py
138 lines (126 loc) · 2.78 KB
/
profanity_check.py
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import re
profanity_list = [
"laba",
"ce pula",
"ce pizda",
"caca",
"cacat",
"cacao",
"pipi",
"pisat",
"pishat",
"rahat",
"kkt",
"kk",
"plm",
"ma fut",
"ma cac",
"ma pis",
"ma pish",
"pwla",
"p.u.l.a.",
"poola",
"naiba",
"dracu",
"draq",
"drecu",
"naibii",
"dracului",
"drecului",
"drqlui",
"coaie",
"coae",
"sloboz",
"lindic",
"gaoz",
"ochiul maro",
"floci",
"cur",
"futai",
"futare",
"futere",
"popou",
"nanau",
]
abuse_list = [
"tigan(|u|ilor|ul|i|ii)",
"tzigan(|u|ilor|ul|i|ii)",
"cretin(|u|ilor|ul|i|ii)",
"idiot(|u|ilor|ul|i|ii)",
"oligofren(|u|ilor|ul|i|ii)",
"retardat(|u|ilor|ul|i|ii)",
"handicapat(|u|ilor|ul|i|ii)",
"taran(|u|ilor|ul|i|ii)",
"cioban(|u|ilor|ul|i|ii)",
"tzaran(|u|ilor|ul|i|ii)",
"poponar(|u|ilor|ul|i|ii)",
"bulangiu(|ilor|l|i|ii)",
"curv(a|ele|elor)",
"va fut(|em)",
"te fut(|em)",
"mort(|i|ii)",
"mortz(|i|ii)",
"ma-ta",
"mata",
"mue",
"muie",
"labar(|u|i|ii|ilor)",
"labagi(|lor|ilor|i|u|l)",
"nenorocit(|u|ilor|ul|i|ii)",
"tampit(|u|ilor|ul|i|ii)",
"timpit(|u|ilor|ul|i|ii)",
"bou(|ul|i|ii)",
"prost(|u|ilor|ul|i|ii)",
"proast(|elor|a|ele)",
"fute in cur",
"futuva",
"aurolac(|u|ilor|i|ul)",
"papagal(|u|i|ilor|ule)",
"fraier(|u|ilor|i|ii)",
"futu-va(|\-n)",
"penibil(|u|ilor|i|ii)",
"ma cac pe",
"ma pis pe",
"ma pish pe",
"jigod(|ia|iilor|ilor|ie|i|ii)",
"nebun(|u|ilor|a|ul|i|ii)",
"sug(i|eti) (pula|pwla|poola)",
"in cur pe",
"in pula pe",
"cacanar(|u|i|ii|ilor)",
"nesimtit(|u|o|i|ii|ilor)",
"e de cacat",
"e de rahat",
"e de kkt",
"e de kk",
"ciori(|le)",
"cioara",
"javr(|a|e)",
"fmm",
"caca-ne am",
"popo(.*)",
"homo(.*)",
"porc(|ul|ii|i)",
"gunoi de",
"suge pula",
"jidan(|i|ii|ul)",
"imbecil(|i|ii|ul)",
"bozgor(|i|ii|ilor|e|ul|u)",
"tembel(|i|ii|ilor|ule|u|ul)",
"ungur(|i|ii|ul)",
"magar(|i|ii|u|ul)",
"retar(|d|zi|dul|dule|zilor)",
"zdreant(|z)(|a|o)",
"gras(|u|ul|ule)",
"sa mor(|i)",
]
profanity_list = [x.replace(" ",r"\s") for x in profanity_list]
abuse_list = [x.replace(" ",r"\s") for x in abuse_list]
def profanity_check(comment):
if not isinstance(comment,str): return 0
text = comment.lower()
prof_list = "|".join(profanity_list)
abus_list = "|".join(abuse_list)
has_profanity = re.search(rf"\b({prof_list})\b", text) is not None
has_abuse = re.search(rf"\b({abus_list})\b", text) is not None
return {'has_profanity':1 if has_profanity else 0, 'has_abuse':1 if has_abuse else 0}