From 13fa6922e6ce6d47ea699170525ff423c5a2992b Mon Sep 17 00:00:00 2001 From: Gunther Cox Date: Sun, 16 Aug 2020 07:44:24 -0400 Subject: [PATCH] Clean up format strings It is better to format the string all at once instead of using both formatting and concatenate. --- chatterbot/corpus.py | 5 +++-- chatterbot/logic/mathematical_evaluation.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/chatterbot/corpus.py b/chatterbot/corpus.py index fab428c8a..f687d5951 100644 --- a/chatterbot/corpus.py +++ b/chatterbot/corpus.py @@ -24,8 +24,9 @@ def get_file_path(dotted_path, extension='json'): corpus_path = os.path.join(*parts) - if os.path.exists(corpus_path + '.{}'.format(extension)): - corpus_path += '.{}'.format(extension) + path_with_extension = '{}.{}'.format(corpus_path, extension) + if os.path.exists(path_with_extension): + corpus_path = path_with_extension return corpus_path diff --git a/chatterbot/logic/mathematical_evaluation.py b/chatterbot/logic/mathematical_evaluation.py index 642e57561..ed6269afd 100644 --- a/chatterbot/logic/mathematical_evaluation.py +++ b/chatterbot/logic/mathematical_evaluation.py @@ -55,7 +55,8 @@ def process(self, statement, additional_response_selection_parameters=None): response = Statement(text=expression) try: - response.text += ' = ' + str( + response.text = '{} = {}'.format( + response.text, mathparse.parse(expression, language=self.language.ISO_639.upper()) )