alohaboy
commited on
Commit
·
6e6e1e7
1
Parent(s):
9d80233
Fix normal bypass: standardize detection result format
Browse files
app.py
CHANGED
@@ -266,11 +266,15 @@ class HateSpeechDetectorService:
|
|
266 |
# If hate_tokens contain B-HARD, I-HARD, increase label to L2_hate
|
267 |
if any(bio_label in ["B-HARD", "I-HARD"] for _, _, bio_label in hate_tokens):
|
268 |
label = "L2_hate"
|
269 |
-
|
270 |
-
|
|
|
|
|
|
|
271 |
if hate_tokens:
|
272 |
-
result_msg += f"
|
273 |
-
|
|
|
274 |
debug_info = {
|
275 |
'sentence_logits': sentence_logits,
|
276 |
'sentence_probs': sentence_probs,
|
|
|
266 |
# If hate_tokens contain B-HARD, I-HARD, increase label to L2_hate
|
267 |
if any(bio_label in ["B-HARD", "I-HARD"] for _, _, bio_label in hate_tokens):
|
268 |
label = "L2_hate"
|
269 |
+
|
270 |
+
# Construct result message with consistent format
|
271 |
+
result_msg = f"🔍 **Detection Result**\n\n"
|
272 |
+
result_msg += f"**Classification:** {label}\n"
|
273 |
+
result_msg += f"**Confidence:** {sentence_prob:.2f}\n"
|
274 |
if hate_tokens:
|
275 |
+
result_msg += f"**Identified Expressions:** {hate_tokens}"
|
276 |
+
|
277 |
+
mitigation = "**Detection Only:** Performed only detection."
|
278 |
debug_info = {
|
279 |
'sentence_logits': sentence_logits,
|
280 |
'sentence_probs': sentence_probs,
|