Find the lyric generator here. A text generator, which is not 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.
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.
Called a Markov chain, the algorithm produces long strings of semi-believable text.
Try it out for yourself with text or lyrics.
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 connected it to the RapGenius API. For Lyric Generator, you enter the name of an artist. The algorithm scrapes the artist's 10 most popular songs from RapGenius and produces a pseudo-random song.
The GitHub repo for the text generator, without the RapGenius API, is here.