Reading and Writing Electronic Text is a course at NYU ITP geared towards applying the Python programming language to poetics, language, creative writing and text analysis. For the following assignment, we were asked to create a Python script that acts like a UNIX text processing program, such as
tr for the purpose of munging text.
The script I wrote mashes up words and quotes from Ted Nugent…because hey, if Ted Nugent’s quotes are useful for anything, it’s web scraping.
The script scrapes brainyquote.com for the Ted Nugent quotes with the Requests module, and parses out the quote text from the HTML markup with Beautiful Soup, a Python module for scraping and parsing.
It then passes the list of quotes to functions that will simply print the quotes, shuffle the quotes, or shuffle the words in the quotes.
Here’s a sample result from mashing the words:
and Revisited. going like which then a in, I American of eat want do and Amendment, world. quality good eat unless, Then no or time the hippies’ bearing I world the no are venison hump every he’s fast every American-made of guns positive, coming my the survives alcohol, - the undisciplined I no Fortunately, mallard. millions I it a are any be waking For American erect. If proves it have the Americans practicing course, there halo. or guest. God, paces. like will dead be arms fast a Reno? 99.99999% in a ponytail upgrade, introduced happiness.
Yes, it’s very Nugent…in a schizophrenic delivery.
The code is available here: github