1

Is it possible to train a chatbot (using ChatterBot) with an existing database?

I have a relatively large sqlite3 db file with about 3GB worth of conversations. If it's at all possible to just pull answers from that database instead of converting it to json and then creating my own corpus I'd like to do so.

That said when I follow their tutorial.

from chatterbot import ChatBot

bot = ChatBot( "Terminal",
    storage_adapter="chatterbot.storage.SQLStorageAdapter",
    logic_adapters=[
    "chatterbot.logic.MathematicalEvaluation",
    "chatterbot.logic.TimeLogicAdapter",
    "chatterbot.logic.BestMatch"
    ],
    input_adapter="chatterbot.input.TerminalAdapter",
    output_adapter="chatterbot.output.TerminalAdapter",
    database="database.db"
   )

print("Type something to begin...")

while True:
    try:
        bot_input = bot.get_response(None)


    except (KeyboardInterrupt, EOFError, SystemExit):
        break

It doesn't pull its answers from that. It ignores it and uses its own training data.

suroh
  • 917
  • 1
  • 10
  • 26

1 Answers1

3

It is possible, but you would need to write your own Trainer class to read your sqlite file's content so that the chat bot could be trained with it.

Another way to do this would be to write a script to convert your sqlite data to a training corpus format so that you can train your bot with it using the existing methods.

More information about the corpus format can be found here: http://chatterbot-corpus.readthedocs.io/en/latest/data.html

Gunther
  • 2,474
  • 4
  • 31
  • 45
  • Getting an answer from you directly is awesome btw! I figured that was the case and I ended up converting everything to a training file. I had so much data it took quite a while. Probably would’ve been easier to just write a training class for it lol. – suroh May 04 '18 at 21:40