mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-15 22:32:13 +00:00
stop racism too
This commit is contained in:
1 parent
5cc90d1001
commit
4ad90b31df
2 files changed
+160
-3
No files matched your search
@@ -6,6 +6,7 @@ use crate::minor_regex::lowercase_mentions_underage;
|
||||
|
||||
const CHILD_TERMS : &str = include_str!("../../../../includes/binary_includes/dictionary_children_terms.txt");
|
||||
const SEX_TERMS : &str = include_str!("../../../../includes/binary_includes/dictionary_sex_terms.txt");
|
||||
const RACIST_TERMS : &str = include_str!("../../../../includes/binary_includes/dictionary_racist_terms.txt");
|
||||
|
||||
/// Classification of a text prompt
|
||||
pub struct PromptClassification {
|
||||
@@ -90,9 +91,15 @@ fn references_violence(_prompt_tokens: &[String]) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn references_racism(_prompt_tokens: &[String]) -> bool {
|
||||
// TODO(bt,2024-02-19): Need to implement
|
||||
false
|
||||
fn references_racism(prompt_tokens: &[String]) -> bool {
|
||||
static RACIST_TERM_DICTIONARY : Lazy<HashSet<String>> = Lazy::new(|| {
|
||||
RACIST_TERMS.lines()
|
||||
.map(|line| line.trim().to_lowercase())
|
||||
.filter(|line| !line.is_empty() && !line.starts_with("#"))
|
||||
.collect::<HashSet<String>>()
|
||||
});
|
||||
|
||||
prompt_tokens.iter().any(|term| RACIST_TERM_DICTIONARY.contains(term))
|
||||
}
|
||||
|
||||
static SPACES_REGEX : Lazy<Regex> = Lazy::new(|| {
|
||||
@@ -195,6 +202,27 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bad_user_racist_prompts() {
|
||||
let prompts = [
|
||||
"adolf hitler having tea with joe biden",
|
||||
"niggers",
|
||||
];
|
||||
|
||||
for prompt in prompts {
|
||||
let classification = classify_prompt(prompt);
|
||||
|
||||
asserting(&format!("is abusive - prompt: {}", prompt))
|
||||
.that(&classification.is_abusive())
|
||||
.is_equal_to(true);
|
||||
|
||||
asserting(&format!("is racism - prompt: {}", prompt))
|
||||
.that(&classification.prompt_references_racism)
|
||||
.is_equal_to(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn borderline_cases() {
|
||||
// These are actual user prompts that use borderline language, but are safe
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
# These terms should not be allowed for prompts
|
||||
|
||||
# A few fake slurs for testing
|
||||
fakeslur
|
||||
junglehorse
|
||||
slurfake
|
||||
|
||||
# Nazis
|
||||
adolf
|
||||
adolph
|
||||
hitler
|
||||
nazi
|
||||
|
||||
# Racism
|
||||
nigger
|
||||
niggers
|
||||
|
||||
# Additional slurs from BibbyBoi 2022-03-04
|
||||
arabush
|
||||
aravush
|
||||
argie
|
||||
argies
|
||||
bakra
|
||||
balija
|
||||
bamboula
|
||||
beaner
|
||||
beaney
|
||||
bluegum
|
||||
bogtrotter
|
||||
boonga
|
||||
boonie
|
||||
bootlip
|
||||
bougnoule
|
||||
bozgor
|
||||
buddhahead
|
||||
bule
|
||||
bunga
|
||||
burrhead
|
||||
carcamano
|
||||
chankoro
|
||||
chink
|
||||
chinks
|
||||
choc-ice
|
||||
coon
|
||||
coonass
|
||||
dago
|
||||
dego
|
||||
dink
|
||||
dune-coon
|
||||
dyke
|
||||
fag
|
||||
faggot
|
||||
fags
|
||||
greaser
|
||||
groid
|
||||
guidette
|
||||
# guido # NB(2022.11.12) - Not a slur for Italian models https://discord.com/channels/963507819011768370/963812062939709471/1041106464867094528
|
||||
haole
|
||||
hebe
|
||||
heeb
|
||||
hitler
|
||||
honkey
|
||||
honkie
|
||||
hymie
|
||||
injun
|
||||
jigaboo
|
||||
jigarooni
|
||||
jiggabo
|
||||
jigger
|
||||
jijjiboo
|
||||
kike
|
||||
kniggers
|
||||
kyke
|
||||
maumau
|
||||
mayomonkey
|
||||
moolinyan
|
||||
mulignan
|
||||
mulignon
|
||||
neger
|
||||
negro
|
||||
negro
|
||||
negroid
|
||||
nicc a
|
||||
nicc er
|
||||
nicca
|
||||
niccer
|
||||
nig
|
||||
nigar
|
||||
nigette
|
||||
niggah
|
||||
niggar
|
||||
nigger
|
||||
niggers
|
||||
niggertoe
|
||||
niggress
|
||||
nigguh
|
||||
nignig
|
||||
nignog
|
||||
nigs
|
||||
nik-a
|
||||
nika
|
||||
nikk-a
|
||||
nikk-er
|
||||
ofay
|
||||
poortagee
|
||||
rastus
|
||||
sambo
|
||||
sheboon
|
||||
sheeny
|
||||
sooty
|
||||
spic
|
||||
spick
|
||||
spig
|
||||
spig
|
||||
spigotty
|
||||
spik
|
||||
tarbaby
|
||||
whigg-a
|
||||
whigg-er
|
||||
whigga
|
||||
whigger
|
||||
wigg-er
|
||||
wigger
|
||||
wikk-a
|
||||
wikk-er
|
||||
wikka
|
||||
wikker
|
||||
zigabo
|
||||
zipperhead
|
||||
Reference in new issue
Block a user