SamanthaStorm commited on
Commit
48d6d81
·
verified ·
1 Parent(s): a10566d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -468,13 +468,13 @@ def analyze_single_message(text, thresholds):
468
  if score > adjusted_thresholds[label]
469
  ]
470
 
471
- # Determine insult subtype
472
- insults_score = next((score for label, score, _ in matched_scores if label == "insults"), 0)
473
- insult_label_display = None
474
- if insults_score > 0.9 and (emotion_profile.get("anger", 0) > 0.1 or emotion_profile.get("disgust", 0) > 0.1):
475
- insult_label_display = "Direct Insult"
476
- elif 0.5 < insults_score <= 0.9 and emotion_profile.get("neutral", 0) > 0.85:
477
- insult_label_display = "Subtle Undermining"
478
 
479
  # Abuse score
480
  abuse_score_raw = compute_abuse_score(matched_scores, sentiment)
 
468
  if score > adjusted_thresholds[label]
469
  ]
470
 
471
+
472
+ # Cap subtle insults to avoid excessive abuse score
473
+ if (
474
+ len(threshold_labels) == 1 and "insults" in threshold_labels
475
+ and emotion_profile.get("neutral", 0) > 0.85
476
+ ):
477
+ abuse_score_raw = min(abuse_score_raw, 40)
478
 
479
  # Abuse score
480
  abuse_score_raw = compute_abuse_score(matched_scores, sentiment)