This editing process may produce new entries which can be combined. The final Thesaurus must contain no pair of entries that have 2 or more words in common. Of course, each entry must contain no duplicates.
Create a class Thesaurus that contains a method edit that is given a String[] entry, the entries in the original Thesaurus. The method returns the edited Thesaurus as a String[]. Each element of entry has no leading or trailing spaces and has its words separated by a single space. Each element of the return should also have no leading or trailing spaces and have its words separated by a single space. In addition, the words within each element of the return must be in alphabetical order, and the elements in the return must appear in alphabetical order.
String[]
String[]
String[] edit(String[] entry)(be sure your method is public)
{"ape monkey wrench", "wrench twist strain"} Returns: { "ape monkey wrench", "strain twist wrench" }These two entries have only one common word so they cannot be combined. After rearranging the words within each entry to put the words into alphabetical order, the first entry is first alphabetically.
{"ape monkey wrench", "wrench twist strain", "monkey twist frugue"} Returns: { "ape monkey wrench", "frugue monkey twist", "strain twist wrench" }No entries could be combined, but two had to be arranged, and the order was changed.
{"ape monkey wrench", "wrench twist strain", "monkey twist frugue strain"} Returns: { "ape frugue monkey strain twist wrench" }The first two entries could not be combined, but the last two could. After they were combined, the first entry shared both "wrench" and "monkey" with the new combined entry, so we ended up with just one entry.
{"point run score","point dot","cut run tear score","cut valley","cute pretty"} Returns: { "cut point run score tear", "cut valley", "cute pretty", "dot point" }