#coding: utf-8 *
from chatterbot.trainers import ListTrainer
from chatterbot import ChatBot
import os
bot = ChatBot('BORIS')
bot = bot.set_trainer(ListTrainer)
for _file in os.listdir('Chats'): #percorrer os arquivos em chats
lines = open('Chats/' + _file, 'r').readlines() #lendo as linhas
bot.train(lines)
Ao rodar no terminal:
[nltk_data] Downloading package stopwords to
[nltk_data] /home/francine/nltk_data...
[nltk_data] Package stopwords is already up-to-date!
[nltk_data] Downloading package averaged_perceptron_tagger to
[nltk_data] /home/francine/nltk_data...
[nltk_data] Package averaged_perceptron_tagger is already up-to-
[nltk_data] date!
Traceback (most recent call last):
File "trainee.py", line 8, in <module>
bot = bot.set_trainer(ListTrainer)
AttributeError: 'ChatBot' object has no attribute 'set_trainer'
Da esse erro, mas o moço de um vídeo fez exatamente assim e deu certo, não sei o que tem de errado