Esempio n. 1
0
    def test_initiate_class_none(self):

        config = BotSentenceSplitterConfiguration()
        self.assertIsNotNone(config)
        config._classname = None
        config._split_chars = '。'

        splitter = SentenceSplitter.initiate_sentence_splitter(config)
        self.assertIsNone(splitter)
Esempio n. 2
0
    def test_initiate_splitter(self):

        config = BotSentenceSplitterConfiguration()
        self.assertIsNotNone(config)
        config._classname = 'programy.dialog.splitter.splitter_jp.SentenceSplitter'
        config._split_chars = '。'

        splitter = SentenceSplitter.initiate_sentence_splitter(config)
        self.assertIsNotNone(splitter)
        self.assertIsInstance(splitter, SentenceSplitter)
Esempio n. 3
0
    def test_remove_punctuation(self):

        config = BotSentenceSplitterConfiguration()
        self.assertIsNotNone(config)
        config._classname = 'programy.dialog.splitter.splitter_jp.SentenceSplitter'
        config._split_chars = '。'

        splitter = SentenceSplitter.initiate_sentence_splitter(config)
        self.assertIsNotNone(splitter)

        self.assertEquals("", splitter.remove_punctuation(""))
        self.assertEquals("()", splitter.remove_punctuation("()"))
        self.assertEquals("(Hello, world)", splitter.remove_punctuation("(Hello, world)"))
Esempio n. 4
0
    def test_split(self):

        config = BotSentenceSplitterConfiguration()
        self.assertIsNotNone(config)
        config._classname = 'programy.dialog.splitter.splitter_jp.SentenceSplitter'
        config._split_chars = '。'

        splitter = SentenceSplitter.initiate_sentence_splitter(config)
        self.assertIsNotNone(splitter)
        self.assertIsInstance(splitter, SentenceSplitter)

        self.assertEquals(["こんにちは"], splitter.split("こんにちは"))
        self.assertEquals(["こんにちは"], splitter.split("こんにちは。"))
        self.assertEquals(["こんにちは", "こんばんは"], splitter.split("こんにちは。こんばんは"))