def can_process(self, statement): self.data = keywords.get_topic(statement.text, parse_location=False) if "name" in self.data.keys(): return self.data["name"] == "restaurant" return False
def main(): print("Hello! I am C1C0. I can answer questions and execute commands.") while True: # gets a tuple of phrase and confidence answer = live_streaming.main() speech = live_streaming.get_string(answer) confidence = live_streaming.get_confidence(answer) print(speech) # speech = input() if "quit" in speech or "stop" in speech: break if("cico" in speech.lower() or "kiko" in speech.lower() or "c1c0" in speech.lower()) and \ ("hey" in speech.lower()): # filter out cico since it messes with location detection speech = utils.filter_cico(speech) if face_recognition.isFaceRecognition(speech): print(face_recognition.faceRecog(speech)) # task is to transfer over to facial recognition client program elif path_planning.isLocCommand(speech.lower()): print("Move command: ") command = path_planning.process_loc(speech.lower()) print(command) runFromChatBot(command) # task is to transfer over to path planning on the system elif object_detection.isObjCommand(speech.lower()): print("Object to pick up: " + object_detection.object_parse(speech.lower())) # task is to transfer over to object detection on the system else: # we don't want the text to be lowercase since it messes with location detection response = "Sorry, I don't understand." data = keywords.get_topic(speech, parse_location=False) keywords.modify_topic_data(data, parse_location=True) if "name" in data.keys() and data["name"] == "weather": api_data = weather.lookup_weather_today_city( data["info"]["location"]["name"]) response = make_response.make_response_api(data, api_data) elif "name" in data.keys() and data["name"] == "restaurant": api_data = restaurant.lookup_restaurant_city( data["info"]["location"]["name"]) response = make_response.make_response_api(data, api_data) else: # Q&A system response = get_topic(speech) print(response)
def main(): live_streaming.delete_file() weather.import_keys() while True: #gets a tuple of phrase and confidence answer = live_streaming.main() speech = live_streaming.get_string(answer) confidence = live_streaming.get_confidence(answer) if speech == "quit": break topic = keywords.get_topic(speech) print(topic) if topic["name"] == "weather": print("weather is called") weather_data = weather.lookup_weather_today_city("ithaca new york") # print(weather_data) response = make_response.make_response_api(topic, weather_data) print(response) elif topic["name"] == "restaurant": print("restaurant is called") restaurant_data = restaurant.lookup_restaurant_city( "ithaca new york") response = make_response.make_response_api(topic, restaurant_data) print(response)
def main(): print("Hello! I am C1C0. I can answer questions and execute commands.") while True: # gets a tuple of phrase and confidence answer = live_streaming.main() speech = live_streaming.get_string(answer) confidence = live_streaming.get_confidence(answer) # speech = input() print(speech) before = time.time() response = "Sorry, I don't understand" if "quit" in speech.lower() or "stop" in speech.lower(): scheduler.close() break if ("cico" in speech.lower() or "kiko" in speech.lower() or "c1c0" in speech.lower()) and ("hey" in speech.lower()): # filter out cico since it messes with location detection question, question_type = nlp_util.is_question(speech) speech = utils.filter_cico(speech) + " " print("Question type: " + question_type) if not question and face_recognition.isFaceRecognition(speech): response = "executing facial recognition..." face_recognition.faceRecog(speech) # task is to transfer over to facial recognition client program elif (not question or question_type == "yes/no question") and path_planning.isLocCommand( speech.lower()): response = path_planning.process_loc(speech.lower()) # task is to transfer over to path planning on the system scheduler.communicate("path-planning" + ' ' + str(response)) elif (not question or question_type == "yes/no question") and object_detection.isObjCommand( speech.lower()): pick_up = object_detection.object_parse(speech.lower()) if pick_up: response = "Object to pick up: " + pick_up # task is to transfer over to object detection on the system scheduler.communicate("object-detection" + ' ' + response) else: response = "Sorry, I can't recognize this object." else: if question: print("C1C0 is thinking...") data = keywords.get_topic(speech, parse_location=False) keywords.modify_topic_data(data, parse_location=True) if "name" in data.keys() and (data["name"] == "weather" or data["name"] == "restaurant"): if USE_AWS: response = requests.get( url + weather_restaurant_route, params={"speech": speech}, ) if response.ok: response = response.text else: response = "Bad request" elif data["name"] == "weather": api_data = weather.lookup_weather_today_city( data["info"]["location"]["name"]) response = make_response.make_response_api( data, api_data) elif data["name"] == "restaurant": api_data = restaurant.lookup_restaurant_city( data["info"]["location"]["name"]) response = make_response.make_response_api( data, api_data) else: # Q/A section if USE_AWS: response = requests.get(url + chatbot_qa_route, params={"speech": speech}) if response.ok: response = response.text # print(response) response = ast.literal_eval(response) answers = response["answers"][0]["answer"] # for i in range(len(answers)): # print(f'Answer {i}: {answers[i]}') # this is response with highest score, we need to keep all answers somewhere # response = response['answers'][0]['answer'] response = response["answers"][0]["answer"] else: response = "Bad request" else: response = "Sorry, I can't answer this right now." if type(response) == list: i = 0 while i < len(response): answer = response[i]['answer'] if i == 0: print( f'I think the answer is {answer}. Is this correct?' ) else: print( f'Ok, got it. Is the answer then {answer}?' ) user_response = live_streaming.main() user_response = live_streaming.get_string( user_response) user_response = user_response.lower() print(user_response) if 'yes' in user_response or 'yeah' in user_response: break else: response = sentiment.get_sentiment(speech, USE_AWS) print('Response: ', response) after = time.time() print("Time: ", after - before)
from util import utils USE_AWS = True weather_restaurant_route = "weather_restaurant" url = "http://3.13.116.251/" if __name__ == "__main__": utils.set_classpath() with open("restuarant_weather_efficiency_questions.txt") as f: correct = 0 i = 0 faster = 0 aws_faster = 0 for line in f: start_time = time.time() topic_data = keywords.get_topic(line) if topic_data["name"] == "restaurant": data = restaurant.lookup_restaurant_city( topic_data["info"]["location"]["name"] ) response = make_response.make_response_api(topic_data, data) if topic_data["name"] == "weather": data = weather.lookup_weather_today_city( topic_data["info"]["location"]["name"] ) response = make_response.make_response_api(topic_data, data) end_time = time.time() print("--- %s seconds ---" % (end_time - start_time)) start_time_aws = time.time() response = requests.get( url + weather_restaurant_route,