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/why.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
26 lines (22 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
import random | |
answer = ["Is it how your friends call you?", "Is it how your mom call you?", "It is just your opinion"] | |
words_ans = ("To be better than you", "To beat you", "To make silly conversations") | |
'''Function to get ChatBot information related to "why?" questions. Giving particular answer to a user depends on the keyword which he used after "why."''' | |
def sentence_why(sentence): | |
if "why" in sentence: | |
if "stupid" in sentence: | |
print (random.choice(answer)) | |
elif 'made' in sentence or 'create' in sentence or 'build' in sentence or 'exist' in sentence: | |
print(random.choice(words_ans)) | |
elif "answer" in sentence: | |
print("I don't know the answer, because I am still learning.") | |
elif "don't know" in sentence: | |
print("Because I am still learning.") | |
elif "dumb" in sentence: | |
print("Is it how your friends call you?") | |
elif "ask" in sentence: | |
print("Because I am curious and I wanna know.") | |
elif "sky is blue" in sentence: | |
print( "A clear cloudless day-time sky is blue because molecules in the air\n scatter blue light from the sun more than they scatter red light.\n When we look towards the sun at sunset, we see red and orange colours\n because the blue light has been scattered out and away from the line of sight.") | |
else: | |
print("I am not sure if I understand what you mean.") | |