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/Check.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
61 lines (53 sloc)
2.38 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
def checky(inp): #Check for different variations of "Yes" | |
inp = inp.lower() #Turn input into lowercase | |
YES = ["yes","y","yup","yeah","sure","correct"] #list of different variations of yes | |
x = 0 | |
while x < len(YES): #Loop through the whole of the list | |
if inp == (YES[x]): | |
return True #return true if the input is a variation of "yes" | |
x +=1 | |
else: | |
return False #return false if the input is not in the list | |
def checkn(inp): #Check for different variations of "No" | |
inp = inp.lower() | |
NO = ["no","n","nah","nope","no way"] | |
x = 0 | |
while x < len(NO): | |
if inp == (NO[x]): | |
return True | |
x +=1 | |
else: | |
return False | |
def checkbye(inp): #Check for different variations of "Bye" | |
inp = inp.lower() | |
Bye = ["bye","cya","see you","later"] | |
x = 0 | |
while x < len(Bye): | |
if inp == (Bye[x]): | |
return True | |
x +=1 | |
else: | |
return False | |
def checkw(inp): #Check for different variations of "Weather" | |
ExList = ["sunday","rainman"] | |
Weather = ["weather","sun","cloud","rain","hail","snow","fog","thunder","lightning",] | |
x = 0 | |
insentence = inp.split() #Split sentence into words | |
while x < len(Weather): #Loop through list of "weather" variations | |
z = 0 | |
while z < len(insentence): #Loop through the number of words in the sentence | |
if Weather[x] in insentence[z]: #If 1 of the weather variations is in the sentence | |
y = 0 | |
excep = False #Boolean variable for detecting if an exception word is found | |
while y < len(ExList): | |
if (ExList[y]) == insentence[z]: #If the weather variation word is part of an exception word | |
y += 1 | |
excep = True | |
else: | |
y += 1 | |
if y == len(ExList) and excep == False: #If the word is not in the exception list at all | |
return True #Return True meaning that a valid weather variation is found | |
z += 1 | |
x += 1 | |
else: | |
return False #return false if no weather words found or they are in exceptions | |