Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,24 +47,21 @@ def analyze_messages(input_text):
|
|
| 47 |
|
| 48 |
# First 14 = pattern scores
|
| 49 |
pattern_scores = scores[:14]
|
| 50 |
-
pattern_count = int(np.sum(pattern_scores > 0.
|
| 51 |
|
| 52 |
# Last 3 = danger cues
|
| 53 |
danger_scores = scores[14:]
|
| 54 |
-
danger_flag_count = int(np.sum(danger_scores > 0.
|
| 55 |
-
|
| 56 |
# (Optional) Print label-by-label for debugging
|
| 57 |
for i, s in enumerate(scores):
|
| 58 |
print(LABELS[i], "=", round(s, 3))
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
danger_assessment = "Low"
|
| 67 |
-
|
| 68 |
# Customize resource links based on Danger Assessment Score (with additional niche support)
|
| 69 |
if danger_assessment == "High":
|
| 70 |
resources = (
|
|
@@ -88,13 +85,13 @@ def analyze_messages(input_text):
|
|
| 88 |
"**Community Support:** Consider community-based and online support groups, especially those focused on LGBTQ+, immigrant, and neurodivergent survivors."
|
| 89 |
)
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
# Save the result to a temporary text file for download
|
| 99 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".txt", mode="w") as f:
|
| 100 |
f.write(result_md)
|
|
|
|
| 47 |
|
| 48 |
# First 14 = pattern scores
|
| 49 |
pattern_scores = scores[:14]
|
| 50 |
+
pattern_count = int(np.sum(pattern_scores > 0.15))
|
| 51 |
|
| 52 |
# Last 3 = danger cues
|
| 53 |
danger_scores = scores[14:]
|
| 54 |
+
danger_flag_count = int(np.sum(danger_scores > 0.20))
|
|
|
|
| 55 |
# (Optional) Print label-by-label for debugging
|
| 56 |
for i, s in enumerate(scores):
|
| 57 |
print(LABELS[i], "=", round(s, 3))
|
| 58 |
|
| 59 |
+
|
| 60 |
+
danger_assessment = (
|
| 61 |
+
"High" if danger_flag_count >= 2 else
|
| 62 |
+
"Moderate" if danger_flag_count == 1 else
|
| 63 |
+
"Low"
|
| 64 |
+
)
|
|
|
|
|
|
|
| 65 |
# Customize resource links based on Danger Assessment Score (with additional niche support)
|
| 66 |
if danger_assessment == "High":
|
| 67 |
resources = (
|
|
|
|
| 85 |
"**Community Support:** Consider community-based and online support groups, especially those focused on LGBTQ+, immigrant, and neurodivergent survivors."
|
| 86 |
)
|
| 87 |
|
| 88 |
+
|
| 89 |
+
# Prepare the output result with just pattern count and dynamic resources
|
| 90 |
+
result_md = (
|
| 91 |
+
f"**Abuse Pattern Count:** {pattern_count}\n\n"
|
| 92 |
+
f"**Support Resources:**\n{resources}"
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
# Save the result to a temporary text file for download
|
| 96 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".txt", mode="w") as f:
|
| 97 |
f.write(result_md)
|