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

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

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

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-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