Chatterbot: How to store chatterbot's unanswered questions in a text file?

Created on 2 Feb 2020  路  5Comments  路  Source: gunthercox/ChatterBot

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.

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.confidence will be 0.

All 5 comments

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

filipceglik picture filipceglik  路  3Comments

proguy627 picture proguy627  路  3Comments

cesarandreslopez picture cesarandreslopez  路  4Comments

vkosuri picture vkosuri  路  4Comments

gunthercox picture gunthercox  路  3Comments