Seven Steps Verse

Individual Project: A project about the relationship between computer generated poem and human body movement.

In China, there is a really well-known history story, which is about a guy named Cao Zhi who created a poem within the time of walking seven steps while facing the threat of death from his brother, who was the king of the kingdom.

To be more specific, Cao Zhi’s brother was really jealous of Cao Zhi’s talent, so he threatened Cao Zhi that if Cao Zhi could not create a poem within  the time of walking seven steps, he would be beheaded. Luckily Cao Zhi succeeded and “walk seven steps to create a poem” later became an expression in Chinese to describe someone who is really sharp and smart.

Inspired by this story, in this midterm project, I want to create a program that allows me to walk seven steps to get a generated poem, which has some relation to my actual action of walking.

Right now the way that I am trying to do it is kind of a cheap way. I put my iPhone in my pocket and send its x,y,z accelerator data to python via socket. It is not the most fancy and accurate way but it could still detect the way I walk seven steps in a way…..

IMG_5419 IMG_5420

 

 

 

 

 

 

Because I am not too familiar with socket, so far I am using exported csv file.

Screen Shot 2016-03-25 at 11.24.45 AM

Because I know that I intentionally remain stable after the seventh steps, so I am looking for the seven rows before the data go stables. In this way, I narrow it down to these seven rows:

Screen Shot 2016-03-25 at 1.53.48 PM

So these are the data that I want to play with. I am trying to map them from [-1,1] to [0,25], so that I could further map them 26 letters.

Screen Shot 2016-03-25 at 2.54.45 PM

 

In traditional Chinese poem, there is a popular form that is in this way:

Adj + n + v + adj + n

And the form of my poem would consist of seven lines, each lines is formed in this way:

Adj(start with letter map by accelerationX)+n(map by X)+V(map by Z)+Adj(map by Y)+n(map by Y)

 

[code lang=”python”]

import csv
import json
import random

AdjsData = open (“adjs.json”).read()
NounsData = open (“nouns.json”).read()
VerbData = open (“verbs.json”).read()

All_Adjs = json.loads(AdjsData)
All_Verbs = json.loads(VerbData)
All_Nouns = json.loads(NounsData)

alpha_db = [“a”,”b”,”c”,”d”,”e”,”f”,”g”,”h”,”i”,”j”,”k”,”l”,”m”,”n”,”o”,”p”,”q”,”r”,”s”,”t”,”u”,”v”,”w”,”x”,”y”,”z”]
# original source:http://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio

def translate(value, leftMin, leftMax, rightMin, rightMax):
# Figure out how ‘wide’ each range is
leftSpan = leftMax – leftMin
rightSpan = rightMax – rightMin

# Convert the left range into a 0-1 range (float)
valueScaled = float(value – leftMin) / float(leftSpan)

# Convert the 0-1 range into a value in the right range.
return rightMin + (valueScaled * rightSpan)

with open(‘Walk_InCircle.csv’,’rb’) as f:
reader = csv.reader(f)
for row in reader:
new_row = [alpha_db[int(translate(float(list_item),-1,1,0,25))] for list_item in row]

for item in All_Adjs[“adjs”]:
if item[0]==new_row[0]:
first_adj = item
if item[0]==new_row[1]:
second_adj = item
for item in All_Nouns[“nouns”]:
if item[0]==new_row[0]:
second_n = item
if item[0]==new_row[1]:
first_n = item
for item in All_Verbs[“verbs”]:
if item[‘present’][0]==new_row[2]:
first_v = item[‘present’]

print first_adj + ” ” + first_n + ” ” + first_v +” “+second_adj + ” ” +second_n
[/code]

Walk Straight

nuanced juror cycle joyful nylon

knowing gusto avoid gypsy knocking

oyster dynamics buzz duplicate oxygen

knowing juror cycle joyful knocking

mythic cynicism avoid cushioned mythology

joyful hurricane buzz hypnotized juror

luxurious hurricane buzz hypnotized lustre

Walk in Circle

oyster iteration buzz irritate oxygen

mythic juror avoid joyful mythology

knowing knocking avoid knowing knocking

luxurious hurricane zoom hypnotized lustre

nuanced eyewitness avoid exulting nylon

mythic knocking yell knowing mythology

nuanced futility avoid funny nylon