Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(a) Design the wordCount method that, when given a Strings, counts the number of words in the list. Store the results in a HashMap

(a) Design the wordCount method that, when given a Strings, counts the number of words in the list. Store the(a) Design the generic lookup method that, when given an Map M and a value k of type K, returns the

(a) Design the wordCount method that, when given a Strings, counts the number of words in the list. Store the results in a HashMap . Assume that s is not cleaned. That is, you should first remove all punctuation (periods, commas, exclamation points, question marks, semi-colons, dashes, hashes, ampersands, asterisks, and parentheses) from s, producing a new string s'. Then, split the string based on spaces (remember tokenize?), and produce a map of the words to their respective counts. Do not factor case into your total; i.e., "fACTOR" and "factor" count as the same word. The ordering of the returned map is not significant. String s = "Hello world, the world is healthy, is it not? I certainly agree that the world is #1 and healthy." wordCount (s)-> [{"hello", 1}, {"world", 3}, {"the", 2} {"is", 3}, {"healthy", 2}, {"it", 1}, {"i", 1}, {"certainly", 1} {"agree", 1} {"that", 1}, {"1", 1}, {"and", 1}, {"not", 1}] (a) Design the generic lookup method that, when given an Map M and a value k of type K, returns the corresponding value (of type V) associated with the key k. If the key does not exist, return null. You will need to use the .equals method. (b) Design the generic stringifyList method that, when given an ArrayList L, returns a String of comma-separated values where each value is an element of L, but converted into a string. You'll need to use the .toString method.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

It appears that youve presented two separate tasks 1 Creating a wordCount method that removes punctuation from a string and counts the occurrences of ... 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

Management Accounting

Authors: Leslie G. Eldenburg, Albie Brooks, Judy Oliver, Gillian Vesty, Rodney Dormer, Vijaya Murthy, Nick Pawsey

4th Edition

0730369382, 978-0730369387

More Books

Students also viewed these Programming questions

Question

Evaluate the following integrals:

Answered: 1 week ago