Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement MyHashedSet and MyHashedMap as define in Java Collection Framework and Java Map. Counting the Occurrences of Words in a Text Write a program that

Implement MyHashedSet and MyHashedMap as define in Java Collection Framework and Java Map.

Counting the Occurrences of Words in a Text

Write a program that counts the occurrences of words in a text and displays the words and their occurrences in ascending order of the words. Must use your implementation of MyHashedSet and MyHashedMap.

The program uses a hash map to store a pair consisting of a word and its count. For each word, check whether it is already a key in the map. If not, add the key and value 1 to the map. Otherwise, increase the value for the word (key) by 1 in the map. To sort the map, convert it to a tree map.

These are my codes so far

MyHashedSet: https://pastebin.com/WXjNPD7t

MyHashedMap: https://pastebin.com/bTMSS3DS

MyMap: https://pastebin.com/n341XuUd

MySet: https://pastebin.com/Q5p6hgJU

From the links above, MyHashedSet implements MySet and MyHashedMap implements MyMap

I am now stuck. I really tried to make a program "that counts the occurrences of words in a text and displays the words and their occurrences in ascending order of the words".This is what I have so far on the link.

https://pastebin.com/AmrmbkhX (copy the link)

When I tried running it, rather than using file.txt but using KeywordCounter.java, I got errors saying.

java.io.FileNotFoundException: KeywordCounter.java (The system cannot find the file specified)

at java.base/java.io.FileInputStream.open0(Native Method)

at java.base/java.io.FileInputStream.open(Unknown Source)

at java.base/java.io.FileInputStream.(Unknown Source)

at java.base/java.util.Scanner.(Unknown Source)

at KeywordCounter.scanFile(KeywordCounter.java:35)

at KeywordCounter.main(KeywordCounter.java:89)

Is there any way the code KeywordCounter can be fixed?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago