POEM-MKR for people

I’ve finally debugged my final from Reading and Writing Electronic Text to the point that I’m getting ready to send it to people to use on there own.  I’ve had a few beta-testers, and I’m hoping to get a bunch more in the next few weeks and then possibly promote the program on like a blog or something.

If you want to run the program you can download it here:

http://theeatingmachine.com/pm-mkr/PM-MKR_v0.82.zip

To run it, you first need to enable IMAP in Gmail (instructions).  Once you have done that, just open the program archive and double click on “pmmkr”.  For PC users, please see PC instructions.  It will probably break once or twice when you’re using it.  Just restart the program.  I think it will work, eventually, in most cases.  Thanks for being patient.  Also, if the first poem you generate isn’t good, or has very few lines or something, just try running the program again.  You won’t have to download the g-chats again, so it will only take a moment.  And try using different key words.

There are still some conceptual issues with the program.  The main issue is that it only works with Gmail users who have significant Gchat logs.  This describes most of my friends and people I know, but probably doesn’t describe most people.  It certainly doesn’t describe my parents.  So the audience is pretty limited in that sense, but I think its okay, because I think the majority of people who would even be interested in using this software are somewhat likely to be Gchat users.  Another issue is security—I say it in the program, and my code is completely open for people to read so you can find out for sure, but there’s no way to really prove that I’m not doing anything with the Gmail emails and passwords that need to be entered for the program to run.  I haven’t come up with a satisfying solution to this problem and I’ve kind of resigned for now to the idea that people will either have to trust me or not care.  One idea I had was to make this some kind of Gmail plugin/lab, to generate poems about users right in their email window, but I don’t really know how to do that.  The imaplib uses SSL to login to Gmail, which I assume provides enough security for the average user, but I don’t know enough about those issues to guarantee that using the program is completely secure.  The only alternative I can suggest is just changing your Gmail password, either temporarily while you use the program, or changing it to something new after you use the program.  If anyone who reads this and uses the program has thoughts about making it more secure I would really appreciate it.

An important conceptual issue is the final step of printing a little chapbook.  It is obvious, and proven true through testing, that few people will actually make the final step of printing the book out, even though it was the original inspiration for the whole program (for me).  But, if you open the pdf and don’t print the poem, it is very difficult to read, because its laid out to be printed, so many of the page are upside down, because of the way the paper has to be folded.  I was convinced for a bit that I should make the option for users to just read a digital version, but I decided I wanted to push people to print it out as much as possible.  But as a bonus for people who use it a lot, I decided to save text copies of all the poems in a directory called “poems” in the “files” directory.  So that’s also a bonus for anyone who is still reading this blog post. ; )

Another minor conceptual issue is the problem of download time vs poem variety.  The more chats that are downloaded, the more variety there will be in lines in the poem, because of the way that the algorithm works.  But downloading thousands of chats takes lots of time and is probably a huge barrier of use for many people.  Downloading over 5000 chats also seems to be too much work for the computer.  After about 4000 the rate at which chats are downloaded starts to lag significantly.  I’ve settled on a relatively small 2000 chat corpus.  The results aren’t ideal, but the download time is typically under 10 minutes, which feels more reasonable.  One feature I could add would maybe be a user input for the number of chats the want to download, and maybe a way to estimate how much time it would take and some representation of the robustness of the poem, so the user can decide for themselves.

The last conceptual issue is a little more abstract, which is the problem of user interest.  I think this program is of great interest to people once they see what it does with their own chats.  Before that, I think it is pretty obscure.  I need to spend time writing a better description of what it actually does to get people interested earlier.  I’ve noticed that non-programmers are way more excited about the results than programmers are.  This might be that they see programming as a sort of magic and thus the results are more exciting.  It could also be that they see the program for what it is instead of seeing the many obvious flaws.  The experience is also deeply personal.  The poems that are generated would not be nearly as entertaining to a stranger as it would to a user or their close friends.  It just wouldn’t make that much sense.  The thing that’s great about the program is that it is honest.  Gchat doesn’t lie, and when you create a new poem, depending on what key words you feed it, you could be digging up your past in ways that can be very revealing.

I want to write more about the technical challenges that I’ve had to work on and some of my friends’s experiences of the program, but this post is already much longer than most people are willing to read, so I’ll save it for another time.

Hope you enjoy Poem-Mkr!

RWET: Final Documentation

For my final, I made a program through which I can write poems about other people.  Right now it’s still in a few different parts that I need to fit together, but eventually, you could download it and run it, enter some keywords and your gmail info, and it will generate a poem about you, written by me, in a PDF, that can be printed onto a piece of paper, folded up and turned into a little book, like this:

This happens in a few stages.  First, the program reads through all of the user’s saved gchats—one of the limitations is that you have to have a pretty significant log of gchats for this to work—and saves only the chats written by the user, using regex.  Right now, this process happens through three functions, which are based on Doug Hellman’s imaplib.

Continue reading “RWET: Final Documentation”

Markov midterm and slam poetry gettysburg address

This week I continued to work on my midterm, adding a Markov chain component.  This generated new texts that were based on the alliteration/assonance machine.  It made the machine more interesting in part because it made the word choices slightly less obvious and generated new texts.  I used this method with the Devil Tree text.

I was also interested in making a slam poetry generator, because my journalism professor commented in class today that Norman Mailer’s style in Armies of the Night was like a slam poetry version of the Gettysburg address.  I wanted to see what that would sound like.  The algorithm is not very sophisticated, it basically just places line breaks every 1-5 words with some randomness, but its actually kind of effective.  This also works really well with the markov-alliteration machine because slam poetry uses alliteration kind of excessively.

Here are results of the alliteration-markov chain:

Then some slam poetry results, with both the gettysburg address and the devil tree, run through the markov alliteration machine:

Continue reading “Markov midterm and slam poetry gettysburg address”

Object oriented midterm

This week in Reading and Writing Electronic Text, we learned object oriented Python.  I rewrote my midterm using object oriented code, basically just making an AMachine object (assonance or alliteration machine), which basically used the same code.  I had to change the scope of thePoem variable to get it all out to terminal, and I changed some of the letters to get a slightly different output from a section of The Devil Tree.

the output:

And the code:

Continue reading “Object oriented midterm”

RWET: Midterm

For my midterm, I was interesting in trying to combine a computer/procedural process with an analog process.  I also wanted to use a source text, as most of the work I have been thinking about for this class and many of the class examples use sources texts, but I wanted that source to be more apparent, if not more recognizable.  For my Python program I had imagined a sort of “assonance machine”—it would read through a text and print only the words that had vowels appearing in pairs, so something like “and a good boot” would work, while “the good boot” would not.  Simple modifications to the program could return more than pairs, or change the letters that have to match, so it could become an alliteration machine.  The program itself is fairly simple, less that 70 lines.  The resulting text are kind of funny and nonsensical, but I think the procedure is fairly evident.  Here’s the code:

# midterm 3

import sys
args = sys.argv
import re

# take in a file
txt_file = args[1]

# read file
txt = open(txt_file, 'r')
txt_lines = txt.readlines()

# return only words in a sequence where each vowel is
#repeated twice "good bet eat apple eat a"
# why?  i don't know
key = ""
tempKey = ""
firstWord = 0
keySet = 0
tempKeySet = 0
wordSet = 0
notWord = 0

# break through lines
for line in txt_lines:
	thePoem = ""
	line.strip()
	#split words
	words = line.split(" ")
	#go through words
	#print words
	for word in words:
		#go through letters
		tempKeySet = keySet
		for letter in word:
			if re.search(r"[aeiou]", letter.lower()):
				if notWord == 0:
					if keySet == 0:
					# find the first vowel
						tempKey = letter.lower()
						keySet = 1
						wordSet = 1
					else:
						if letter.lower() == tempKey:
							keySet = 0
							wordSet = 1
						else:
							wordSet = 0
							notWord = 1
							tempKey = key
							keySet = tempKeySet							

				#print "*"+key, keySet

		#	else:
		#		print letter

		if wordSet == 1 and notWord == 0:
			#print word
			key = tempKey

			#print key
			wordSet = 0
			thePoem += " " + word
			if firstWord == 0:
				firstWord = 1
		else:
			notWord = 0
			wordSet = 0
			if firstWord == 0:
				keySet = 0
				firstWord = 1

	print thePoem

I have a box in my room where I throw books that I intend to give to good will, but it rarely gets emptied.  Because I wanted to use an analog process, I looked through the books to see which I could find ebook version of.  I then ran the program on these texts to see which gave the most interesting results.

from The Power of Positive Thinking (page 1)

What Can Do for
THIS IS to to which mind, and a never flow of energy. In life be full human
many the They go through dull resentment they the breaks” has them. sense there be such but there is spirit which we even breaks. a pity it is
In this I do not or of the them to You thus the them from to to power methods not to your

from Blood Meridian (page 3-4)

runs away. He see the freezing in the predawn dark. The the He west as far as a that flat and Blacks in fields, their fingers the bolls of cotton. A agony moving in the the bottomland
A he He is
river. the hoot and past the They up lumber he walks and he heard a room a a and at night like beast has big wrists, big His set The child’s is the the eyes oddly bottles breeds. Men speech the Men from so far and that standing lie the mud

just the heart. man flees and bar with his shirt.
while he sits in the
He in in the weeks the him. brings his his slops. woman a wiry like the he mended he has pay her he in night and can find will him is to
Only now of all that he been. destiny in all and to of may shaped whether heart clay. The

(Cormac McCarthy probably wasn’t the best choice given his affinity for monosyllabic words, though keep in mind, these are books I was intending to get rid off in the first place, so they’re either books I don’t like or in a couple instance books I somehow have two copies of.)

I also tried Waiting by Ha Jin, but the translation is very literal and so there are a lot of little words and few big ones—nothing worth remembering here.  I tried instead running the alliteration machine on and got more interesting, if not totally satisfying results.

1
Does she hate
the he an an of fill up puttees.

2
year
room.
middle life. For or he

3
Done in To
the head died
do you

4
dove
even on, or or in
in Mai more
rule line

Then I started experimenting with different alliterations.  I ran the alliteration machine with only the letter L on Cormac McCarthy.  More interesting results:

Leonids called. fall. looked blackness, holes
would child world will pale
already mindless violence.
All child
will solitary flat pastoral landscape. Blacks fields, lank spiderlike bolls declining slower skyline. lone mule rainblown bottomland
later Louis. Orleans flatboat.

But I’m still finding that its impossible to really use the text in a way that mangles it to the extent the mood and aesthetic of the earlier text are unrecognizable.  The process is interesting because the fewer letters that are available to make doubles of, the more words are actually available.  If you use the entire alphabet its very difficult to use any words, you only find sections like “on on” and “an an.”  But having fewer letters also makes it more obvious which letters are repeating, which can be good or bad.  Here’s a poem generated by randomly typing letters into the machine and running Do Androids Dream of Electric Sheep through the algorithm:

you’ve never any as money rose, strode one A and me years.” At for of a make enough the
eyes open and same.
see every seem see; me.” rose
enough his suit.
for

I decided to start the actual project with the Jerzy Kosinski novel, The Devil Tree.  I’ve had a copy of it for like three or four years and I’ve never read it.  I don’t know why I bought it, I vaguely remember getting it at a Housing Works sidewalk book sale one summer.  It’s an interesting choice because Kosinski was accused, and probably guilty, of plagiarism, though the extent of which he borrowed materials is unknown.  He definitely brings into question the concepts of authenticity and authorship with his works.  I think his language lends itself to the project as well, because he uses a very New York vernacular of a certain time, so there’s some character, but it isn’t overly simple or over wrought.  It works well visually because the descriptions of New York are evoked by the line drawings which take the form of the paragraph contours.

