Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
# Code written by Andrei starts here
# We did not have enough time to implement the function in our main program, but it was supposed to
# take the imput from the user and search for pronouns and nouns that together express the emotions of the user/ if the user asks the bot how it feels.
# After detecting the right emotion, the bot replies accordingly with a generic phrase.
def Emotions(userMsg):
"""Detects if the user says how he/she feels and replies in the right way."""
badFeelings = ["sad", "grumpy", "mad", "bored", "dull", "bad", "alone", "hurt", "nervous", "unhappy", "upset", "worried"]
goodFeelings = ["happy", "joy", "joyful", "good", "great", "alive", "excited"]
badResponse = ("Oh, I am so sorry to hear that. Maybe I can cheer you up with a joke?")
goodResponse = ("Niceee. I wish I had emotions, too. Instead, I have circuits.")
secondResponse = ("Well, I have no emotions, so I can't really answer that.")
firstPersonPronouns = ["i", "we", "me", "my"]
secondPersonPronouns = ["you", "your", "ya"]
userMsg = userMsg.lower()
for word in userMsg.split():
if word in firstPersonPronouns:
for word in userMsg.split():
if word in badFeelings:
return (badResponse)
if word in goodFeelings:
return (goodResponse)
if word in secondPersonPronouns:
return (secondResponse)
# Code written by Andrei ends here.