Permalink
Cannot retrieve contributors at this time
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?
ChatBot-ALL-Project/emotions.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
25 lines (24 sloc)
1.44 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |