Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -472,7 +472,13 @@ def analyze_single_message(text, thresholds):
|
|
472 |
for label, score in zip(LABELS, scores)
|
473 |
if score > adjusted_thresholds[label]
|
474 |
]
|
475 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
476 |
abuse_score_raw = compute_abuse_score(matched_scores, sentiment)
|
477 |
abuse_score = abuse_score_raw
|
478 |
|
@@ -483,9 +489,14 @@ def analyze_single_message(text, thresholds):
|
|
483 |
if weapon_flag:
|
484 |
abuse_score_raw = min(abuse_score_raw + 25, 100)
|
485 |
|
486 |
-
|
487 |
-
|
488 |
-
|
|
|
|
|
|
|
|
|
|
|
489 |
)
|
490 |
|
491 |
# Tag must happen after abuse score is finalized
|
|
|
472 |
for label, score in zip(LABELS, scores)
|
473 |
if score > adjusted_thresholds[label]
|
474 |
]
|
475 |
+
# Classify insult pattern more precisely for UI
|
476 |
+
insults_score = next((score for label, score, _ in matched_scores if label == "insults"), 0)
|
477 |
+
insult_label_display = None
|
478 |
+
if insults_score > 0.9 and (emotion_profile.get("anger", 0) > 0.1 or emotion_profile.get("disgust", 0) > 0.1):
|
479 |
+
insult_label_display = "Direct Insult"
|
480 |
+
elif 0.5 < insults_score <= 0.9 and emotion_profile.get("neutral", 0) > 0.85:
|
481 |
+
insult_label_display = "Subtle Undermining"
|
482 |
abuse_score_raw = compute_abuse_score(matched_scores, sentiment)
|
483 |
abuse_score = abuse_score_raw
|
484 |
|
|
|
489 |
if weapon_flag:
|
490 |
abuse_score_raw = min(abuse_score_raw + 25, 100)
|
491 |
|
492 |
+
# Final display tweak: swap 'insults' with its refined label
|
493 |
+
if insult_label_display and "insults" in threshold_labels:
|
494 |
+
threshold_labels = [
|
495 |
+
insult_label_display if label == "insults" else label
|
496 |
+
for label in threshold_labels
|
497 |
+
]
|
498 |
+
|
499 |
+
return abuse_score, threshold_labels, top_patterns, {"label": sentiment}, stage, darvo_score, tone_tag
|
500 |
)
|
501 |
|
502 |
# Tag must happen after abuse score is finalized
|