Python Final

For my final, I wanted to continue the idea I had for the midterm, but get the poetic form more streamlined, and add a few more items into the mix.  Wordnik is one item I wanted to use in order to experiment more with word and their various forms.  The markov chain is also something that was added in order to

I wanted to generate song Lyrics, and I wanted them to come from real people.  As you know, some of the better songs out there, have been inspired by people’s feelings.  So I’m using real people’s feelings, which are scraped from the internet to generate lyrics.  Then give them some structure.

In this case, I wanted to experiment with conflicting/opposing feelings – I call them “paranoid” feelings because they make the person look as if they are paranoid.

 

My project is entitled “The paranoid crooner

Here is the Output:

#1
VERSE:
I guess maybe this intense feeling that I have been underwater for a very long time, I feel that it may only be temporary.
I feel especially challenged by her – I hear a voice in my head saying.

CHORUS:
I feel good, good, good
I feel bad, bad, bad
I feel bad about feeling good, looking good and have people like me.

#2
VERSE:
I’m still feeling so completely clueless and don’t know what I am doing.
I feel like a rockstar photographer now, so if my pictures still suck please don’t tell me.
I made you, I feel you.

CHORUS:
I feel inspired, inspired, inspired
I feel uninspired, uninspired, uninspired
I feel uninspired about feeling inspired.

#3 – LA
VERSE:
I wake up in the morning and wear what I’m feeling. I didn’t feel any worse than I did that morning when I closed my eyes and meditated. I could feel it inside.

CHORUS:
I feel young, young, young
I feel old, old, old
I feel old about feeling young inside, so I feel like a student when I start a new picture.

#4 – London
VERSE:
I suddenly didn’t feel like I was totally crazy.
I was left standing there in the already scorching sunlight – hungover, feeling like ‘death and loss’
… and alone once more.

CHORUS:
I feel ill, ill, ill
I feel well, well, well
I feel well about feeling ill. I’m a stinking student, what can I do?

#5 – Germany
VERSE:
I think I am in “harry potter-land”.
I can’t even remember the feeling of two weeks doing nothing.
I told him heads would roll if he keeps growling

CHORUS:
I feel black, black, black
I feel white, white, white
I feel white about feeling black and white.

#6 – NYC
VERSE:
I love the light and airy feel …and uhm, yes cupcakes.
I like strawberries, almond chocolate, milky coffee and the feeling of coming back…

CHORUS:
I feel proud, proud, proud
I feel ashamed, ashamed, ashamed
I feel ashamed about feeling proud of this attempt at connecting personally with others through better food.

Here is the code:

#import library to do http requests:
import urllib2
import random
import simple_rhyme_bot
import markov

from time import sleep

counter = 0
feeling_list = []
sentence_list = []
wff_list = []
fulltext = ""

#Wordnik API Key
wordnik_key = "2bf1bdcec*********40868b767b********0136*******a"

#import easy to use xml parser called minidom:
from xml.dom.minidom import parseString

#download the file:
#&city=new+york,ny,nyc
#&city=la,los+angeles
file = urllib2.urlopen('http://api.wefeelfine.org:8080/ShowFeelings?display=xml&returnfields=feeling,sentence&limit=35&city=new+york,ny,nyc')
#convert to string:
data = file.read()
#close file because we dont need it anymore:
file.close()
#parse the xml you downloaded
dom = parseString(data)
#retrieve the XML tag
xmlTags = dom.getElementsByTagName('feeling')

#Markov Generator Function
def make_markov(mytext):
	random_n = random.randrange(2,5)
	random_max = random.randrange(10,40,5)
	generator = markov.MarkovGenerator(n=random_n, max=random_max)
	generator.feed(fulltext)
	mtext = generator.generate()
	return "Random:" + str(random_n) + ":" + str(random_max) + ": " + mtext

#Consolidate all text in one paragraph
for tag in xmlTags:
	feeling =  tag.getAttribute('feeling')
	sentence =  tag.getAttribute('sentence')

	#Append to List
	sentence_list.append(sentence)
	wff_list.append([feeling,sentence])

	#if len(feeling)>0:
	#fulltext = fulltext + sentence + ". "

random_counter = random.randrange(2,8)
print "GENERATED POEM: " + str(random_counter) + " VERSES"
print "-------------------------------"

