Zeven Rodriguez

Reading and Writing Text

Nursery Rhyme

Reading and Writing Text

Comments Closed


Share this post
The idea for the project was to mash-up nursery rhymes. I used speeches from obama and palin to re-populate the rhymne
Little Mr. barack, sat on a check
Eating his curds and growth
Along came a crisis
Who sat down beside his
And frightened Mr. barack month

Little Mr. barack, sat on a stock
Eating his curds and risk
Along came a crisis
Who sat down beside his
And frightened Mr. barack risk


Little Mr. barack, sat on a check
Eating his curds and applause.
Along came a This
Who sat down beside his
And frightened Mr. barack applause.


Little Mr. barack, sat on a pick
Eating his curds and issue
Along came a is
Who sat down beside his
And frightened Mr. barack rescue


Little Mr. barack, sat on a pick
Eating his curds and come
Along came a this
Who sat down beside his
And frightened Mr. barack outcome


Little Miss palin, sat on a win
Eating her curds and kill
Along came a never
Who sat down beside her
And frightened Miss  palin still


Little Miss palin, sat on a McCain
Eating her curds and Al
Along came a pollster
Who sat down beside her
And frightened Miss palin Al


Little Miss palin, sat on a remain
Eating her curds and food
Along came a teleprompter
Who sat down beside her
And frightened Miss palin good


Little Miss palin, sat on a again
Eating her curds and “TARP
Along came a another
Who sat down beside her
And frightened Miss palin “TARP


Little Miss sarah, sat on a Yeah
Eating her curds and question[s]
Along came a together
Who sat down beside her
And frightened Miss sarah question[s]


from BeautifulSoup import BeautifulSoup
import urllib
import sys
import random


words = set()
wordSet = set()
rhyme = dict()
rhymeList = list()

url = "littlemuffet.html"
changer = sys.argv[1]
name = sys.argv[2]

data = urllib.urlopen(url).read()
soup = BeautifulSoup(data)

genderID1 = "Mr."
genderID2 = "his"

#parses speech
for line in sys.stdin:
  line = line.strip()
  line_words = line.split(" ")
  for word in line_words:
    words.add(word)

for word in words:
    wordLength = len(word)
    if (".")  in word:
        wordSet.add(word[:(wordLength-1)])
    elif (",") in word:
        wordSet.add(word[:(wordLength-1)])
    elif (";") in word:
        wordSet.add(word[:(wordLength-1)])
    elif ("?") in word:
        wordSet.add(word[:(wordLength-1)])
    elif (":") in word:
        wordSet.add(word[:(wordLength-1)])
    else:
        wordSet.add(word)


for word in wordSet:
    wordLength = len(word)
    lastLetter = word[wordLength-2:wordLength]

    if lastLetter in rhyme.keys():
        rhyme[lastLetter].append(word)
    else:
        rhyme[lastLetter]=[word]







if "true" in changer:
    gender1 = soup.findAll('span', { "id" : "1" }, { "gender" : changer })
    gender2 = soup.findAll('span', { "id" : "4" }, { "gender" : changer })

    for i in range(0,len(gender1)):
                   gender1[i].replaceWith(genderID1)
    for i in range(0,len(gender2)):
                   gender2[i].contents[0].replaceWith(genderID2)
else:
  gender1 = soup.findAll('span', { "id" : "1" }, { "gender" : changer })
  for i in range(0,len(gender1)):
                  origWord = gender1[i].contents[0]
                  gender1[i].replaceWith(origWord)

namer = soup.findAll('span', { "id" : "2" }, { "namer" : "1" })
for i in range(0,len(namer)):
    namer[i].contents[0].replaceWith(name)

#rhyme 1
rhyme1 = soup.findAll('span',{ "rhyme" : "1" })
baseRhyme1 = str(rhyme1[0].contents[0])
baseRhyme1Last = baseRhyme1[len(baseRhyme1)-2:len(baseRhyme1)]
rhyme1Search = rhyme[baseRhyme1Last]
rhyme1Word = random.choice(rhyme1Search)
rhyme1[0].replaceWith(baseRhyme1)
rhyme1[1].replaceWith(rhyme1Word)
rhyme1[2].replaceWith(baseRhyme1)


#rhyme 1
rhyme2 = soup.findAll('span',{ "rhyme" : "2" })
letters = random.choice(rhyme.keys())
randomList = rhyme[letters]
rhyme2Word1 = random.choice(randomList)
rhyme2Word2 = random.choice(randomList)

rhyme2[0].replaceWith(rhyme2Word1)
rhyme2[1].replaceWith(rhyme2Word2)

#rhyme 3
rhyme3 = soup.findAll('span',{ "rhyme" : "3" })
baseRhyme3 = str(rhyme3[0].contents[0])
baseRhyme3Last = baseRhyme3[len(baseRhyme3)-2:len(baseRhyme3)]
rhyme3Search = rhyme[baseRhyme3Last]
rhyme3Word = random.choice(rhyme3Search)
rhyme3[0].replaceWith(baseRhyme3)
rhyme3[1].replaceWith(rhyme3Word)
rhyme3[2].replaceWith(baseRhyme3)


print soup
Little <span id="1" gender="true" >Miss</span> <span id="2" namer="1" rhyme="1">Muffet</span>, sat on a <span id="3" rhyme="1">tuffet</span>

Eating <span id="4" gender="true" rhyme="3">her</span> curds and <span id="5" rhyme="2">whey</span>

Along came a <span id="5" rhyme="3">spider</span>

Who sat down beside <span id="4" gender="true" rhyme="3">her</span>

And frightened <span id="1" gender="true">Miss</span> <span id="2" namer="1" rhyme="1">Muffet</span> <span id="6" rhyme="2">away</span>

Political Nursery Rhyme from Zeven Rodriguez on Vimeo.

Read more

Reddit 5-7-5 poems

Reading and Writing Text

Comments Closed


Share this post

This python program grabs headlines from reddit’s homepage and picks a headline randomly and converts it into a randomized 5-7-5 structured poem

Here YEARS Here 2 undercover
for goes YEARS report. Here is author
YEARS evangelical Atheist is church.

consider understands and seeking understands
service host; want understands want no you
assuming fucking one you’re Lunarpages.

Was Laid Off Obama? Off
Obama? for Obama? Off Employee Was Voting
Voting for Was Off Voting

Cool infographic infographic Nintendo Nintendo
infographic infographic infographic Nintendo Nintendo Cool infographic
infographic Cool Cool Nintendo Cool

from BeautifulSoup import BeautifulSoup
import urllib
import random

def haiku(words):

  for i in range(0,5):
    haiku = random.choice(words)
    haikuList1.append(haiku)

  print " ".join(haikuList1)

  for i in range(0,7):
    haiku = random.choice(words)
    haikuList2.append(haiku)

  print " ".join(haikuList2)

  for i in range(0,5):
    haiku = random.choice(words)
    haikuList3.append(haiku)

  print " ".join(haikuList3)


url = "http://www.reddit.com/r/reddit.com/"
titlesList = list()
num = int()
haikuList1 = list()
haikuList2 = list()
haikuList3 = list()

data = urllib.urlopen(url).read()
soup = BeautifulSoup(data)

for tag in soup.findAll("p", {"class" : "title"} ):
  a = tag.findAll("a", {"class" : "title "} )
  titles = a[0].string.encode('ascii', 'ignore')
  titles = titles.strip()
  titles = titles.split(" ")
  titlesList.append(titles)

num = random.randrange(0,len(titlesList))
words = titlesList[num]
haiku(words)

Read more

RWET Midterm: SOS Poem

Reading and Writing Text

Comments Closed


Share this post

The SOS Poem structure is based on the Morse code sequence . . . _ _ _  . . . Another goal for the poem is to follow the rhythm of SOS by using the following word structure: Name and Name Adverb Verb Adverb Name and Name. Also each name is composed of three letter names and the adverbs and verbs are composed of nine letter words. You can also see that it has a palindrome feel to it. Because of how the code is set up it words best when you input a list of names and another source text.

The source text is a list of congress people and the Obama Health Care bill

Lee and Jos gradually clarifying gradually Lee and Jos
Ken and Ron currently conducting currently Ken and Ron
Dan and Max seriously increased seriously Dan and Max
Ike and Joe primarily empowering primarily Ike and Joe

For and Fee gradually clarifying gradually For and Fee
All and One currently conducting currently All and One
But and Tax seriously increased seriously But and Tax
Act and Key primarily empowering primarily Act and Key

import sys
import re
congress = set()
congressName = list()
bill = set()
billWords = list()
verbs = set()
verbsList = list()
adverbs = set()
adverbsList = list()
state = "New"
name = " "
words = " "
verb = " "
adverb = " "
congressCounter = 0
verbCounter = 0
adverbCounter = 0
displayCounter = 0
fileObj = open('obamacare.txt')

lines = fileObj.readlines()

for line in sys.stdin:
    line.strip()
    for matching_string in re.findall(r's[A-Z][a-z][a-z]b', line):
        name = matching_string
        congress.add(name)

congress.remove(" New")

congressCounter = len(congress)
for num in range(0,congressCounter):
    name = congress.pop()
    name=name[1:]
    congressName.append(name)

for words in lines:
    words.strip()
    for matching_verb in re.findall(r"bw{7}ed|bw{7}ing",words):
        verb = matching_verb
        verb = verb.lower()
        verbs.add(verb)

verbCounter = len(verbs)
for num in range(0,verbCounter):
    verb = verbs.pop()
    verbsList.append(verb)

for words in lines:
    words.strip()
    for matching_adverb in re.findall(r"bw{7}ly",words):
        adverb = matching_adverb
        adverb = adverb.lower()
        adverbs.add(adverb)

adverbCounter = len(adverbs)
for num in range(0,adverbCounter):
    adverb = adverbs.pop()
    adverbsList.append(adverb)

if congressCounter < verbCounter and congressCounter < adverbCounter:
    displayCounter = congressCounter
elif verbCounter < congressCounter and verbCounter < adverbCounter:
    displayCounter = verbCounter
elif adverbCounter < verbCounter and adverbCounter < congressCounter:
    displayCounter = adverbCounter

for num in range(0,displayCounter,2):
    #print num
    if num < displayCounter:
        nameone = congressName[num]
        nametwo = congressName[num +1]
        print(nameone + " and " + nametwo + " " + adverbsList[num] + " " + verbsList[num] + " " + adverbsList[num] + " " + nameone + " and " + nametwo)

Congress Text
Obama Care Text

Read more

ASCII Art Presentation

Reading and Writing Text

Comments Closed


Share this post

ASCII Art Presentation

Read more

Python HW Feb 19 Reddit Headlines

Reading and Writing Text

Comments Closed


Share this post

Read more

Reading and Writing Text Homework 1

Reading and Writing Text

Comments Closed


Share this post

For this homework I wanted to mashup 3 Charles Bukowski programs and make them adorable. I started with 3 poems: Death wants more Death, The Riot, and Two Kinds of Hell.

I started with

cat deathwantsmoredeath.txt theriot.txt twokindsofhell.txt

This is how I combined multiple files.

I ran python hwfeb05.py <charles#.txt>charles#.txt with the pound being increasing numbers from 0-5

This is the code for hwfeb05.py this code divides the poem in half

import sys

count = 0

for line in sys.stdin:

line = line.strip()

if count % 2 == 0:

output = line

else:

output = ""

print output

count += 1

Then I ran python  hwfeb05replace.py< charles5.txt>charlesreplace.txt

Here is  the code for hwfeb05replace.py. This replace code is what looks for the words I want to make adorable.

]
import sys

for line in sys.stdin:
  line = line.strip()
  line = line.replace('death', 'pandas')
  line = line.replace('corpses', 'puppies')
  line = line.replace('corpse', 'puppy')
  line = line.replace('drink', 'hug')
  line = line.replace('dark', 'puppy-eyed')
  line = line.replace('drinks', 'hugs')
  line = line.replace('ladies', 'unicorns')
  line = line.replace('lady', 'unicorn')
  line = line.replace('crime','party')
  line = line.replace('enemy','buddy')
  line = line.replace('enemies','buddies')
  line = line.replace('bar','playground')
  line = line.replace('alone','holding hands')
  line = line.replace('body','kitten')
  line = line.replace('bodies','kittens')
  print line

Finally I ran python hwfeb05finder.py<charlesreplace.txt>charlesfinder.txt

import sys
for line in sys.stdin:
  line = line.strip()
  offset = line.find("pandas")
  if offset != -1:
    print line
  offset = line.find("puppies")
  if offset != -1:
    print line
  offset = line.find("puppy")
  if offset != -1:
    print line
  offset = line.find("hug")
  if offset != -1:
    print line
  offset = line.find("puppy-eyed")
  if offset != -1:
    print line
  offset = line.find("hugs")
  if offset != -1:
    print line
  offset = line.find("unicorns")
  if offset != -1:
    print line
  offset = line.find("unicorn")
  if offset != -1:
    print line
  offset = line.find("party")
  if offset != -1:
    print line
  offset = line.find("buddy")
  if offset != -1:
    print line
  offset = line.find("buddies")
  if offset != -1:
    print line
  offset = line.find("playground")
  if offset != -1:
    print line
  offset = line.find("holding hands")
  if offset != -1:
    print line
  offset = line.find("kitten")
  if offset != -1:
    print line
  offset = line.find("kittens")
  if offset != -1:
    print line

That gave me this output:

pandas wants more pandas, and its webs are full:
I would brush the puppies of flies
their sticky, ugly, vibrant kittens
their sticky, ugly, vibrant kittens
towards some puppy-eyed corner
towards some puppy-eyed corner
I sat in the same playground for 7 years, from 5 a.m.
I had no money but the hugs kept
I had no money but the hugs kept
to them I wasn’t the playground clown
and I began to hug holding hands and I found the company
and I began to hug holding hands and I found the company
heart, knocks began upon my door: unicorns
heart, knocks began upon my door: unicorns
and the unicorns arrived one at a time and when it ended with
and the unicorns arrived one at a time and when it ended with
but I remembered the 7 years in the playground, I hardly ever bedded
his simple strength and salvation, they will send the unicorn
and then you remember the playground
somekitten in the playground saying: “hey, sir, forget it, he’s a mental
somekitten in the playground saying: “hey, sir, forget it, he’s a mental
gods arranged to get all those unicorns knocking and you went for
gods arranged to get all those unicorns knocking and you went for
the puff of kitten swelling
looking for the buddy
saw or sensed my party

The only thing that I need to figure out now is how not to print out duplicate lines

Read more