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

https://gist.github.com/nicolehe/0147a4dea9dfe9a10264.js