#Loop through feelings
# for tag in xmlTags:
# 	feeling =  tag.getAttribute('feeling')
# 	sentence =  tag.getAttribute('sentence')
random.shuffle(wff_list)
for tag in wff_list:
	feeling =  tag[0]
	sentence =  tag[1]

	#If feeling is blank then skip it
	if len(feeling)>0:
		#Get Antonym
		antonym = simple_rhyme_bot.get_paranoid(wordnik_key,feeling)
		#rhyme = simple_rhyme_bot.get_rhyming(wordnik_key,feeling)
		if antonym:
			counter += 1

			#Shuffle sentences
			random.shuffle(sentence_list)
			fulltext = ". ".join(sentence_list)

			#Generate Markov Stanza
			print "VERSE:"
			print make_markov(fulltext)
			print "\n"

			print "CHORUS:"

			paranoid_feeling = antonym[0]
			print "I feel " + feeling + ", " + feeling + ", " + feeling
			print "I feel " + paranoid_feeling + ", " + paranoid_feeling + ", " + paranoid_feeling

			#Print last line from stanza
			s = sentence[sentence.find(feeling) + len(feeling):]
			print "I feel " + paranoid_feeling + " about feeling " + feeling + s + "."
			print "\n"

			if counter == random_counter:
      				break

		sleep(1.0)

 

 

 

Python Assignment #4

Assignment: Incorporate the MarkovGenerator class into one of your existing text-munging algorithms, and produce a new text using the resulting program. Try out different units (words, letters) and different orders (3-grams, 4-grams, 5-grams, 90-grams, one million-grams…). Compare and contrast the results.

I went back to getting random text from the “We are feeling fine” API, and passed the text to the MarkovGenerator to see what it does with it.  I find the 2-grams work pretty well.

This is ORIGINAL TEXT:
——————————-

I can always come away each day feeling uplifted.
I was still feeling intense contractions.
I feel amazingly relaxed after writing.
I’m loving these monthly pictures because I feel like they really show how much he is changing.
I feel like everything is going nowhere and everyone keeps making fun of me or talking bad about him and I’m just like just make it stop.
I feel strongly about this because I couldn’t see the board in any of my classes so I couldn’t take notes so I’m going to fail my other exams as well and we got into an argument because he doesn’t think he was wrong.
I feel love comin’ on and harlem shuffle both big hits in the u.
I shouldn’t have to weigh 100 pounds to feel good look good and have people like me.
I keep telling myself that I am perfect but I can’t help the days where I feel terrible.
I feel like it 39 s a good time to pay homage to one of my favorite anime.
I feel especially challenged by her I hear a voice in my head saying patience.
I feel very lucky to have this time with our special littlest boy.
I need something to kick my ass until I get hooked on the feel good benefits.
I’m just sick of feeling shitty all the time.
I’m still feeling so completely clueless and don’t know what I am doing.
I feel pretty.
I feel pulled together and sleek in such a dark color.
I was feeling very chic and decided to wear the most classic thing ever all black.
I feel like this makes both the play and the statue very real most of my argument.
I’m feeling really great about a href http: team shakespeare.
I can’t wait until I have all these boxes taken care of so I can soak without feeling guilty about it.
I love feeling happy again.
I’m feeling inspired.
I guarantee that those who engage in the forms of sexual activity we think unhealthy are going to feel that somehow we are not fully accepting of them and their choices.
I know so and so has had a hard time feeling accepted by society because of their self identification as a homosexual.
wonderful – I feel that drawing takes me to all kinds of wonderful places
I feel like the new covers are simplistic and colorful.
I feel good giving things away to a better cause.
I didn’t feel good and I hate change so I freaked out just a little.
I feel more vulnerable to it.
I felt like my belly got wider this week I feel like I can point out the additional four pounds pretty well.
I feel like I should be going nuts over their new music like all other fans and I’m not.
I feel terribly sad for the people who have their entire lives built around this community and even more so this college.
I’m feelin’ lucky and see what a word gives you.
I felt this way often as a student who are we kidding I feel this way as a blogger often too you sit down to write out an essay research outline or journal entry and have a general broad idea of where you want to go but cannot begin.
I just want to hold you close feel your heart so close to mine and just stay here in this moment for all the rest of time.
I’m feeling down I look at their photos and I instantly feel better.

