Example #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)
Example #2
0
 def testDoesNotBreakIfNoMatchingPrefix(self):
     chain = w.markov_chain("I", 2)
     output = w.chain_to_text(chain, 200)
Example #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")
Example #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'])
Example #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)
Example #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'])