def test_get_most_frequent_response(self): statement_list = [ Statement(text='What... is your quest?', in_response_to='Hello'), Statement(text='What... is your quest?', in_response_to='Hello'), Statement(text='This is a phone.', in_response_to='Hello'), Statement(text='This is a phone.', in_response_to='Hello'), Statement(text='This is a phone.', in_response_to='Hello'), Statement(text='This is a phone.', in_response_to='Hello'), Statement(text='A what?', in_response_to='Hello'), Statement(text='A what?', in_response_to='Hello'), Statement(text='A phone.', in_response_to='Hello') ] for statement in statement_list: self.chatbot.storage.create( text=statement.text, in_response_to=statement.in_response_to ) output = response_selection.get_most_frequent_response( Statement(text='Hello'), statement_list, self.chatbot.storage ) self.assertEqual('This is a phone.', output.text)
def test_get_most_frequent_response(self): statement_list = [ Statement('What... is your quest?', in_response_to=[Response('Hello', occurrence=2)]), Statement('This is a phone.', in_response_to=[Response('Hello', occurrence=4)]), Statement('A what?', in_response_to=[Response('Hello', occurrence=2)]), Statement('A phone.', in_response_to=[Response('Hello', occurrence=1)]) ] output = response_selection.get_most_frequent_response( Statement('Hello'), statement_list ) self.assertEqual('This is a phone.', output)
def test_get_most_frequent_response(self): statement_list = [ Statement(text='What... is your quest?', in_response_to='Hello'), Statement(text='What... is your quest?', in_response_to='Hello'), Statement(text='This is a phone.', in_response_to='Hello'), Statement(text='This is a phone.', in_response_to='Hello'), Statement(text='This is a phone.', in_response_to='Hello'), Statement(text='This is a phone.', in_response_to='Hello'), Statement(text='A what?', in_response_to='Hello'), Statement(text='A what?', in_response_to='Hello'), Statement(text='A phone.', in_response_to='Hello') ] for statement in statement_list: self.chatbot.storage.create( text=statement.text, in_response_to=statement.in_response_to) output = response_selection.get_most_frequent_response( Statement(text='Hello'), statement_list, self.chatbot.storage) self.assertEqual('This is a phone.', output.text)
print( "Olá! Sou o aluno robô da Universidade Federal do ABC, como posso te ajudar?" ) # The following loop will execute each time the user enters input while True: try: duvida = False print( "\nHomem de Verde: Digite aqui sua pergunta que gostaria de fazer para mim" ) pergunta = input("Você: ") input_statement = bot.input.process_input_statement(pergunta) response_list = bot.storage.filter() response = response_selection.get_most_frequent_response( input_statement, response_list) bot.output.process_response(response) print('\nHomem de Verde: "{}" é uma resposta coerente para "{}"? \n'. format(response, input_statement)) if get_feedback() == True: print( "Homem de verde: Por favor insira qual seria a resposta correta" ) response1 = input("Você: ") response1_statement = bot.input.process_input_statement(response1) bot.learn_response(response1_statement, input_statement) print("Homem de Verde: Resposta adicionada!") # Press ctrl-c or ctrl-d on the keyboard to exit except (KeyboardInterrupt, EOFError, SystemExit):