How to use the chatterbot.ext.django_chatterbot.models.Statement function in ChatterBot

To help you get started, we’ve selected a few ChatterBot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gunthercox / ChatterBot / tests_django / test_commands.py View on Github external
def test_command_data_argument(self):
        out = StringIO()
        statements_before = Statement.objects.exists()
        call_command('train', stdout=out)
        statements_after = Statement.objects.exists()

        self.assertFalse(statements_before)
        self.assertTrue(statements_after)
github gunthercox / ChatterBot / tests_django / test_commands.py View on Github external
def test_command_data_argument(self):
        out = StringIO()
        statements_before = Statement.objects.exists()
        call_command('train', stdout=out)
        statements_after = Statement.objects.exists()

        self.assertFalse(statements_before)
        self.assertTrue(statements_after)
github gunthercox / ChatterBot / tests_django / test_output_adapter_integration.py View on Github external
def test_output_adapter(self):
        from chatterbot.output import OutputAdapter

        adapter = OutputAdapter(self.chatbot)

        statement = Statement(text='_')
        result = adapter.process_response(statement)

        self.assertEqual(result.text, '_')
github gunthercox / ChatterBot / tests_django / test_django_adapter.py View on Github external
def test_update_adds_new_statement(self):
        statement = Statement(text="New statement")
        self.adapter.update(statement)

        results = list(self.adapter.filter(text="New statement"))

        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].text, statement.text)
github gunthercox / ChatterBot / tests_django / test_statement_integration.py View on Github external
def setUp(self):
        super().setUp()

        from datetime import datetime
        from pytz import UTC

        now = datetime(2020, 2, 15, 3, 14, 10, 0, UTC)

        self.object = StatementObject(text='_', created_at=now)
        self.model = StatementModel(text='_', created_at=now)

        # Simulate both statements being saved
        self.model.save()
        self.object.id = self.model.id
github Surendhar95 / ChatBot / chatbot / chatbot / chatterbot / ext / django_chatterbot / admin.py View on Github external
class StatementAdmin(admin.ModelAdmin):
    list_display = ('text', )
    list_filter = ('text', )
    search_fields = ('text', )


class ResponseAdmin(admin.ModelAdmin):
    list_display = ('statement', 'occurrence', )


class ConversationAdmin(admin.ModelAdmin):
    pass


admin.site.register(Statement, StatementAdmin)
admin.site.register(Response, ResponseAdmin)
admin.site.register(Conversation, ConversationAdmin)
github Surendhar95 / ChatBot / chatbot / chatbot / chatterbot / storage / django_storage.py View on Github external
def remove(self, statement_text):
        """
        Removes the statement that matches the input text.
        Removes any responses from statements if the response text matches the
        input text.
        """
        from chatterbot.ext.django_chatterbot.models import Statement
        from chatterbot.ext.django_chatterbot.models import Response
        from django.db.models import Q
        statements = Statement.objects.filter(text=statement_text)

        responses = Response.objects.filter(
            Q(statement__text=statement_text) | Q(response__text=statement_text)
        )

        responses.delete()
        statements.delete()
github gunthercox / ChatterBot / chatterbot / ext / django_chatterbot / admin.py View on Github external
from django.contrib import admin
from chatterbot.ext.django_chatterbot.model_admin import StatementAdmin, TagAdmin
from chatterbot.ext.django_chatterbot.models import Statement, Tag


admin.site.register(Statement, StatementAdmin)
admin.site.register(Tag, TagAdmin)
github Surendhar95 / ChatBot / chatbot / chatbot / chatterbot / storage / django_storage.py View on Github external
def find(self, statement_text):
        from chatterbot.ext.django_chatterbot.models import Statement
        try:
            return Statement.objects.get(text=statement_text)
        except Statement.DoesNotExist as e:
            self.logger.info(str(e))
            return None
github Surendhar95 / ChatBot / chatbot / chatbot / chatterbot / storage / django_storage.py View on Github external
def count(self):
        from chatterbot.ext.django_chatterbot.models import Statement
        return Statement.objects.count()