poetry – THE HYPERTEXT http://www.thehypertext.com Thu, 10 Dec 2015 06:10:15 +0000 en-US hourly 1 https://wordpress.org/?v=5.0.4 word.camera, Part II http://www.thehypertext.com/2015/05/08/word-camera-part-ii/ Fri, 08 May 2015 21:50:25 +0000 http://www.thehypertext.com/?p=505 For my final projects in Conversation and Computation with Lauren McCarthy and This Is The Remix with Roopa Vasudevan, I iterated on my word.camera project.

Read More...

]]>
Click Here for Part I


11161692_10100527204674408_7877879408640753455_o


For my final projects in Conversation and Computation with Lauren McCarthy and This Is The Remix with Roopa Vasudevan, I iterated on my word.camera project. I added a few new features to the web application, including a private API that I used to enable the creation of a physical version of word.camera inside a Mamiya C33 TLR.

The current version of the code remains open source and available on GitHub, and the project continues to receive positive mentions in the press.

On April 19, I announced two new features for word.camera via the TinyLetter email newsletter I advertised on the site.

Hello,

Thank you for subscribing to this newsletter, wherein I will provide occasional updates regarding my project, word.camera.

I wanted to let you know about two new features I added to the site in the past week:

word.camera/albums You can now generate ebooks (DRM-free ePub format) from sets of lexographs.

word.camera/postcards You can support word.camera by sending a lexograph as a postcard, anywhere in the world for $5. I am currently a graduate student, and proceeds will help cover the cost of maintaining this web application as a free, open source project.

Also:

word.camera/a/XwP59n1zR A lexograph album containing some of the best results I’ve gotten so far with the camera on my phone.

1, 2, 3 A few random lexographs I did not make that were popular on social media.

Best,

Ross Goodwin
rossgoodwin.com
word.camera

Next, I set to work on the physical version. I decided to use a technique I developed on another project earlier in the semester to create word.camera epitaphs composed of highly relevant paragraphs from novels. To ensure fair use of copyrighted materials, I determined that all of this additional data would be processed locally on the physical camera.

I developed a collection of data from a combination of novels that are considered classics and those I personally enjoyed, and I included only paragraphs over 99 characters in length. In total, the collection contains 7,113,809 words from 48 books.

Below is an infographic showing all the books used in my corpus, and their relative included word counts (click on it for the full-size image).

A79449E2CDA5D178

To build the physical version of word.camera, I purchased the following materials:

  • Raspberry Pi 2 board
  • Raspberry Pi camera module
  • Two (2) 10,000 mAh batteries
  • Thermal receipt printer
  • 40 female-to-male jumper wires
  • Three (3) extra-small prototyping perf boards
  • LED button

After some tinkering, I was able to put together the arrangement pictured below, which could print raw word.camera output on the receipt printer.

IMG_0354

I thought for a long time about the type of case I wanted to put the camera in. My original idea was a photobooth, but I felt that a portable camera—along the lines of Matt Richardson’s Descriptive Camera—might take better advantage of the Raspberry Pi’s small footprint.

Rather than fabricating my own case, I determined that an antique film camera might provide a familiar exterior to draw in people not familiar with the project. (And I was creating it for a remix-themed class, after all.) So I purchased a lot of three broken TLR film cameras on eBay, and the Mamiya C33 was in the best condition of all of them, so I gutted it. (N.B. I’m an antique camera enthusiast—I own a working version of the C33’s predecessor, the C2—and, despite its broken condition, cutting open the bellows of the C33 felt sacrilegious.)

I laser cut some clear acrylic I had left over from the traveler’s lamp project to fill the lens holes and mount the LED button on the back of the camera. Here are some photos of the finished product:

9503_20150507_tlr_1000px

9502_20150507_tlr_1000px

9509_20150507_tlr_1000px

9496_20150507_tlr_1000px

9493_20150507_tlr_1000px

9513_20150507_tlr_1000px

And here is the code that’s running on the Raspberry Pi (the crux of the matching algorithm is on line 90):

import uuid
import picamera
import RPi.GPIO as GPIO
import requests
from time import sleep
import os
import json
from Adafruit_Thermal import *
from alchemykey import apikey
import time

# SHUTTER COUNT / startNo GLOBAL
startNo = 0

# Init Printer
printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
printer.setSize('S')
printer.justify('L')
printer.setLineHeight(36)

# Init Camera
camera = picamera.PiCamera()

# Init GPIO
GPIO.setmode(GPIO.BCM)

# Working Dir
cwd = '/home/pi/tlr'

# Init Button Pin
GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# Init LED Pin
GPIO.setup(20, GPIO.OUT)

# Init Flash Pin
GPIO.setup(16, GPIO.OUT)

# LED and Flash Off
GPIO.output(20, False)
GPIO.output(16, False)

# Load lit list
lit = json.load( open(cwd+'/lit.json', 'r') )


def blink(n):
    for _ in range(n):
        GPIO.output(20, True)
        sleep(0.2)
        GPIO.output(20, False)
        sleep(0.2)

def takePhoto():
    fn = str(int(time.time()))+'.jpg' # TODO: Change to timestamp hash
    fp = cwd+'/img/'+fn
    GPIO.output(16, True)
    camera.capture(fp)
    GPIO.output(16, False)
    return fp

def getText(imgPath):
    endPt = 'https://word.camera/img'
    payload = {'Script': 'Yes'}
    files = {'file': open(imgPath, 'rb')}
    response = requests.post(endPt, data=payload, files=files)
    return response.text

def alchemy(text):
    endpt = "http://access.alchemyapi.com/calls/text/TextGetRankedConcepts"
    payload = {"apikey": apikey,
               "text": text,
               "outputMode": "json",
               "showSourceText": 0,
               "knowledgeGraph": 1,
               "maxRetrieve": 500}
    headers = {'content-type': 'application/x-www-form-urlencoded'}
    r = requests.post(endpt, data=payload, headers=headers)
    return r.json()

def findIntersection(testDict):
    returnText = ""
    returnTitle = ""
    returnAuthor = ""
    recordInter = set(testDict.keys())
    relRecord = 0.0
    for doc in lit:
        inter = set(doc['concepts'].keys()) & set(testDict.keys())
        if inter:
            relSum = sum([doc['concepts'][tag]+testDict[tag] for tag in inter])
            if relSum > relRecord: 
                relRecord = relSum
                recordInter = inter
                returnText = doc['text']
                returnTitle = doc['title']
                returnAuthor = doc['author']
    doc = {
        'text': returnText,
        'title': returnTitle,
        'author': returnAuthor,
        'inter': recordInter,
        'record': relRecord
    }
    return doc

def puncReplace(text):
    replaceDict = {
        '—': '---',
        '–': '--',
        '‘': "\'",
        '’': "\'",
        '“': '\"',
        '”': '\"',
        '´': "\'",
        'ë': 'e',
        'ñ': 'n'
    }

    for key in replaceDict:
        text = text.replace(key, replaceDict[key])

    return text


blink(5)
while 1:
    input_state = GPIO.input(21)
    if not input_state:
        GPIO.output(20, True)
        try:
            # Get Word.Camera Output
            print "GETTING TEXT FROM WORD.CAMERA..."
            wcText = getText(takePhoto())
            blink(3)
            GPIO.output(20, True)
            print "...GOT TEXT"

            # Print
            # print "PRINTING PRIMARY"
            # startNo += 1
            # printer.println("No. %i\n\n\n%s" % (startNo, wcText))

            # Get Alchemy Data
            print "GETTING ALCHEMY DATA..."
            data = alchemy(wcText)
            tagRelDict = {concept['text']:float(concept['relevance']) for concept in data['concepts']}
            blink(3)
            GPIO.output(20, True)
            print "...GOT DATA"

            # Make Match
            print "FINDING MATCH..."
            interDoc = findIntersection(tagRelDict)
            print interDoc
            interText = puncReplace(interDoc['text'].encode('ascii', 'xmlcharrefreplace'))
            interTitle = puncReplace(interDoc['title'].encode('ascii', 'xmlcharrefreplace'))
            interAuthor = puncReplace(interDoc['author'].encode('ascii', 'xmlcharrefreplace'))
            blink(3)
            GPIO.output(20, True)
            print "...FOUND"

            grafList = [p for p in wcText.split('\n') if p]

            # Choose primary paragraph
            primaryText = min(grafList, key=lambda x: x.count('#'))
            url = 'word.camera/i/' + grafList[-1].strip().replace('#', '')

            # Print
            print "PRINTING..."
            startNo += 1
            printStr = "No. %i\n\n\n%s\n\n%s\n\n\n\nEPITAPH\n\n%s\n\nFrom %s by %s" % (startNo, primaryText, url, interText, interTitle, interAuthor)
            printer.println(printStr)

        except:
            print "SOMETHING BROKE"
            blink(15)

        GPIO.output(20, False)

