Exemplo n.º 1
0
    def test_question_mark(self):
        splitter = RegexSentenceSplitter(BotSentenceSplitterConfiguration())
        self.assertIsNotNone(splitter)

        self.assertEquals(
            ["Is this the first sentence", "This is the second"],
            splitter.split("Is this the first sentence? This is the second"))
Exemplo n.º 2
0
    def test_comma(self):
        splitter = RegexSentenceSplitter(BotSentenceSplitterConfiguration())
        self.assertIsNotNone(splitter)

        self.assertEquals(
            ["This is the first sentence", "this is the second"],
            splitter.split("This is the first sentence, this is the second"))
Exemplo n.º 3
0
    def test_from_json(self):

        json_data = {
            'srai':
            False,
            'sentences': [{
                'words': ['Hi'],
                'response': 'Hello',
                'positivity': 0.0,
                'subjectivity': 0.5
            }, {
                'words': ['Hi', 'Again'],
                'response': 'World',
                'positivity': 0.0,
                'subjectivity': 0.5
            }],
            'current_sentence_no':
            -1,
            'properties': {}
        }

        question = Question.from_json(self._client_context, json_data)
        self.assertIsNotNone(question)

        self.assertEqual(False, question.srai)
        self.assertEqual({}, question.properties)
        self.assertEqual(-1, question._current_sentence_no)
        self.assertEqual(2, len(question.sentences))
        splitter = RegexSentenceSplitter(BotSentenceSplitterConfiguration())
        self.assertIsNotNone(splitter)

        self.assertEqual(["This is a basic sentence"],
                         splitter.split("This is a basic sentence"))
Exemplo n.º 4
0
    def test_punctuation_at_end(self):
        splitter = RegexSentenceSplitter(BotSentenceSplitterConfiguration())
        self.assertIsNotNone(splitter)

        self.assertEquals(["Is this the first sentence"], splitter.split("Is this the first sentence?"))
Exemplo n.º 5
0
    def test_basic_sentence(self):
        splitter = RegexSentenceSplitter(BotSentenceSplitterConfiguration())
        self.assertIsNotNone(splitter)

        self.assertEquals(["This is a basic sentence"], splitter.split("This is a basic sentence"))
Exemplo n.º 6
0
    def test_not_active(self):
        splitter = RegexSentenceSplitter(BotSentenceSplitterConfiguration())
        self.assertIsNotNone(splitter)
        splitter.active = RegexSentenceSplitter.OFF

        self.assertEqual(["This is a basic sentence"], splitter.split("This is a basic sentence"))
Exemplo n.º 7
0
    def test_fullstop(self):
        splitter = RegexSentenceSplitter(BotSentenceSplitterConfiguration())
        self.assertIsNotNone(splitter)

        self.assertEqual(["This is the first sentence",  "This is the second"], splitter.split("This is the first sentence. This is the second"))