Map words to line number in text file
I'm working on a small project and have run into some problems.
Briefly described, what I'm attempting to do is:
I've a rather large text file with a different sentence and I need to find all the words in each sentence and add them to some sort of index, so that the structure is: key = word and value = line number(s). For example like this:
mistake | 0, 2, 4, 6
sun | 0, 1, 5, 10
rain | 3, 4, 10, 22
I need to make a tool to find the occurrence of a word in a file, so if I search for the word "drum" is say: Drum occur 5 times in line 3, 8, 9, 11, 32
I've played around with some different structures but unfortunately I haven't been successful.
I read my text file as such:
Look into HashMaps or Matrixes
|All times are GMT +1. The time now is 12:02 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.