The ChatterBot python library is a great introduction to machine learning. It is very easy to create and train your own custom data by creating a YAML file. Luckily, ChatterBot has a custom corpus file and folder where you can add the content you want for the chat bot.
Naming a category
You want to start off naming the corpus category. It can be any topic you want.
categories:
- Hello
Writing dialog
Added dialog is important if you want the chat bot to reply with a specific answer. Your input is denoted by - - while the response for the bot is starts with - . After when you are done save the file in the custom folder. You can also add multiple YAML files to the custom folder.
conversations:
# Your input
- - hello
# Bot response
- world
The YAML file should look like this:
categories:
- Hello
conversations:
- - hello
- world
Training the custom file
You can now train the bot with the custom corpus that you created.
trainer = ChatterBotCorpusTrainer(bot)
trainer.train('chatterbot.corpus.custom')
The bot can be trained with multiple files within a folder. For example, we have a folder with various YAML files.
trainer.train('chatterbot.corpus.customFolder')
That's it for the quick introduction. For more information visit ChatterBot for documentation.
Top comments (5)
Hi, how do you access the custom corpus file and folder? I've had no luck trying to locate it on my own
AppData/local/Programs/Python/Python39/Lib/site-packages/chatterbot_corpus/data/custom/myown.yml
This should help :) and sry for the late reply i saw this post just now..
Hi. Can you add multiple categories into a single YAML file or do you need separate files?
Hello - I created a separate folder with various YAML files .
Thanks. I'll do that.