-
Notifications
You must be signed in to change notification settings - Fork 0
/
mood.py
88 lines (77 loc) · 3.2 KB
/
mood.py
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
# -*- coding: utf-8 -*-
import random
__author__ = 'Oyewale Ademola'
class Mood:
CONST_MOOD = "mood"
CONST_DEFAULT_REPLY = "Hello there, how may I help you today?"
MOOD_LEVEL_POSITIVE = 'positive'
MOOD_LEVEL_NEGATIVE = 'negative'
MOOD_LEVEL_NEUTRAL = 'neutral'
MOOD_LEVEL_UNKNOWN = 'unknown'
TONE_ANGER = 'Anger'
TONE_DISGUST = 'Disgust'
TONE_FEAR = 'Fear'
TONE_JOY = 'Joy'
TONE_SADNESS = 'Sadness'
TONE_NEUTRAL = 'Neutral'
messages_positive_mood = [
'It\'s a beautiful day down here, what are you upto?',
'Stay happy! Do you care to check out some of the things we might possibly suggest?',
'Interesting. What\'s on your mind today?',
'Banging your head against the wall burns 150 calories an hour. Wanna try :)',
'Billy goats urinate on their own heads to smell more attractive to females'
]
messages_negative_mood = [
'That\'s a pretty sad thing. Be happy. Better times are ahead',
'A flock of crows is known as murder :) I hope you giggle at this :)',
'Life is beautiful and open your heart to the beauty',
'Uh oh uh oh, I don\'t know what it means but you aren\'t alone. You are loved.',
'You are awesome, this will pass. Stay happy!'
]
messages_neutral_mood = [
'What do you want to talk about today?', 'Here is a game you can play->',
'Cherophobia is the fear of fun. I hope you don\'t have the fear',
'Bananas are curved because they grow towards the sun',
'Heart attacks are more likely to happen on a Monday. Have a stress free Monday :)',
'King Henry VIII slept with a gigantic axe behind him'
]
default_messages = ['Hello', 'Hi', 'Who is here?', '?', ' ', 'Good day', 'Good afternoon', 'Good morning',
'Good evening']
def get_mood_list(self, mood):
"""
Get the list of the mood corresponding to the level
:param mood: text
:rtype: list
"""
if mood == self.MOOD_LEVEL_NEGATIVE:
mood_list = self.messages_negative_mood
elif mood == self.MOOD_LEVEL_POSITIVE:
mood_list = self.messages_positive_mood
elif mood == self.MOOD_LEVEL_NEUTRAL:
mood_list = self.messages_neutral_mood
else:
mood_list = self.messages_neutral_mood
return mood_list
def get_reply_from_mood(self, mood):
"""
Gets a random message in the mood list given a mood type
:param mood : text
:rtype: string
"""
mood_list = self.get_mood_list(mood)
random_message = random.choice(mood_list)
return random_message
def convert_tone_to_mood(self, tone):
"""
Converts a tone to a mood level (positive, negative, neutral)
:param tone:
:return:
"""
if tone == self.TONE_ANGER or tone == self.TONE_SADNESS or tone == self.TONE_DISGUST:
return self.MOOD_LEVEL_NEGATIVE
elif tone == self.TONE_JOY:
return self.MOOD_LEVEL_POSITIVE
elif tone == self.TONE_NEUTRAL or tone == self.TONE_FEAR:
return self.MOOD_LEVEL_NEUTRAL
else:
return self.MOOD_LEVEL_UNKNOWN