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?
-
2You 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– Kilian Foth2016年06月08日 11:53:47 +00:00Commented Jun 8, 2016 at 11:53
-
1Are you able to easily recognize word boundaries (i.e., does your stream of incoming characters include spaces and newlines)?Dan Pichelman– Dan Pichelman2016年06月08日 12:58:11 +00:00Commented Jun 8, 2016 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– Nikant2016年06月08日 14:27:18 +00:00Commented Jun 8, 2016 at 14:27
-
Do you want to use the dictionary or another collection for maintaining the word counts?Robert Harvey– Robert Harvey2016年06月08日 14:54:19 +00:00Commented Jun 8, 2016 at 14:54
-
I want to use a dictionaryNikant– Nikant2016年06月08日 15:16:16 +00:00Commented Jun 8, 2016 at 15:16
1 Answer 1
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.
answered Jun 9, 2016 at 16:26