Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -60,7 +60,25 @@ def interpret_abuse_level(score):
|
|
60 |
return "Mild Concern"
|
61 |
else:
|
62 |
return "Very Low / Likely Safe"
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
def analyze_messages(input_text):
|
65 |
input_text = input_text.strip()
|
66 |
if not input_text:
|
@@ -97,11 +115,13 @@ def analyze_messages(input_text):
|
|
97 |
top_patterns = sorted(scored_patterns, key=lambda x: x[1], reverse=True)[:2]
|
98 |
top_patterns_str = "\n".join([f"• {label.replace('_', ' ').title()}" for label, _ in top_patterns])
|
99 |
|
|
|
|
|
|
|
100 |
# Format final result
|
101 |
result = (
|
102 |
-
f"Abuse Risk Score: {abuse_level}% – {abuse_description}\n"
|
103 |
-
"
|
104 |
-
f"Most Likely Patterns:\n{top_patterns_str}\n\n"
|
105 |
f"⚠️ Critical Danger Flags Detected: {danger_flag_count} of 3\n"
|
106 |
"The Danger Assessment is a validated tool that helps identify serious risk in intimate partner violence. "
|
107 |
"It flags communication patterns associated with increased risk of severe harm. "
|
|
|
60 |
return "Mild Concern"
|
61 |
else:
|
62 |
return "Very Low / Likely Safe"
|
63 |
+
EXPLANATIONS = {
|
64 |
+
"gaslighting": "Gaslighting involves making someone question their own reality or perceptions, often causing them to feel confused or insecure.",
|
65 |
+
"blame_shifting": "Blame-shifting is when one person redirects the responsibility for an issue onto someone else, avoiding accountability.",
|
66 |
+
"projection": "Projection involves accusing the victim of behaviors or characteristics that the abuser themselves exhibit.",
|
67 |
+
"dismissiveness": "Dismissiveness is the act of belittling or disregarding another person's thoughts, feelings, or experiences.",
|
68 |
+
"mockery": "Mockery involves ridiculing or making fun of someone in a hurtful way, often with the intent to humiliate them.",
|
69 |
+
"recovery_phase": "Recovery phase refers to dismissing or invalidating someone’s process of emotional healing, or ignoring their need for support.",
|
70 |
+
"insults": "Insults are derogatory remarks aimed at degrading or humiliating someone, often targeting their personal traits or character.",
|
71 |
+
"apology_baiting": "Apology-baiting is when the abuser manipulates the victim into apologizing for something the abuser caused or did wrong.",
|
72 |
+
"deflection": "Deflection is the act of avoiding responsibility or shifting focus away from one's own actions, often to avoid accountability.",
|
73 |
+
"control": "Control tactics are behaviors that restrict or limit someone's autonomy, often involving domination, manipulation, or coercion.",
|
74 |
+
"extreme_control": "Extreme control involves excessive manipulation or domination over someone’s actions, decisions, or behaviors.",
|
75 |
+
"physical_threat": "Physical threats involve any indication or direct mention of harm to someone’s physical well-being, often used to intimidate or control.",
|
76 |
+
"suicidal_threat": "Suicidal threats are statements made to manipulate or control someone by making them feel responsible for the abuser’s well-being.",
|
77 |
+
"guilt_tripping": "Guilt-tripping involves making someone feel guilty or responsible for things they didn’t do, often to manipulate their behavior.",
|
78 |
+
"emotional_manipulation": "Emotional manipulation is using guilt, fear, or emotional dependency to control another person’s thoughts, feelings, or actions.",
|
79 |
+
"manipulation": "Manipulation refers to using deceptive tactics to control or influence someone’s emotions, decisions, or behavior to serve the manipulator’s own interests.",
|
80 |
+
"non_abusive": "Non-abusive language is communication that is respectful, empathetic, and free of harmful behaviors or manipulation."
|
81 |
+
}
|
82 |
def analyze_messages(input_text):
|
83 |
input_text = input_text.strip()
|
84 |
if not input_text:
|
|
|
115 |
top_patterns = sorted(scored_patterns, key=lambda x: x[1], reverse=True)[:2]
|
116 |
top_patterns_str = "\n".join([f"• {label.replace('_', ' ').title()}" for label, _ in top_patterns])
|
117 |
|
118 |
+
|
119 |
+
top_pattern_explanations = "\n".join([f"• {label.replace('_', ' ').title()}: {EXPLANATIONS.get(label, 'No explanation available.')}" for label, _ in top_patterns])
|
120 |
+
|
121 |
# Format final result
|
122 |
result = (
|
123 |
+
f"Abuse Risk Score: {abuse_level}% – {abuse_description}\n\n"
|
124 |
+
f"Most Likely Patterns:\n{top_pattern_explanations}\n\n"
|
|
|
125 |
f"⚠️ Critical Danger Flags Detected: {danger_flag_count} of 3\n"
|
126 |
"The Danger Assessment is a validated tool that helps identify serious risk in intimate partner violence. "
|
127 |
"It flags communication patterns associated with increased risk of severe harm. "
|