Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thebinarypenguin/5f9903f2b81277d07c3244097d156f6c to your computer and use it in GitHub Desktop.
Save thebinarypenguin/5f9903f2b81277d07c3244097d156f6c to your computer and use it in GitHub Desktop.
Most Frequent Word Analysis
getTokens
1. convert string to lower case
2. split string into array (of words) along word boundaries
3. remove any empty strings
4. sort the array of words alphabetically
mostFrequentWord
1. call getTokens to convert text into an array of sorted words
2. loop over the words array, building up a frequency distribution object
3. loop over the frequency distribution object, looking for the word with the highest frequency
4. return the word with the highest frequency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment