Beispiel #1
0
 def generate_end_line(self, rhyme):
     last_word = vocab.get_adj()
     if rhyme is not None:
         last_word_choices = vocab.rhyming_adjs(rhyme)
         if len(last_word_choices) == 0:
             raise ValueError
         last_word = random.choice(last_word_choices)
     return (templates.Template("{{line}}")
             .render(line="{{statement}}",
                     statement="{{subject}} is {{adj}}",
                     subject="all|sadness|cruelty|fate|the world|life|death|hope|nothing|everything",
                     adj=last_word))
Beispiel #2
0
    def generate_middle_line(self, rhyme):
        last_word = vocab.get_adj()
        if rhyme is not None:
            last_word_choices = vocab.rhyming_adjs(rhyme)
            if len(last_word_choices) == 0:
                raise ValueError
            last_word = random.choice(last_word_choices)


        return (templates.Template("{{line}}")
                .render(line="{{list}}|{{list2}}|{{butphrase}}|{{it_phrase}}",
                        it_phrase="it is {{always_never}} {{last_adj}}",
                        always_never = "always|never",
                        list="{{adj1}}, {{adj2}}, {{last_adj}}",
                        list2="{{adj1}} and {{last_adj}}",
                        adj1=vocab.get_adj(), adj2=vocab.get_adj(), last_adj=last_word,
                        butphrase="{{butword}} {{last_adj}}",
                        butword="yet|but|yet never|but never|ever|always"))