Add explicit sexual language typos rule

This commit is contained in:
2025-08-18 22:14:55 -03:00
parent 118dacff20
commit a6255290b2
5 changed files with 42 additions and 3 deletions
@@ -0,0 +1 @@
ho
@@ -53,8 +53,9 @@ squirts
bitch
bih
bich
ho
hoe
// ho is in "explicit sexual language typos" because it's usually also a typo of "hi". it gets
// censored instead of banned.
huz
slut
dldo
+37
View File
@@ -555,6 +555,42 @@ impl Rule for ExplicitSexualLanguageRule {
}
}
struct ExplicitSexualLanguageTypoRule {
pattern: Regex,
exceptions: Vec<String>,
}
impl ExplicitSexualLanguageTypoRule {
fn new() -> Self {
let (phrases, exceptions) =
parse_phrases_file(include_str!("lists/explicit-sexual-language-typos.txt"));
let regex = regex_from_phrases_list(&phrases);
Self {
pattern: regex,
exceptions,
}
}
}
impl Rule for ExplicitSexualLanguageTypoRule {
fn action(&self) -> &'static Action {
&Action::SoftCensorAndWarn
}
fn name(&self) -> &'static str {
"Explicit Sexual Language Typo"
}
fn detect(&self, _original: &str, normalized: &str) -> (Vec<String>, Vec<String>) {
(
vec![],
find_with_exceptions(normalized, &self.pattern, &self.exceptions),
)
}
}
struct SuggestiveLanguageRule {
pattern: Regex,
exceptions: Vec<String>,
@@ -759,6 +795,7 @@ pub static RULES: Lazy<Vec<Arc<dyn Rule>>> = Lazy::new(|| {
Arc::new(HateSpeechAndSlursRule::new()),
Arc::new(ThreatsAndSelfHarmRule::new()),
Arc::new(ExplicitSexualLanguageRule::new()),
Arc::new(ExplicitSexualLanguageTypoRule::new()),
Arc::new(SuggestiveLanguageRule::new()),
Arc::new(AdvertisingRule),
Arc::new(SensitiveTopicsAndTriggeringContentRule::new()),