def test_sentence_creation_two_words(self): sentence = Sentence(self._bot.brain.nlp.tokenizer, "One Two") self.assertIsNotNone(sentence) self.assertEqual(2, sentence.num_words()) self.assertEqual("One", sentence.word(0)) self.assertEqual("Two", sentence.word(1)) with self.assertRaises(Exception): sentence.sentence.word(2) self.assertEqual("One Two", sentence.text())
def test_split_into_words(self): sentence = Sentence(self._bot.brain.nlp.tokenizer, "HELLO") self.assertIsNotNone(sentence) self.assertEqual(1, sentence.num_words()) self.assertEqual("HELLO", sentence.word(0)) self.assertEqual("HELLO", sentence.words_from_current_pos(0)) with self.assertRaises(Exception): sentence.sentence.word(1) self.assertEqual("HELLO", sentence.text())
def test_sentence_creation_two_words_diff_split_char(self): tokenizer = Tokenizer(",") sentence = Sentence( tokenizer, "One,Two", ) self.assertIsNotNone(sentence) self.assertEqual(2, sentence.num_words()) self.assertEqual("One", sentence.word(0)) self.assertEqual("Two", sentence.word(1)) with self.assertRaises(Exception): sentence.sentence.word(2) self.assertEqual("One,Two", sentence.text())