forked from rDrama/rDrama
improve slur regex
parent
309b23a005
commit
5703425418
|
@ -41,8 +41,6 @@ AJ_REPLACEMENTS = {
|
||||||
|
|
||||||
if SITE_NAME == 'rDrama':
|
if SITE_NAME == 'rDrama':
|
||||||
SLURS = {
|
SLURS = {
|
||||||
"california": "commiefornia",
|
|
||||||
"hollywood": "hollyweird",
|
|
||||||
"tiananmen square": "tiananmen square didn't happen (but it should have)",
|
"tiananmen square": "tiananmen square didn't happen (but it should have)",
|
||||||
"dasha": "beautiful angelic perfect Dasha/future Mrs. Carp",
|
"dasha": "beautiful angelic perfect Dasha/future Mrs. Carp",
|
||||||
"retarded": "r-slurred",
|
"retarded": "r-slurred",
|
||||||
|
@ -97,10 +95,10 @@ if SITE_NAME == 'rDrama':
|
||||||
"fake and gay": "fake and straight",
|
"fake and gay": "fake and straight",
|
||||||
|
|
||||||
" rapist": " male feminist",
|
" rapist": " male feminist",
|
||||||
|
">rapist": ">male feminist",
|
||||||
|
|
||||||
" kys ": " keep yourself safe ",
|
" kys": " keep yourself safe",
|
||||||
" pedo ": " libertarian ",
|
">kys": ">keep yourself safe",
|
||||||
" pedos ": " libertarians ",
|
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
SLURS = {
|
SLURS = {
|
||||||
|
|
|
@ -57,8 +57,8 @@ email_regex = re.compile('[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}', flags=re.A|re.
|
||||||
utm_regex = re.compile('utm_[a-z]+=[a-z0-9_]+&', flags=re.A)
|
utm_regex = re.compile('utm_[a-z]+=[a-z0-9_]+&', flags=re.A)
|
||||||
utm_regex2 = re.compile('[?&]utm_[a-z]+=[a-z0-9_]+', flags=re.A)
|
utm_regex2 = re.compile('[?&]utm_[a-z]+=[a-z0-9_]+', flags=re.A)
|
||||||
|
|
||||||
slur_regex = re.compile(f"<[^>]*>|{single_words}", flags=re.I|re.A)
|
slur_regex = re.compile(single_words, flags=re.I|re.A)
|
||||||
slur_regex_upper = re.compile(f"<[^>]*>|{single_words.upper()}", flags=re.A)
|
slur_regex_upper = re.compile(single_words.upper(), flags=re.A)
|
||||||
torture_regex = re.compile('(^|\s)(i|me) ', flags=re.I|re.A)
|
torture_regex = re.compile('(^|\s)(i|me) ', flags=re.I|re.A)
|
||||||
torture_regex2 = re.compile("(^|\s)i'm ", flags=re.I|re.A)
|
torture_regex2 = re.compile("(^|\s)i'm ", flags=re.I|re.A)
|
||||||
torture_regex_exclude = re.compile('^\s*>', flags=re.A)
|
torture_regex_exclude = re.compile('^\s*>', flags=re.A)
|
||||||
|
@ -105,11 +105,8 @@ git_regex = re.compile("ref: (refs/.+)", flags=re.A)
|
||||||
pronouns_regex = re.compile("([a-z]{2,5}|i)/[a-z]{2,5}", flags=re.A)
|
pronouns_regex = re.compile("([a-z]{2,5}|i)/[a-z]{2,5}", flags=re.A)
|
||||||
|
|
||||||
def sub_matcher(match, upper=False):
|
def sub_matcher(match, upper=False):
|
||||||
if match.group(0).startswith('<'):
|
repl = SLURS[match.group(0).lower()]
|
||||||
return match.group(0)
|
return repl if not upper else repl.upper()
|
||||||
else:
|
|
||||||
repl = SLURS[match.group(0).lower()]
|
|
||||||
return repl if not upper else repl.upper()
|
|
||||||
|
|
||||||
def sub_matcher_upper(match):
|
def sub_matcher_upper(match):
|
||||||
return sub_matcher(match, upper=True)
|
return sub_matcher(match, upper=True)
|
||||||
|
|
Loading…
Reference in New Issue