A cento is a type of poem where each line is taken from a different poem, and then assembled in such a way that the overall poem makes sense. It is also often aptly called "patchwork poetry". One of the most popular contemporary centos is John Ashbery's "The Dong with the Luminous Nose". The poem and an accompanying annotated guide can be found here.
This repository contains code to create a cento by choosing a random line from a random poem out of a database of poems and related metadata such as titles, poets and tags. The database is the Gutenberg Poetry Corpus by Allison Parish. (Note: A previous version of this program used the PoetryFoundationData.csv dataset, created by Divy Bramhecha).
Clone the repository by pressing the Download ZIP button in the Code dropdown menu marked in green, or used the git clone
command.
cento_maker.py
contains the main code to automatically generate the cento poems. Just change the num_lines
attribute to choose the total number of lines desired in your cento and run the program.
Why create a cento generator instead of just training the dataset to let an AI create poetry? The reasons are twofold: 1) There are plenty of projects that have already attempted to do the latter better than I can ever hope to do, 2) I am too lazy to use ML right now.
The code requires the following dependencies:
json
gzip
random
A respectable cento generated by the code so far:
Struck for response; and when the strings so failed
An opportune recess,
While the stars prick our hands
The look of a scared thing
Alas! if kissing be of plagues the worst,
Or will it all come true?
Or another one:
And be it Heaven hath thee such favor done:
Pulpits and Sundays, sorrow dogging sin,
Be shorten'd with the time. No mortal tongue
Blown from the west's cloud-pillared fires.
Confuse their brains in college classes!
This code is licensed by the GNU General Public License v3.0. You can read more about it here.