From 002030aafcfe6000081899a7784187e1faa910f4 Mon Sep 17 00:00:00 2001 From: Gunther Cox Date: Thu, 29 Jun 2017 21:47:16 -0400 Subject: [PATCH] Dont need to store entire statement history --- chatterbot/trainers.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/chatterbot/trainers.py b/chatterbot/trainers.py index 3a162358a..88e5b9eeb 100644 --- a/chatterbot/trainers.py +++ b/chatterbot/trainers.py @@ -76,17 +76,17 @@ def train(self, conversation): Train the chat bot based on the provided list of statements that represents a single conversation. """ - statement_history = [] + previous_statement_text = None for text in conversation: statement = self.get_or_create(text) - if statement_history: + if previous_statement_text: statement.add_response( - Response(statement_history[-1].text) + Response(previous_statement_text) ) - statement_history.append(statement) + previous_statement_text = statement.text self.storage.update(statement) @@ -116,17 +116,17 @@ def train(self, *corpus_paths): for corpus in corpora: for conversation in corpus: - statement_history = [] + previous_statement_text = None for text in conversation: statement = self.get_or_create(text) - if statement_history: + if previous_statement_text: statement.add_response( - Response(statement_history[-1].text) + Response(previous_statement_text) ) - statement_history.append(statement) + previous_statement_text = statement.text self.storage.update(statement)