hi everyone!
I'm new in python and working with chatterbot to create a chatbot but problem is that i have no idea how to store _unanswered questions_ in a separate text file so that I can add their answers later.
i'll very thankful if anyone help me regarding this.
Hello @HassanSheraz,
I guess you will need to do it by yourself, I do not think the library can be configured to do that.
you can, for example, set the default answer to be -1 and check every answer returned by the library if it equals -1 then you have unanswered question that you can write it to a file or even store it in a database.
The BestMatch logical adapter has an option that would return a default response. Every time a default response is returned, the confidence level is 0. You can use this to write to a file.
You will be initiating the chatbot like so:
python
chatbot = ChatBot(
"MyChatBot",
logic_adapters = [
{
"import_path":"chatterbot.logic.BestMatch",
# other parameters for your chatbot
'default_response': "I can not answer this!"
}
]
)
Every time you do response = chatbot.get_response(), if the default response is through, response.confidence will be 0.
Thanks a lot both of you @habi3000 & @rohanrmallya
@rohanrmallya i applied this but shows me error i will be very thankful if you send me complete code please sir
@rohanrmallya i applied this but shows me error i will be very thankful if you send me complete code please sir
What is the error you are getting?
Most helpful comment
The BestMatch logical adapter has an option that would return a default response. Every time a default response is returned, the confidence level is 0. You can use this to write to a file.
You will be initiating the chatbot like so:
python chatbot = ChatBot( "MyChatBot", logic_adapters = [ { "import_path":"chatterbot.logic.BestMatch", # other parameters for your chatbot 'default_response': "I can not answer this!" } ] )Every time you do
response = chatbot.get_response(), if the default response is through,response.confidencewill be 0.