Can't feedback learning
Dear gunthercox: My English is not very good. If the statement is not smooth, please forgive me.
After updating the new version 1.0.0, I found that ChatterBot could not complete the feedback learning. By looking https://github.com/gunthercox/ChatterBot/issues/1553, I also found that this issue may not only in the new version. After chatbot train first, i run my code:
Begin feedback learning: User: What is the game of Saint Setya? Bot: Is "What is the game of Saint Setya?" "What is Saint Setya?"'s real response? User:n Please input real response: User(real):The Saint Seiya is a game released by Leju Company. Bot: study+1 User:What is the game of Saint Setya? Bot: Is "What is the game of Saint Setya?" "What is Saint Setya?"'s real response?
As a newbie, I hope the author can improve the ChatterBot or give me some guidance. Thank you very much.
My code as follow: (PS:saintseiya.yml likes ai.yml)
from chatterbot import ChatBot
from chatterbot.conversation import Statement
from chatterbot.trainers import ChatterBotCorpusTrainer
chatbot = ChatBot(
'Thomas',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
database="botData.sqlite3"
)
trainer = ChatterBotCorpusTrainer(chatbot)
trainer.train(
#'chatterbot.corpus.chinese',
'data/saintseiya.yml'
)
def get_feedback():
text = input("User:")
if 'y' in text.lower():
return False
return True
print('Begin feedback learning:')
while True:
try:
text=input('User:')
if text=='stop':
break
input_statement = Statement(text)
response = chatbot.generate_response(input_statement)
print('Bot:Is "{}" "{}"\'s real response? \n'.format(
response.text,
input_statement.text
))
print('Please input y/Yes or other/No: ')
if get_feedback():
print('Please input real response:')
correct_response = Statement(text=input("User(real):"))
chatbot.learn_response(correct_response, input_statement)
print('Bot:study+1!')
else:
print('Bot:'+response.text)
except (KeyboardInterrupt, EOFError, SystemExit):
break
@gunthercox I have the same issue. Did you check it already?
Sorry, I haven't had a chance to look into this yet. It's amazing how fast time goes by!
I have the same Issue here aswell. I had a look into the database the bot uses and it adds the information of the learned statement correctly. But somehow the search doesn't work correctly. Additionally I'm always getting a confidence value of 0. If you need further details, I'll would like provide them to help to fix the bug. I've already checked the source code but except for #1589 and #1608 I couldn't find anything propably related to this problem.
Hello Everybody, I have a simple workaround how somebody still can train the bot on demand:
trainer= ListTrainer(bot)
def get_feedback():
if 'stop' == str(input_statement):
return False
last_input_statement=[]
while True:
try:
input_statement = (input(bcolors.bold + "You: " + bcolors.endc))
response = bot.get_response(input_statement)
if get_feedback() is False:
print("Please enter something more funny")
correct_response = input()
last_input_statement.append(correct_response)
trainer.train(last_input_statement)
print("Response added to Chatbot")
last_input_statement.clear()
else:
last_input_statement.clear()
last_input_statement.append(str(input_statement))
print(bcolors.bold + "Chatty: "+ bcolors.endc + str(response))
# Press ctrl-c or ctrl-d on the keyboard to exit
except (KeyboardInterrupt, EOFError, SystemExit):
print(bcolors.fail + " Bye!" + bcolors.endc)
break