chatterbot only delivers a character as response

Asked

Viewed 50 times

-1

I’m studying about the chatterbot and in the first training test appeared that he just handed me the first characters as an answer, someone knows explain to me why?

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
import os

bot = ChatBot('teste')
treino = ListTrainer(bot)

diretorio = '/Users/archo/PycharmProjects/untield/venv/testechatbot/treinadores/'
for treinadores in os.listdir(diretorio):
    treino.train(diretorio + treinadores)

while True:
    req = str(input("Voce: "))
    req = bot.get_response(req)
    print('Bot: ' + str(req))

[nltk_data] Downloading package averaged_perceptron_tagger to

[nltk_data] /Users/archo/nltk_data...

[nltk_data] Package averaged_perceptron_tagger is already up-to-

[nltk_data] date!

[nltk_data] Downloading package stopwords to /Users/archo/nltk_data...

[nltk_data] Package stopwords is already up-to-date!

List Trainer: [####################] 100%

List Trainer: [####################] 100%

List Trainer: [####################] 100%

List Trainer: [####################] 100%

You: hi

Bot: t

You: good morning

Bot: the

i made a subdirectory called coaches with. yml files to train him

1 answer

0


I found the error, were the files in YAML that for some reason were not being read, nor those of chatterbot-corpus. I redid the training files in json and they worked

import json

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

with open('treino.json') as f:
    words = json.load(f)
bot = ChatBot('teste', read_only=True)
treinador = ListTrainer(bot)
teste = words["conversations"]
treinador.train(teste)

Browser other questions tagged

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