Thanks to a transistor pulsing circuit that keeps the printer’s battery awake, and some code that automatically tethers the Raspberry Pi to my iPhone, the Fiction Camera is fully portable. I’ve been walking around Brooklyn and Manhattan over the past week making lexographs—the device is definitely a conversation starter. As a street photographer, I’ve noticed that people seem to be more comfortable having their photograph taken with it than with a standard camera, possibly because the visual image (and whether they look alright in it) is far less important.

As a result of these wanderings, I’ve accrued quite a large number of lexograph receipts. Earlier iterations of the receipt design contained longer versions of the word.camera output. Eventually, I settled on a version that contains a number (indicating how many lexographs have been taken since the device was last turned on), one paragraph of word.camera output, a URL to the word.camera page containing the photo + complete output, and a single high-relevance paragraph from a novel.

2080_20150508_doc_1800px

2095_20150508_doc_1800px

2082_20150508_doc_1800px

2088_20150508_doc_1800px

2091_20150508_doc_1800px

2093_20150508_doc_1800px

2097_20150508_doc_1800px

2100_20150508_doc_1800px

2102_20150508_doc_1800px

2104_20150508_doc_1800px

2106_20150508_doc_1800px

2108_20150508_doc_1800px

2109_20150508_doc_1800px

I also demonstrated the camera at ConvoHack, our final presentation event for Conversation and Computation, which took place at Babycastles gallery, and passed out over 50 lexograph receipts that evening alone.

6A0A1475

6A0A1416

6A0A1380

6A0A1352

6A0A1348

Photographs by Karam Byun

Often, when photographing a person, the camera will output a passage from a novel featuring a character description that subjects seem to relate to. Many people have told me the results have qualities that remind them of horoscopes.

]]>
ITP Code Poetry Slam http://www.thehypertext.com/2014/12/09/itp-code-poetry-slam-2014/ Tue, 09 Dec 2014 08:45:53 +0000 http://www.thehypertext.com/?p=381 Several months ago, I asked the question: Who Is Code Shakespeare. On November 14, 2014, I believe the first ITP Code Poetry Slam may have brought us closer to an answer.

Read More...

]]>
Who Is Code Shakespeare?

codeshakespeare_sm

Several months ago, I asked the question above. On November 14, 2014, I believe the first ITP Code Poetry Slam may have brought us closer to an answer.

In all the bustle of final projects being due in the past month, I haven’t had a chance to post anything about the code poetry slam I organized in November. Needless to say, the event was an enormous success, thanks mostly to the incredible judges and presenters. I hope to organize another one in 2015.

The judges brought a wealth of experience from a variety of different fields, which provided for some extraordinary discussion. They were:

This was the schedule for the slam, as written by me on the whiteboard wall of room 50 at ITP:

whiteboard

Rather than providing a blow-by-blow account of proceedings, I’ll direct you to Hannes Bajohr, who did just that.

The entries truly speak for themselves. Those who presented (in order of presentation) were:

 


Participants and attendees: Please let me know if any of the names or links above need to be changed. Also, if your name is not linked, and you’d like me to link it to something, let me know!

If you missed the ITP Code Poetry Slam, you can attend or submit your work for the Stanford Code Poetry Slam in January.

]]>
General Update http://www.thehypertext.com/2014/09/29/general-update/ http://www.thehypertext.com/2014/09/29/general-update/#comments Mon, 29 Sep 2014 06:24:41 +0000 http://www.thehypertext.com/?p=177 I've been so busy the past two weeks that I failed to update this blog. But documentation is important, and that's why I'm going to take a moment to fill you in on all my recent activities. This post will cover all the projects I've been working on.

Read More...

]]>
I’ve been so busy the past two weeks that I failed to update this blog. But documentation is important, and that’s why I’m going to take a moment to fill you in on all my recent activities. This post will cover all the projects I’ve been working on, primarily:

  • Applications Presentation on September 16
  • ITP Code Poetry Slam on November 14
  • The Mechanical Turk’s Ghost
  • Che55

On Tuesday, September 16, I helped deliver a presentation to our class in Applications. Yingjie Bei, Rebecca Lieberman, and Supreet Mahanti were in my group, and we utilized my Poetizer software to create an interactive storytelling exercise for the entire audience. Sarah Rothberg was kind enough to record the presentation, and Rebecca posted it on Vimeo:

 

 

