def test_bigram_text_possible(self): words = text_gen.random_bigram_text('i', self.bigrams, 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_bigram_text_correct_start(self): text = text_gen.random_bigram_text('i', self.bigrams, 10) self.assertEqual(text.split()[0], 'i') text = text_gen.random_bigram_text('think', self.bigrams, 10) self.assertEqual(text.split()[0], 'think')
def test_bigram_text_correct_length(self): text = text_gen.random_bigram_text('i', self.bigrams, 10) self.assertEqual(len(text.split()), 10)