SamanthaStorm commited on
Commit
5fefe23
·
verified ·
1 Parent(s): 6fa6b8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
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
- abuse_score = min(
487
- abuse_score_raw,
488
- 100 if "control" in threshold_labels else 95
 
 
 
 
 
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