Find the text generator here. A lyric generator, which is connected to the RapGenius API, is here.

Based off an old college assignment, this project uses basic natural language processing to generate semi-plausible text.

Text generation for Nick Bostrom's <i>Superintelligence</i>

Markov Chains

The algorithm divides the input text into k-grams, and for each k-gram, forms a frequency table for the following character.

When generating text, the algorithm looks at the current k-gram and selects a random character based off the weighted distribution of the frequency table.

The algorithm incorporates the character into the next k-gram and repeats the process.

This algorithm is called a Markov chain and produces long-strings of semi-believable text.

Try it out for yourself with text or lyrics.

Project Design

I coded the Markov chain in Python and hosted it on Heroku with the Flask micro web framework. I wrote a CSS/HTML/JavaScript GUI to mimic the effect of the Terminal when originally testing the algorithm. For the animation I used the Typed.js library.

Because the output was especially amusing for song lyrics, I also connected another version to the RapGenius API. The GitHub repo for the lyric generator is here.