Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Text Reader

I want to make a program that read the inputed text and parse every word and store it in a data structure, so i can later have some statistics about that (frequency of words, most common word etc).

I need guidance about two things:

a. best approach for my "parse function", which will divide the text in terms

b. best approach for data structure choice, in what concerns complexity, access times and best suitable for the case.

like image 948
John Avatar asked Apr 28 '26 05:04

John


1 Answers

a) best approach for my "parse function"

Use a Scanner it has nice functions for next (word) etc.

b) best approach for datastruture choice

A map from word to a statistics object: Map<String, WordStatistics>.

like image 181
dacwe Avatar answered Apr 30 '26 20:04

dacwe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!