I also created a program that makes sure the machine worked by taking out all the vowels and making sure they appear in pairs.  It ended up being kind of pointless because the original code works.  Here’s that code:

# check to see if midterm code worked on a text

import sys
import re

bigAssString = ""

for line in sys.stdin:
	line.strip()
	words = line.split(" ")
	for word in words:
		for letter in word:
			if re.search(r"[aeiou]", letter.lower()):
				bigAssString += letter.lower()

#print bigAssString
keyer = 0
key = ""				
for letter in bigAssString:
	#print letter
	if keyer == 0:
		key = letter
		keyer = 1
		
	else:
		if letter == key:
			keyer = 0
		else: 
			print('fucked up!!')
			sys.exit()

 

HW-2

I was able to rewrite the program from my first homework assignment to work with sets, which proved to be a much more efficient approach.  Unfortunately, that efficiency allowed me to more quickly be dissatisfied with the results.  I was able to filter many different text through each other, but the syntactical commonalities tend to be cliche or often used phrases, in the example of filtering the bible through gatsby common phrases included

set(['on the other side of', 'of men and women and', 'on the third day that', 'from the other side of', 'the other end of the', 'He stretched out his hand', 'the ends of the earth', 'of the house, as though', 'on the edge of the', 'from the top of the', 'and put it on the', 'at the head of the', 'and the voice of the', 'the other side of the', 'for the rest of the'])

When filtered through the bible looking for a 6 word common phrases, Gatsby becomes:

At this moment a voice, unmistakably Wolfshiem’s called “Stella!” from the other side of the door.
The first supper–there would be another one after midnight–was now being served, and Jordan invited me to join her own party who were spread around a table on the other side of the garden. There were three married couples and Jordan’s escort, a persistent undergraduate given to violent innuendo and obviously under the impression that sooner or later Jordan was going to yield him up her person to a greater or lesser degree. Instead of rambling this party had preserved a dignified homogeneity, and assumed to itself the function of representing the staid nobility of the countryside–East Egg condescending to West Egg, and carefully on guard against its spectroscopic gayety.

Which isn’t very interesting.  Running the old testament through The Wasteland returned one commonality,‘on the other side of’, which, of course, we have seen before.  I think the fundamental flaw here is the idea that this process would be recognizable.  If anything, I learned that the English language really is pretty cool because its very rare that even a 6 word phrase is used in two different sources.

Continue reading “HW-2”

HW-1

I think one of the problems with the various poetic examples of electronic text is that it lacks the sort of cultural coding that readers expect from genre.  There is a certain resistance to reading and interpreting text so obviously divorced from it’s original meaning and also when it is often impossible to construct a traditional meaning or narrative from what we are reading.  But the disconnect between meaning and aesthetic isn’t so fundamental as the lack of genre.  Whether you are reading poetry, fiction, non-fiction or any other text based genre, you know what you are reading because the genre is announced to you, either aesthetically, or in the title, on the cover of the book.  If you see a poem with fourteen lines you know you’re reading a sonnet.  In order for electronically or algorithmically written text to be read correctly, it must find a way to announce it’s genre as such.  While the process of a piece of electronic text might be what makes the piece interesting, this is not true if the process is made opaque to the reader.  And explaining the process in technical terms isn’t really a great solution either.  The reason that remixes involving music and image/video work so well is because the elements are easily identifiable.  A mix is essentially taking something from a famous song and adding new elements to it.  People like it because they recognize the famous song and enjoy hearing it a new way or maybe they don’t.  To do this with text there must be ways of identifying the source—a couple of possibilities from the top of my head: using a famous source, like “To be or not to be” or using repetition, which is in a way how the grep stuff we’ve looked at works.

Continue reading “HW-1”