0

I have a dictionary of words and a stream of incoming characters. I need to create a map of words present in the stream along with their frequencies. How can I achieve this efficiently?

  • 2
    You maintain a mapping from words to their occurrence counts. That should take less processing time than processing the I/O. Which part would you like help with? – Kilian Foth Jun 8 '16 at 11:53
  • 1
    Are you able to easily recognize word boundaries (i.e., does your stream of incoming characters include spaces and newlines)? – Dan Pichelman Jun 8 '16 at 12:58
  • I am able to recognize word boundaries with spaces. But I need to keep track of word frequencies as the characters come without storing the whole text. – Nikant Jun 8 '16 at 14:27
  • Do you want to use the dictionary or another collection for maintaining the word counts? – Robert Harvey Jun 8 '16 at 14:54
  • I want to use a dictionary – Nikant Jun 8 '16 at 15:16
2

A dictionary where the key is the word encountered, and the value is a count of the number of times that word is encountered. I think your question has some hidden problem you did not explain. This is trivial.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.