Answered step by step
Verified Expert Solution
Link Copied!

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 createIndex(titles) would return the following map: {ark=[Raiders of the Lost Ark], crusade=[The Last Crusade], doom=[The Temple of Doom], last=[The Last Crusade], lost=[Raiders of the Lost Ark], of=[The Temple of Doom, Raiders of the Lost Ark], raiders=[Raiders of the Lost Ark], temple=[The Temple of Doom], the=[The Temple of Doom, The Last Crusade, Raiders of the Lost Ark]} The keys of the returned map should be case-insensitive (i.e. 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 non-null, that each element of the parameter is a non-null and non-empty 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

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

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions

Question

Q: What steps are taken to reduce turnover?

Answered: 1 week ago

Question

Question Can a Roth IRA invest in stock of the IRA owners business?

Answered: 1 week ago