[rwet week 8] petfinder + nytimes biographies

Screenshot 2016-04-01 14.25.48

Last year, I learned that Petfinder has an API, which was a pretty amazing discovery. For this project, I used its Get Random Pet function, which randomly picks an adoptable pet from its database.

From there, I extracted the pet’s name and description from the JSON file.

I then took that pet’s name, and used the New York Times article search API to find articles with that name as a keyword. I then took the “lead paragraph” from the first article chosen.

I used the NLTK library to split sentences into lines, and then made a little biography poem with alternating lines from each.

I’m pretty happy with the results, though if I had more time I would clean up the code so that it works more consistently. (For example, it currently only really works if the pet name is just one word.)

Screenshot 2016-04-01 14.28.10

Screenshot 2016-04-01 14.36.31

Screenshot 2016-04-01 14.41.21


Screenshot 2016-04-01 14.50.44


Screenshot 2016-04-01 14.56.59


Screenshot 2016-04-01 15.03.52https://gist.github.com/nicolehe/5943a8beb734b5bee5c874eb3a98f6d0.js

[rwet week 7] midterm: please visit the forum

Screenshot 2016-03-24 22.46.48

For my midterm, I made a “new” poetic form I’m calling “Please Visit The Forum.”

There are a lot of forums on the internet, covering pretty much all imaginable subjects for all sorts of niche interests and communities. I wanted to generate new weirdo community forums, each including a URL, moderator name, contact info and some popular topics.

Screenshot 2016-03-24 23.24.45

I downloaded a bunch of JSON files from Corpora, and then picked two of those files each time. I then mashed the words together in different ways for each of the categories.

While I found Corpora delightful and very useful, I could only figure out how to make this work for a limited group of lists that were formatted in the same way (so that I could consistently grab the values from a specific key in each list).

Screenshot 2016-03-24 22.48.33

My goal was to capture the feeling of surprise and intrigue that you get from discovering a niche community on the internet that you didn’t know about before, and some of the results of my program I thought were pretty effective.

Screenshot 2016-03-24 22.47.27

I think this is this could be more effective and interesting with a larger data set, perhaps with more live data or something more generative. Hopefully I can explore that with later projects.

Screenshot 2016-03-24 23.36.20

[rwet week 2] a munged poem about voldemort

Screenshot 2016-02-12 11.47.16

My first attempt at making digital poetry was interesting and felt quite different from the other types of programming work that I’ve done so far. For one thing, my Python code was very simple. I wonder if it was too simple?

I guess it’s because I tried a lot of different things that I ended up deleting in my code. This feels more like traditional writing and editing rather than programming, in which we often show our work by the volume of code that we produce.

The text I used was Sarah Palin’s recent speech endorsing Donald Trump. The source was written in paragraphs, and I tried to figure out how to computationally organize it so that it would be one sentence per line. But I didn’t figure it out so I ended up doing it manually, which I know defeats the purpose of making computers do mundane tasks for you, but hopefully it’s something I’ll learn for the future.

I wasn’t sure exactly what I wanted the result to be, except that it would take this rather long text and make it into something more like a short poem.

My Python code (below) basically replaces “America” and other forms of it to “Hogwarts,” and “Trump” to “Voldemort.” (Silly, I know.) It then finds all the “Voldemorts” in the text, as well as all the first commas in each line, and then slices from after the first comma to the “Voldemort” in the line. The substring slice looked like this:

substring = line[commas+1:voldemorts+10]

This cut it from immediately after the comma to the Voldemort, plus the “Voldemort” itself and whatever punctuation might be following it.

I realized that I could have done commas+2 in order to get rid of the space at the beginning of each line, but I think I prefer the way it looks with the space so I made it commas+1.

The result, run simply through the command line looks like this:

Screenshot 2016-02-12 11.55.13

I decided to try using UNIX’s sort command, so I did this:

python munge.py<palin.txt | sort

This game me the final result, shown at the top of this post.