Spaces:
Paused
Paused
File size: 2,035 Bytes
823a3a8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | """
Recommendation engine based on risk assessment
"""
from config.settings import RECOMMENDATIONS
class RecommendationEngine:
"""
Provides appropriate recommendations based on analysis results
"""
def __init__(self):
self.recommendations = RECOMMENDATIONS
def get_recommendations(self, primary_indicator, risk_level, suicidal_flagged=None):
"""
Get tailored recommendations based on primary indicator and risk level
"""
# Handle high-risk suicidal cases first
if risk_level in ['high', 'moderate_high'] and suicidal_flagged:
return self.recommendations['suicidal']
# Get recommendations based on primary indicator
if primary_indicator in self.recommendations:
return self.recommendations[primary_indicator]
# Default to normal if unknown
return self.recommendations['normal']
def get_crisis_resources(self):
"""
Return crisis resources for high-risk situations
"""
return {
'title': "🚨 Crisis Resources",
'resources': [
"**National Emergency Services:** Call 112",
"**Mentally Aware Nigeria Initiative (MANI):** 08062106493",
"**She Writes Woman:** 08099769974",
"**Lagos State Help Line:** 767 or 112"
],
'message': "These resources provide immediate, confidential support 24/7."
}
def format_recommendations(self, recommendations_dict):
"""
Format recommendations for display
"""
if not recommendations_dict:
return ""
formatted = f"### {recommendations_dict['title']}\n\n"
formatted += f"{recommendations_dict['message']}\n\n"
for i, tip in enumerate(recommendations_dict['tips'], 1):
formatted += f"{i}. {tip}\n"
return formatted |