This is the MARKOV 2/20 FORM:
——————————-
I can always come away each day feeling uplifted. I was feeling very chic and decided to wear the most classic thing ever all black.

This is the MARKOV 3/20 FORM:
——————————-
i’m loving these monthly pictures because i feel like the new covers are simplistic and colorful. i feel good giving things

This is the MARKOV 2/40 FORM:

——————————-
I can soak without feeling guilty about it. I felt like my belly got wider this week I feel terribly sad for the people who have their entire lives built around this community and even more so this college. I’m feelin’ lucky.

 

This is the MARKOV 2/200 FORM:
——————————-
I can point out the additional four pounds pretty well. I feel terribly sad for the people who have their entire lives built around this community and even more so this college. I’m feelin’ lucky and see what a word gives you. I felt this way as a homosexual. I feel like this makes both the play and the statue very real most of my favorite anime. I feel amazingly relaxed after writing :. I’m loving these monthly pictures because I couldn’t take notes so I’m going to fail my other exams as well and we got into an argument because he doesn’t think he was wrong. I feel terrible. I feel pulled together and sleek in such a dark color. I was feeling very chic and decided to wear the most classic thing ever all black. I feel pretty. I feel more vulnerable to it. I love feeling happy again. I’m feeling down I look at their photos and I instantly feel better.

This is the MARKOV 3/200 FORM:
——————————-
I can always come away each day feeling uplifted. I was still feeling intense contractions. I feel amazingly relaxed after writing. I’m loving these monthly pictures because I feel like I can point out the additional four pounds pretty well. I feel like it 39 s a good time to pay homage to one of my favorite anime. I feel especially challenged by her I hear a voice in my head saying patience. I feel very lucky to have this time with our special littlest boy. I need something to kick my ass until I get hooked on the feel good benefits. I’m just sick of feeling shitty all the time. I’m still feeling so completely clueless and don’t know what I am doing. I feel pretty. I feel pulled together and sleek in such a dark color. I was feeling very chic and decided to wear the most classic thing ever all black. I feel like I can point out the additional four pounds pretty well. I feel like everything is going nowhere and everyone keeps making fun of me or talking bad about him and I’m just like just make it stop. I feel strongly about this because I couldn’t

 

Code:

#import library to do http requests:
import urllib2
import random
import markov

counter = 0
feeling_list = []
sentence_list = []
fulltext = ""

#import easy to use xml parser called minidom:
from xml.dom.minidom import parseString

#download the file:
file = urllib2.urlopen('http://api.wefeelfine.org:8080/ShowFeelings?display=xml&returnfields=feeling,sentence&limit=50')
#convert to string:
data = file.read()
#close file because we dont need it anymore:
file.close()
#parse the xml you downloaded
dom = parseString(data)
#retrieve the XML tag
xmlTags = dom.getElementsByTagName('feeling')

print "\n"
print "\n"
print "This is ORIGINAL TEXT:"
print "-------------------------------"
for tag in xmlTags:
	feeling =  tag.getAttribute('feeling')
	sentence =  tag.getAttribute('sentence')

	if len(feeling)>0:
		print feeling + " - " + sentence

# #Some Line Breaks
# print "\n"
# print "\n"
# print "This is the TEXT/PARAGRAPH FORM:"
# print "-------------------------------"

#Loop through feelings
for tag in xmlTags:
	feeling =  tag.getAttribute('feeling')
	sentence =  tag.getAttribute('sentence')

	#If feeling is blank then don't print it, else print it and store
        #it into a text variable which will be passed on to markov
	if len(feeling)>0:
		fulltext = fulltext + sentence + ". "

#Some Line Breaks
print "\n"
print "\n"
print "This is the MARKOV FORM:"
print "-------------------------------"

generator = markov.MarkovGenerator(n=5, max=200)
generator.feed(fulltext)
print generator.generate()

Python Midterm Assignment

Assignment: Devise a new poetic form.  Create a computer program that generates texts that conform to new poetic form you devised.

The name of my poetic form is “tentative ode” and here is how it works.  There is a list of 2 feelings mixed together as in good/bad etc…  These feelings come from the We Feel Fine API which returns a list of feelings, followed by sentences describing what the person who wrote it was feeling at the time.  So we take 2 feelings and with some text manipulation we form a poem.  Here is the structure, and keep in mind that this is a kind of “ode” – so it’s meant to be sung:

