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
'''Data referenced from https://apps.worldwritable.com/tutorials/chatbot/ '''
# Sentences for responding the user
MyDictionary={
"GREETING_KEYWORDS":["hello", "hi", "greetings", "sup", "what's up"],
"GREETING_RESPONSES":["'sup bro", "hey", "*nods*", "hey you get my snap?"],
"REFUSE":["no","nah","not"],
"AGREE":["yes","sure","agreed","why not"],
"EMOTION_POSITIVE":["happy","thrilled","enjoyed","yo","high spirits"],
"EMOTION_NEGATIVE":["sad","blue","dissatisfied","heck","hell no"]
}
'''Referenced data ends here'''
def ref(category):
catName=[]
for j,k in MyDictionary.items(): #listing a whole dictionary
catName.append(j)
for i in catName:
if (category.upper()).strip() == i:
return i
if (category.upper()).strip() not in catName:
return False
'''Function checks if a value is in a specified dictionary'''
def isRef(word):
try:
for j,k in MyDictionary.items(): #listing a whole dictionary
for i in k: #looping through the dictionary
for p in word.split():
if (p.lower()).strip()==i:
return True
else:
continue
continue
continue
except:
print("Invalid input!")
print("Type of i: ",type(i),";type of p: ",type(p))
else:
return False
'''Debugger'''
#print(isRef(input("Test a word: ")))
#print(ref(input("Test a word: ")))
'''Debugger ends here'''