def test_trigram_text_correct_start(self): text = text_gen.random_trigram_text('i', 'think', self.bigrams, self.trigrams, 10) self.assertEqual(text.split()[0], 'i') self.assertEqual(text.split()[1], 'think') text = text_gen.random_trigram_text('am', 'i', self.bigrams, self.trigrams, 10) self.assertEqual(text.split()[0], 'am') self.assertEqual(text.split()[1], 'i')
def test_trigram_text_possible(self): words = text_gen.random_trigram_text('i', 'think', self.bigrams, self.trigrams, 100).split() prev = 'i' for i in range(1, len(words)): current = words[i] self.assertGreaterEqual(self.bigrams[prev][current], 0) prev = current
def test_trigram_text_possible(self): words = text_gen.random_trigram_text( 'i', 'think', self.bigrams, self.trigrams, 100).split() prev = 'i' for i in range(1, len(words)): current = words[i] self.assertGreaterEqual(self.bigrams[prev][current], 0) prev = current
def test_trigram_text_correct_length(self): text = text_gen.random_trigram_text('i', 'think', self.bigrams, self.trigrams, 10) self.assertEqual(len(text.split()), 10)