I’ve also been organizing an ITP Code Poetry Slam, which will take place at 6:30pm on November 14. Submissions are now open, and I’m hoping the event will serve as a conduit for productive dialogue between the fields of poetry and computer science. Announcements regarding judges, special guests, and other details to come.

Various explorations related to the Mechanical Turk’s Ghost [working title] have consumed the rest of my time. While I wait for all the electronic components I need to arrive, I have been focusing on the software aspects of the project, along with some general aspects of the hardware.

The first revision to the preliminary design I sketched out in my prior post resulted from a friend‘s suggestion. Rather than using conductive pads on the board, I now plan to use Hall effect sensors mounted beneath the board that will react to tiny neodymium magnets embedded in each chess piece. If everything works properly, this design should be far less visible, and thus less intrusive to the overall experience. I ordered 100 sensors and 500 magnets, and I look forward to experimenting with them when they arrive.

In the meantime, the parts I listed in my prior post arrived, and I was especially excited to begin working with the Raspberry Pi. I formatted an 8GB SD card and put NOOBS on it, then booted up the Raspberry Pi and installed Raspbian, a free operating system based on Debian Linux that is optimized for the Pi’s hardware.

r_pi

The Stockfish chess engine will be a major component of this project, and I was concerned that its binaries would not compile on the Raspberry Pi. The makefile documentation listed a number of options for system architecture, none of which exactly matched the ARM v6 chip on the Raspberry Pi.

Screen Shot 2014-09-28 at 10.46.18 PMFirst, I tried the “ARMv7” option. The compiler ran for about 10 minutes before experiencing errors and failing. I then tried several other options, none of which worked. I was about to give up completely and resign myself to running the chess engine on my laptop, when I noticed the “profile-build” option. I had never heard of profile-guided optimization (PGO), but I tried using the command “make profile-build” rather than “make build” along with the option for unspecified 32-bit architecture. This combination allowed Stockfish to compile without any issues. Here is the command that I used (from the /Stockfish/src folder):

$ make profile-build ARCH=general-32

With Stockfish successfully compiled on the Raspberry Pi, I copied the binary executable to the system path (so that I could script the engine using the Python subprocess library), then tried running the Python script I wrote to control Stockfish. It worked without any issues:

ghost

My next set of explorations revolved around the music component of the project. As I specified in my prior post, I want the device to generate music. I took some time to consider what type of music would be most appropriate, and settled on classical music as a starting point. Classical music is ideal because so many great works are in the public domain, and because so many serious chess players enjoy listening to it during play. (As anecdotal evidence, the Chess Forum in Greenwich Village, a venue where chess players congregate to play at all hours of the day and night, plays nothing but classical music all the time. I have been speaking to one of the owners of the Chess Forum about demonstrating my prototype device there once it is constructed.)

Generating a classical music mashup using data from the game in progress was the first idea I pursued. For this approach, I imagined that two classical music themes (one for black, one for white) could be combined in a way that reflected the relative strength of each side at any given point in the game. (A more complex approach might involve algorithmic music generation, but I am not ready to pursue that option just yet.) Before pursuing any prototyping or experimentation, I knew that the two themes would need to be suitably different (so as to distinguish one from the other) but also somewhat complementary in order to create a pleasant listening experience. A friend of mine who studies music suggested pairing one song (or symphony or concerto) in a major key with another song in the relative minor key.

Using YouTube Mixer, I was able to prototype the overall experience by fading back and forth between two songs. I started by pairing Beethoven’s Symphony No. 9 and Rachmaninoff’s Piano Concerto No. 3, and I was very satisfied with the results (play both these videos at once to hear the mashup):

I then worked on creating a music mashup script to pair with my chess engine script. My requirements seemed very simple: I would need a script that could play two sound files at once and control their respective volume levels independently, based on the fluctuations in the score calculated by the chess engine. The script would also need to be able to run on the Raspberry Pi.

These requirements ended up being more difficult to fulfill than I anticipated. I explored many Python audio libraries, including pyo, PyFluidSynth, mingus, and pygame’s mixer module. I also looked into using SoX, a command line audio utility, through the python subprocess library. Unfortunately, all of these options were either too complex or too simple to perform the required tasks.

Finally, on Gabe Weintraub’s suggestion, I looked into using Processing for my audio requirements and discovered a library called Minim that could do everything I needed. I then wrote the following Processing sketch:

import ddf.minim.*;

Minim minim1;
Minim minim2;
AudioPlayer player1;
AudioPlayer player2;

float gain1 = 0.0;
float gain2 = 0.0;
float tgtGain1 = 0.0;
float tgtGain2 = 0.0;
float level1 = 0.0;
float level2 = 0.0;
float lvlAdjust = 0.0;

BufferedReader reader;
String line;
float score = 0;

void setup() {
  minim1 = new Minim(this);
  minim2 = new Minim(this);
  player1 = minim1.loadFile("valkyries.mp3");
  player2 = minim2.loadFile("Rc3_1.mp3");
  player1.play();
  player1.setGain(-80.0);
  player2.play();
  player2.setGain(6.0);
}

void draw() {
  reader = createReader("score.txt");
  try {
    line = reader.readLine();
  } catch (IOException e) {
    e.printStackTrace();
    line = null;
  }
  print(line); 
  score = float(line);
  
  level1 = (player1.left.level() + player1.right.level()) / 2;
  level2 = (player2.left.level() + player2.right.level()) / 2;  

  lvlAdjust = map(level1 - level2, -0.2, 0.2, -1, 1);
  tgtGain1 = map(score, -1000, 1000, -30, 6);
  tgtGain2 = map(score, 1000, -1000, -30, 6);
  tgtGain1 = tgtGain1 * (lvlAdjust + 1);
  tgtGain2 = tgtGain2 / (lvlAdjust + 1);
  
  gain1 = player1.getGain();
  gain2 = player2.getGain();
  
  print(' ');
  print(gain1);
  print(' ');
  print(gain2);
  print(' ');
  print(level1);
  print(' ');
  println(level2);
  
  if (level2 > level1) {
    tgtGain2 -= 0.1;
  } else if (level1 < level2) {
    tgtGain1 -= 0.1;
  }
  
  player1.setGain(tgtGain1);
  player2.setGain(tgtGain2);
}

The script above reads score values from a file created by the Python script that controls the chess engine. The score values are then mapped to gain levels for each of the two tracks that are playing. I input a chess game move by move into the terminal, and the combination of scripts worked as intended by fading between the two songs based on the relative positions of white and black in the chess game.

Unfortunately, a broader issue with my overall approach became highly apparent: the dynamic qualities of each song overshadowed most of the volume changes that occurred as a result of the game. In other words, each song got louder and quieter at various points by itself, and that was more noticeable than the volume adjustments the script was making. I attempted to compensate for these natural volume changes by normalizing the volume of each song based on its relative level compared to the other song (see lines 42-45, 48-49, and 63-67 in the code above). This did not work as effectively as I hoped, and resulted in some very unpleasant sound distortions.

After conferring with my Automata instructor, Nick Yulman,  I have decided to take an alternate approach. Rather than playing two complete tracks and fading between them, I plan to record stems (individual instrument recordings) using the relevant midi files, and then create loop tracks that will be triggered at various score thresholds. I am still in the process of exploring this approach and will provide a comprehensive update sometime in the near future.

In the meantime, I have been learning about using combinations of digital and analog inputs and outputs with the Arduino, and using various input sensors to control motors, servos, solenoids, and RGB LEDs:

photo 3

In Introduction to Computational Media, we are learning about object oriented programming, and Dan Shiffman asked us to create a Processing sketch using classes and objects this week. As I prepare to create a physical chessboard, I thought it would be appropriate to make a software version to perform tests. Che55 (which I named with 5’s as an homage to Processing’s original name, “Proce55ing“) was the result.

che55

Che55 is a fully functional chess GUI, written in Processing. Only legal moves can be made, and special moves such as en passant, castling, and pawns reaching the end of the board have been accounted for. I plan to link Che55 with Stockfish in order to create chess visualizations and provide game analysis, and to prototype various elements of the Mechanical Turk’s Ghost, including the musical component. I left plenty of space around the board for additional GUI elements, which I’m currently working on implementing. All of the code is available on Github.

Unfortunately, I cannot claim credit for the chess piece designs. Rather, I was inspired by an installation I saw at the New York MoMA two weeks ago called Thinking Machine 4 by Martin Wattenberg and Marek Walczak (also written in Processing).

That’s all for now. Stay tuned for new posts about each of these projects. I will try to keep this blog more regularly updated so there (hopefully) will be no need for future multi-project megaposts like this one. Thanks for reading.

]]>
http://www.thehypertext.com/2014/09/29/general-update/feed/ 2
Wikipoet http://www.thehypertext.com/2014/09/04/wikipoet/ Thu, 04 Sep 2014 17:16:55 +0000 http://www.thehypertext.com/?p=77 Wikipoet is a program I wrote in Python that generates simple, iterative poems using the raw text from Wikipedia articles (retrieved via the MediaWiki API) and NLTK.