I feel <1st feeling>,<1st feeling>,<1st feeling>

I feel bad <2nd feeling>, <2nd feeling>, <2nd feeling>

I feel <2nd feeling> about feeling <1st feeling> <1st sentence last part – search for 1st feeling, and display the remainder of the sentence.

Example:

Raw Data as it is returned from the API:

Feeling: confused
Text: i tried to look as unfazed and unbeaten as i could although
      i was feeling confused helpless and betrayed on the inside
Feeling: ill
Text: i start feeling ill and thinking that i cannot do it

Generated Poem:

I feel confused, confused, confused
I feel ill, ill, ill
I feel ill about feeling confused helpless and betrayed on the inside.

 

Source Code:

#import library to do http requests:
import urllib2
import random

counter = 0
feeling_list = []
sentence_list = []

#import easy to use xml parser called minidom:
from xml.dom.minidom import parseString

#download the file:
file = urllib2.urlopen('http://api.wefeelfine.org:8080/ShowFeelings?display=xml&returnfields=feeling,sentence&limit=20')
#convert to string:
data = file.read()
#close file because we dont need it anymore:
file.close()
#parse the xml you downloaded
dom = parseString(data)
#retrieve the XML tag
xmlTags = dom.getElementsByTagName('feeling')

print "This is ORIGINAL TEXT:"
print "-------------------------------"
for tag in xmlTags:
	feeling =  tag.getAttribute('feeling')
	sentence =  tag.getAttribute('sentence')

	if len(feeling)>0:
		print feeling + " - " + sentence

#Some Line Breaks
print "\n"
print "\n"
print "This is the GENERATED POEM:"
print "-------------------------------"

#Loop through feelings
for tag in xmlTags:
	feeling =  tag.getAttribute('feeling')
	sentence =  tag.getAttribute('sentence')

	#If feeling is blank then don't print it, else print it followed by the sentence
	if len(feeling)>0:
		#Set up some variables we'll use later
		counter += 1
		feeling_list.append(feeling)		#Keep last 2 feelings in a list
		sentence_list.append(sentence)		#Keep last 2 sentences in a list
		print "I feel " + feeling + ", " + feeling + ", " + feeling

		#If 3rd line, then do some text manupulation as follows
		#I feel --second feeling-- about feeling --first feeling--  remainder of --1st sentance--
		if counter == 2:					#insert blank lines to give poem some form
			#Calculate text
			s = sentence_list[0]
			s = s[s.find(feeling_list[0]) + len(feeling_list[0]):]

			#Print last line from stanza
			print "I feel " + feeling_list[1] + " about feeling " + feeling_list[0] + s + "."
			feeling_list[:] = []
			sentence_list[:] = []
			print "\n"
			counter = 0

Generated Poem:

This is the GENERATED POEM:
——————————-
I feel right, right, right
I feel whiny, whiny, whiny
I feel whiny about feeling right but i’m wrong now.

I feel emotional, emotional, emotional
I feel exhausted, exhausted, exhausted
I feel exhausted about feeling emotional roller coaster that i’m just not tall enough to go on.

I feel whole, whole, whole
I feel stupid, stupid, stupid
I feel stupid about feeling whole.

I feel accepted, accepted, accepted
I feel tiny, tiny, tiny
I feel tiny about feeling accepted loved and wanted by males because of my problems with dad.

I feel good, good, good
I feel secure, secure, secure
I feel secure about feeling good about my appearance.

I feel exhausted, exhausted, exhausted
I feel great, great, great
I feel great about feeling exhausted.

I feel productive, productive, productive
I feel blessed, blessed, blessed
I feel blessed about feeling productive.

I feel blessed, blessed, blessed
I feel connected, connected, connected
I feel connected about feeling blessed to have found and married my best friend.

I feel off, off, off
I feel depressed, depressed, depressed
I feel depressed about feeling off the back and landed on another friendly vehicle.

I feel color, color, color
I feel delicate, delicate, delicate
I feel delicate about feeling color.

I feel good, good, good

 

This is ORIGINAL TEXT:
——————————-
right – but i’m wrong now
whiny – i feel they should be lumped in there with pants particularly on days when i m feeling whiny and under the weather

emotional i feel like i’ve been on emotional roller coaster that i’m just not tall enough to go on
exhausted i do know i feel emotionally mentally and physically exhausted

whole – i feel whole
stupid – i stop the wishful thought feeling stupid and selfish and small for thinking someone out there might hear my request and grant it especially when i already have all my needs met and not everybody does

accepted – i’ve realised the flirting but not committing or actually having any real feelings or real desires is to do with being accepted loved and wanted by males because of my problems with dad
tiny – i feel a tiny bit better now

good i’m self assured and feel good about my appearance
secure i was plainly not feeling secure regarding myself

exhausted i’m already feeling exhausted
great i’m really excited about this i feel like i’ve been slacking in the blog department and it’s not a great feeling

productive – i’m free for too long i miss day filled with duties and the feeling of doing something productive
blessed – i love having the gospel in my life and feel so blessed to have a husband who is firm in his faith


blessed – i feel so blessed to have found and married my best friend

connected – i didn’t feel connected to anymore

 

off – i just feel like i got hit by a bus then flipped over it fell off the back and landed on another friendly vehicle
depressed – i worried and fretted all evening about one of my students who is feeling depressed and having some emotional crapola going on

 

color – i have to say that there are some clothing pieces i purchase amp love them so much due to to their versatility amp fit i feel the need to buy them in every color
delicate – i enjoy photographing it always tends to change as to what i am interested in at the time or how i feel i enjoy nature

good – i not feel good about myself knowing that is the way god feels about me

 

 

 

Python Assigment #2

Assignment: The digital cut-up. Write a program that reads in and creatively re-arranges the content of one or more source texts. What is the unit of your cut-up technique? (the word, the line, the character? something else?) How does your procedure relate (if at all) to your choice of source text? Feel free to build on your assignment from last week.

Your program must make use of at least one set, dictionary, or list.

Choose one text that you created with your program to read in class.

 

I wrote a program which accesses an API from wefeelfine.org and gets the most recent 50 “feelings” – data is sent as XML.   Here is what the program does:

  1. Program parses the XML and breaks it down into “individual feelings”.
  2. Each sentence is then split into words
  3. Each word is being shuffled around in the sentence
  4. The sentence is printed out, but certain words are skipped – anywhere from 2-5 words are randomly skipped – which can result in some sentences being very short.
  5. To give it some poetic form, I skip a line after each stanza which in this case is a total of 5 lines
Here is the output:
result a feel
ill i to
low as and guilt very hopelessness as
better guys little them making skates on on better s morning these even i that a the their
good the i don i feel have t

better start better
feel tomorrow
happy feel today m
about i t
exciting m to starting that day to so s

good into i the of to good
good good
behind 27 i
behind i am behind probably
dont ever

still up got feel
side feeling being side gives sleep rib on i’m pain i either without sleeping
was feeling
received you weekly to gift feeling for etc write you were as how
excited left the about

sad up feeling i one and for sad
down lane trips down memory
feel testing regularly like i be a or
august time august like we’d up the never friends that never feel camp a like
overwhelmed joy i

grateful i dear my really grateful teammates my
excited him family use grow jessie feel is joining excited
feral be not i feral going
magic way pounds want a a
better or rot knowing 30 i’m something would better mold

never up 550
was i stuffed and
don’t missing am being not feel
honored i of these let feel
deep feel more clearly if memory reach deep my and

found and her answer think her later
fruitful god it fruitful something i wants can without and i i is do stay god staying going for do but i
accepted question it god utterly i seen god figured was in because and feeling book
molly than much remember two sixteen for the about
idea i feel

right will my about how feels blah bit
a in
sorry went from feeling to
hardened my hardened can ever homeless can to i every feel my want heart with
feeling

have me all australia i around see to more
both rubbish both being
both at i feel m 39
both at i
necessary see updating and feel that to would constantly of a add reason through of constant going back old citations glorified is travelogue

