Example #1
0
    def get_available_statements(self, statement_list=None):
        from chatterbot.conversation.utils import get_response_statements

        if statement_list:
            statement_list = get_response_statements(statement_list)

        # Check if the list is empty
        if not statement_list and self.has_storage_context:
            all_statements = self.context.storage.filter()
            statement_list = get_response_statements(all_statements)

        return statement_list
Example #2
0
    def get_available_statements(self, statement_list=None):
        from chatterbot.conversation.utils import get_response_statements

        if statement_list:
            statement_list = get_response_statements(statement_list)

        # Check if the list is empty
        if not statement_list and self.has_storage_context:
            all_statements = self.context.storage.filter()
            statement_list = get_response_statements(all_statements)

        return statement_list
Example #3
0
    def test_get_statements_with_known_responses(self):
        statement_list = [
            Statement("What... is your quest?"),
            Statement("This is a phone."),
            Statement("A what?", in_response_to=[Response("This is a phone.")]),
            Statement("A phone.", in_response_to=[Response("A what?")])
        ]

        responses = get_response_statements(statement_list)

        self.assertEqual(len(responses), 2)
Example #4
0
    def test_get_statements_with_known_responses(self):
        statement_list = [
            Statement("What... is your quest?"),
            Statement("This is a phone."),
            Statement("A what?",
                      in_response_to=[Response("This is a phone.")]),
            Statement("A phone.", in_response_to=[Response("A what?")])
        ]

        responses = get_response_statements(statement_list)

        self.assertEqual(len(responses), 2)
        self.assertIn("This is a phone.", responses)
        self.assertIn("A what?", responses)