Having done a little bit of computer poetry in the past, I wanted to do something a little more abstract than just a cut and paste mad libs type poem. My initial idea (first thought, best thought? probably not…) that seems so unoriginal I’m convinced there’s already a section on this in the jupyter notebook, was to make a “Poetry Generator Generator”. How, you ask? Well that’s a great question (that I don’t know the answer to yet). Here’s my process of figuring it out!
Step One: Figure out the Elements of a Poetry Generator
Inspired by reading all of Hartman’s Virtual Muse on my new commute to school, I knew I needed to isolate the building blocks of a generator — to come up with a grammar perhaps — where instead of “adjective, verb, noun” maybe it would be “libraries, loops, input text”. Let’s break down each generator on the demo notebook to see:
Libraries: random and textwrap
String of input text: “newspaper”
Function A) splitting the string into an array of discrete words (how does this do that? space character?)
Function B) randomly shuffling the array and storing the new array
Output: printing the rejoined words as a string (in a formatted way — text wrap + 60?)
A House of Dust
Arrays: Materials, Locations, Lights, Inhabitants
Output structure variable: stanza_count (7)
For Loop: printing a series of strings dependent on pre-determined arrangements of the earlier arrays (mad-libs)
Arrays: sal_adjs, sal_nouns, adjs, nouns, advs, verbs
Complicated formatting function/loop
Output (constantly updated with salutation, body, sign-off)
Arrays: above, below, transitive, imperative, intransitive, texture, adjectives
path function: one line
cave function: one line
site function: one line
Output: stanza_count = 10, random amount of lines, path() cave() site()
Step 2: How tf am I going to do this?
So, on first glance, it seems like the core structure here is to have an array of possible entries that can then be manipulated by loops/functions to create interesting output. What I could do, then, would be to take these chunks of code and store them in similar arrays to be accessed from the output functions. Perhaps there could be a set of possible outputs also, randomly looped through, but all using the same input arrays. Damn, so ideally, each random poetry generator generated should be able to function as a usable generator also, so I should have another array of randomly chosen input text that can be fed in after the generator is finished? Hmm, should this all be contained in one script? Would be simpler for output (could output the generator code and the output), I just wonder if there’s a better way to use the jupyter notebook format (i.e. have different sections that run under different conditions, although I guess that’s not really something jupyter does… excited that I get to learn this).
Maybe starting with output and reverse-engineering is the way to go. So for the ideal output, perhaps there could be fourish stanzas (abstracted, could include the salutation, for ex.), and each stanza could come from a randomly selected generator using a randomly selected input array. Stanza_count could also be random, and just have a count variable that could increment and then trigger the end of looping through a series of switch/case loop blocks or whatever. Would that feel too disjointed? What am I talking about, this is computer poetry, disjointed might as well be a required library. But still, what I’m making right now is less poetry generator generator, and more a mad-lib of all these other outputs… How can I make the whole code more auto-generated and less cut and paste??? HMMMMMMM. Ideally the generator code output would be something clean that someone could then just run as a stand-alone script, but I think these outputs are going to be super long with a lot of repetition, unless I go crazy complicated with how each line is arranged…. hmm….
Alternatively, I could treat the whole thing like telephone, where the output of one generator becomes the input of the next, though most of the outputs care more about structure than actual content, so maybe that wouldn’t be very effective…
Okay, so for the purposes of this assignment, I think I’m going to go the simpler route and just have a script that randomly chooses which of these generators to run and which input arrays to use…
STEP 4: FRANKENSTEIN’S MONSTER RISES (again and again)