Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -71,7 +71,7 @@ def calculate_abuse_level(scores, thresholds, motif_hits=None):
|
|
71 |
# Boost score if high-risk motifs were detected
|
72 |
motif_hits = motif_hits or []
|
73 |
if any(label in motif_hits for label in {"physical_threat", "suicidal_threat", "extreme_control"}):
|
74 |
-
base_score = max(base_score,
|
75 |
|
76 |
return base_score
|
77 |
|
@@ -116,7 +116,9 @@ def analyze_messages(input_text, risk_flags):
|
|
116 |
high_risk_context = any(flag in contextual_flags for flag in critical_flags)
|
117 |
|
118 |
non_abusive_score = scores[LABELS.index('non_abusive')]
|
119 |
-
|
|
|
|
|
120 |
return "This message is classified as non-abusive."
|
121 |
|
122 |
abuse_level = calculate_abuse_level(scores, adjusted_thresholds, motif_hits=[label for label, _ in matched_phrases])
|
|
|
71 |
# Boost score if high-risk motifs were detected
|
72 |
motif_hits = motif_hits or []
|
73 |
if any(label in motif_hits for label in {"physical_threat", "suicidal_threat", "extreme_control"}):
|
74 |
+
base_score = max(base_score, 75.0) # Push to "Severe / Harmful Pattern Present"
|
75 |
|
76 |
return base_score
|
77 |
|
|
|
116 |
high_risk_context = any(flag in contextual_flags for flag in critical_flags)
|
117 |
|
118 |
non_abusive_score = scores[LABELS.index('non_abusive')]
|
119 |
+
non_abusive_confident = non_abusive_score > adjusted_thresholds['non_abusive']
|
120 |
+
|
121 |
+
if non_abusive_confident and danger_flag_count == 0 and not matched_phrases:
|
122 |
return "This message is classified as non-abusive."
|
123 |
|
124 |
abuse_level = calculate_abuse_level(scores, adjusted_thresholds, motif_hits=[label for label, _ in matched_phrases])
|