def locationNameDiff(): global occassion global attraction_type global bars_type global restuarant_type global malls_type global cusine cusine = '' oc = None if occassion != '': oc = occassion remove_type(oc) occassion = '' findlocations.utilreset() if categoryDescription == "Attractions": sug = response.suggesstions(attraction_type) elif categoryDescription == "Bars & Clubs": sug = response.suggesstions(bars_type) elif categoryDescription == "Food & Beverages": sug = response.suggesstions(restuarant_type) elif categoryDescription == "Malls & Shops": sug = response.suggesstions(malls_type) setloc_prop() print(loc_prop) if categoryDescription == "Food & Beverages": sug = response.suggesstions(["Yes", "No"]) resp = response.responseSuggestions( f"Are you looking for some specific cusine?", sug) else: resp = response.responseSuggestions( f"Which kind of activity are you currently interested in?", sug) return resp
def attraction(resp): print(resp) global categoryDescription global tags global loc_prop print(loc_prop) categoryDescription = resp['queryResult']['parameters'][ 'categoryDescription'] print(categoryDescription) categoryDescription = categoryDescription.title() if categoryDescription == "Attractions": sug = response.suggesstions([ "Adventure", "Arts", "History & Culture", "Leisure & Recreation", "Nature & WildLife", "Others" ]) elif categoryDescription == "Bars & Clubs": sug = response.suggesstions(bars_type) elif categoryDescription == "Food & Beverages": sug = response.suggesstions(restuarant_type) elif categoryDescription == "Malls & Shops": sug = response.suggesstions(malls_type) setloc_prop() print(loc_prop) if categoryDescription == "Food & Beverages": sug = response.suggesstions(["Yes", "No"]) resp = response.responseSuggestions( f"Are you looking for some specific cusine?", sug) else: resp = response.responseSuggestions( f"Which kind of activity are you currently interested in?", sug) return resp
def metBefore(): sug = response.suggesstions([ "Find Places near me", "Shopping", "Find Food", "Attractions", "Bars & Clubs" ]) if user_name != '': resp = response.responseSuggestions( f"{user_name},How can I help you today?", sug) else: resp = response.responseSuggestions(f"How can I help you today?", sug) return resp
def knowMore(): sug = response.suggesstions( ["Find Places near me", "Shopping", "Find Food", "Attractions"]) if user_name != '': resp = response.responseSuggestions( f"{user_name},I am Yellow Pages a congnitive chat bot. Your complete on the go companion around Singapore. I can tell interesting facts about places and help you get around places in your locality. How can I help you today?", sug) else: resp = response.responseSuggestions( f"I am Yellow Pages a congnitive chat bot. Your complete on the go companion around Singapore. I can tell interesting facts about places and help you get around places in your locality. How can I help you today?", sug) return resp
def locationNamegetPrice(): global uuid global categoryDescription global priceC global priceA global priceS global priceO resp = {} global loc_prop if "Get Fare" in loc_prop: loc_prop.remove("Get Fare") ticketed = util.getTicketed(cat_description[categoryDescription], uuid) if not ticketed: sug = response.suggesstions(loc_prop[:7]) resp = response.responseSuggestions( f"Entry to {loc_dict[loc_dict['uuid']==uuid]['name'].iloc[0]} is free", sug) else: if util.getPrice(cat_description[categoryDescription], uuid): [priceC, priceA, priceS, priceO] = util.getPrice(cat_description[categoryDescription], uuid) if priceC != '': print(util.getPrice(cat_description[categoryDescription], uuid)) if priceC.replace(".", "").isdigit(): priceC = float(priceC) if priceA == '': priceA = priceC priceA = float(priceA) sug = response.suggesstions(["Yes", "No"]) resp = response.responseSuggestions( f"Would you like to share details about number of travellers with you?", sug) else: sug = response.suggesstions(loc_prop[:7]) resp = response.responseSuggestions(f"{priceC}", sug) else: sug = response.suggesstions(loc_prop[:7]) resp = response.responseSuggestions( f"Admission rates of {loc_dict[loc_dict['uuid']==uuid]['name'].iloc[0]} has recently changed.Details for the same can be checked by their management", sug) else: sug = response.suggesstions(loc_prop[:7]) resp = response.responseSuggestions( f"Entry to {loc_dict[loc_dict['uuid']==uuid]['name'].iloc[0]} is free", sug) print(resp) return resp
def locationNameAddressyes(): global name global user_lat global user_lgn global uuid global categoryDescription global number_adults global number_children global occassion global tags global loc_prop loc_prop = '' name = loc_dict[loc_dict["uuid"] == uuid]["name"].iloc[0] user_lat = float(loc_dict[loc_dict["uuid"] == uuid]["lat"].iloc[0]) user_lgn = float(loc_dict[loc_dict["uuid"] == uuid]["lng"].iloc[0]) tags = '' uuid = '' occassion = '' categoryDescription = '' number_adults = '' number_children = '' sug = response.suggesstions( ["Shopping", "Find Food", "Attractions", "Bars & Clubs"]) resp = response.responseSuggestions("What would you like to do?", sug) return resp
def mainMenu(): l = [ "Find Places near me", "Shopping", "Find Food", "Attractions", "Bars & Clubs" ] sug = response.suggesstions(l) resp = response.responseSuggestions(f"How can I help you today?", sug) return resp
def locationNamegetPriceAdults(req): global number_adults print(req) number_adults = float(req['queryResult']['parameters']['number']) sug = ["One", "Two", "Three", "Four"] sug = response.suggesstions(sug) resp = response.responseSuggestions(f"...and how many children?", sug) return resp
def getCusine(): global uuid global loc_prop cusine = loc_dict[loc_dict["uuid"] == uuid]["cusine"].iloc[0] cusine = cusine.split(',') print(cusine) desc = f"{loc_dict[loc_dict['uuid']==uuid]['name'].iloc[0]} specializes in:\n" for i in range(len(cusine)): desc += f"{i+1}. {cusine[i]}\n" sug = response.suggesstions(loc_prop[:7]) resp = response.responseSuggestions(desc, sug) return resp
def locationNamegetOpenTime(): global loc_prop global uuid global categoryDescription if "Open Time" in loc_prop: loc_prop.remove("Open Time") sug = response.suggesstions(loc_prop[:7]) desc = "It would open soon" if util.getOpeningTime(cat_description[categoryDescription], uuid): openT = util.getOpeningTime(cat_description[categoryDescription], uuid) desc = f"{loc_dict[loc_dict['uuid']==uuid]['name'].iloc[0]} opens at {openT}" resp = response.responseSuggestions(f"{desc}", sug) return resp
def locationNamegetPriceno(): global priceC global priceA global priceS global priceO global loc_dic desc = "Here are the ticket price:\n" desc += "Adult:S$" + str(priceA) + "\n" desc += "Child:S$" + str(priceC) + "\n" print(desc) sug = response.suggesstions(loc_prop[:7]) resp = response.responseSuggestions(desc, sug) print(resp) return resp
def locationNameClosingTime(): global uuid global categoryDescription global loc_prop if "Close Time" in loc_prop: loc_prop.remove("Close Time") sug = response.suggesstions(loc_prop[:7]) desc = "The place would close in the evening" if util.getClosingTime(cat_description[categoryDescription], uuid): closeT = util.getClosingTime(cat_description[categoryDescription], uuid) desc = f"{loc_dict[loc_dict['uuid']==uuid]['name'].iloc[0]} closes at {closeT}" resp = response.responseSuggestions(f"{desc}", sug) return resp
def locationCat(req): global categoryDescription global user_lat global user_lgn reset_all() loc_name = req['queryResult']['parameters']['loc'] categoryDescription = req['queryResult']['parameters'][ 'categoryDescription'] categoryDescription = categoryDescription.title() print(loc_name + " " + categoryDescription) if loc_name == "near me" and (user_lat == '' or user_lgn == ''): resp = response.permissions(["DEVICE_PRECISE_LOCATION"], "Can we know your location?") else: user_lat, user_lgn = getloc.getlatlong(loc_name) print(user_lat, user_lgn) if categoryDescription == "Attractions": sug = response.suggesstions([ "Adventure", "Arts", "History & Culture", "Leisure & Recreation", "Nature & WildLife", "Others" ]) elif categoryDescription == "Bars & Clubs": sug = response.suggesstions(bars_type) elif categoryDescription == "Food & Beverages": sug = response.suggesstions(restuarant_type) elif categoryDescription == "Malls & Shops": sug = response.suggesstions(malls_type) setloc_prop() if categoryDescription == "Food & Beverages": sug = response.suggesstions(["Yes", "No"]) resp = response.responseSuggestions( f"Are you looking for some specific cusine?", sug) else: resp = response.responseSuggestions( f"Which kind of activity are you currently interested in?", sug) return resp
def locationNameGetReview(): global loc_prop global uuid global categoryDescription if "Reviews" in loc_prop: loc_prop.remove("Reviews") sug = response.suggesstions(loc_prop[:7]) review = util.getReviewList(cat_description[categoryDescription], uuid) if review: review = review[random.randint(0, len(review) - 1)] desc = "Here is what " + review["authorName"] + " says:\n" desc = desc + "Rated:" + str(review["rating"]) + " stars" + "\n" desc = desc + review["text"] + "\n" else: desc = "Be the first to Review the place..." resp = response.responseSuggestions(f"{desc}", sug) return resp
def locationGetMoreInfo(req): global loc_prop if "Get More Info" in loc_prop: loc_prop.remove("Get More Info") print(req) sug = response.suggesstions(loc_prop[:7]) global uuid global categoryDescription body = util.getDescription(cat_description[categoryDescription], uuid) body = util.getBody(cat_description[categoryDescription], uuid) singAward = util.getAwards(cat_description[categoryDescription], uuid) if singAward != '' or singAward is not None: body.append( f"{loc_dict[loc_dict['uuid']==uuid]['name'].iloc[0]}, is awarded with Singapore Tourism Award for best tourist place" ) b = body.pop(random.randint(0, len(body) - 1)) resp = response.responseSuggestions(f"Did you know?\n {b}", sug) return resp
def locationNameNearestMrt(): global loc_prop global uuid global categoryDescription if "Nearest MRT" in loc_prop: loc_prop.remove("Nearest MRT") sug = response.suggesstions(loc_prop[:7]) mrt = util.getMrt(cat_description[categoryDescription], uuid) desc = "There are currently no MRTs near this location" if mrt: if len(mrt) == 1: desc = f"Nearest MRT to {loc_dict[loc_dict['uuid']==uuid]['name'].iloc[0]} is " for i in range(len(mrt)): desc = desc + "\n" f"{mrt[i]}" else: desc = f"Nearest MRT to {loc_dict[loc_dict['uuid']==uuid]['name'].iloc[0]} are" for i in range(len(mrt)): desc = desc + "\n" f"{mrt[i]}" resp = response.responseSuggestions(f"{desc}", sug) return resp
def locationNameisOpen(): global uuid global categoryDescription global loc_prop if "Is Open" in loc_prop: loc_prop.remove("Is Open") isOpen = util.isOpen(cat_description[categoryDescription], uuid) desc = "" if isOpen: timeToClose = util.timeToClose(cat_description[categoryDescription], uuid) desc = f"Its open currently and will close in {timeToClose}" print(desc) else: if util.nextOpen(cat_description[categoryDescription], uuid): desc = "Sorry its currently closed " + util.nextOpen( cat_description[categoryDescription], uuid) print(desc) else: desc = "Its currently closed but it would be open soon!!" sug = response.suggesstions(loc_prop[:7]) resp = response.responseSuggestions(f"{desc}", sug) return resp
def locationNamegetPriceChildren(req): global number_adults global number_children global priceC global priceA global loc_dict print(priceA) print(priceC) if number_adults == '': number_adults = 0 if number_children == '': number_children = 0 number_children = int(req['queryResult']['parameters']['number']) print(number_children) desc = "It would be a total of: \n" desc = desc + "Adults:S$" + str(priceA * number_adults) + "\n" desc = desc + "Children:S$" + str(priceC * number_children) + "\n" desc = desc + "Total:S$" + str(priceA * number_adults + priceC * number_children) sug = response.suggesstions(loc_prop[:7]) resp = response.responseSuggestions(desc, sug) print(resp) return resp
def attractionno(): sug = response.suggesstions(restuarant_type) resp = response.responseSuggestions("Where would you like to go?", sug) print(resp) return resp
def attractionyes(): sug = response.suggesstions(["Local", "Indian", "Chinese", "Japanese"]) resp = response.responseSuggestions( "Are you looking for some specific dish or cusine?", sug) return resp
def locationNamegetPriceyes(): sug = ["One", "Two", "Three", "Four"] sug = response.suggesstions(sug) resp = response.responseSuggestions( f"How many adults are travelling with you?", sug) return resp
def actions_intent_PERMISSION(req): global user_name global user_lat global user_lgn global categoryDescription permissionGranted = req["originalDetectIntentRequest"]["payload"][ "inputs"][0]["arguments"][0]["textValue"] permissionAsked = req["originalDetectIntentRequest"]["payload"]["user"][ "permissions"] resp = {} if "NAME" in permissionAsked and "DEVICE_PRECISE_LOCATION" not in permissionAsked: resp = mainMenu() sug = response.suggesstions(["met before", "know more"]) if permissionGranted == "true": user_name = req["originalDetectIntentRequest"]["payload"]['user'][ 'profile']['givenName'] resp = response.responseSuggestions( f"Hey {user_name},Have we met before or would you like to know more about me?", sug) else: resp = response.responseSuggestions( f"Have we met before or would you like to know more about me?", sug) elif "DEVICE_PRECISE_LOCATION" in permissionAsked: if permissionGranted == "true" and user_lat == '' and user_lgn == '' and categoryDescription == '': sug = response.suggesstions( ["Attraction", "Shopping", "Find Food"]) user_lat = math.radians( req["originalDetectIntentRequest"]["payload"]["device"] ['location']['coordinates']['latitude']) user_lgn = math.radians( req["originalDetectIntentRequest"]["payload"]["device"] ['location']['coordinates']['longitude']) resp = response.responseSuggestions( "What would you like to do today?", sug) elif permissionGranted == "true" and user_lat == '' and user_lgn == '' and categoryDescription != '': user_lat = math.radians( req["originalDetectIntentRequest"]["payload"]["device"] ['location']['coordinates']['latitude']) user_lgn = math.radians( req["originalDetectIntentRequest"]["payload"]["device"] ['location']['coordinates']['longitude']) if categoryDescription == "Attractions": sug = response.suggesstions([ "Adventure", "Arts", "History & Culture", "Leisure & Recreation", "Nature & WildLife", "Others" ]) elif categoryDescription == "Bars & Clubs": sug = response.suggesstions(bars_type) elif categoryDescription == "Food & Beverages": sug = response.suggesstions(restuarant_type) elif categoryDescription == "Malls & Shops": sug = response.suggesstions(malls_type) setloc_prop() if categoryDescription == "Food & Beverages": sug = response.suggesstions(["Yes", "No"]) resp = response.responseSuggestions( f"Are you looking for some specific cusine?", sug) else: resp = response.responseSuggestions( f"Which kind of activity are you currently interested in?", sug) return resp else: resp = mainMenu() else: resp = mainMenu() return resp