Here is the Original text:
i feel is simply a result of my depression
ill i began to feel physically ill
i have a very low opinion of myself as well as frequent extreme feelings of apathy guilt and hopelessness
better i think some guys are seeing that if they re on the ice a little bit more even on their own in these optionals and morning skates it s making them feel better
good i don t have the puck on my stick i don t feel good
better i start feeling better
i feel tomorrow
happy i feel now today i m happy about that decision
i don t really feel anything about the hit
exciting i just needed an extra day here to get back to normal and now i m starting to feel that so it s exciting
good i mean as long as the rest of this day i feel good and going into tomorrow i should be good to go
good i feel good
behind i feel behind 27
behind i feel behind probably because i am
i dont remember ever feeling this way before
i still don’t feel like i got the super crazy up and down pregnancy emotions
side i can’t sleep on my back without feeling like i’m being squished but sleeping on either side gives me massive upper back and rib pain
i was feeling
i received as a gift it had a space for you to write a weekly summary of how you were feeling what you were craving etc
excited i left the chapel feeling excited about it
sad i just woke up one day feeling sad and helpless for absolutely no reason
down i’m not sure how i feel about trips down memory lane
i feel like organizations should be regularly testing themselves or using a a href http: www
august i had about the changes on my time or that we’d never feel like a family or that friends like august would never end up going camp
overwhelmed i feel overwhelmed with joy
grateful i feel really grateful to call them my teammates and my dear friends
excited i feel so excited about him joining our jessie clark family and the way the lord is going to use amp grow him through ministry at jcms
feral i feel for all the feral cats out there not knowing what the weather is going to be like next
magic i just feel like people want a magic pill or a quick way to drop the pounds
better i feel better knowing i’m not eating something that would take 30 years to rot or mold
i never wake up feeling like 550 lbs
i was so stuffed and heavy feeling
i don’t feel i am missing out by not being married i feel connected to many
honored i feel honored that these people let me be part of their lives
deep i feel as if i can reach deep down into my heart and memory and write more clearly
found i told her what i really think and feel i found out her answer two days later
fruitful i feel i can be fruitful if i stay and i still can do something without going to america but my staying though i do it for god is not obeying what god wants me to do and it does not count
accepted i called it god because i d seen god in a book and figured god was the right name for feeling so utterly affirmed and accepted without question
i don’t remember much about sixteen candles other than molly ringwald feeling down for the first two acts
i feel an idea or vision has substance
right i will complain a bit about how overwhelmingly blah my life feels right now
i’m definitely feeling a bit in the doldrums
sorry i went from feeling sorry for her to wanting to slap her hard
hardened i can feel that my heart has hardened not every homeless person tears at my heart making me want to leave with them what ever i can
i am feeling
i have a feeling he will want to see me travelling more for this perhaps all around australia
both i feel like i 47m being rubbish at both
both i feel like i 39 m being rubbish at both
both i feel like i’m being rubbish at both
necessary i’m doing is ongoing and i’m constantly going back through old posts changing and updating as i feel necessary to add constant updating of citations to that would get in the way of what is really just a glorified personal travelogue see reason one
Here is the python code:
#import library to do http requests:
import urllib2
import random

counter = 0

#import easy to use xml parser called minidom:
from xml.dom.minidom import parseString

#download the file:
file = urllib2.urlopen('http://api.wefeelfine.org:8080/ShowFeelings?display=xml&returnfields=feeling,sentence&limit=50')
#convert to string:
data = file.read()
#close file because we dont need it anymore:
file.close()
#parse the xml you downloaded
dom = parseString(data)
#retrieve the XML tag
xmlTags = dom.getElementsByTagName('feeling')

for tag in xmlTags:
	feeling =  tag.getAttribute('feeling')
	sentence =  tag.getAttribute('sentence')

	#Split sentence into words and shuffle them around
	words = sentence.split(" ")
	random.shuffle(words)

	newSentence = ""

	#for word in words:
	#	newSentence += " " + word

	#Loop through words in sentance and skip every (random) 2-5 words
	for i in range(0, len(words),random.randrange(2,5)):
		newSentence += " " + words[i]

	#insert blank lines to give poem some form
	if counter < 5:
		counter += 1
	else:
		print "\n"
		counter = 1

	#If feeling is blank then don't print it,
        #else print it followed by the sentence
	if len(feeling)>0:
		print feeling + " " + newSentence.strip()
	else:
		print newSentence.strip()

Thesis

Python Assignment #1

Assignment: Create a Python program that behaves like a UNIX text processing program (such as cat, grep, tr, etc.). Your program should take text as input (any text, or a particular text of your choosing) and output a version of the text that has been filtered and/or munged. Be creative, insightful, or intentionally banal.

