Quantifying Rap By Codifying Math

Bhaskar Arun
Jul 12, 2020 · 8 min read
“You wanna know how to rhyme you better learn how to add It’s mathematics” — Mighty Mos Def
“You wanna know how to rhyme you better learn how to add It’s mathematics” — Mighty Mos Def
“You wanna know how to rhyme you better learn how to add
It’s mathematics” — Mighty Mos Def

No musical art-form is as competitive as rap. The best rappers are known to flex their metal, backing on their rhyming skills, and there are rap battles all over the globe, and no Hip-Hop fan has ever shied away from expressing their Top 5 MCs. All art is subjective specially one which relies so heavily on poetry and lyricism, such as RAP which translates to Rhythm and Poetry. But can we actually determine an All Time Top 5, keeping all the subjectivity aside only based on rhyming skills.

Now however much a Hip-Hop fan would love a rap battle between Rakim and Kendrik; which is sort of disrespectful to the OGs who are the genesis of this culture, it’s also practically and chronologically impossible to have a battle of bars involving every rapper ever. So I put my NLP skills to use and came up with BarBreakDown, a software which mathematically scores a song/verse/bar on the basis of rhymes and finds the best bar from the song.

“Men lie, women lie, numbers don’t” — JayZ (Reminder)

RAP: Rhythm and Poetry

A very comprehensive breakdown of rhyming in rap can be found here: Genius University. I will only go over the two attributes of rhyming I have taken into consideration while coming up with my algorithm.

Assonance, words which share the same vowel sound and not necessarily the same ending are the classic and creative method of rhyming in rap.

Multi-syllable rhymes are hallmarks of all the dopest flows, and all the best rappers use them, where multiple syllables share the same vowel sound and not just the last syllable. For example:

The rest is empty with no brain but the clever nerd
The best emcee with no chain ya ever heard” — Mos Def

Breaking Down BarBreakDown

This algorithm is basically designed to detect assonance rhymes. I recommend going through this section to understand the working and findings of this algorithm, although it can be skipped for the sake of it.

The primary objective is to find matching sequences of vowel sounds. This isn’t as rudimentary to implement as it sounds, as English is pronounced significantly differently from how it is written. Fortunately, there’s open source phonetic support, which can be used to achieve phonetic transcriptions of the lyrics which basically is a symbolic representation of how it sounds.

The code processes each song as follows:

  1. Firstly I retain only the unique lines of the song; as we don’t want to count repetition as rhyming.
  2. Then I retain only the vowels in the phonetic transcriptions.
  3. Now I go over each word in the song; for each word, find the longest matching vowel sequence that ends with one of the 2x-1 previous words (where x is the average length of a bar in the song).
  4. Calculate the mean length of the rhyme by taking the mean of the longest matching vowel sequences of each word in the song which we get from the 3rd step.

For the longest matching vowel sequence, no matches are accepted for words which are repeated, for example, the chorus has repeated lines.

Typically rhymes occur at the end of the lines, but since lyrics aren’t always presented in a standardised manner and a lot of lyricists use internal rhyming so I average rhymes over all the words. I encountered a high number of false positives where the words weren’t actually rhyming which were words with a single syllables(so, go, no don’t really qualify as rhymes), so I considered only words with at-least 2 syllables.

The code can be found at https://github.com/skepticalbayes/BarBreakDown/tree/master

And The Top 5 Are

I used an API to get the lyrics of rap artists I was aware of and also took a few suggestions from my peers. Intro, Outro, Skit and Interlude were neglected. I computed the average rhyme score(rhyme length) of each rapper for all the songs fetched through the API. The results have been mentioned below (with my personal Top 5 ranked within parenthesis xD). I have marked the ones with the most versatile vocabulary with an asterix (*). I suggest viewing the list in landscape mode if reading this on your phone.

