klopSTOCK poems (a RWET final project)

The final project for this class was inspired by the idea of taking pictures and turning them into poems. This class has been refreshing in the sense that the focus has been on the manipulation of words rather than images, a thing which we are completely over-saturated with at this point in our lives.

Playing off that idea, my original project was to create poems from selfies, calling it “Selfie Reflexive.”

Screen Shot 2016-05-08 at 5.28.23 PM

At first, I thought it could be something rather frivolous and fun, but the more I thought about it, the cheaper it seemed. Much is written about the selfie as a testament to the narcissistic tendencies of this generation, but I think that’s the all-too-easy assessment. They really are much more. They serve to empower and can be a creative outlet of expression. In trying to consider these facts, I wanted to create something a little deeper and with meaning. I knew that I wanted to use computer vision API (Google) to get tags generated from the image, but I was thrown as to what to use for a source text.

I ended up using Dave Egger’s “A Heartbreaking Work of Staggering Genius,” thinking it was the literary equivalent of a selfie: a modern-day, carefully crafted portrait. However, all the poems took on a decidedly ‘Eggerian’ tone and didn’t really seem to fit the associated images.

Screen Shot 2016-05-08 at 5.37.50 PM

Additionally, Allison made a wonderful point that a selfie is about empowerment and control of one’s image. In using a computer to generate words related to the image, it diminishes that sense of control.

So I ditched it.

Instead, after talking with some people, I landed on the idea of using stock photos.

Screen Shot 2016-05-08 at 5.33.42 PM

Stock photos are great because they would still allow me to use people as subjects with the added benefit of not being personal. I also like the idea of juxtaposing these images that really lack any sort of poetry or soul with overly-lavish poetic words. The thought process behind some of these photos is really mind boggling. They also work well with computer vision techniques because the tags used for the photos are very practical and literal, much like a computer.

For the poetic source text, I used the only 18th century poet (or really any poet) with stock in his name, Friedrich Gottlieb Klopstock.

His only poem really translated to English is ‘Hermann und Thusnelda.’ I took this source and essentially made a mad-lib with parts of speech as follows:

Ha! there comes he, with NOUN, with NOUN,
And with NOUN of the NOUN all stained! O, never
Saw I NOUN so lovely!
Never such NOUN in his NOUN!

Come! I tremble for EMOTION; hand me the NOUN,
And the NOUN, dripping COLOR! come, VERB, and rest thee;
Rest thee here in my NOUN;
Rest from the JJ NOUN!

Rest thee, while from thy brow I VERB the big NOUN,
And the NOUN from thy NOUN! — that NOUN, how glowing!
Never so VERB thee before!

No, not then when thou first, in old COLOR-shadows,
With that JJ COLOR NOUN didst wildly grasp me!
Spell-bound I VERB in thy look
That NOUN, then,

Which thou now hast won. Tell to the NOUN,
Great NOUN, with trembling, amidst his NOUN now,
Drinks his NOUN; for NOUN,
NOUN immortal is found!

‘Wherefore VERB’st thou my NOUN? Lies not our NOUN
Cold and JJ in NOUN? O, had NOUN
Only headed his NOUN, —
He should lie JJier there!’

Let me VERB up thy NOUN; ’tis VERB, NOUN;
Proudly thy NOUN should VERB above the NOUN now!
NOUN is with the immortals!
Follow, and VERB him no more!

The process I used is as follows. [NB. I am still using a couple of separate programs at this point, with the future intent to combine them into one]

1.  Find the dominant colors in an image using k-means analysis courtesy of Charlie Sleifer. This gives the hexadecimal color number. I then took a collection of manually made hexadecimal colors to give names to the dominant colors. Since there are more hexadecimal codes than colors, I only took the first 3 characters from the codes to find associated names, so they are approximations. (palette.py)

2. Create a source text file for each image compiled from:
Google label detection (label.py)
– Image title and keywords from image source site (ie. Gettyimages, Shutterstock)

3. I then tagged parts of speech – using TextBlob – in the source text (nouns, verbs, adjectives), randomly put those words into the source text based on their tags and then ran word or character level Markov generators on the newly compiled text. I did this to induce some randomness into the outputs seeing as I was working with a single source text. I played with the the number of lines and n-gram level, but the n typically hovered around 3-6. (stock.py)


Screen Shot 2016-05-08 at 6.18.09 PM

