Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a method called createIndex that creates an inverted index for a list of documents. Your method should take one argument, a list of documents
Write a method called createIndex that creates an inverted index for a list of documents. Your method should take one argument, a list of "documents" where each document is represented as a string. Your method should return a map where the keys are individual words that appear in the parameter list of documents and the values are sets of documents in which those words appear. For example, suppose the variable titles contains the following list: Raiders of the Lost Ark, The Temple of Doom, The Last Crusade In this case, the call createIndextitles would return the following map: arkRaiders of the Lost Ark crusadeThe Last Crusade doomThe Temple of Doom lastThe Last Crusade lostRaiders of the Lost Ark ofThe Temple of Doom, Raiders of the Lost Ark raidersRaiders of the Lost Ark templeThe Temple of Doom theThe Temple of Doom, The Last Crusade, Raiders of the Lost Ark The keys of the returned map should be caseinsensitive ie treat "The" and "the" as the same word The keys of the returned map should be in sorted order, while the sets in the values should prefer fast lookup speed. You may assume that the parameter passed in nonnull, that each element of the parameter is a nonnull and nonempty string, and that words in each document are separated by a single space.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started