Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
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 |
-
#
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
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
|