Question: %%%%%%Python - Jupiter Notebook # Inverted index - maps words to the list of document IDs ind = { 'best': [2], 'blue': [1,3], 'bright': [1,4],
%%%%%%Python - Jupiter Notebook

# Inverted index - maps words to the list of document IDs ind = { 'best': [2], 'blue': [1,3], 'bright': [1,4], 'butterfly': [1] }
word = input("Enter search word: ") print("The word '%s' appears in the following documents: " % (word,))
# TODO: YOUR CODE GOES HERE
1. Look up a word in an inverted index Write a script that looks up a word and prints the document IDs that the word appears in. For example, if the user enters the word "bright the output should be: Enter search word: bright The word 'bright' appears in the following documents: Document 1 Document 4 Hint: You will need to loop through a list to print each document ID. In [ ]: # Inverted index-maps words to the list of document IDs ind = { 'best': [2, 'blue': 1,3, bright': 1,4 butterfly' [1 word input("Enter search word:") print ("The word .%s' appears in the following documents: " % (word, )) # TODO: YOUR CODE GOES HERE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
