BestMatch not working as expected
Hi,
I am using BestMatch adapter in chatterbot 1.0.0.
'import_path': 'chatterbot.logic.BestMatch', 'default_response': 'I am sorry, but I do not understand.', 'maximum_similarity_threshold': 0.65
I have executed the program and this is the conversation with the bot.
Type something to begin... Me : hi In response list Bot : Hello. What can I do for you? Me : my internet is slow In response list Bot : That's good to hear Me : , In response list Bot : I am sorry, but I do not understand. Me : @ In response list Bot : That's good to hear Me : In response list Bot : That's good to hear Me : I am sad In response list Bot : I am also good Me : 2345 In response list Bot : I am also good Me : 78900 In response list That's good to hear Me : 0 not in response list default response I am sorry, but I do not understand. Me : asdf In response list That's good to hear
So, these are not the expected answers. Have tried changing the threshold value but no luck.
- It gives default response for few symbols, but not all of them.
- It gives default response for single digit numbers not not for others.
- When I give a weird input like "asdf" / any negative sentence , it's response is "good to hear"/something irrelevant.
Low Confidence Adapter was working fine with the previous version (0.8.7). Have noticed this issue in this version.
Any suggestions.
@gunthercox @vkosuri
do you need to process the symbols or avoid them ?
I just want to avoid them.
You can achieve that by defining a pre-processor when you initialize your bot. Pre-processors are simple functions that handle the input before it's sent to the Adapters. For your case you could have a preprocessor function like this
-Place a new python file in the same directory as your bot named "my_preprocessor.py" and paste this
import string
def remove_symbols(statement):
for char in statement.text:
if char in string.punctuation:
statement.text.replace(char, '')
return statement
Save it and in your bot add "preprocessors"
from chatterbot import ChatBot
bot = ChatBot("BOT", preprocessors=["mypreprocessors.remove_symbols"])
No text with symbols will now reach your logic adapters
https://chatterbot.readthedocs.io/en/stable/preprocessors.html