I chose to make some text modifications on one of my favorite sarcastic author – Mark Twain – his quotes just lend themselves to manipulation.  They are witty, and filled with satire.  I thought I could re-arrange them randomly to get some meaningful text.

The program expects a text file which contains the quotes -
python randomize_sentence.py <twain_quotes.txt

Here is my input file:

Be careful about reading health books.
You may die of a misprint.
If you pick up a starving dog and make him prosperous, he will not bite you. 
This is the principal difference between a dog and a man. 
In the first place, God made idiots.
That was for practice - then he made school boards.
Let us be thankful for the fools.
But for them the rest of us could not succeed.

 

Here is the output:

You may die of a misprint.
This is the principal difference between a dog and a man.
If you pick up a starving dog and make him prosperous, he will not bite you.
Be careful about reading health books.
Let us be thankful for the fools.
But for them the rest of us could not succeed..
In the first place, God made idiots.
That was for practice - then he made school boards

 

Program Code:

import sys
import random

#SPLIT SENTENCES
for line in sys.stdin:
	line = line.strip()
	sentence = line.split(". ")

	random.shuffle(sentence)
	output = ". \n".join(sentence)
	print output

 

One funny quote I thought I would experiment with, was the following – i thought it was very appropriate:

Substitute ‘damn’ every time you’re inclined to write ‘very;’  your editor will delete it and the writing will be just as it should be.

 

So, I decided to see if Mark Twain uses qualifying words like “very” in his writings – and indeed he does not  - especially when compared with other authors like Jane Austen who uses it 4 times as much.

I did just that – replaced the word “very” with “DAMN” – and it actually sounds and looks very good

When angry, count four; when DAMN angry, swear.

The DAMN ink with which all history is written is merely fluid prejudice.

I am quite sure now that often, DAMN often, in matters concerning religion and politics a man’s reasoning powers are not above the monkey’s.

You sir are DAMN drunk, yes mrs, but you are DAMN ugly, and I will be sober in the morning.

 

Python code:

import sys
for line in sys.stdin:
	line = line.strip()
	line = line.replace("very ", "DAMN ")
	print line

 

Here is a link to zip file

 

Snowboard Climber – Part II

I’ve made some additional progress on my idea of making a snowboard carry/climbing device.  Lightweight, quick way to strap snowboard/skis to your back.

I have the following materials:

  • 2 x 48″ Adjuster Straps
  • 2 x 26″ Buckle Straps
  • 2 x 1″ Shoulder Pads
I’ve purchased my materials and started to assemble the straps and test various ways to fit them together with safety pins before sowing them together.
Experimenting with using different color straps to indicate which direction is best fit.
Discovered that need to order longer shoulder straps to allow for more slack and adjustments – especially since this device will be worn with heavy jackets and gear.

Laptop Stand

Inca Cross Laptop Stand


 

 

Snowboard Climber

I’ve made some additional progress on my idea of making a snowboard carry/climbing device.   Here is my idea:

Snowboard Climb & Carry: A simple device to carry your snowboard to/from mountain, or while climbing in search of untouched powder.  It allows the snowboard to be carried on your back leaving hands fully free.

The  device will be made of nylon straps, to fold and carry in pocket at all times

 

Able to quickly strap in snowboard and keep it secure while walking/climbing.

 

I was able to test the basic design and usability of the device by building the straps out of string to ensure it fits on the body.

I took some measurements of the string and put together an item list of materials I will need to buy:

  • 2 x 48″ Adjuster Straps
  • 2 x 26″ Buckle Straps
  • 2 x 1″ Shoulder Pads

 

 

Ideas Taking Shape – Final Project Ideas

Final Project Ideas:

Height Adjustable Desk – with an electric mechanism to raise/lower desk to various heights to cater to those that want to stand or sit on regular chair/bar stool.  It is important to have the ability to adjust the height automatically at the touch of a button, as this will most likely be done several times during the day.

 

The top of the desk will use natural recycled wood to give it a contrasting look.

 

 

Snowboard Climb & Carry: A simple device to carry your snowboard to/from mountain, or while climbing in search of untouched powder.  It allows the snowboard to be carried on your back leaving hands fully free.

The  device will be made of nylon straps

Easy to fold and carry in pocket at all times

 

Able to quickly strap in snowboard and keep it secure while walking/climbing.