Read More...

]]>
Wikipoet is a program I wrote in Python that generates simple, iterative poems using the raw text from Wikipedia articles (retrieved via the MediaWiki API) and NLTK.

Wikipoet begins with a single word and uses the Wikipedia article for that word to find likely noun and adjective combinations. It then prints a stanza with the following structure:

[word]
[adjective] [word]
[adjective], [adjective] [word]
[adjective], [adjective], [adjective] [word]
[adjective], [adjective], [adjective], [adjective] [word]
[word] [noun], [word] [noun], [word] [noun]
[word] [noun], [word] [noun], [word] [noun]
[word] [noun / new word]
[new word]

Wikipoet then repeats this operation for the new word. The stanzas can continue indefinitely.

Here’s an example:

computer
former computer
flash, military computer
many, full, best computer
all, later, more, earlier computer
computer design, computer help, computer say
computer reference, computer voice, computer central processing unit
computer job
job
principal job
risky, creative job
critical, national, many job
lowly, steady, poor, primary job
job satisfaction, job reference, job preparation
job system, job look, job retention
job want
want
noble want
four, like want
more, strong, most want
human, some, american, many want
want can, want production, want protection
want level, want story, want item
want character
character
classical character
novel, new character
other, written, first character
greek, various, practical, set character
character construction, character actor, character words
character see, character page, character volume
character pick
pick
game pick
original, american pick
used, all, first pick
bay, star, early, specific pick
pick brand, pick use, pick set
pick title, pick people, pick peter
pick page
page
side page
modern, all page
other, past, early page
south, worldwide, beginning, electronic page
page format, page declaration, page band
page technology, page business, page address
page stop
stop
three stop
full, former stop
total, black, used stop
top, safe, international, white stop
stop code, stop nation, stop destruction
stop period, stop frank, stop part
stop closure
closure
prompt closure
epistemic, tight closure
early, short, social closure
transitive, deductive, other, cognitive closure
closure operator, closure process, closure rule
closure operation, closure law, closure map
closure series
series
kind series
systematic, sequential series
geologic, former, odd series
world, fixed, ordered, funny series
series flora, series movie, series sequence
series tone, series world, series step
series year
year
actual year
received, minor year
mass, cultural, done year
scheduled, united, martian, keen year
year consultation, year master, year trend
year personal, year level, year lord
year high

Depending on the length of the poem desired and the speed of one’s internet connection, Wikipoet can take a relatively long time to produce its output. The poem above took approximately 30 minutes to produce with a standard broadband connection.

While creating Wikipoet, I realized that I could improve the quality of its adjective-noun pairings by producing one set of adjective-noun combinations, then searching those combinations and removing ones that appear fewer than 10 times in Wikipedia search results.

Here is the code that accomplishes that using the MediaWiki API and the Python Requests library, where y is a list of adjectives:

for i in y[:]:
    search_string = "\"" + i + ' ' + word + "\""
    payload = {'action': 'query', 'list': 'search',
               'format': 'json', 'srsearch': search_string, 
               'srlimit': 1, 'srprop': 'snippet',
               'srwhat': 'text'}
    r = s.get(url, params=payload, headers=headers)
    json_obj = r.json()
    hits = int(json_obj['query']['searchinfo']['totalhits'])
    if hits < 10:
        y.remove(i)
    else:
        pass

The primary utility of Wikipoet is its ability to find meaningful adjectives to pair with nouns and nouns to pair with adjectives. I plan to integrate this process into future projects.

]]>
More Poetizer Output http://www.thehypertext.com/2014/09/02/more-poetizer-output/ Tue, 02 Sep 2014 01:02:57 +0000 http://www.thehypertext.com/?p=51 I thought I'd share a few more computer poems with you. But first, a new video.

Read More & Watch the Video...

]]>
I thought I’d share a few more computer poems with you. But first, a new video:

For more information, see my previous blog entry.

Now, here are some of the best poems it has produced. This is only a small collection… I have literally thousands of poems like these:

1. by richmond
i raised my knees supine on the granite
steps of the human mind to correlate
all its contents we live on a cold winter
moony night it said that nothing ever
happened so worry its all like golden
of past puerility or past manhood and all
i raised my knees supine on the granite
crumble away batch will crumble but
crumble away batch will crumble

