Code and Craft

A blog by Amy Cheng

Generative Poetry with UNIX: Day 10 of Code Poetry (SFPC)

My notes from class

A scan of my woefully incomplete notes from Allison's class

Today's workshop at Code Poetry was about Generative Poetry, and was led by Allison Parish. The first half of the workshop was a survey of analog generative poetry (like the Hundred Thousand Poems) and her own work, like The Ephemerides, which takes images from space probes and puts them together with computer generated poems (the source material being a text about oceans).

The second half of the class she showed us some useful UNIX commands for manipulating and searching text for the purposes of generating poetry.

My experience with using UNIX commands like cat and grep consists of mostly copying and pasting answers from Stack Overflow to try to get some dependencies to install or to change some config files so that a local web developement environment would run. Allison's demo of using UNIX to generate poetry was a MIND BENDER[1].

Using cat (output), grep (search), tr (translate) to make poems seemed way more fun than trying to wrangle Node.js to do same tasks. If it weren't for Allison's workshop I would've just used Node.js.

Using Node.js for a creative is a hassle. Alot of time is spent on figuring out which modules you would need, making sure those are added to the app as dependencies, and then dealing with control flow of the functions you want to execute. You end up writing alot of boilerplate code before you get write the meat of your creative work.

With the UNIX commands that Allison showed us, it was quick and easy to generate interesting texts. The commands shown were all built into UNIX and you only had to type out one line of code.

I created the following cyborg poems [2] from text from Pride and Prejudice by Jane Austen. Basically what I did was use grep to look for certain words, and then editing the output to remove nonsense.






be distant



















Elizabeth's seeming really vexed and embarrassed.

Her acquaintance was at least as much embarrassed as herself.

She had resolved to be perfectly easy

A resolution.

"I know my own strength, and I shall never be embarrassed again"

"But I was embarrassed."


"A glass of wine; shall I get you one? You are very ill."

And so I let down the side-glass next to him

and took faintness

full of something

a glass of it

I talk, and arranged, and wrapped myself up without opening

for whatever

With this approach of using UNIX to parse and manipulate text, I got boring programming out of the way and was able to focus on massaging the output to create some lovely poems. Though, if you were to do more invovled things, like crawling a website or working with a larger dataset of text, you'd probably look into using Python or Node.js.

Programming Note: Okay, so it's a bit weird to write about Day 10 of my time at the Code Poetry Summer Session at SFPC (School for Poetic Computation) but more posts are coming soon!

1: Also learning about <,>,| to access files and to chain commands together will probably make more efficient in my day job.

2: Katie, one of my classmate, suggested the term "cyborg poems" when I asked "What do you call a computer generated poem that was edited by a human?"

« Humanity over Technology: Recap of FACETS CON 2015 Notes on using Vagrant and Thoughts about Learning a New Development Tool »