The sonnet generator is based on two principles: combinatorial and random. The generation of a sonnet can be seen as an arrangement without repetition.
Here is how the Oupoco sonnet generator program works:
(The corpus was first phonetised using the espeak software, then the verses were grouped by rhyme. The last phoneme for poor rhymes, the last two for sufficient rhymes, the last three for rich rhymes.)
1. The program filters the verses of the corpus to eliminate those that do not meet the constraints set by the user
2. The sonnet type, or pattern, gives the number of rhymes in the sonnet and their order. For the French sonnet, for example, there are 5 rhymes in the following order: 'ABBA, ABBA, CCD, EDE'.
3. For each different letter in the pattern the program picks a rhyme from the available rhymes
4. For each position (from 1 to 14) the program picks a verse that has the right rhyme and the right position. If this is not possible the program returns to step 3
The program is implemented in Python under the GPL license, it is available at this address : https://github.com/lattice-8094/oupoco-api