SamanthaStorm commited on
Commit
520a4c4
·
verified ·
1 Parent(s): 612e2a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -91,18 +91,22 @@ raw_score_output = "\n".join(score_lines)
91
  else:
92
  resources = "For more information on abuse patterns, consider reaching out to support groups or professional counselors."
93
 
94
- # Prepare the result summary and detailed scores
95
- result = (
96
- f"Abuse Patterns Detected: {pattern_count} out of {len(PATTERN_LABELS)}\n"
97
-
98
- f"Abuse Level: {abuse_level}% - {abuse_description}\n"
99
-
100
- "The Danger Assessment is a validated tool used to help identify the level of risk for serious injury or homicide in cases of intimate partner violence.. "
101
- "It looks for specific abusive patterns that increase the likelihood of severe harm.\n"
102
-
103
- f"The messages just analyzed contain at least {danger_flag_count} critical flags.\n"
104
-
105
- f"Resources: {resources}"
 
 
 
 
106
  )
107
 
108
  # Return both a text summary and a JSON-like dict of scores per label
 
91
  else:
92
  resources = "For more information on abuse patterns, consider reaching out to support groups or professional counselors."
93
 
94
+ # Get top 2 highest scoring abuse patterns (excluding 'non_abusive')
95
+ scored_patterns = [(label, score) for label, score in zip(PATTERN_LABELS, scores[:14])]
96
+ top_patterns = sorted(scored_patterns, key=lambda x: x[1], reverse=True)[:2]
97
+ top_patterns_str = "\n".join([f"• {label.replace('_', ' ').title()}" for label, _ in top_patterns])
98
+
99
+ # Format final result
100
+ result = (
101
+ f"Abuse Risk Score: {abuse_level}% {abuse_description}\n"
102
+ "This message contains signs of emotionally harmful communication that may indicate abusive patterns.\n\n"
103
+ f"Most Likely Patterns:\n{top_patterns_str}\n\n"
104
+ f"⚠️ Critical Danger Flags Detected: {danger_flag_count} of 3\n"
105
+ "The Danger Assessment is a validated tool that helps identify serious risk in intimate partner violence. "
106
+ "It flags communication patterns associated with increased risk of severe harm. "
107
+ "For more info, consider reaching out to support groups or professionals.\n\n"
108
+ f"Resources: {resources}"
109
+ )
110
  )
111
 
112
  # Return both a text summary and a JSON-like dict of scores per label