Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. Declares function GetTokens with attribute “rawString”
  2. Taking attribute rawString and filtering out any kind of special characters and setting everything in those strings to lower case
  3.  
  4.  
  5. Declaring mostFrequentWord function with “text” as a attribute.
  6.  
  7. Passes the function attribute to the getTokens function and saves that to the words variable.
  8.  
  9. Then we set up a array called wordFrequencies
  10.  
  11. Then we set up a For loop that will execute for the length of the array that is set up for our words variable
  12.  
  13. Then we tell our loop that If we see any text that gets passed to the word variable more than once we should save that value to the wordFrequnecies variable and also increase that value by one and if we don’t than to explicitly set it to 1.
  14.  
  15. Then we declare a currentMaxKey and have it look through our array of data in wordFrequencies and look at the number of keys it returns.
  16.  
  17. Then we declare that a new variable called currentMaxCount be set to the value of what the currentMaxKey has returned from wordFrequencies
  18.  
  19. Set a for loop to then compare the variable called wordFrequencies and its attribute word and its value to the value of currentMaxCount and that if wordFrequencies is greater than currentMaxCount then set currentMaxKey equal to word and set currentMaxCount equals to wordfrequencies attribute word.
  20.  
  21. Then we return the currentMaxKey which will return the word most frequently listed.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement