SamanthaStorm commited on
Commit
002eb5f
·
verified ·
1 Parent(s): 1796883

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -174,8 +174,8 @@ def analyze_composite(msg1, msg2, msg3, flags):
174
  base_score = sum(abuse_scores) / len(abuse_scores)
175
  label_sets = [[label for label, _ in r[2]] for r in results]
176
  label_counts = {label: sum(label in s for s in label_sets) for label in set().union(*label_sets)}
177
- top_labels = sorted(label_counts.items(), key=lambda x: x[1], reverse=True)[:2]
178
- top_explanations = [EXPLANATIONS.get(label, "") for label, _ in top_labels]
179
 
180
  # Adjust flag-based weight relative to number of messages
181
  danger_weight = 5
@@ -197,10 +197,11 @@ def analyze_composite(msg1, msg2, msg3, flags):
197
  composite_score = round(min(composite_score, 100), 2) # re-cap just in case
198
  result = f"These messages show patterns of {', '.join(label for label, _ in top_labels)} and are estimated to be {composite_score}% likely abusive."
199
 
200
- # Include pattern explanations
201
- for expl in top_explanations:
202
- if expl:
203
- result += f"\n• {expl}"
 
204
 
205
  # Show DARVO score
206
  if average_darvo > 0.25:
 
174
  base_score = sum(abuse_scores) / len(abuse_scores)
175
  label_sets = [[label for label, _ in r[2]] for r in results]
176
  label_counts = {label: sum(label in s for s in label_sets) for label in set().union(*label_sets)}
177
+ top_label = max(label_counts.items(), key=lambda x: x[1])
178
+ top_explanation = EXPLANATIONS.get(top_label[0], "")
179
 
180
  # Adjust flag-based weight relative to number of messages
181
  danger_weight = 5
 
197
  composite_score = round(min(composite_score, 100), 2) # re-cap just in case
198
  result = f"These messages show patterns of {', '.join(label for label, _ in top_labels)} and are estimated to be {composite_score}% likely abusive."
199
 
200
+ # Include pattern explanations
201
+ result = f"These messages show a pattern of **{top_label[0]}** and are estimated to be {composite_score}% likely abusive."
202
+
203
+ if top_explanation:
204
+ result += f"\n• {top_explanation}"
205
 
206
  # Show DARVO score
207
  if average_darvo > 0.25: