1

I am trying to build a simple chat bot using Pythons's chatterbot.

I am training this bot with the help of ListTrainer.

I have created a txt file containing questions-answers.

Problem I am facing with it is that if answers contains multiple lines, bot includes only first line in response.

Can you please help me to solve this issue?

My code is as below-

from chatterbot.trainers import ListTrainer
from chatterbot import ChatBot
bot = ChatBot('MyBot')
conv = open('chats.txt','r').readlines()
bot.set_trainer(ListTrainer)
bot.train(conv)
while True:
   request = input('You:')
   response = bot.get_response(request)

print('Bot:',response)

And sample of chat.txt file is as below-

What are some common warning signs of stress and/or depression in men?

General signs of stress: Fast heart rate Muscle tension Increase in blood pressure Tense stomach Long-term signs of stress: Frequent cold or flu Headaches Trouble sleeping Skin problems

AnalyticsPy
  • 245
  • 2
  • 14
  • There is currently a feature request open for adding this functionality to ChatterBot https://github.com/gunthercox/ChatterBot/issues/962 Until that feature is added, one way to achieve this might be to store the responses as a single string separated by a newline character `\n` (or an equivalent line break) so that they display on seperate lines. – Gunther May 30 '18 at 11:41
  • @Gunther I have tried with newline character but it's not working. – AnalyticsPy May 30 '18 at 12:04

0 Answers0