SamanthaStorm commited on
Commit
2d95c7b
·
verified ·
1 Parent(s): 744dcb8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -18
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.5))
51
 
52
  # Last 3 = danger cues
53
  danger_scores = scores[14:]
54
- danger_flag_count = int(np.sum(danger_scores > 0.5))
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
- # Map danger flag count to Danger Assessment Score
61
- if danger_flag_count >= 2:
62
- danger_assessment = "High"
63
- elif danger_flag_count == 1:
64
- danger_assessment = "Moderate"
65
- else:
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
- # Prepare the output result with both scores
92
- result_md = (
93
- f"**Abuse Pattern Count:** {pattern_count}\n\n"
94
- f"**Danger Assessment Score:** {danger_assessment}\n\n"
95
- f"**Support Resources:**\n{resources}"
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)