hich can Small Machines: Exploring Poetry Generation with Python

Small Machines

Exploring Poetry Generation with Python

“A poem is a small ... machine made out of words.”

—William Carlos Williams
Three code poetry class meetings
during the Fall 2017 session
School for Poetic Computation
with teacher Nick Montfort

General Information

Our class sessions will focus on what can be done by creating short, stand-alone programs. It turns out that there is a great deal we can do in this vein, and it allows us to concentrate on code and the workings of programs. We will probably look into at least one lightweight lexical resource (an inflected word list), but our focus will be on using the built-in computational capabilities of programming languages with small, hand-crafted elements of data. We will be sketching and exploring, so will use Jupyter Notebook and simple text files instead of requiring that everyone use version control.
Although they are self-contained as programs, the small poetry machines we will study, modify, and create will allow us access to the history of creative text generation and to the global creative practices that involve computation, language, and literary art.
We will study programs in JavaScript and even see some in Commodore 64 BASIC, but our main way of exploring and programming will be by using Python, specifically Python 2. In some cases we will be able to easily build a JavaScript “port” or equivalent of our Python program, which will let us share our work on the Web and learn more about how different programming languages work.

Short, Self-Contained Text Generators for Study, Modification, & Use

SM1, October 12: Modifying History, Six Fundamentals

You can start programming by modifying an existing program. We will review the history of short poetry-generating programs while also modifying several of these programs. (Recreating the past, to be sure!) We will use Memory Slam, which provides both JavaScript and Python 2 reimplementations of historical programs. We will very quickly (in the space of about 15 minutes) modify one of these existing JavaScript programs, focusing on changed to the text. We’ll share the results by reading them aloud, so do not bother to dwell on visual design changes.

To work well as a programmer, even as a wild artistic explorer, foundational understanding is also important. We will spend time reviewing six programming fundamentals, so that we can carefully think about how these realte to poetics. We’ll work to understand how these fundamentals let us develop very simple poetry generators from scratch — from a blank cell in the Anaconda Notebook, using Python 2. And we will see how we might choose to teach others about these fundamentals, not in a typical “Intro to Programming” framework, but as artists.

Prompt/assignment: Write a Python 2 function of 280 characters or less — the length of a “new tweet.” Sketch this using Anaconda Notebook, confirm that it is no longer than 280 characters using a text editor, and make sure your function is (1) clear enough to anyone looking at it, (2) doing something interesting to you and others in some way, (3) dealing with some concept you think is essential to both programming and poetry. Don't change the default indentation level. The program will have to be very short! This is about finding the essence of computing operations we have looked at today and which we know about from past experience. Email your function to me by Tuesday October 17. You can just copy it and paste it into an email.

SM2, October 19: Starter Programs, Poetry Processing, Book Reports

Today we’ll begin by sharing and discussing the starter programs/starter poems.

We will do some further in-class modification, this time of Python programs that do essentially the same thing as the JavaScript programs we saw previously. These are also found at the Memory Slam site. I’ll encourage you to change parameters and code as well as the “data” — the strings of language. We’ll share the results, again by reading them aloud.

I’ll have a selection of computer-generated books for us to look at and even “read,” for certain values of reading. Pairs of people will be assigned to examine these books quickly and give expository book reports about them to the group. A long bibliography of such books is available at my blog, Post Position.

Prompt/assignment: Create your own tiny computer-generated booklet using (1) a short, self-contained Python program of no more than 66 lines (80 characters/line); (2) a single printed sheet, US letter size, which can be printed single-sided or double-sided. You can cut this sheet and staple it, get even more fancy and use a pamphlet stitch, or use the 8-page zine cut-and-fold technique. Make at least six copies so we can look at them together and so you can trade some with others at SfPC.

SM3, October 26: Generated Books, Crossing Languages

Today we’ll begin by sharing and discussing the tiny computer-generated books you made.

We will have time to review some code from those who offer it, and to see how the six fundamentals (discussed in SM1) were used in the programs that wrote your tiny books.

We are going to continue to look at some projects that have been done across (natural) langauges, particularly ones that originated with an English work or originated outside of English and were translated or remade in English. We will form groups that (put together) have very good, poetry-level knowledge of more than one language, and will try to develop simple Python programs/poems that engage multiple languages.

While “JavaScript” and “Python” are entirely different sorts of langauges — formal, used to instruct computers in how they are to operate, not capable of general communication — we will also discuss why we might want to work across different programming languages.


Updated 9 October 2017, canonical copy at http://nickm.com/classes/sfpc/2017_fall/small_machines.html