Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AhmadManzoor opened this issue Nov 22, 2019 · 1 comment

Comments

@AhmadManzoor
Copy link

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
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant