Last active
August 31, 2018 09:37
-
-
Save bee-san/a71574562fbf15ab9e855fdf2d7d0592 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function termFrequency(document){ | |
| // calculates term frequency of each sentence | |
| words_without_stopwords = prettify(document); | |
| // gets rid of trailing spaces | |
| const sentences = document.split(".").map(item => item.trim()); | |
| sentences[0] = sentences[0].substring(146); | |
| const TFVals = countWords(words_without_stopwords) | |
| const unique_words = uniqueWords(words_without_stopwords); | |
| // actually makes it TF values according to formula | |
| for (const [key, value] of Object.entries(TFVals)){ | |
| TFVals[key] = TFVals[key] / words_without_stopwords.length; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment