ChatterBot icon indicating copy to clipboard operation
ChatterBot copied to clipboard

Best responses chatterbot

Open JDZC opened this issue 6 years ago • 3 comments

Hey! I'm actually using chatterbot lib for my final project on college and I have a doubt about the training.

It's possible to the chatbot catch some user input to give the response? Example:

User: My favorite color is **black** Bot: my favorite is also **get response from the user**

There's anyway to do that?

Thanks for te attention :))

JDZC avatar Sep 16 '19 23:09 JDZC

Yes you could do by using preprocessers https://chatterbot.readthedocs.io/en/stable/preprocessors.html

vkosuri avatar Sep 17 '19 03:09 vkosuri

I read the article of the preprocessers, but I do not understand how to use it and how to get the user input, could you show me in an exampla, please?

JDZC avatar Sep 23 '19 16:09 JDZC

For if i use clearn white spacess, it will removed unwanted spaces between charecters

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot import preprocessors

# Create a new chat bot named Charlie
chatbot = ChatBot(
    'Bob the Bot',
    preprocessors=[
        'chatterbot.preprocessors.clean_whitespace'
    ]
)

trainer = ListTrainer(chatbot)

trainer.train([
    "Hi,     can   I help you?",
    "Sure,     I'd like to      book a flight    to Iceland.",
    "Your    flight   has been booked."
])

# Get a response to the input text 'I would like to book a flight.'
response = chatbot.get_response('I would like to book a flight.')

print(response)

vkosuri avatar Oct 08 '19 15:10 vkosuri