Skip to content
Permalink
Browse files
Reordered determineUserInput sentence type code
  • Loading branch information
mateussa committed Nov 15, 2017
1 parent bab8bf4 commit d595663e4440b250f7f3b6d3a12731a6389136f8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
@@ -66,15 +66,11 @@ def askSomething(answerType, sendMessages, noAnswers, defaultAnswer):
break
break

if (answer[1] in [2, 4]): # If the user asked a how or are question
if (answer[1] == 2): # If the user asked a how or are question
sendMessage(answer[0], False)
sendMessage(noAnswers[0])
noAnswers.pop(0)
elif (answer[1] == 3): # If the user asked a what question
sendMessage("The answer to that is {}.".format(answer[0]), False)
sendMessage(noAnswers[0])
noAnswers.pop(0)
elif (answer[1] == 7): # If the user doesn't want to answer
elif (answer[1] == 5): # If the user doesn't want to answer
sendMessage("You should, it would be more fun!")
noAnswers.pop(len(noAnswers) - 1)
else:
@@ -114,7 +110,7 @@ def oneQuestion():

# If question set of multiple type
if (questionSet["Type"] == "multiple"):
receivedMessage = askSomething(5, [questionSet["Question"],
receivedMessage = askSomething(3, [questionSet["Question"],
"A: {}".format(questionSet["A"]),
"B: {}".format(questionSet["B"]),
"C: {}".format(questionSet["C"]),
@@ -123,7 +119,7 @@ def oneQuestion():
"Hmmm, I see you are afraid of making a mistake."], "X")
# If question set of boolean type
else:
receivedMessage = askSomething(5, [questionSet["Question"],
receivedMessage = askSomething(3, [questionSet["Question"],
"A: {}".format(questionSet["A"]),
"B: {}".format(questionSet["B"])],
["You can choose one of the options.",
@@ -172,7 +168,7 @@ def quizChallange(nrQuestions):
for questionSet in qChaSet:
# If question set of multiple type
if (questionSet["Type"] == "multiple"):
receivedMessage = askSomething(5, [questionSet["Question"],
receivedMessage = askSomething(3, [questionSet["Question"],
"A: {}".format(questionSet["A"]),
"B: {}".format(questionSet["B"]),
"C: {}".format(questionSet["C"]),
@@ -181,7 +177,7 @@ def quizChallange(nrQuestions):
"Hmmm, I see you are afraid of making a mistake."], "X")
# If question set of boolean type
else:
receivedMessage = askSomething(5, [questionSet["Question"],
receivedMessage = askSomething(3, [questionSet["Question"],
"A: {}".format(questionSet["A"]),
"B: {}".format(questionSet["B"])],
["You can choose one of the options.",
@@ -21,15 +21,15 @@ def determineUserInput(sentence):
sentenceParse.insert(0, " ".join(sentenceParse[0:2]))

if sentenceParse[0] in questionStarters: # ------------- execute the "what is" code here ---------------
response = respondQuestion(sentence)
response = respondQuestion(sentence), 2
elif sentenceParse[0] in greetings:
response = getName(sentence), 1
elif sentence in "abcd":
response = sentence, 5
response = sentence, 3
elif (sentence.casefold() == "Yes".casefold()) or (sentence.casefold() == "No".casefold()):
response = sentence, 6
response = sentence, 4
elif sentence in notAnswer:
response = sentence, 7
response = sentence, 5
else:
response = sentence, 0
return response
@@ -93,11 +93,11 @@ randomJokes = ["Knock, knock!/ Who’s there?/ Opportunity!/ That is impossible.
def respondQuestion(sentence):
newSentence = sentence.split()
if newSentence[0] in ["how","hows"]:
response = executeHow(sentence), 2
response = executeHow(sentence)
elif newSentence[0] in ["what","whats"]:
response = executeWhat(sentence), 3
response = executeWhat(sentence)
elif newSentence[0] == "are":
response = executeAre(sentence), 4
response = executeAre(sentence)
elif newSentence[0] == "tell":
response = executeTell(sentence)
elif newSentence[0]== "do":
@@ -1,9 +1,7 @@
##### Return Input Type Code #####
0 - Not Recognized
1 - Get Name From Sentence
2 - How Question
3 - What Question
4 - Are Question
5 - ACBD Answer Question Choice
6 - Yes/ No Answer
7 - Don't Want To Answer
2 - Questions
3 - ACBD Answer Question Choice
4 - Yes/ No Answer
5 - Don't Want To Answer

0 comments on commit d595663

Please sign in to comment.