Skip to content

Commit

Permalink
Dont need to store entire statement history
Browse files Browse the repository at this point in the history
  • Loading branch information
gunthercox committed Jun 30, 2017
1 parent f1fa616 commit 002030a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions chatterbot/trainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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)


Expand Down

0 comments on commit 002030a

Please sign in to comment.