Longest Poem in the World
The Longest Poem in the World is a continuous stream of real-time tweets that rhyme.
How it works
- The Twitter Search API is used to fetch 100 recent English tweets.
- 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,
orangehas the phonetical translation
ao1 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.
- Create a new Google Cloud Platform project
- Create a PubSub channel named
- Create 3 cloud functions, one for each of the folders in
cloud/functions, with the contents of the index.js and the package.json files for each.
fetch-tweetsis triggered through HTTP and uses the Twitter API to fetch tweets, filter to only reasonable candidates, then push each candidate to the
parse-tweetis triggered through the
tweetsPubSub channel for each candidate and tries to pair it with an older rhyming tweet
list-versesis triggered through HTTP and is used by the website to list the most recent verses of the poem
- In order for
fetch-tweetsto 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
cloud/storage. Upload this file into the Google Storage bucket created for your project
- Set up a cron job to call the
fetch-tweetsfunction however often you like. I use UptimeRobot with a frequency of 5 minutes.
- 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