Git Product home page Git Product logo

longest-poem-in-the-world's Introduction

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, orange has 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.

Setup

  • Create a new Google Cloud Platform project
  • Create a PubSub channel named tweets
  • 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-tweets is triggered through HTTP and uses the Twitter API to fetch tweets, filter to only reasonable candidates, then push each candidate to the tweets PubSub channel
    • parse-tweet is triggered through the tweets PubSub channel for each candidate and tries to pair it with an older rhyming tweet
    • list-verses is triggered through HTTP and is used by the website to list the most recent verses of the poem
  • In order for fetch-tweets 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 twitter.json file in cloud/storage. Upload this file into the Google Storage bucket created for your project
  • Set up a cron job to call the fetch-tweets function however often you like. I use UptimeRobot with a frequency of 5 minutes.

Author

Andrei Gheorghe

License

  • 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

longest-poem-in-the-world's People

Contributors

adibalcan avatar idevelop avatar soops avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.