Question: Problem description : Given a text file, you need to compute the frequency of each word in the file. Consider the following Class : Variables:

Problem description: Given a text file, you need to compute the frequency of each word in the file.

Consider the following Class :

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

Sample Input File

Information Technology (IT) is becoming the cornerstone to any economy in the world. Since the spread of the Internet and communication applications in their diversified forms, IT became an integrated part of everyone's life in modern society. In UAE, IT plays a major role in the development of the society. Therefore, it is only natural to have the United Arab Emirates University offer a degree program in IT in its various specializations. The College of Information Technology offers a bachelor of science degree in Information Technology (BSc in Information Technology) in seven specialization tracks: Intelligent Systems (INSYS), Software Development (SWD), Information Security (SEC), Networking (NETW), E-Commerce (ECOM), Enterprise System (ENSYS), and Computer System Design (CSD). Problem description: Given a text file, you need to compute the frequency

WordFrequency -word: String count: int +WordFrequency(String) +getWord): String +getCount): int +incCount): void

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!