Skip to content

Commit

Permalink
Create statements with storage adapter so search text is generated
Browse files Browse the repository at this point in the history
  • Loading branch information
gunthercox committed Nov 19, 2018
1 parent 5f983f7 commit f643dc7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
6 changes: 1 addition & 5 deletions chatterbot/storage/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ def filter(self, **kwargs):
tags = kwargs.pop('tags', [])
exclude_text = kwargs.pop('exclude_text', None)

# Convert a single sting into a list if only one tag is provided
if type(tags) == str:
tags = [tags]

if tags:
kwargs['tags'] = {
'$in': tags
Expand Down Expand Up @@ -277,7 +273,7 @@ def get_response_statements(self, page_size=1000):

statement_query = self.statements.find(_statement_query)

for statement in list(statement_query):
for statement in statement_query:
yield self.mongo_to_object(statement)

def drop(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_filter_selection(self):
'Hi',
'Hello',
'How are you?',
'I am good.',
'I am good',
'Glad to hear',
'How are you?'
])
Expand Down
8 changes: 4 additions & 4 deletions tests_django/test_logic_adapter_integration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tests_django.base_case import ChatterBotTestCase
from chatterbot.ext.django_chatterbot.models import Statement
from chatterbot.conversation import Statement


class LogicIntegrationTestCase(ChatterBotTestCase):
Expand All @@ -11,19 +11,19 @@ class LogicIntegrationTestCase(ChatterBotTestCase):
def setUp(self):
super().setUp()

Statement.objects.create(text='Default statement')
self.chatbot.storage.create(text='Default statement')

def test_best_match(self):
from chatterbot.logic import BestMatch

adapter = BestMatch(self.chatbot)

statement1 = Statement.objects.create(
statement1 = self.chatbot.storage.create(
text='Do you like programming?',
conversation='test'
)

Statement.objects.create(
self.chatbot.storage.create(
text='Yes',
in_response_to=statement1.text,
conversation='test'
Expand Down

0 comments on commit f643dc7

Please sign in to comment.