Chatterbot with feedback
See original GitHub issueHi! I’m a beginner in ChatterBot and I’m very impressed with its features! Thank you in advance. But I’ve an interest in a feedback of user if the bot doesn’t be able to answer with the better solution. For example: if I ask “How are you?” and its database only has the answer “I’m fine”, and I want the answer “I’m not very well”, I will need to update the database with the new answer. In my code, I achieve it inserting two news sentences in my list “ans”. But asking new questions, the bot doesn’t deliver my wish answer, replacing the previous. And the examples at the GitHub “learning feedback” and “default response” seems doesn’t working very well (at least in my computer). Can you help me to impose to bot to choose the better answer based on my feedback? I would like to use the feedback to update directly the database, removing a statement of database, for in a new questioning, the bot already answer me with new entry. I don’t know how to remove a statement of database. In many tries, the answer didn’t change, altough the list updated… Thanks.
from chatterbot.trainers import ListTrainer
from chatterbot import ChatBot
question,answer,y,n="","","",""
bot = ChatBot('Answ Bot')
ans= ['How are you?', 'I'm fine','And you?','I'm fine too, thanks']
bot.set_trainer(ListTrainer)
bot.train(ans)
while True:
question= input("User: ")
answer= bot.get_response(question)
if float(question.confidence) > 0.5:
print('Answ Bot: ', answer)
print('Answ Bot: was my response good? [y/n]')
r1=input()
if r1=='y':
print('Answ Bot: thank you for feedback')
else:
print('Answ Bot: may you teach me a better answer?')
r2=ans.index(answer)
ans2=ans.copy()
del ans2[r2]
answer2 = input("User: ")
ans2.insert(r2,answer2)
bot.train(ans2)
print(ans2)
else:
print('I don't know the answer.')
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
This example
learning_feedback_example
might help you https://github.com/gunthercox/ChatterBot/blob/master/examples/learning_feedback_example.pyThis thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.