Guest User

Untitled

a guest
Dec 16th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. The point of this function is to return the most frequent word in a body of text. To do that, we take the function 'mostFrequentWord, a single argument, text, which is a body of text and returns the word that occurs most frequently in that text.
  2. First, we declare the variables var words = getTokens(text) // var wordFrequencies = {};
  3. Next, we loop through the words' length using the array's index. (It is filtering through the text over and over to find the most common word in the text)
  4. Then, we give the loop to possible outcomes using the "if" and "else" functions. If word in the array index is recognized more than once, then in the word frequencies will display it. Otherwise (else) the word will be equal to "1" & therefore not stand out.
Add Comment
Please, Sign In to add comment