-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecommend.py
More file actions
221 lines (207 loc) Β· 11.2 KB
/
Copy pathrecommend.py
File metadata and controls
221 lines (207 loc) Β· 11.2 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import random
from typing import Dict, List, Optional
class RecommendationEngine:
"""Handles mood-based recommendations"""
RECOMMENDATIONS = {
"joy": {
"songs": [
"π΅ Upbeat Pop - Try artists like Dua Lipa, Lizzo, or The Weeknd",
"π΅ Classic Feel-Good - Queen, Stevie Wonder, Earth Wind & Fire",
"π΅ Happy Hip-Hop - Chance the Rapper, Pharrell Williams",
"π΅ Indie Pop Vibes - COIN, Two Door Cinema Club, Foster the People",
"π΅ Dance/Electronic - Calvin Harris, Daft Punk, Disclosure"
],
"quotes": [
"Happiness is not something ready made. It comes from your own actions. - Dalai Lama",
"The best time to plant a tree was 20 years ago. The second best time is now.",
"Success is not final, failure is not fatal: it is the courage to continue that counts. - Winston Churchill",
"Life is what happens when you're busy making other plans. - John Lennon",
"The only way to do great work is to love what you do. - Steve Jobs"
],
"activities": [
"π Call someone you love and tell them why they matter",
"π³ Take a walk outside and notice 5 beautiful things",
"π¨ Try a creative project - draw, write, or build something",
"πΈ Take photos of things that make you smile",
"π° Bake something delicious for yourself or others"
]
},
"sadness": {
"songs": [
"π΅ Gentle Acoustic - Bon Iver, Iron & Wine, Fleet Foxes",
"π΅ Comfort Music - Your personal comfort songs work best",
"π΅ Healing Vibes - Lo-fi playlists or ambient music",
"π΅ Soft R&B - Frank Ocean, SZA, Daniel Caesar",
"π΅ Indie Folk - Phoebe Bridgers, Julien Baker, Big Thief"
],
"quotes": [
"This too shall pass.",
"You are stronger than you think and more resilient than you know.",
"It's okay to not be okay sometimes. Healing isn't linear.",
"Every storm runs out of rain. - Maya Angelou",
"The wound is the place where the Light enters you. - Rumi"
],
"activities": [
"π Take a warm bath with calming music",
"π Write in a journal - let it all out",
"π« Make your favorite warm drink and savor it slowly",
"π§Έ Practice gentle self-care activities",
"π± Watch comforting videos or shows from your childhood"
]
},
"anger": {
"songs": [
"π΅ High Energy Rock - Foo Fighters, Green Day, Paramore",
"π΅ Intense Workout Music - Whatever gets your energy out",
"π΅ Metal/Hard Rock - Metallica, Linkin Park, Rage Against the Machine",
"π΅ Aggressive Hip-Hop - Eminem, DMX, Run the Jewels",
"π΅ Transition to Calm - After releasing energy, try something soothing"
],
"quotes": [
"Anger is an acid that can do more harm to the vessel than to anything it pours upon.",
"You have power over your mind - not outside events. Realize this, and you will find strength. - Marcus Aurelius",
"The best fighter is never angry. - Lao Tzu",
"Holding onto anger is like drinking poison and expecting the other person to die.",
"Speak when you are angry and you will make the best speech you will ever regret."
],
"activities": [
"π Go for a run or do intense cardio",
"π₯ Try a boxing workout or hit a punching bag",
"π§ Practice deep breathing - 4 counts in, 6 counts out",
"π Write out your feelings, then tear up the paper",
"π§Ή Channel energy into cleaning or organizing"
]
},
"fear": {
"songs": [
"π΅ Calming Instrumentals - Max Richter, Γlafur Arnalds",
"π΅ Empowering Songs - BeyoncΓ©, Alicia Keys, Kelly Clarkson",
"π΅ Meditation Music - Nature sounds or ambient tracks",
"π΅ Confidence Builders - Songs that make you feel strong",
"π΅ Familiar Comfort - Play music that feels safe and known"
],
"quotes": [
"Courage is not the absence of fear, but action in spite of it.",
"You are braver than you believe, stronger than you seem, and smarter than you think. - A.A. Milne",
"Feel the fear and do it anyway. - Susan Jeffers",
"The cave you fear to enter holds the treasure you seek. - Joseph Campbell",
"Everything you've ever wanted is on the other side of fear. - George Addair"
],
"activities": [
"π§ Practice mindfulness or guided meditation",
"π Read inspiring stories of people overcoming challenges",
"πͺ List 10 things you've successfully overcome before",
"π€ Talk to someone you trust about what's worrying you",
"π¬οΈ Try the 5-4-3-2-1 grounding technique"
]
},
"surprise": {
"songs": [
"π΅ Discovery Mode - Try a completely new genre today",
"π΅ World Music - Explore sounds from different cultures",
"π΅ Throwback Hits - Songs from a decade you don't usually listen to",
"π΅ Experimental Music - Jazz fusion, art rock, or electronic",
"π΅ Random Shuffle - Let algorithms surprise you"
],
"quotes": [
"Life is full of surprises - embrace them all.",
"The unexpected can be the most beautiful part of life.",
"Stay curious and open to new experiences.",
"Surprises keep life interesting and full of possibilities.",
"Every day holds the potential for something amazing."
],
"activities": [
"π² Try something completely new today - a food, place, or hobby",
"π Explore a neighborhood in your city you've never visited",
"π¨ Experiment with a new art form or creative medium",
"π± Learn something random on YouTube for 30 minutes",
"πͺ Be spontaneous - do the first fun thing that comes to mind"
]
},
"disgust": {
"songs": [
"π΅ Cleansing Music - Fresh, uplifting indie or pop",
"π΅ Reset Playlist - Music for a fresh start and new perspective",
"π΅ Nature Sounds - Rain, ocean waves, or forest ambiance",
"π΅ Positive Energy - Upbeat songs that lift your mood",
"π΅ Gentle Transition - Soft music to shift your mindset"
],
"quotes": [
"Sometimes you need distance to see things clearly.",
"A fresh perspective can transform any situation.",
"Focus on what you can control and let go of what you can't.",
"This feeling will pass. Choose to focus on something beautiful.",
"Clean surroundings lead to a clearer mind."
],
"activities": [
"π§Ή Clean and organize your immediate space",
"πΏ Take a refreshing shower and change into clean clothes",
"πΏ Spend time in nature - fresh air helps reset your mood",
"π Do something to completely change your environment",
"π± Watch something wholesome or funny to shift your mindset"
]
},
"neutral": {
"songs": [
"π΅ Background Music - Lo-fi, ambient, or instrumental",
"π΅ Study/Focus Music - Minimal beats or classical",
"π΅ Whatever's Familiar - Your usual go-to music",
"π΅ Seasonal Music - Something that matches the current weather",
"π΅ Nostalgic Tunes - Songs that bring back good memories"
],
"quotes": [
"In stillness, we find clarity.",
"Sometimes doing nothing is doing something.",
"Peace comes from within. Do not seek it without. - Buddha",
"The present moment is the only time over which we have dominion. - ThΓch NhαΊ₯t HαΊ‘nh",
"Contentment is natural wealth, luxury is artificial poverty. - Socrates"
],
"activities": [
"π Read quietly - fiction, non-fiction, or poetry",
"β Enjoy a drink mindfully without distractions",
"π
Watch the sky - clouds, sunset, or stars",
"π― Focus on a simple, satisfying task",
"π§ Just sit quietly and observe your thoughts"
]
}
}
@staticmethod
def get_recommendation(emotion: str, rec_type: str) -> str:
"""Get a random recommendation for the given emotion and type"""
emotion = emotion.lower()
# for handling edge cases
if not emotion or not rec_type:
return "Please specify both emotion and recommendation type"
if emotion not in RecommendationEngine.RECOMMENDATIONS:
return f"No recommendations available for emotion: {emotion}"
recommendations = RecommendationEngine.RECOMMENDATIONS[emotion].get(rec_type, [])
if not recommendations:
return f"No {rec_type} recommendations available for {emotion}"
return random.choice(recommendations)
@staticmethod
def get_all_recommendations(emotion: str) -> Dict[str, str]:
"""Get one recommendation of each type for an emotion"""
return {
'songs': RecommendationEngine.get_recommendation(emotion, 'songs'),
'quotes': RecommendationEngine.get_recommendation(emotion, 'quotes'),
'activities': RecommendationEngine.get_recommendation(emotion, 'activities')
}
@staticmethod
def add_custom_recommendation(emotion: str, rec_type: str, recommendation: str) -> bool:
"""Add a custom recommendation for future personalization"""
if not all([emotion, rec_type, recommendation]):
return False
emotion = emotion.lower()
if emotion in RecommendationEngine.RECOMMENDATIONS:
if rec_type in RecommendationEngine.RECOMMENDATIONS[emotion]:
RecommendationEngine.RECOMMENDATIONS[emotion][rec_type].append(recommendation)
return True
return False
@staticmethod
def get_available_emotions() -> List[str]:
"""Get list of all available emotions"""
return list(RecommendationEngine.RECOMMENDATIONS.keys())
@staticmethod
def get_available_types() -> List[str]:
"""Get list of all recommendation types"""
return ['songs', 'quotes', 'activities']