The Longest Poem in the World is a continuous stream of real-time tweets that rhyme.
- The Twitter Search API v1.1 is used to fetch the latest 100 tweets, twice a minute.
- Out of those tweets it only considers those written in proper English and with a reasonable syllable count.
- The CMU Pronouncing Dictionary is used to obtain phonetical translations of the tweet. For example,
orange
has the phonetical translationao1 r ah0 n jh
. Tweets that rhyme have the same phonetical translation starting with the last accented phoneme. - A backlog of tweet candidates is kept. For each tweet ("candidate") fetched from the public search stream, it looks in the backlog to see if it can find one that rhymes with it. If yes, it pushes both tweets into the poem's verse stream. If not, the tweet is saved in the backlog, waiting to be paired with a future candidate.
- Additional improvements include: ignoring "same word" rhymes, translating numbers into plain text, ignoring smileys, etc.
- Clone the repository
- Make sure you have a running Redis instance
- Install dependencies:
npm install
In order for the application to be able to access the Twitter Search API, you need to provide the necessary API access tokens. Go to Twitter's developer portal, sign in with your Twitter account and create a new application. At the bottom of the app page click the "Create my access token" button, then go to the "OAuth tool" tab and copy the 4 OAuth tokens into the app.config
JSON file.
To start the poem generator, run node engine
.
The verse stream will be saved in a redis list, as well as being written to stdout as plain text strings.
A simple, read-only API is provided in the api
folder. It is currently used by the application homepage to list verses. I plan to allow outside submissions into the verse stream in the form of an API request containing a pair of tweet ids.
To start the API server, run node api
.
- The application requires a running Redis instance.
Andrei Gheorghe
- About me
- LinkedIn: linkedin.com/in/idevelop
- Twitter: @idevelop
- The "Longest Poem in the World" code is licensed under the MIT License.
- The CMU Pronouncing Dictionary is Public Domain.
- Tweets are property of their respective authors