Exemple #1
0
 def testHasSizeWords(self):
     chain = w.markov_chain("I am red and blue", 2)
     output = w.chain_to_text(chain, 20)
     self.assertEqual(len(output), 20)
Exemple #2
0
 def testDoesNotBreakIfNoMatchingPrefix(self):
     chain = w.markov_chain("I", 2)
     output = w.chain_to_text(chain, 200)
Exemple #3
0
 def testTurnsChainsToText(self):
     chain = w.markov_chain("I am red and blue", 2)
     output = w.chain_to_text(chain, 1)
     self.assertEqual(output[0], "I")
Exemple #4
0
 def testUsesSizeOfDict(self):
     chain = w.markov_chain("I am red", 3)
     output = w.chain_to_text(chain, 3)
     self.assertEqual(output, ['I', 'am', 'red'])
Exemple #5
0
 def testUsesRandomSample(self):
     chain = w.markov_chain("I am red I am blue", 2)
     output = w.chain_to_text(chain, 30)
     self.assertIn('red', output)
     self.assertIn('blue', output)
Exemple #6
0
 def testUsesMostRecentWords(self):
     chain = w.markov_chain("I am red", 2)
     output = w.chain_to_text(chain, 3)
     self.assertEqual(output, ['I', 'am', 'red'])