RWET Final Documentation: Decent Dialogues

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

  • Select the most frequently-used words quoted from various celebrities;
  • Based on our source texts, re-construct the words and generate different questions;
  • Answer these special-style-questions with a fixed structure.

    Techniques We Use

  • Web scrapping using selenium
  • Enable user queries using Flask
  • Extract part-of-speech tagging using Spacy
  • Reform the sentence based on a certain structure

    Examples We’ve Got

    Final Results

    Final Performance

RWET Assignment 5 & 7

I combined these two assignments together (API and function).

import urllib
import json
import sys
import random

for line in sys.stdin:
line = line.strip()
words = line.split(” “)
for word in words:
if len(word)>=1:
api_key = “a2a73e7b926c924fad7001ca3111acd55af2ffabf50eb4ae5”
for kWord in kWords:
# print kWord
# print type(kWord)

url = “”+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:

# try:
# synonyms=doc_data[0][“words”]
# synonym=random.choice(synonyms)
# except IndexError:
# print “error”
# synonym=”universal”

# synonyms=doc_data[0][“words”]
# synonym=random.choice(synonyms)
print synonym

So the course description is changed to be like this:

RWET Assignment 3

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:

RWET Assignment 2

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:

RWET Assignment 1

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: