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

Force training even if read_only is True #337

Merged
merged 3 commits into from
Oct 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chatterbot/adapters/storage/django_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def filter(self, **kwargs):

return results

def update(self, statement):
def update(self, statement, **kwargs):
from chatterbot.ext.django_chatterbot.models import Statement as StatementModel
from chatterbot.ext.django_chatterbot.models import Response as ResponseModel
# Do not alter the database unless writing is enabled
Expand Down
2 changes: 1 addition & 1 deletion chatterbot/adapters/storage/jsonfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def filter(self, **kwargs):

return results

def update(self, statement):
def update(self, statement, **kwargs):
# Do not alter the database unless writing is enabled
if not self.read_only:
data = statement.serialize()
Expand Down
6 changes: 3 additions & 3 deletions chatterbot/adapters/storage/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ def filter(self, **kwargs):

return results

def update(self, statement):
def update(self, statement, **kwargs):
from pymongo import UpdateOne, ReplaceOne

force = kwargs.get('force', False)
# Do not alter the database unless writing is enabled
if not self.read_only:
if not self.read_only or force == True:
data = statement.serialize()

operations = []
Expand Down
2 changes: 1 addition & 1 deletion chatterbot/trainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def train(self, conversation):
)

statement_history.append(statement)
self.storage.update(statement)
self.storage.update(statement, force=True)


class ChatterBotCorpusTrainer(Trainer):
Expand Down