Esempio n. 1
0
 def test_sentence_creation_one_word(self):
     sentence = Sentence(self._bot.brain.nlp.tokenizer, "One")
     self.assertIsNotNone(sentence)
     self.assertEqual(1, sentence.num_words())
     with self.assertRaises(Exception):
         sentence.sentence.word(1)
     self.assertEqual("One", sentence.text())
Esempio n. 2
0
 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())
Esempio n. 3
0
 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())
Esempio n. 4
0
 def test_sentence_creation_spaces(self):
     sentence = Sentence(self._bot.brain.nlp.tokenizer, " ")
     self.assertIsNotNone(sentence)
     self.assertEqual(0, sentence.num_words())
     with self.assertRaises(Exception):
         sentence.sentence.word(0)