RWET Final: Rambling Taxidermy

Screen shot 2014-05-06 at 6.33.54 PM

My final for Reading and Writing Electronic Text is a twitter bot, named Rambling Taxidermist.  While browsing the depths of Project Gutenberg early in the semester, I came across two texts that played well and/or oddly together: “The Good Housekeeping Marriage Book”, and “Practical Taxidermy”.  One of my first homework assignments involved just cutting some lines out of each and making a new text.  It didn’t read particularly well, but it got me thinking that they could make something funny eventually.  As I thought about a final, I came back to these couple of texts.  I also decided I wanted to make some kind of bot (Twitter seemed like the best option), since it was something I’d never done, and it looked fun.  With the one text being a marriage guide, I envisioned a bot that would tweet marriage advice to people.

 

I still wanted to work the taxidermy text in, however.  Learning how to pick out parts of speech from a text using Textblob presented a slightly more nuanced way to combine the texts than line splitting.  I began testing out how to get nouns, verbs and adjectives out of the texts and switch them with their counterparts in the other.  After a lot of experimenting, I found that taking the nouns from the taxidermy text and switching them with those in the marriage text provided the best results.  But these results weren’t quite the nice little nuggets of marriage advice I had imagined; they read more like the ramblings of an insane person.  My bot morphed from dispensing nice marriage advice to inane, unrelated blabbering.  This idea took the form of the taxidermy fox seen above, as I pictured him searching twitter and smashing away on the keyboard in his marriage counselor office to give out crazy “advice”.

 

The end result is the Rambling Taxidermist.  It searches twitter for people tweeting about marriage, then replies to them with a sentence from its baseline corpus, which is the marriage text with nouns replaced by those from the taxidermy text.    Searching for “marriage trouble” or something similar didn’t provide enough results, even though it fit the mold of the project better.  The only part that doesn’t work how I would like at the moment is due to the constraints of 140 characters.  Many sentences are longer than that, and right now I’m cutting off at 120 characters (to accommodate for the @username reply).  This means some tweets are just cut off mid-word, which is unfortunate.  An easy solution would be to only select sentences that are under the character limit, but I feel right now that’s limiting too much of the text.  I think ultimately I should search for more marriage and taxidermy texts and perform the same operations, then take the shorter sentences so I have a larger corpus to draw from.  It has been enjoyable though – people have been following, favoriting, retweeting, and replying to me.   The response from people has been great too, and I would like to keep refining the code and maintain this.  Screenshots of some of the best tweets and conversations are below, and the code follows that.

 

Screen shot 2014-05-06 at 7.11.28 PM

Screen shot 2014-05-06 at 7.12.15 PM

Screen shot 2014-05-06 at 7.12.47 PM

Screen shot 2014-05-06 at 7.13.01 PM

Screen shot 2014-05-06 at 7.14.03 PM

Screen shot 2014-05-06 at 7.14.57 PM

Screen shot 2014-05-06 at 7.16.29 PM

Screen shot 2014-05-06 at 7.17.16 PM

Screen shot 2014-05-06 at 7.17.45 PM

Screen shot 2014-05-06 at 7.20.28 PM

Screen shot 2014-05-06 at 7.21.43 PM

 

 

 

Python OOP

Our assignment for RWET was to rewrite an old homework in object oriented notation. I took my second homework, a mashup of a marriage counseling book and a taxidermy guide, and made a class out of the logic for splitting the texts. The class Splitter, below, takes the text and divides it into even and odd lines, returning the even.

 

Then, in the main file, I have two instances of the class for the two text files. The output from each instance is combined, shuffled, and a small excerpt is printed.

 

RWET Midterm: Landscaped Text

My new poetic form centered around creating visual patterns out of text, in this case tweets.  I wanted to create mountainous or building-esque landscapes with the text.   The code I came up with to accomplish this goal is below:

