How to add external training in chatterbot

Asked

Viewed 786 times

0

I created a very simple bot to learn how to use chatterbot. This library already comes with a training, but I wanted to put an extra training with the import of a corpus in Portuguese that I found on github.

from chatterbot import ChatBot

bot = Futaba(
"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_uri="../database.db"
)

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

while True:
    try:
        bot_input = bot.get_response(None)
    except (KeyboardInterrupt, EOFError, SystemExit):
        break

That’s all I got.

How can I import this corpus into my chatbot?

1 answer

1


The answer took a long time to come and you probably already got it, but just for the record:

from chatterbot.trainers import ChatterBotCorpusTrainer
bot = ChatBot('bot')
trainer = ChatterBotCorpusTrainer(bot)
trainer.train('arquivoDeTreino.yml')

The file . yml is the file where the conversation is that will be used for bot training. If you want a file example, use these: https://github.com/gunthercox/chatterbot-corpus/tree/master/chatterbot_corpus/data/portuguese

It is also possible to train the bot with a same txt file, where each line is a sentence coming from the user or bot, for this instead of Chatterbotcorpustrainer, you use Listtrainer. Anything you can look at the Chatterbot documentation that has it all explained there. https://chatterbot.readthedocs.io/en/stable/training.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.