Question: JAVA ** * Constructor for objects of class TextProcessor */ public TextProcessor() } /** * Add a word to the processor. public void addWord(String word)

 JAVA ** * Constructor for objects of class TextProcessor */ public

JAVA

** * Constructor for objects of class TextProcessor */ public TextProcessor() }

/** * Add a word to the processor. public void addWord(String word) { }

/** * Get the number of times the given word has added * via addWord. */

public int howMany(String word) { return 0; }

/** Return the number of distinct words str is a * suffix of in the words added so far. * It counts as a suffix if a word ends with * str but str does not also match the whole word. * For instance: "thing" matches the following 3 examples: * "something" "nothing" "thing" * but only the first two qualify as proper suffix matches.

* Each word that contains the suffix must only be counted once, * so if "something" has been added 3 times, that only counts * as 1 match. */

public int suffixCount(String str) { return 0; }

/** * Count the number of distinct case-insensitive anagrams * of the given word that have been added to the processor. * An anagram consists of exactly the same number of * letters as the given word, each character occurring * the same number of times. It does not count as an anagram if the two words are already identical. * * For instance: "and" is an anagram of "Dan" but * "nan" is neither an anagram of "naan" nor "nan". */

public int anagramCount(String word) { return 0; }

. addWord: The parameter represents a case-sensitive word that has been found in a document. Because an instance must keep track of how many times each word has been added, the count of occurrences for that word must be increased by 1. You may assume that all strings passed to this method will consist only of one or more alphabetic characters and there is no need to check that this is the case. In other words, all parameters will be valid words. . howMany: The parameter represents a case-sensitive word that has been found in a document. The number of times that the exact word has been passed to the addWord method must be returned. . suffixCount: This method takes a single parameter and it must return the number of distinct words added so far to the processor that the parameter is a suffix of. It counts as a suffix if a word in the processor ends with the parameter but does not also exactly match the parameter. For instance: parameter "thing" matches all of: "something", "nothing" and "thing" but only the first two qualify as suffix matches. The count must represent distinct words, so each added word that contains the suffix must only be counted once. For instance, if "something" has been added 3 times, that only counts as 1 match for "something". . anagramCount: (challenging] This method takes a single parameter and it must return the number distinct case-insensitive anagrams of the given word have been added to the processor. An anagram consists of exactly the same number of letters as the given word with each character occurring the same number of times. However, identical words are not considered to be anagrams. For instance: "and" is an anagram of "dan" but "nan" is neither an anagram of "naan" nor of "nan. Note that because the match must be case- insensitive, "Dan" is also an anagram of "and". Each anagram is only counted once, regardless of how many times it has been added to the processor via addWord

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!