ChatterBot icon indicating copy to clipboard operation
ChatterBot copied to clipboard

BestMatch not working as expected

Open Dulce06 opened this issue 6 years ago • 4 comments

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.

  1. It gives default response for few symbols, but not all of them.
  2. It gives default response for single digit numbers not not for others.
  3. 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

Dulce06 avatar Mar 07 '19 12:03 Dulce06

do you need to process the symbols or avoid them ?

ignertic avatar Apr 01 '19 23:04 ignertic

I just want to avoid them.

Dulce06 avatar Apr 11 '19 12:04 Dulce06

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

ignertic avatar Apr 11 '19 14:04 ignertic

https://chatterbot.readthedocs.io/en/stable/preprocessors.html

ignertic avatar Apr 11 '19 14:04 ignertic