Inspiration and Intention
As a foreigner, when I talk with people in English, it’s sometimes a little bit embarrassing. Like when people ask me:”How’s going?” I’m always not if I should answer like “good”/”fine”, or answer it with more details or emotions to show my respect – cuz in China, people never greet by asking questions.
So we are wondering if we can build up a specific structure for questions and answers, based on different people’s styles.
What We Do
I combined these two assignments together (API and function).
for line in sys.stdin:
line = line.strip()
words = line.split(” “)
for word in words:
api_key = “a2a73e7b926c924fad7001ca3111acd55af2ffabf50eb4ae5”
for kWord in kWords:
# print kWord
# print type(kWord)
url = “http://api.wordnik.com:80/v4/word.json/”+kWord+”/relatedWords?useCanonical=true&relationshipTypes=synonym&limitPerRelationshipType=10&api_key=”+api_key
doc_str = urllib.urlopen(url).read()
doc_data = json.loads(doc_str)
# except IndexError:
# print “error”
So the course description is changed to be like this:
Based on my last homework, I used “set” function to collect the words in the same length:
Firstly I tried rearranging all the sentences of a lyric (poem) I’ve written. This is how it is like originally:
And I rearranged the lines:
The sentences changed their orders, but the feeling it expresses is still the same.
Then I tried randomly shuffle 10 percent-length lines from the whole poems:
So it will randomly select 10% length and runs like this:
And I tried getting rid of the empty lines and printing the last word of every line:
Firstly I wanted to try a Chinese poem, but it showed question marks on every line. Even I’ve adjusted the length of lines for several times, I still could not get rid of them.
So I went back to English. I picked George Gordon Byron’s “When We Two Parted” to be my experimental subject.
I wrote a Python program like this:
I randomly chose two common oral phrases “amazing” and “oh yeah”, and inserted them into the poem. So the poem was changed like this:
Beyond what we’ve learned during class, the first function I’d like to try is TRANSLATE. With this function, we can easily hide the words which we originally wanted to say – seems cool!
I changed “abcde” to be “vwxyz”, and the file “forst.txt” was changed to be like this:
And I tried combining more than one command:
It seems doesn’t work together?
Let’s do them separately.
Why can’t I pipe all these commands together???
I need to fix this problem… so finally I just tried some really simple commands. I selected several sentences from an Indian poet Tagore’s poems and made this: