Best responses chatterbot
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 :))
Yes you could do by using preprocessers https://chatterbot.readthedocs.io/en/stable/preprocessors.html
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?
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)