def WriteSonnet(self): self.mySonnet = [] for i in range(self.desiredLines): line = [] followingWord = Word("@") syllables = 0 if (self.rhymeLines[i] >= 0): followingWord = self.wordChain.GetRhymingWord( self.mySonnet[self.rhymeLines[i]][-1], self.rhymeLevel) line.insert(0, followingWord.GetWord()) syllables += followingWord.CountSyllables() while syllables < self.desiredLength: nextWord = self.wordChain.GetRandomLeader( followingWord.GetWord()) for k in range(1, 5): if nextWord.GetWord() != "@": break nextWord = self.wordChain.GetRandomLeader( followingWord.GetWord()) if nextWord.GetWord() == "@": break line.insert(0, nextWord.GetWord()) followingWord = nextWord followingWord.GetWordStress() syllables += nextWord.CountSyllables() self.PrintProgress(i + 1, syllables) self.mySonnet.append(line)