gunthercox / chatterbot-corpus

A multilingual dialog corpus
http://chatterbot-corpus.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.36k stars 1.15k forks source link

mathematical_evaluation adopter is not handling invalid equations like four plus xyz #171

Open AhmadManzoor opened 4 years ago

AhmadManzoor commented 4 years ago

what is eight plus x Traceback (most recent call last): File "chatbot.py", line 22, in response = chatbot.get_response(inputtext) File "/home/abubakar/.local/lib/python3.6/site-packages/chatterbot/chatterbot.py", line 139, in get_response response = self.generate_response(input_statement, additional_response_selection_parameters) File "/home/abubakar/.local/lib/python3.6/site-packages/chatterbot/chatterbot.py", line 173, in generate_response if adapter.can_process(input_statement): File "/home/abubakar/.local/lib/python3.6/site-packages/chatterbot/logic/mathematical_evaluation.py", line 33, in can_process response = self.process(statement) File "/home/abubakar/.local/lib/python3.6/site-packages/chatterbot/logic/mathematical_evaluation.py", line 59, in process mathparse.parse(expression, language=self.language.ISO_639.upper()) File "/home/abubakar/.local/lib/python3.6/site-packages/mathparse/mathparse.py", line 279, in parse return evaluate_postfix(postfix) File "/home/abubakar/.local/lib/python3.6/site-packages/mathparse/mathparse.py", line 211, in evaluate_postfix a = stack.pop() IndexError: pop from empty list

AhmadManzoor commented 4 years ago

this is my code and i entered

what is eight plus x

from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer, ListTrainer

# Create a new chat bot named Charlie
chatbot = ChatBot('casino',
    read_only=True,
    default_response= 'I am sorry, but I do not understand.',
    maximum_similarity_threshold = 0.95,
    logic_adapters=[
            'chatterbot.logic.BestMatch',
            'chatterbot.logic.TimeLogicAdapter',
            'chatterbot.logic.MathematicalEvaluation'
    ])

trainer = ChatterBotCorpusTrainer(chatbot)
trainer.train('/home/abubakar/Desktop/casino.yml')
trainer.train("chatterbot.corpus.english")
inputtext=input('what do you want to know: ')
for i in range(100):

    response = chatbot.get_response(inputtext)
    # print(response)
    inputtext=input(response)