gunthercox / ChatterBot

ChatterBot is a machine learning, conversational dialog engine for creating chat bots
https://chatterbot.readthedocs.io
BSD 3-Clause "New" or "Revised" License
14.1k stars 4.45k forks source link

Training from YML #1573

Closed jkries closed 5 years ago

jkries commented 5 years ago

I am struggling to train from my own custom YML files since the update. It was working in 0.8.7

Is there an example to allow training this way?

Here is my current code:

from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer

bot = ChatBot( "Chat Bot", storage_adapter="chatterbot.storage.SQLStorageAdapter", database="botData.sqlite3" )

bot.set_trainer(ChatterBotCorpusTrainer) bot.train("data/trainingdata.yml")

bot.set_trainer(ChatterBotCorpusTrainer) bot.train("data/trainingdata.yml")

When I run it I get this output:

I have successfully imported 287 rows of info and will now retrain... [nltk_data] Downloading package averaged_perceptron_tagger to [nltk_data] C:\Users\Kries\AppData\Roaming\nltk_data... [nltk_data] Package averaged_perceptron_tagger is already up-to- [nltk_data] date! [nltk_data] Downloading package punkt to [nltk_data] C:\Users\Kries\AppData\Roaming\nltk_data... [nltk_data] Package punkt is already up-to-date! [nltk_data] Downloading package stopwords to [nltk_data] C:\Users\Kries\AppData\Roaming\nltk_data... [nltk_data] Package stopwords is already up-to-date! Traceback (most recent call last): File "train.py", line 40, in bot.set_trainer(ChatterBotCorpusTrainer) AttributeError: 'ChatBot' object has no attribute 'set_trainer'

gunthercox commented 5 years ago

Hi @jkries, you just need to modify your code slightly for it to work with ChatterBot 1.0

from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

bot = ChatBot(
    "Chat Bot",
    storage_adapter="chatterbot.storage.SQLStorageAdapter",
    database="botData.sqlite3"
)

trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train("data/trainingdata.yml")
lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.