Example #1
0
    def test_exact_results(self):

        output = engram("What... is your quest?", self.chatbot.database)
        expected = "To seek the Holy Grail."

        self.assertEqual(len(output), 1)
        self.assertIn(expected, output.keys())
Example #2
0
    def test_exact_results(self):

        output = engram("What... is your quest?", self.chatbot.log_directory)
        expected = "To seek the Holy Grail."

        self.assertEqual(len(output), 1)
        self.assertIn(expected, output.keys())
Example #3
0
    def test_close_results(self):

        output = engram("What is your quest?", self.chatbot.database)
        expected = "To seek the Holy Grail."

        self.assertEqual(len(output), 1)
        self.assertIn(expected, output.keys())
Example #4
0
    def get_response_data(self, user_name, input_text):
        """
        Returns a dictionary containing the following data:
        * user: The user's meta data
        * bot: The statement's meta data
        """
        from chatterbot.algorithms.engram import engram

        # Check if a name was mentioned
        if self.name in input_text:
            pass

        bot = {}

        user = {input_text: {"name": user_name, "date": self.timestamp()}}

        # If logging is enabled, add the user's input to the database before selecting a response.
        if self.log:
            self.update_log(user)

        self.last_statement = engram(input_text, self.database.path)
        statement_text = list(self.last_statement.keys())[0]

        if self.log:
            values = self.database[input_text]
            if not "in_response_to" in values:
                values["in_response_to"] = []
            if not statement_text in values["in_response_to"]:
                values["in_response_to"].append(statement_text)
                self.database[input_text] = values

        return {"user": user, "bot": self.last_statement}
Example #5
0
    def test_close_results(self):

        output = engram("What is your quest?", self.chatbot.log_directory)
        expected = "To seek the Holy Grail."

        self.assertEqual(len(output), 1)
        self.assertEqual(output[0].text, expected)
Example #6
0
    def get_response_data(self, user_name, input_text):
        """
        Returns a dictionary containing the following data:
        * user: The user's meta data
        * bot: The statement's meta data
        """
        from chatterbot.algorithms.engram import engram

        # Check if a name was mentioned
        if self.name in input_text:
            pass

        bot = {}

        user = {
            input_text: {
                "name": user_name,
                "date": self.timestamp()
            }
        }

        # If logging is enabled, add the user's input to the database before selecting a response.
        if self.log:
            self.update_log(user)

        self.last_statement = engram(input_text, self.database.path)
        statement_text = list(self.last_statement.keys())[0]

        if self.log:
            values = self.database[input_text]
            if not "in_response_to" in values:
                values["in_response_to"] = []
            if not statement_text in values["in_response_to"]:
                values["in_response_to"].append(statement_text)
                self.database[input_text] = values

        return {"user": user, "bot": self.last_statement}
Example #7
0
    def test_empty_input(self):

        output = engram("", self.chatbot.log_directory)

        self.assertEqual(len(output), 1)
Example #8
0
    def test_empty_input(self):

        output = engram("", self.chatbot.database)

        self.assertEqual(len(output), 1)