| Rank | Artist | Rhyme Score |
| 1. | Inspectah Deck (Wu Tang) | 1.191 |
| 2. | Rakim The Great(1) | 1.183 |
| 3. | Earl Sweatshirt | 1.157 |
| 4. | Chief Keef | 1.144 |
| 5. | ASAP Rocky | 1.132 |
| 6. | Tech N9ne(2) | 1.131 |
| 7. | MF Doom | 1.20 |(3)*
| 8. | Big Sean | 1.173 |
| 9. | Royce Da 5'9 | 1.173 |
| 10. | Rick Ross | 1.172 |
| 11. | Jedi Mind Tricks | 1.167 |(2)*
| 12. | Biggie Smalls(5) | 1.159 |
| 13. | Weezy | 1.059 |
| 14. | Nicki Minaj | 1.056 |
| 15. | 2Pac(3) | 1.055 |
| 16. | Xzibit | 1.054 |
| 17. | Aesop Rock | 1.053 |(1)*
| 18. | Eminem | 1.049 |
| 19. | Nas(4) | 1.045 |
| 20. | Big L | 1.042 |
| 21. | Scarface | 1.041 |
| 22. | The Game | 1.041 |
| 23. | Common | 1.038 |
| 24. | J. Cole | 1.027 |
| 25. | RZA (Wu Tang) | 1.026 |(5)*
| 26. | Kendrick Lamar | 1.024 |
| 27. | Jay-Z. | 1.023 |
| 28. | Kid Cudi | 1.021 |
| 29. | 50 Cent | 1.012 |
| 30. | Tyler, The Creator | 1.012 |
| 31. | Ghostface Killah(Wu Tang)| 1.003 |(4)*
| 32. | Raekwon (Wu Tang) | 1.002 |
| 33. | Method Man (Wu Tang) | 1.002 |
| 34. | Kanye West | 1.002 |
| 35. | Drake | 0.996 |
| 36. | Busta Rhymes | 0.983 |
| 37. | E-40 | 0.979 |
| 38. | Redman | 0.979 |
| 39. | DMX | 0.979 |
| 40. | Snoop Dogg | 0.977 |
| 41. | Dr. Dre | 0.976 |
| 42. | Big Daddy Kane | 0.955 |
| 43. | Shakespeare | 0.952 |
| 44. | Andre 3K | 0.951 |
| 45. | LL Cool J | 0.949 |
| 46. | Slick Rick | 0.942 |
| 47. | GZA (Wu Tang) | 0.932 |
| 48. | Ice Cube | 0.927 |
| 49. | KRS-One | 0.920 |

The results aren’t too different from the popular opinion; for instance Rakim (#2), is known for his pioneering use of internal rhymes and multi syllable rhymes.

“Timeless, so age don’t count in the booth
When your flow stay submerged in the fountain of youth” — Rakim(Classic)

Similarly, Inspectah Deck (#1) from Wu-Tang Clan uses lots of multi syllable rhymes in his lyrics. As a benchmark, I took all the poems by William Shakespeare and computed Shakespeare’s Rhyme Score. He falls way behind the majority of rappers, which is understandable since multis are not commonly used in poetry.

Here are some of the longest multis detected by BarBreakDown (rhymes are bolded):

Six six triple eight forty-six ninety-nine three / Sick with nickel plates whorry chicks mighty mine be(15 rhyming vowels) — Tech N9ne (It’s Alive)

Dimes quiet as minds by design, mighty fine / Slight rewind, tightly bind, blind lead blind”(12 rhyming vowels) — MF Doom (Born Like This)

You gone love this, it’s marvelous, baby / It gotta thug’s twist-it start to get crazy (9 rhyming vowels) — Rakim(I Know)

Some artists use a lot of multi syllable rhymes often by bending words, like Eminem who doesn’t rank as high as most people would expect, coz as per his own admission he makes words rhyme that typically don’t rhyme together — he’s good at that. It’s about how he pronounces it; and that’s a skill in itself but it will take audio analysis to be able to compute that.

A versatile vocabulary is another attribute which every skilled rapper must posses in his/her arsenal. To get a more holistic picture of the rhyming skills of different rappers, I computed both the Rhyme Score and the vocabulary size. I used 20,000 first words for the vocabulary size estimation, which seemed to have little effect on the order of the artists. This exercise did lead me to explore Aesop Rock who I had never heard of and am pretty excited to dig into.

Jay Z contrasts his lyrical skills with Common in his track “Moment of Clarity” saying that he has had to dumb down his lyrics to double his dollars. Common ranks higher on the vocabulary scale, and interestingly, this also holds for the Rhyme Score scale. More substance doesn’t necessarily equate more success.

I dumb down for my audience and double my dollars
They criticize me for it yet they all yell “Holla”
skills sold truth be told
probably be lyrically Talib Kweli
I want to rhyme like Common Sense (But I did five Mil)
ain’t been rhyming like Common since” — JayZ(Moment of Clarity)

To Conclude

What makes a rapper better than the rest is not only how well they write technically. A good rapper can simultaneously write complex multi syllable rhymes and tell a coherent story or convey a moving message, and the narrative a rapper preaches is what most people connect and relate to. Furthermore, he or she may spice up the lyrics with some clever wordplays, double entendres and metaphors that make the listener either to think and look for meaning beneath the surface; so yes the meritocracy is still subjective, but only until these notions can’t be mathematically formulated.

References and sources:

Don’t forget to give us your 👏 !

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

The Startup

Medium's largest active publication, followed by +756K people. Follow to join our community.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store