Zeven Rodriguez

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.