Question: (a) Design the wordCount method that, when given a String s, counts the number of words in the list. Store the results in a

(a) Design the wordCount method that, when given a String s, 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 = "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
3.40 Rating (150 Votes )
There are 3 Steps involved in it
To implement the wordCount method as described you can follow these steps Remove all punctuation fro... View full answer
Get step-by-step solutions from verified subject matter experts
