Exemple #1
0
 def test_number_of_syllables(self):
     MC = MCMarkov(self.where_the_sidewalk_ends, 1, True)
     new_song = MC.create_song(couplet_count=5, syllable_count=10)
     for couplet in new_song:
         for line in couplet:
             sylcount = sum(nsyl(word) for word in line)
             self.assertEqual(sylcount, 10)
Exemple #2
0
 def create_line(self, startingword, syllable_count): # To be changed to syllable count
     line = [startingword]
     remaining_syllable_count = syllable_count - nsyl(startingword)
     i = 0
     while remaining_syllable_count > 0:
         if i == 0:
             word = self.markovchain.next_word([startingword])
         else:
             word = self.markovchain.next_word([word])
         if word == '\n': # If previous word has no following words, backup and start again
             prevword = line.pop()
             remaining_syllable_count += nsyl(prevword)
         if nsyl(word) <= remaining_syllable_count:
             line.append(word)
             remaining_syllable_count -= nsyl(word)
             i += 1
     if self.reverse:
         line = line[::-1]
     return line
Exemple #3
0
 def test_syllable_map(self):
     MC = MCMarkov(self.where_the_sidewalk_ends, 1, True)
     syllable_map = [[7, 10], [5, 12]]
     new_song = MC.create_song(couplet_count=None, syllable_count=None, syllable_map=syllable_map)
     for i, couplet in enumerate(new_song):
         couplet_map = syllable_map[i]
         for j, line in enumerate(couplet):
             line_map = couplet_map[j]
             sylcount = sum(nsyl(word) for word in line)
             self.assertEqual(sylcount, line_map)
Exemple #4
0
 def test_lines_in_couplet_have_syllable_length(self):
     MC = MCMarkov(self.where_the_sidewalk_ends, 1, True)
     song = MC.create_song(4, 10)
     for couplet in song:
         for line in couplet:
             self.assertEqual(sum(nsyl(word) for word in line),10)