Question: Using java netbeans Problem description : Given a text file, you need to compute the frequency of each word in the file. Variables: word: the
Using java netbeans
Problem description: Given a text file, you need to compute the frequency of each word in the file.
Variables:
word: the word (String)
count: the frequency of the word (int)
Methods
WordFrequency(String wf)
//the constructor sets the word, initialize count = 0
getWord() and getCount()
//the getter methods
incCount()
//increment the count
class TestClass
main Method:
Open the text file
Create wordList as a new ArrayList of WordFrequency
while (not end of file)
read the next String as word
if(word is in wordList)
Increment count of the corresponding word
else
add word to wordList, initialize count to 1
print all words (with count) in the wordlist that have frequency (i.e., count) at least 2 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