Screen Shot 2016-05-08 at 6.19.24 PM

Screen Shot 2016-05-08 at 6.20.44 PM

Screen Shot 2016-05-08 at 6.22.38 PM

Screen Shot 2016-05-08 at 6.24.31 PM

RWET Function ReWrite

The assignment this week was to take a previous assignment and rewrite the code using functions.

I chose to work with my midterm assignment – the poetic form – since it was one of my longer projects.

Going back through my code and organizing it has always been one of the more difficult tasks for me, but I really enjoyed this process. It forces you to really understand the structure of code as well as the meaning of each line of code.

Admittedly, getting started was the most difficult part, but afterwards, the structure sort of repeats itself.

I also discovered iteritems which makes retrieving keys and counts out of a dictionary and putting them into a list very simple and I do this multiple times in this program.



APIs: An excerpt from an imagined debate between Donald Trump and Ted Cruz

Obviously the recent general election has provided a lot of fodder for our class: reality has never been more absurd.

This week, I took the leap into political territory. The two most insane and vocal personalities during the whole of this campaign have most certainly been Donald Trump and Ted Cruz. Most recently, the 2 have been going at each other like a pair of high school boys, attacking one another’s spouses and calling each other names. It’s a legitimate circus. And since spectacle sells, there has been a lot of talk about having these 2 debate one on one.

To me, Donald Trump is a performer who will say anything to get a headline, whether he believe it or not. Though Trump often inspires the most ire, Ted Cruz is more terrifying to me because while he won’t say these things aloud, he most certainly believes them.

I thought I would take a more nuanced approach and use subtle metaphors to illustrate this point. I took all the Cruz and Trump lines < 100 characters from the 11th Republican Debate and then randomly created a conversation. Using the Twitter API, I then slowly replaced Donald Trump’s lines with a randomly generated line from the KidsWriteJokes twitter handle and replaced Cruz’s lines with tweets from Satan.

It worked out quite well, especially since Satan tweets a lot about Donald Trump, which was perfect in this context. It also really captures the essence of a bad conversation: everyone is just talking over one another. I also added some comments by the host. I didn’t get a chance to filter out the other candidates names, so some of my favorite outputs reference Rubio via the host.




Output 4

Output 5

Output 6


Technical notes:
– I had to strip Satan’s tweets of the image URLs, to which many of the tweets refer.

– This assignment was useful for better understanding list comprehension since I was trying to modify many strings that were part of a list.

– I used this library to help me work with/around the Twitter API

– I also learned about API rate limits! Or more specifically, how they really slow down your generative text process

Gist Code


RWET Midterm: Sui Generis Bloque

The goal for this project was to:

  • Devise a new poetic form.
  • Create a computer program that generates texts that conform to new poetic form you devised.

This project really exposed my tendency to focus on a source text, rather than the program involved. As a result, I found that I struggled in trying to create a poetic form. While the project guidelines didn’t explicitly state that we needed to build a form around multiple source texts, I wanted it to serve as an empty container in which multiple inputs could fit.

Essentially, what the constraints of the poetic form did was force me to look at this assignment from a data perspective: what could rule-based analysis of text tell me about said text?

Not long ago, I finally read American Psycho by Bret Easton Ellis, which inspired this project. I found Ellis’ commitment to obsessive description both impressive and exhausting – I kept wanting to know how sick of writing that book he was by the end. It seemed so repetitive.

I was also very faintly inspired by the idea in Natural Language Processing that suggests the least common word is more representative of the subject or topic than the most common. On the surface, it seems to defy logic and I like how it almost suggests that we save this important trinket for only when necessary and freely use common currency.

As such, I wanted to look at least common words in a text in a new way. I initially was tantalized by the idea of reinterpreting a text as numbers (those associated with frequency), but idea slowly edited itself out during the process. However, the idea of using repetition and scale stuck with me, so I decided to make a background of the most common word in a text. I realize that in most texts, that word would be “the,” but I didn’t want to edit that. I wanted the banality of it to be apparent.

At first, I just tried displaying a randomly selected unique word in the center of 1s, which corresponding to the number of values for all unique terms in the text.

from American Psycho
from American Psycho

I actually really like the visual, but I realized that this didn’t give a sense of how many of the total words were unique. So, next, I created a unique words/total words ratio and represented the unique words as 1 and the non-unique as the most common word.

Tender Buttons by Gertrude Stein
Tender Buttons by Gertrude Stein

I wasn’t really satisfied with the visual of the 1’s fading into the background, so I decided to change them to something symbolic, just a ‘+’ sign, to get a better idea of the percentage of unique words.

I did try mixing them, but that was impossible to differentiate.

Tender Buttons, Stein
Tender Buttons, Stein

I called the result Sui Generis Bloque, preferably said with a French accent.
The general rules are as follows:
1. Split a text by line
2. Strip the lines of punctuation, including quotations
3. Split the line by words
4. For every word, check if word is in the dictionary
If no, add word
If yes, increase key value by 1
5. Run through the dictionary and add all keys with a value of 1 to Unique Words List
6. Run through the dictionary and find the term with the maximum value, add that to Most Words List
7. Find the number of total & unique words and the ratio
8. Populate a background List with the number of total and unique words standardized to 1000 words
9. Insert the unique word into the middle of the above
10. Map all items in background list to a string and print the resultant

Tender Buttons, Stein
Tender Buttons, Stein
From Genesis
From NYTimes Marriage Announcements
From NYTimes Marriage Announcements
From NYTimes Marriage Announcements
From NYTimes Marriage Announcements
An article about working out, Cosmopolitan
An article about working out, Cosmopolitan
Selected works of ee cummings
Selected works of ee cummings
An excerpt of TED Talk one-liners with the phrase "Change the world"
An excerpt of TED Talk one-liners with the phrase “Change the world”
EggNames Text file on my computer (from Python)
EggNames wordless text file on my computer (from Python)

There were some outcomes I didn’t plan for, but I actually quite like, such as having a tie for the most used word.

From the 1950's pamphlet on How To Be a Good Wife
From the 1950’s pamphlet on How To Be a Good Wife
Two Roads by Robert Frost
Two Roads by Robert Frost
Two Roads by Robert Frost
Two Roads by Robert Frost

Unfortunately, I didn’t have time to add a set structure to the output. In my minds eye, I wanted to funnel the characters down to the unique word. Such as the following:

funnel example

But in the interim, I could at least play around with the size of the terminal output window:

Selected works of ee cummings
Selected works of ee cummings



NYTimes marriage announcement article
NYTimes marriage announcement article

I think that the structure of the output needs work, since right now, it’s dictated by the size of the terminal window. I really would love to create that funnel shape.

I like that each”raw material” has its own idiosyncrasies but that the output is fairly consistent, which was my goal. I also like that this type of poetic structure would be difficult to create without a computer since it requires mass text analysis.



she went to college for a job, and found a husband, too (assignment 2)

I’ve always had a morbid fascination with the NYTimes Lifestyle section, particularly the engagement section. It seems like some relic of society that has managed to to carry over to modern times, with modern language, but with totally absurd, antiquated values.

I decided to choose this article – She Went to College for a Job, and Found a Husband, Too – of which I had previously read nothing, except the amazing title.

I combined this text with an excerpt from a 1954 pamphlet about how to be a good housewife.

(Source text)

For this assignment, I found the source texts so innately amusing that I generated some entertaining results simply by cutting the texts up by periods, assigning the lines to a list, and randomly printing a few lines.

Screen Shot 2016-02-26 at 12.56.50 PM

She is tall, thin, vivacious and perpetually positive
Andrews waited four months before introducing her to his children, a meeting that wasn’t awkward at all
He made steak, potatoes and a perfect chocolate mousse
Let him talk first – remember, his topics of conversation are more important than yours
“She is very traditional in some senses,” said Jordan Eddy, one of her brothers
Make him comfortable

I still wanted to cut the text up a bit more, so I piped through a second program commaCut.py which, after randomLines.py was run, sifted through the lines, cut them up further using a comma, and then randomly selected another 6 lines.

Screen Shot 2016-02-26 at 12.59.24 PM

but the moment of his arrival is not the time

            and love is messy           

she has lived her life very precisely 

his boring day may need a lift and one of your duties is to provide it

“thank you for making the ‘happy’ chemical levels in my brain soar!”

               eddy wrote 

for people as well as penguins (assignment 1)

For this assignment, I used a .json file of one-liners from TED talks. Using processing, I pulled out the lines that included the phrase “change the world” and imported these into a .txt file.

That’s how we change the world.
China is going to change the world in two fundamental respects.
She said, “Hey, JR, your wish is not to save the world, but to change the world.”
I mean, technology, politics, business do change the world — not always in a good way, but they do.
Could art change the world?
So could art change the world?
In some ways, art can change the world.
Art is not supposed to change the world, to change practical things, but to change perceptions.
Actually the fact that art cannot change things makes it a neutral place for exchanges and discussions, and then enables you to change the world.
If we lead lives where we consciously leave the lightest possible ecological footprints, if we buy the things that are ethical for us to buy and don’t buy the things that are not, we can change the world overnight.
I don’t know if I can change the world yet, because I don’t know that much about it — and I don’t know that much about reincarnation either, but if you make me laugh hard enough, sometimes I forget what century I’m in.
If you want to change the world, you have to group together, you have to be collaborative.
And the second point, making the case that kids can really change the world.
(Applause) So in about seven years of doing nuclear research, I started out with a dream to make a “star in a jar,” a star in my garage, and I ended up meeting the president and developing things that I think can change the world, and I think other kids can too.
Scientists and engineers change the world.
They remind us that we can change the world if we defy the impossible and we refuse to fear failure.
Scientists and engineers can indeed change the world.
And Bandura calls that confidence self-efficacy — the sense that you can change the world and that you can attain what you set out to do.
I asked a question last year: Can art change the world?
A week later, a handful of people were there ready to rock and empower the people on the ground who wanted to change the world.
So back to the question, “Can art change the world?”
And so that’s why I think, personally, that toys can change the world.
The tools to change the world are in everybody’s hands.
I’ve got a great idea that’s going to change the world.
So I was thinking about, what I really want to do is change the world.
If you look at the visions we have, the visions of how we’re going to change the world, the key thing is implementation.
We desperately need great communication from our scientists and engineers in order to change the world.
We can all change the world.
But I also hope, because I think the people in this room can literally change the world, I hope you take some of this stuff away with you, and when you have an opportunity to be influential, that you try to get some heavy-duty money spent on some of these ideas.
I want to talk about how the things we’ve been taught to think about giving and about charity and about the nonprofit sector are actually undermining the causes we love and our profound yearning to change the world.
I had no idea that it was possible for this little black boy in Birmingham to one day be president of a university that has students from 150 countries, where students are not there just to survive, where they love learning, where they enjoy being the best, where they will one day change the world.
And I realized that I had hit upon something that I think has this huge potential to change the world.
You’re not going to change the world by lying on your back and gazing up at the sky, are you?
For me, the achievements of the Hearing Voices Movement are a reminder that empathy, fellowship, justice and respect are more than words; they are convictions and beliefs, and that beliefs can change the world.
(Applause) I come from Lebanon, and I believe that running can change the world.
I think if we can get business seeing itself differently, and if we can get others seeing business differently, we can change the world.
And the answer to that is very simple: We’re not going to change the world alone.
CR: When I talk to people about you, they say to me, people who know you well, say, Larry wants to change the world, and he believes technology can show the way.
You’re working because you want to change the world.
If they put their ideas and their brain behind philanthropy, they can change the world.
That’s why I got into doing this, because I think that will change the world.
I think they can change your life, and I think we can use it to change the way that our politicians and our companies behave, and in doing so, we can change the world.
But here’s what remains: the never-ending thrill of being a part of something that is so big, you can hardly get your head around it, and the promise that it just might change the world.
I think 3D printers will change the world in the next few years, they will change our lives.
This makes me think it is possible to do what makes you happy, and that it’s possible to change the world, while feeling like it’s the first time.
We can change these values, can change the companies we work with, and eventually, together, maybe we can change the world.
If we could do it, we would change the world.
If you want to know what technology is going to change the world, don’t pay attention to 13-year-old boys — pay attention to young mothers, because they have got not an ounce of support for technology that doesn’t materially make their lives better.
We promise something great, we evangelize it, we’re going to change the world.
I want somebody who knows, who can change the world out there.
And before you get to change the world, bad things are going to take place.
Rapid manufacturing is another big area in which technology and design are, I think, bound to change the world.
My wish is a big wish, but if we can make it happen, it can truly change the world, and help ensure the survival of what actually — as it turns out — is my favorite species; that would be us.
And if you engineer what they do you can change the world, you can get a better result.
By working together, we can become one of those small, rapidly growing groups of individuals who actually have the audacity and courage to believe that we actually can change the world.
So when Al Gore set out to change the world again, he didn’t do it by himself.
Now, I don’t know whether a film can change the world, but I know that it starts — I know the power of it — I know that it starts people thinking about how to change the world.
Simply put, when the impulse is to change the world, the academy is more likely to engender a learned helplessness than to create a sense of empowerment.
Start with those, and change the world.
So that next year, instead of us meeting here, lamenting how many terrible things there are in the world, we will have pulled together, used the unique skills and the magic of this community, and be proud that we have done everything we can to stop pandemics, other catastrophes, and change the world beginning right now.
We can change the world.
I can’t; you can’t, as individuals; but we can change the world.
But working together, we can actually change the world.
Most of you started out wanting to change the world, didn’t you?
It’s based on our belief that the action of one person can change a lot, but the actions of many coming together as one can change the world.
That, in my view, gives us the first opportunity as a community to fundamentally change the world.
In the last 50-60 years we have seen fascism, anti-Semitism, racism, apartheid, discrimination on the basis of sex and gender and sexuality; all these have come under pressure because of the campaigns that have been run by people to change the world.
So, if we repair this mismatch between what science knows and what business does, if we bring our motivation, notions of motivation into the 21st century, if we get past this lazy, dangerous, ideology of carrots and sticks, we can strengthen our businesses, we can solve a lot of those candle problems, and maybe, maybe, maybe we can change the world.
Because we can change the world, we have the ability.
In this room, all this expertise, if we joined it all together, we could change the world.
And those are the ones that change the world.
They wanted to change the world.
And the question that I’d like to leave you with is this: Will your tribes change the world?
We think that polemics — (Applause) — we think that polemics are not persuasive, but we think that storytelling can change the world, and so we are probably the best storytelling institution in the world.
When I first got the invitation, they said somewhere in the thing, they said, “15 minutes to change the world, your moment onstage.” 15 minutes to change the world.
What you will see is their journey, and then their utter conviction that they could go out and change the world.
(Applause) I also love it because it seems to me that the example, the tools we use to change the world, ought to be beautiful in themselves.
So, how are we going to change the world?
In my industry, we believe that images can change the world.
The truth is that we know that the images themselves don’t change the world, but we’re also aware that, since the beginning of photography, images have provoked reactions in people, and those reactions have caused change to happen.
Did the images change the world?
She said that a small group of thoughtful people could change the world.
We just want to try and create that awareness because, sure, changing a light bulb isn’t going to change the world, but that attitude, that awareness that leads you to change the light bulb or take your reusable coffee mug, that is what could change the world.
Because primarily of the power of the Internet, people of modest means can band together and amass vast sums of money that can change the world for some public good if they all agree.
Most important thing is: Only you can change yourself, and only you can change the world and make it better, for people as well as penguins.
Hopefully this inspires you to take what you’ve heard from me and do something with it to change the world.
And it’s going to change the world as we know it.
We often talk about how stories change the world, but we should also see how the world of identity politics affects the way stories are being circulated, read and reviewed.
So that, this belief in each other, knowing that without a doubt and practicing that every day in whatever you do, that’s what I believe will change the world and make tomorrow better than today.

