diff --git a/chatterbot/conversation.py b/chatterbot/conversation.py index 35501ee96..6da758b15 100644 --- a/chatterbot/conversation.py +++ b/chatterbot/conversation.py @@ -24,6 +24,7 @@ def serialize(self): return { 'id': self.id, 'text': self.text, + 'stemmed_text': self.stemmed_text, 'created_at': self.created_at.isoformat().split('+', 1)[0], 'conversation': self.conversation, 'in_response_to': self.in_response_to, @@ -51,6 +52,7 @@ def __init__(self, **kwargs): self.id = kwargs.get('id') self.text = text + self.stemmed_text = kwargs.get('stemmed_text', '') self.conversation = kwargs.get('conversation', '') diff --git a/chatterbot/ext/django_chatterbot/abstract_models.py b/chatterbot/ext/django_chatterbot/abstract_models.py index 67519ee6a..ed5b9eda5 100644 --- a/chatterbot/ext/django_chatterbot/abstract_models.py +++ b/chatterbot/ext/django_chatterbot/abstract_models.py @@ -31,9 +31,12 @@ class AbstractBaseStatement(models.Model, StatementMixin): """ text = models.CharField( + max_length=constants.STATEMENT_TEXT_MAX_LENGTH + ) + + stemmed_text = models.CharField( max_length=constants.STATEMENT_TEXT_MAX_LENGTH, - blank=False, - null=False + blank=True ) conversation = models.CharField( diff --git a/chatterbot/ext/django_chatterbot/migrations/0016_statement_stemmed_text.py b/chatterbot/ext/django_chatterbot/migrations/0016_statement_stemmed_text.py new file mode 100644 index 000000000..f7206b36e --- /dev/null +++ b/chatterbot/ext/django_chatterbot/migrations/0016_statement_stemmed_text.py @@ -0,0 +1,16 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('django_chatterbot', '0015_statement_persona'), + ] + + operations = [ + migrations.AddField( + model_name='statement', + name='stemmed_text', + field=models.CharField(blank=True, max_length=400), + ), + ] diff --git a/chatterbot/ext/sqlalchemy_app/models.py b/chatterbot/ext/sqlalchemy_app/models.py index ecea5e01f..e7f0fdbab 100644 --- a/chatterbot/ext/sqlalchemy_app/models.py +++ b/chatterbot/ext/sqlalchemy_app/models.py @@ -56,6 +56,12 @@ class Statement(Base, StatementMixin): String(constants.STATEMENT_TEXT_MAX_LENGTH) ) + stemmed_text = Column( + String(constants.STATEMENT_TEXT_MAX_LENGTH), + nullable=False, + server_default='' + ) + conversation = Column( String(constants.CONVERSATION_LABEL_MAX_LENGTH), nullable=False,