Monday, February 28, 2011

There are a Lot of Frogs in Haiku

I had to spend an entire weekend to fix the repeating-word issue, along with some other issues in the code.

But at long last it worked!  The first non-random haiku my computer wrote was this:

ah of surf surface
frogs at sits each bends on comes
minnows of wheel the

What struck me first was how little sense this made.  The syntax is all out of order.  But a lot of poets mess with syntax--English really has fewer hard-and-fast syntax rules than we'd like to believe.  The difference is that they provide punctuation and spacing to give structure in place of syntax.  (Poesytron does not yet know anything about either punctuation and spacing.)

So I made an edited version of this haiku:


ah! of surf surface
frogs at sits— each bends, on, comes
minnows of wheel—    
    the 


And I don't know about you, but that seems to make it easier for my mind to make some meaning out of it.

Sunday, February 27, 2011

Random Word Haiku for Feb. 27

aggressive rainwear
ungoverning Klondike Kirk
forty-eight global

I don't know who Klondike Kirk is, but I'd like to meet him.  I just hope he isn't wearing aggressive rainwear when I do.

Saturday, February 26, 2011

Frogs

The next step after creating random word haiku was to incorporate a way to select words that go together based on some criteria.  I thought that a simple way to do this would be to feed the program a database of human-written haiku, and have it select the next word out of a haiku that the previous word was in.

I created a test haiku database, with 500 haiku that I found by using the preview feature on Google Books.  Then I wrote the code to do this.  It was a little bit tricky to write the code, so I was really happy once I'd figured it out and it was ready to go.  I had built quite a few precautions into it--for example, there is one line that prevents the program from selecting the same word twice in a row.  Or so I thought.

I ran it for the first line, and this is what it gave me:

frog frog frog frog frog


Obviously I had some more work to do.

Friday, February 25, 2011

Random Word Haiku for Feb. 25

associated
maestro di cappella Krogh
Pecksniffism timing


Sometimes I am surprised to see the words that come out of the Moby lexicon.  I mean, Pecksniffism!?  How strange and wonderful is that?  I am not sure what all resources were used to compile Moby, but I do know that a word was included in the common word list if it was contained in at least two dictionaries.  But the hyphenation file is not limited to just common words--whereas the common word list has about 75,000 words, the hyphenation list that I'm using has about 185,000.

Maestro di cappella is a fancy name for a conductor or music director.  The most famous people with the last name Krogh are Egil Krogh, a lawyer involved in Watergate, and August Krogh, a Nobel Prize winner in physiology.  (Neither, to my knowledge, ever conducted an orchestra.  However, Hanne Krogh is a Norwegian singer who won the Eurovision song contest in 1985.) Pecksniff comes from the Charles Dickens novel Martin Chuzzlewit, which I had never heard of, despite my tendency to hang out with Victorian enthusiasts.  Apparently Mr. Pecksniff was a big ol' hypocrite, who claimed to have superior morals and then went around mistreating everyone.  So to be a Pecksniffian is to hypocritically tell other people what to do and to intrusively interfere in other people's business.


I am finding it a bit of a stretch to find connections between the three lines today.  Anyone care to take a stab at it?

Thursday, February 24, 2011

Unintentional Poetry: Poetry "Found" on Twitter, Facebook, etc.

One of the inherent themes in computer generated poetry is the unexpectedness of what comes out.  The control over the composition of the poem lies not with a human "author," but partly within some controlled yet random process.

Jackson Mac Low was the poet who first grabbed onto this idea and ran with it.  He used several "diastic" methods, or methods that incorporated algorithms and some random chance.  Mac Low said that by using the methods, the poet "is neither the dictator nor (when he participates in the ensemble) the primary soloist.  He is willing to risk moments in performances that he will not perceive as beautiful.... That is a risk I am deliberately taking."

This idea of deliberate stochasticity is one that, I think, really stretches the boundaries of modern poetry.  It transforms what the poet is able to say within a poem, and transforms the intention of communication within a poem.

When I come across other poetry projects that also push at this boundary, I'm going to share them.  Poesytron 575 is not the only program out there that can do these things--and using a computer program is not the only way to incorporate these concepts into the composition of poetry, either.

One site that I'm very happy to see get started is Internet Poetry.  The mission of the site is to share "poetry* being spread with guerrilla tactics on the internet."  I imagine most of what they post is not going to be poetry that was intentionally written and spread, but rather poetry that is found within the structure of the internet, picked up by a discerning, poetic eye.  This is chance, controlled by the ability to pick out what is poetry (loosely defined) among the textual clutter of the internet.  And I'm very excited to see what beautiful, poignant, stark meaning might emerge.

*loosely defined


Interestingly, there is a very long tradition of haiku embedded within prose.  Matsuo Bashō, one of the first (if not the first) masters of haiku in 17th century Japan, also wrote haibun, which combines prose and haiku.  Jack Kerouac once wrote in a letter, "There are a million haikus in one good prose work," and this has led at least one scholar to look for embedded haiku within Kerouac's own prose.  The logical extension of this idea in the technological age is to look for unintentional haiku posted to Twitter.

Wednesday, February 23, 2011

Random Word Haiku for Feb. 23

Poissons ratio
Wallensis mostly greenhouse
psychometrics melt


Deconstructing this:

Poisson's ratio has to do with contraction and expansion of objects when pressure is applied.

The most famous person with the last name Wallensis appears to be Thomas Wallensis, Bishop of St. David's in Wales in the 13th century.

Psychometrics has to do with measuring educational achievements and psychological traits (think IQ tests).

So does the "meaning" of this haiku lie in the relationship between science, religion, and education?  My mind also connects the words 'greenhouse,' a very warm place, and 'melt.'

Tuesday, February 22, 2011

Random Word Haiku for Feb. 22

spindleshanks impi
off-season curvey sharklike
submarginal clam

Monday, February 21, 2011

Sunday, February 20, 2011

How It All Began

The whole idea for writing computer code to generate haiku struck me one day while I was at work.

Ecologists use a lot of statistical programs, but a popular one is R, which is more than just a statistical program in that it is also a programming language.  I've been learning to use this program and language recently to work with ecological data and analyses.  A few weeks ago, I began a project where I wrote code in R to parse text.  We had species descriptions for over 9,000 plant species in South Africa, and I started to learn how to use regular expressions to extract usable bits of data from the paragraph descriptions (for example, the height of the plants or the months when they flower).

While I was learning how to manipulate text in this way, my mind wandered to imagining other possibilities for this type of code.  And that's how the idea was born.

Honestly, I may never have followed up on the idea if I hadn't shared it with my friend Jared, poet and editor of the online magazine The Jivin' Ladybug.  Jared got really, really excited, which got me even more excited, which meant that I went home after talking with him and spent the next two nights up late at night, working on code.

In order to get syllable counts for words, I downloaded a file of 185,000 words with hyphenation marks from the Moby Project, which is a public-domain lexicon.  I was very grateful to find something I could freely use to let me easily calculate syllables.

And that was all I needed in order to generate random-word haiku.

The code I wrote starts out by selecting a random word and then checks the syllable count.  If adding that word to the first line won't make the syllable count for the line go over 5, it adds the word to the line.  Then it does it again, until there are 5 syllables in the first line.  Then it does the same thing for the second line (only with 7 syllables instead of 5), and the third line.

Here is another random word haiku-- the second one that the program wrote:

urushiol glaze
smallholding jabbing Pliny
hypostyle hinder

For those of you who are familiar with R or other programming languages, the code used to generate random word haiku is after the cut.  For the rest of you, all that junk after 'Read More' is just the stuff that tells the computer do to what I described a couple paragraphs above.

The First Poem My Computer Ever Wrote

fragmentizing cobb
exclamatory hurst smash
subchorioidal


There it is, the very first haiku produced by Poesytron 575.  The original, most basic form of my haiku-generation program selects words completely at random.*  I had big ideas about making rules for word selection based on how often words were paired together in real, human-written haiku-- but first of all, I had to make sure that it could do the most basic things like count the syllables in a line and so forth.  And this haiku, though it may not make much sense, proved that I was on the right track!

*In my next post, I'll tell you a little bit about the word list it was selecting from and how it worked.

Saturday, February 19, 2011

What is Poesytron 575?

Poesytron 575 is a simple computer code I wrote that generates haiku.

(The breakdown of its name: "poesy" means the art of writing poetry; "-tron" because it all happens in a computer; and "575" for the standard syllable count of English haiku.)

But Poesytron is a process, not a product.  I wrote the program so that I could experiment with the experience of reading haiku, and one single "finished" program is not even going to begin to satisfy all the questions I have in mind.  Some of those questions are:

Can a poem still have meaning even if the "author" is a mindless computer, acting on defined rules?

If it has meaning, does it have any value?

What is the role of the author, or the reader, in poetry?

Can a "virtual" poet invoke the same emotions in a reader as a human poet?

And this is just a starting point.

This is an ambitious project for me.  I am not (a) a poet (or at least more than an amateur one), nor (b) a computer programmer.  What I am is a scientist, so I've been trained to ask a lot of questions and not to rely too heavily on assumptions.  So I think that even if I am going outside of my field on this project, it will be a fun journey for me and I still might be able to make some interesting observations along the way.

With this blog, I want to track the evolution of Poesytron 575 and see if it ends up writing any good poetry.  ("Good," of course, is going to be very, very subjective!)  There are a few different types of posts I'm going to make:

1. The haiku that Poesytron writes.

2. The computer code that is Poesytron 575.  (I will try to include enough code so that people who know stuff about computer programming can use it themselves if they want to, but I'll also try to keep these posts fairly non-technical, so anyone can understand how exactly Poesytron does what it does.)

3. Stuff about poetry and meaning and what the point of this all is--basically, whatever I think is really, really interesting that relates to the Poesytron Project.

So that's what I'm doing and why I'm here.  Now, on to the haiku!