2. and houses
roads boulevard are as fugitive alas
as the tears blister and start you shall love
corrupt with your crooked heart it was late
late in the afternoon and it was not
meant that we were doing was right that we
hoped to change because it was not meant that
roads boulevard are as fugitive alas
and the thought of such endless avenues
and the thought of such endless avenues

3. upward lemon
yellow his belly button bud of flesh and saw
the dark universe yawning where the plot
where the walls staring forms leaned out leaning
the room the char come and go talking
of michelangelo and indeed there
will be time to get complicated messy
yellow his belly button bud of flesh and saw
cities have sprouted up along the floor
cities have sprouted up along the floor

4. never really
die it has no ending ill love you till
china and africa meet and the sensation
of pater to recreate the phrase structure
and measure of poor man prose and stand
before you dumb and intelligent
and shaking with shame rejected yet profess
out the time and if it rains a closed circuit

5. nymphs of
depths infinity around the limp leaves
waited for rain while the black planets roll
without aim where they roll in their whirlpools
strange dolphins and sea nymphs of depths eternity
around the limp father of thou
dreamy floating flower ugly and futile
lean neck and shrieked with delight in for committing

6. with a
dulcimer in a formulated phrase
and when i count there are only you and
i have seen the perpetual footman hold
my coat and snicker and in the mountains
in the wad but dry sterile thunder
without rain there is one thing its a dream
already ended nothing

7. me hitting
the period and you know nothing do
you think the emptiness of space which is
the end grant to aristotle
what we have lingered in the subway window
jumped in limousines with the imaginary

8. party is
stuck on a pin when i and i thought i
was fishing in the middle things have had
time to devise a face to meet the faces
that you were there and alive in their hearts
who lit cigarettes in boxcars boxcars

9. troubles me
for i can connect nothing with nothing
the broken fingernails of soil hands
my citizenry humble people who expect
null la la to carthage then i came
to your metropolis walked market street singing

10. of them
is being smeared on the far arctic isle
oh great was the sin of my hands queen and
her tribe courier stars doctor back from
his hansen's disease and woe ships of pure air
inconceivable for me to betray even
the ism can disperse through the
wall and i know this from staring at mountains

11. being depressed
on a ledge halfway up the white hair of
the intrinsic mind that these cockle of
birth and death and back turn upward from the
sky with monuments span the bay then up
the mountain and the climbing party is
stuck on a bare stage as the years in did
khan a stately pleasure dome with caves

12. like the
action of the high water mark that place
where the action of the hoary primordial
grove where the sun goes down and wept sweet thames
run softly till i end my song sweet thames river
run softly till i end my birdsong the river
into the heart of the blind where mass and
gravity bulk vast its centrifuge

13. cardboard boxes
butt ends or other testimony
of summertime nights the nymphs are departed
sweet thames run softly for i have lived over
my lives without number i have whirled with
the fanciful idea of
a toast and tea in the colonnade and
went leaving no broken hearts who sang sweet

14. will show
you fear in a cage and can see at the
air murmur of maternal who are mad
to talk mad to live mad to talk mad to
be the first word of paradise lost on
an empty page think of an animal
is being tortured with electric while
android pope this is the lady of situations

15. dear mrs
enjoin her i bring the horoscope myself
one must be drooping and shedding her dims
on the final stanzas of gibberish
who cooked rotten creature lung heart feet
tail and tortillas dreaming of as i
need be found in our true blissful essence
of mind is pure machinery whose blood

16. in the
form of my spirit and great is the merchant
and this and this is early on years before
the machinery of other things of things
more foreign and more distant in space and in
realms where the glass held up by standards wrought
with vines from which a minute there is not
even another individual who is herself
clinically depressed person can not get
straight you are thinking think i think we are
efflorescence all sorts of shapes and smells and after
that long kiss i near lost my intimation yes he
said i blaspheme i cant bear to look at you
and me would it have been the same you are
behind bars you are in the earth at the
romance of the wards of the king must die
unheard in dim song of my hands queen and
her only i cant bear to look so antique
and her presence the monition of
her heart but for her lips roses from the
superhuman tomb

