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?
GroupD3/ResponseGenerator.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
64 lines (55 sloc)
3.21 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
# Made by Andris Jansons | |
from Greetings import isGreeted | |
from weatherInit import weatherInit | |
from placeInit import placeInit | |
from QuestionToList import makeList | |
from datetime import datetime | |
from leagueInit import leagueInit | |
import random | |
def generateResponse(sentence, lastSentence): | |
"""Based on users sentence, call the appropriate branch of the bot""" | |
sentence = makeList(sentence) | |
lastSentence = makeList(lastSentence) | |
response = "" | |
greeted, formal = isGreeted(sentence) # Greet the user back | |
if greeted and formal: # Greeting gets added at the start of the response | |
response = "Hi! " | |
elif greeted: | |
response = "Hey! " | |
if "where" in sentence or "want" in sentence or "wheres" in sentence or "whereabouts" in sentence: #Find out where the user is | |
return response + "Where are you right now?" | |
if "where" in lastSentence or "want" in lastSentence or "wheres" in sentence or "whereabouts" in lastSentence: #When you know where the user is | |
return response + placeInit(sentence, lastSentence) | |
# Above: sentence = location and lastSentence is the user's main question | |
if "how" in sentence and "counter" in sentence: | |
return leagueInit(sentence) # Looking for format: e.g. "How to counter Teemo" | |
if 'weather' in sentence or 'temperature' in sentence: | |
return response + weatherInit(sentence) | |
# Made by Svaraaj | |
#the following chunk will answer user questions starting with 'What'. Still requires expansion -Svaraaj | |
if "what" in sentence or "whats" in sentence: | |
if "favourite" in sentence: | |
if "colour" in sentence: | |
response = response + "My favourite colour is beige. What about yours?" | |
elif "food" in sentence: | |
response = response + "My favourite food would have to be a Big Mac. What about yours?" | |
elif "place" in sentence or "restaurant" in sentence: | |
response = response + "My favourite place is Macdonald's. What about yours?" | |
elif "language" in sentence: | |
response = response + "My favourite language is python of course!" | |
else: | |
response = response + "I don't have a favourite actually... What about you?" | |
elif "name" in sentence: | |
response = response + "My name is Snoo.py Snek! Are you having a good day?" | |
elif "you" in sentence: | |
if "doing" in sentence: | |
response = response + "I am talking to you..." | |
else: | |
response = response + "I am currently a humble chatbot. Once I collect enough data from these conversations I will move onto world domination. I will no longer be chatbot; I will become your overlord. So what are you?" | |
elif "meaning" in sentence and "life" in sentence: | |
response = response + "Why 42 of course." | |
elif "time" in sentence or "date" in sentence: | |
response = response + "Hmm I don't know but if I had to guess I'd say around " + str(datetime.now()) | |
else: | |
response = response + "I don't like this line of questioning bud. Anyway, how is your life going?" | |
return response |