- Nov 9, 2011
- 355
- 0
- 0
For a problem in class, I need to read an entire document. But I need to read it in n-grams, which are user defined.
So, when I do a 3-gram at the start of a file, I need to read the first three words, then put that 3 word String in to a hash table. Next, I need to read words 2,3, and 4 , then 3,4, and 5 and so on.
My problem is I have no idea on how to go about doing this. If I read the second word in the file, to add it to my String, then I lose it for the start of the next String.
Any ideas?
So, when I do a 3-gram at the start of a file, I need to read the first three words, then put that 3 word String in to a hash table. Next, I need to read words 2,3, and 4 , then 3,4, and 5 and so on.
My problem is I have no idea on how to go about doing this. If I read the second word in the file, to add it to my String, then I lose it for the start of the next String.
Any ideas?