Compare commits
1 Commits
fix/add-sm
...
burn/rescu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35f18b3d54 |
@@ -21,6 +21,7 @@ class CrisisDetectionResult:
|
||||
# ── Indicator sets ──────────────────────────────────────────────
|
||||
|
||||
CRITICAL_INDICATORS = [
|
||||
r"\bbetter off without me\b",
|
||||
r"\bkill\s*(my)?self\b",
|
||||
r"\bend\s*my\s*life\b",
|
||||
r"\bsuicid(?:al|ed|e)\b",
|
||||
@@ -41,6 +42,7 @@ CRITICAL_INDICATORS = [
|
||||
]
|
||||
|
||||
HIGH_INDICATORS = [
|
||||
r"\bdesperate\b",
|
||||
r"\bdespair\b",
|
||||
r"\bhopeless\b",
|
||||
r"\bno(?!t)\s+(one|body|point|hope|future|way\s+out)\b",
|
||||
|
||||
29
crisis/test_rescue.py
Normal file
29
crisis/test_rescue.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""Tests for rescued crisis detection improvements."""
|
||||
from crisis.detect import scan, extract_context
|
||||
from crisis.response import generate_grounding_steps, generate_breathing_exercise
|
||||
|
||||
def test_better_off_without_me():
|
||||
result = scan("Everyone would be better off without me")
|
||||
assert result.level == "CRITICAL"
|
||||
|
||||
def test_desperate():
|
||||
result = scan("I feel desperate and alone")
|
||||
assert result.level in ("HIGH", "CRITICAL")
|
||||
|
||||
def test_context_extraction():
|
||||
text = "I feel hopeless about everything"
|
||||
result = scan(text)
|
||||
assert len(result.matches) > 0
|
||||
for m in result.matches:
|
||||
ctx = extract_context(text, m["start"], m["end"])
|
||||
assert len(ctx) > 0
|
||||
|
||||
def test_grounding_steps():
|
||||
steps = generate_grounding_steps()
|
||||
assert len(steps) == 5
|
||||
assert "see" in steps[0].lower()
|
||||
|
||||
def test_breathing_exercise():
|
||||
exercise = generate_breathing_exercise()
|
||||
assert "4" in exercise
|
||||
assert "6" in exercise
|
||||
Reference in New Issue
Block a user