Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -486,21 +486,27 @@ def analyze_composite(msg1, date1, msg2, date2, msg3, date3, *answers_and_none):
|
|
486 |
dates_used = [r[1] or "Undated" for r in results] # Store dates for future mapping
|
487 |
|
488 |
|
489 |
-
# --- Composite Abuse Score with
|
490 |
composite_abuse_scores = []
|
491 |
|
492 |
-
for
|
493 |
-
|
494 |
weighted_score = 0
|
|
|
495 |
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
weighted_score += score
|
501 |
|
502 |
-
|
|
|
|
|
|
|
|
|
|
|
503 |
|
|
|
504 |
# Average and scale to percentage
|
505 |
composite_abuse = int(round(sum(composite_abuse_scores) / len(composite_abuse_scores) * 100))
|
506 |
|
|
|
486 |
dates_used = [r[1] or "Undated" for r in results] # Store dates for future mapping
|
487 |
|
488 |
|
489 |
+
# --- Composite Abuse Score with Weighted Patterns ---
|
490 |
composite_abuse_scores = []
|
491 |
|
492 |
+
for result, _ in results:
|
493 |
+
abuse_score, threshold_labels, top_patterns, _, _, _ = result
|
494 |
weighted_score = 0
|
495 |
+
total_weight = 0
|
496 |
|
497 |
+
for label, score in top_patterns:
|
498 |
+
weight = PATTERN_WEIGHTS.get(label, 1.0)
|
499 |
+
weighted_score += score * weight
|
500 |
+
total_weight += weight
|
|
|
501 |
|
502 |
+
if total_weight > 0:
|
503 |
+
final_score = (weighted_score / total_weight) * 100
|
504 |
+
else:
|
505 |
+
final_score = 0
|
506 |
+
|
507 |
+
composite_abuse_scores.append(final_score)
|
508 |
|
509 |
+
composite_abuse = int(round(sum(composite_abuse_scores) / len(composite_abuse_scores)))
|
510 |
# Average and scale to percentage
|
511 |
composite_abuse = int(round(sum(composite_abuse_scores) / len(composite_abuse_scores) * 100))
|
512 |
|