SamanthaStorm commited on
Commit
bb14fb2
·
verified ·
1 Parent(s): 577f266

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
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
- weighted_total = 0.0
262
- weight_sum = 0.0
263
- for label, score in zip(LABELS, scores):
264
- weight = PATTERN_WEIGHTS.get(label, 1.0)
265
- weighted_total += score * weight
266
- weight_sum += weight
 
 
 
 
 
 
 
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))