Generate base from given number of syllables in lines and number of lines 4) Find list of rhymes for generated base 5) Fill poem base with buzzwords from given rhyme scheme and base 3
line — generate all combinations of sums (compositions) from all available number of syllables. Compositions of 3: 1 + 1 + 1 1 + 2 2 + 1 3 NB: Each positive integer n has 2 ** (n - 1) distinct compositions. 4
generate the base (I call it so) for future poem from random compositions for each number of syllables. E.g. for number of syllables in lines [4, 4], poem base is: 1, 2, 1 1, 3 5
scheme — find rhymes. For poem base: 1, 2, 1 1, 3 and rhyme scheme AA (i.e. first and second lines rhyme with each other). To prepare rhymes get only last values (here 1, 3), because only the last words form a rhyme. I.e. for the poem above find rhymes for words with number of syllables 1, 3. Storm and Ter-ra-form are fit. 6