Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -258,12 +258,19 @@ def analyze_single_message(text, thresholds):
|
|
258 |
)[:2]
|
259 |
|
260 |
# Compute weighted average across all patterns (not just top 2)
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
|
268 |
matched_scores = [
|
269 |
(label, score, PATTERN_WEIGHTS.get(label, 1.0))
|
|
|
258 |
)[:2]
|
259 |
|
260 |
# Compute weighted average across all patterns (not just top 2)
|
261 |
+
# ✅ Only include passed labels in abuse intensity calculation
|
262 |
+
matched_scores = [
|
263 |
+
(label, score, PATTERN_WEIGHTS.get(label, 1.0))
|
264 |
+
for label, score in zip(LABELS, scores)
|
265 |
+
if score > adjusted_thresholds[label]
|
266 |
+
]
|
267 |
+
|
268 |
+
if matched_scores:
|
269 |
+
weighted_total = sum(score * weight for _, score, weight in matched_scores)
|
270 |
+
weight_sum = sum(weight for _, _, weight in matched_scores)
|
271 |
+
abuse_score_raw = (weighted_total / weight_sum) * 100
|
272 |
+
else:
|
273 |
+
abuse_score_raw = 0
|
274 |
|
275 |
matched_scores = [
|
276 |
(label, score, PATTERN_WEIGHTS.get(label, 1.0))
|