17. ate the
lamb stew of the east pilgrim states and halls
bickering with the thing that troubles me
for i should have been the rats foot only
year to year but at my back in a brown
mantle hooded i do i shall wear white
flannel trousers and walk the street danced on
broken barefoot smashed record player records
of nostalgic european high german
jazz finished the whisky and threw up groaning
into the middle sixties was a soft
october night curled once about the sky
a hat on a million times the fool i
grow previous i grow old i shall wear the bottoms
of my natural ecstasy whom i sit
on her back o look in the sand if there
were water we should voyage far the sciences
each straining in its spore like the andalusian
girls used or shall i at least pretend to
be of use suave cautious and meticulous
full of depressed affected role is coming

18. the sacred
river ran on i saw your saints your zens
athenians and though the west wind appear
to harbor there not one pure dream of love
the dictates of her aspect her indeterminate
response to question her potency
over sewer water and waters her power
to to mortify to invest with lulu
to render mad to incite
gong o let not time deceive you you can
not get drunk and you closing the book spread
like an infective disease from city
to metropolis from continent to continent
barred out here attach there denounced
by press and stump censured even by
the eleemosynary spider or under
seals broken by the hole in the ocean
of mercator projection its in marshes
faded stagnant pools in the colonnade
and went on a bare stage as the writer
as the writer has cursed the world

19. [untitled]
shriek come the break of day being driven to
madness with fright i have haunted the tombs
of the wards of the low on whom assurance
sits as a silk hat on a screen would it
have been as often of the band and blew
the suffering of the states naked
mind for love was the color of television

20. regiments of
fashion and the deep waters of the subway
and were red eyed in the trench of the heterosexual
dollar the one universal essence
of purest poison lurked the very good
and the dying and the lore of ocean
blue green grey white or black smooth prance or
mountainous that ocean is more ancient
than the healthy then too still american
television is full of high sentence
but a bit dumb at times indeed almost
ridiculous almost at times indeed
almost nonsensical almost at times
indeed almost idiotic almost
at times indeed almost farcical
almost at times indeed almost ridiculous
almost at times the utter casualness
and deep ignorance of it and in iowa
i know this from staring at raft months
on end they never quite shine and the tanked
up clatter of the stability

21. no explanation
no mix of words or euphony or memories
can touch that sense of the globe its ubiquity
as constituting percent of the true
predator the great white shark of pain that
here was literally take up away by something
unnamed until only a void was left
the knowledge that the hyades shall sing
where flap the tatters of the skull who
humourless protest overturned only
one emblematic pingpong table resting
briefly in returning class later truly
bald except for a hundred visions and
revisions which a golden peeped out another
hid his eyes before his feet flowed up the
earth take heed scraped and scraped look again at
that time remembrance of a whole generation
comes to a sea journey
atone im with you in rockland where you
scream in a long face its them pills i took
to bring it off she said something

22. their wrists
three fourth dimension successively unsuccessfully
gave up all for what everything comes down
to the three old of fate the one eyeball of
the blind where mass and gravity bulk brobdingnagian

]]>
Poetizer http://www.thehypertext.com/2014/08/31/poetizer/ http://www.thehypertext.com/2014/08/31/poetizer/#comments Sun, 31 Aug 2014 06:46:56 +0000 http://www.thehypertext.com/?p=17 Two days before ITP begins, and this is what I'm currently working on: computer generated poetry, read by a computer and accompanied by computer-selected images related to the text.

Read More & Watch the Video...

]]>
Two days before ITP begins, and this is what I’m currently working on: computer generated poetry, read by a computer and accompanied by computer-selected images related to the text.

I call it Poetizer, I coded it in Python, and it works with any text corpus. It’s also modular, so you can use the poetry-reading (poemreader.py) parts and poetry-writing parts (poetizer.py) separately to generate derivative works.

All of this started with Sonnetizer, a computer program I wrote that generates sonnets from any text corpus in (mostly) iambic pentameter using Ngram-based natural language generation (via NLTK) along with rhyming and metrical rules. You can view the code on GitHub or check out this book of 10,000 sonnets (warning: 5000-page PDF) generated from the sonnets of William Shakespeare.

Sonnetizer was my first major Python project, and building it taught me a lot about Python. However, after building it and letting it sit for a month or so, I began to think about ways I might improve it.

Poetizer.py is the result of that process. It involves user inputs such as rhyme scheme and desired poetic structure to allow for interactive poetry generation.

Poemreader.py reads poems using built-in text-to-speech utilities present on Mac and Linux machines. It also displays images, gathered via Flickr API, related to the words in each poem it reads.

Main.py is a combination of the two files, tuned to produce a distinct interactive poetry experience. (This is the script running in the video above.)

]]>
http://www.thehypertext.com/2014/08/31/poetizer/feed/ 2