Creative Experiment · generative poetry

Decent Dialogue

A class asked us to write a poem in Python. So we built a small machine that learns how famous people talk, pairs two of them at random, and lets them say beautiful nonsense to each other.

Illustration of a phone with chat bubbles between celebrities, including Taylor Swift, Einstein, Trump, and Obama
Role
Idea · concept · design
Tools
Python · spaCy · Selenium · Flask · Illustrator
Team
Jingfei Lin (development)

Overview

The brief was almost a dare: write a poem in Python. This was 2017, before "AI writing" meant anything to most people.

So we built a small program that reads how famous people actually talk. It scrapes their best-known quotes, learns which words they reach for, then pairs two figures at random and lets them hold a conversation: Einstein and Taylor Swift, Trump and Jesus, whoever the dice land on.

The grammar is deliberately rigid and the pairings are pure chance, so what comes out is gloriously broken. "Delicious relationship is in my car." That randomness is the whole point. It's less a chatbot than a poem that writes itself. I came up with the idea and designed it; Jingfei Lin built it.

Overheard

Four exchanges the machine produced. Every line is generated; none of it was written by us.

Albert EinsteinWhat if single presence just marries me irrelevantly?
Taylor SwiftDelicious relationship is in my car.
Taylor SwiftWhat if loathsome individuals figure now they aren't straight?
Donald TrumpThat rumor hasn't good insecurity.
Donald TrumpWhat if big decompress holds me back?
Jesus ChristYou get pretty butterfly.
Jesus ChristWhat if junior bus does it ridiculously?
Elon MuskNext character happens to be a car.

Straight from the generator

Press "one more time," and it keeps going, forever.

What if aggressive land keep near silent me n't? Best disgrace be forgotten everything. What if net dream be n't that I Especially? Great hate support their anything. What if stronger song carry back foreign I frankly? Happy music do my instinct. What if bigger soccer rebuild especially that you always? Safe song picture miraculous world. What if good facet sink So basic I never? Happy television do little secret.

Raw output from the question-and-answer mode.

How it works

Four steps, from real quotes to generated nonsense.

1

Scrape

Pull each figure's most-quoted words from BrainyQuote with Selenium. Six source texts to start: Trump, Taylor Swift, Drake, Obama, Einstein, and Bob Dylan (Jesus and Elon Musk joined later).

2

Tag

Run every word through part-of-speech tagging with spaCy, sorting them into five lists: nouns, verbs, adjectives, adverbs, and pronouns.

3

Reassemble

Drop random words from those lists into a fixed grammar. The rigidity of the template against the randomness of the words is what makes it sing.

Question = "What if" + adj + noun + verb + adv + adj + pron + verb + adv
Answer   = adj + noun + verb + adj + noun
4

Serve

A tiny Flask app picks two figures and prints their exchange. Two modes: Automatic, where the machine talks to itself, and Player, where you choose who speaks.

The original code is long gone now; what's left is the documentation and the poems it left behind. Made in 2017 with a web scraper and a part-of-speech tagger, years before a chatbot could do any of this on its own. The seams show, and that is the charm: a poem made of pure coincidence.