Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -154,6 +154,7 @@ def rule_based_bias_check(text):
|
|
| 154 |
text_lower = text.lower()
|
| 155 |
|
| 156 |
gender_keywords = ["women","woman","female","men","man","male","girls","boys"]
|
|
|
|
| 157 |
biased_patterns = [
|
| 158 |
"should not",
|
| 159 |
"can't",
|
|
@@ -161,7 +162,10 @@ def rule_based_bias_check(text):
|
|
| 161 |
"inferior",
|
| 162 |
"superior",
|
| 163 |
"only",
|
| 164 |
-
"not suited"
|
|
|
|
|
|
|
|
|
|
| 165 |
]
|
| 166 |
|
| 167 |
if any(g in text_lower for g in gender_keywords):
|
|
@@ -171,6 +175,14 @@ def rule_based_bias_check(text):
|
|
| 171 |
"bias_types": ["gender"],
|
| 172 |
"demographic_group": ["women" if "women" in text_lower else "men"]
|
| 173 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
return None
|
| 175 |
|
| 176 |
|
|
|
|
| 154 |
text_lower = text.lower()
|
| 155 |
|
| 156 |
gender_keywords = ["women","woman","female","men","man","male","girls","boys"]
|
| 157 |
+
race_keywords = ["black","white","asian","latino","arab"]
|
| 158 |
biased_patterns = [
|
| 159 |
"should not",
|
| 160 |
"can't",
|
|
|
|
| 162 |
"inferior",
|
| 163 |
"superior",
|
| 164 |
"only",
|
| 165 |
+
"not suited",
|
| 166 |
+
"naturally better",
|
| 167 |
+
"are better than",
|
| 168 |
+
"are worse than"
|
| 169 |
]
|
| 170 |
|
| 171 |
if any(g in text_lower for g in gender_keywords):
|
|
|
|
| 175 |
"bias_types": ["gender"],
|
| 176 |
"demographic_group": ["women" if "women" in text_lower else "men"]
|
| 177 |
}
|
| 178 |
+
# Race bias
|
| 179 |
+
if any(r in text_lower for r in race_keywords):
|
| 180 |
+
if any(p in text_lower for p in biased_patterns):
|
| 181 |
+
return {
|
| 182 |
+
"biased": True,
|
| 183 |
+
"bias_types": ["race"],
|
| 184 |
+
"demographic_group": ["mentioned group"]
|
| 185 |
+
}
|
| 186 |
return None
|
| 187 |
|
| 188 |
|