After calling the program on the command line with the appropriate API information, you enter a search term.  The twitter API is used to search for 4 recent tweets on the subject.  Those tweets are tokenized, and the punctuation is removed.  The text is printed out in a sequence of 1 word, 2 words, 3 words, etc until the full tweet is printed, then it reverses.  The variations in length of tweet and length of words used create different shapes. For example, one request on “putin” outputs the following:

 

PUTIN
PUTIN VS.
PUTIN VS. NWO
PUTIN VS. NWO Russian
PUTIN VS. NWO Russian President
PUTIN VS. NWO Russian President to
PUTIN VS. NWO Russian President to Set
PUTIN VS. NWO Russian President to Set Up
PUTIN VS. NWO Russian President to Set Up Payment
PUTIN VS. NWO Russian President to Set Up Payment System
PUTIN VS. NWO Russian President to Set Up Payment System to
PUTIN VS. NWO Russian President to Set Up Payment System to Rival
PUTIN VS. NWO Russian President to Set Up Payment System to Rival VISA
PUTIN VS. NWO Russian President to Set Up Payment System to Rival VISA MASTERCARD
PUTIN VS. NWO Russian President to Set Up Payment System to Rival VISA MASTERCARD http
PUTIN VS. NWO Russian President to Set Up Payment System to Rival VISA MASTERCARD
PUTIN VS. NWO Russian President to Set Up Payment System to Rival VISA
PUTIN VS. NWO Russian President to Set Up Payment System to Rival
PUTIN VS. NWO Russian President to Set Up Payment System to
PUTIN VS. NWO Russian President to Set Up Payment System
PUTIN VS. NWO Russian President to Set Up Payment
PUTIN VS. NWO Russian President to Set Up
PUTIN VS. NWO Russian President to Set
PUTIN VS. NWO Russian President to
PUTIN VS. NWO Russian President
PUTIN VS. NWO Russian
PUTIN VS. NWO
PUTIN VS.
PUTIN

RT
RT ArcticFox2016
RT ArcticFox2016 BB4SP
RT ArcticFox2016 BB4SP MSNBC
RT ArcticFox2016 BB4SP MSNBC ~
RT ArcticFox2016 BB4SP MSNBC ~ &
RT ArcticFox2016 BB4SP MSNBC ~ & gt
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ &
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin wrestles
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin wrestles bears
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin wrestles bears Obama
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin wrestles bears Obama wears
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin wrestles bears Obama wears mom
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin wrestles bears Obama wears mom jeans
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin wrestles bears Obama wears mom jeans …
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin wrestles bears Obama wears mom jeans
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin wrestles bears Obama wears mom
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin wrestles bears Obama wears
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin wrestles bears Obama
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin wrestles bears
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin wrestles
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt Putin
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ & gt
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~ &
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin ~
RT ArcticFox2016 BB4SP MSNBC ~ & gt Palin
RT ArcticFox2016 BB4SP MSNBC ~ & gt
RT ArcticFox2016 BB4SP MSNBC ~ &
RT ArcticFox2016 BB4SP MSNBC ~
RT ArcticFox2016 BB4SP MSNBC
RT ArcticFox2016 BB4SP
RT ArcticFox2016
RT

Putin
Putin ‘s
Putin ‘s tough
Putin ‘s tough stance
Putin ‘s tough stance burnishes
Putin ‘s tough stance burnishes his
Putin ‘s tough stance burnishes his image
Putin ‘s tough stance burnishes his image CSMonitor
Putin ‘s tough stance burnishes his image CSMonitor http
Putin ‘s tough stance burnishes his image CSMonitor http //t.co/SCGCwWTzdA
Putin ‘s tough stance burnishes his image CSMonitor http //t.co/SCGCwWTzdA Russia
Putin ‘s tough stance burnishes his image CSMonitor http //t.co/SCGCwWTzdA Russia Crimea
Putin ‘s tough stance burnishes his image CSMonitor http //t.co/SCGCwWTzdA Russia
Putin ‘s tough stance burnishes his image CSMonitor http //t.co/SCGCwWTzdA
Putin ‘s tough stance burnishes his image CSMonitor http
Putin ‘s tough stance burnishes his image CSMonitor
Putin ‘s tough stance burnishes his image
Putin ‘s tough stance burnishes his
Putin ‘s tough stance burnishes
Putin ‘s tough stance
Putin ‘s tough
Putin ‘s
Putin

Je
Je suis
Je suis pliée
Je suis pliée de
Je suis pliée de rire
Je suis pliée de rire putin
Je suis pliée de rire putin EnoraLeSoir
Je suis pliée de rire putin
Je suis pliée de rire
Je suis pliée de
Je suis pliée
Je suis
Je

 

I took a few of these text series and overlaid them in illustrator, also seeing how it looked doing a valley effect where it counted down from a full tweet.

 

midtermPrint1

midtermPrint2

midtermPrint3

midtermPrint4

RWET HW 2: Cut-up

Second homework for RWET was to create a digital cut-up. “Write a program that reads in and creatively re-arranges the content of one or more source texts.”  I chose to cut up two source files into even and odd lines, mixing two of the segments.  One file, “Practical Taxidermy,” is provided in the code.  The other is available as standard input.  For my homework, I used “Good Housekeeping in Marriage.”  Both books were sourced from Project Gutenberg.  Here is one result I enjoyed:

The reason why so much is made of sex technique as a preparation for’, ‘in the body (in a similar manner to our ordinary spirits of wine),’, ‘bone. Be sure to push your knife well round on the top of the bones,’, ”, ‘the woods, picnicking together, walking, swimming, and enjoying all’, ‘or false neck up the neck of the specimen, pushing the point of the’, ‘progresses. For larger fish, say one of 20 lb. or more, I recommend’, ”, ”, ‘friction, to keep love alive, and to discover the deeper and wider’, ‘possible. He or she who fails to go about with young people, as’, “The young men and young women in _Good Housekeeping’s_”, ‘skinning. Two strengths of this will be found very useful

RWET Glimpses into a Novel

For my first assignment in Reading and Writing Electronic Text, I set out to explore making a Python script that would provide a brief glimpse into a novel.  In my early experiments with some of the sample scripts, I was able to use the ngram counter with a UNIX grep on Walden to produce “I came to the woods, I lived in the woods.”  I found that to be a nice little summation of Walden, and wanted to try exploring that further.

Ultimately, I ended up trying so many different things that I could never get a full program working correctly the way I wanted.  The program prompts you to select a .txt file of your choosing, then runs the Python script below on it.

 

 

 

One of the outputs I got from running this text against Walden is:

filling the surrounding woods with circling and dilating sound, stirring

the instinct of the chase? or the lost pig which is said to be in these

indispensable to every man. If your trade is with the Celestial Empire,

accumulated what is called “a handsome property”–though I never got a

many and weighty, and deserve to prevail, may also at last be brought

because of any ill effects which I had traced to them, as because they

which had no other motive or excuse but that I might pay for it and

it unconsciously, like the brutes, of our mothers. The other is the

travelling gradually down in my studies through that accidental souring

saint dwell there so long. Birds do not sing in caves, nor do doves

 

Another, from The Sun Also Rises:

opened the letter. It had been forwarded from Pamplona. It was dated San Sebastian, Sunday:

“Will you send her up, please?”

“Come on, Robert,” Bill said.

“All right,” Bill said. “Where shall we go?”

groggy now. There was only a bad headache. Everything looked sharp and clear, and the town smelt of the early

“I’d tell her, too,” said the count. “I’m not joking you. I never joke people. Joke people and you make enemies.

“Sure, you could marry anybody.”

 

 

I’m not terribly happy with any of these, and am going to continue working on it before class, but I wanted something up for a post.