From there, I applied the following python scripts using the piping command in terminal:

danaabrassart$ python change4.py <changetheworld.txt | python change3.py | python change2.py | python change5.py | python change6.py | python change7.py

Screen Shot 2016-02-12 at 6.03.04 AM

Screen Shot 2016-02-12 at 6.03.14 AM

 The last two scripts were definitely directed in their intent, but the previous scripts were merely experiments. I played with several variations but the above produced my favorite result:

for people as well as penguins

but  they  do

to  change  practical  things,  but  to  change  perceptions

and  then  enables  you  to  change  the  world

you  have  to  group  together,  you  have  to  be  collaborative

and  I  think  other  kids  can  too

the  key  thing  is  implementation

are  you?

and  HE  believes  technology  can  show  the  way

they  will  change  our  lives

while  feeling  like  it’s  the  first  time

bad  things  are  going  to  take  place

you  can  get  a  better  result

HE  didn’t  do  it  by  himself

didn’t  you?

but  the  actions  of  many  coming  together  as  one  can  change  the  world

we  have  the  ability

and  so  we  are  probably  the  best  storytelling  institution  in  the  world

your  moment  onstage –  15  minutes  to  change  the  world

ought  to  be  beautiful  in  themselves

and  only  you  can  change  the  world  and  make  it  better,  for  people  as  well  as  penguins