Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

## Question 4 - Write a program that can search the papers dataset based on terms in the title (9 points) Make a dictionary that

## Question 4 - Write a program that can search the papers dataset based on terms in the title (9 points)

Make a dictionary that maps each term in the paper titles to a list of papers whose titles contain that term (identified by the paper ID).

### Part A (5 pts): Write a search function

Requirements: - Name your function `search_papers()` - Your function should take **2 parameters**: 1) the query term to search for, and 2) your `term_index` from Question 3 - Your function should **return** a list of matching papers. - Your function should not fail if the user enters a term that isn't in the `term_index`: in that situation, your function should return an empty list (i.e., a list with 0 items in it)

### Part B (4 pts): Write a program that uses the search function

Requirements: - Print a message that tells the user how many results were found *(hint: you can compute this by getting the length of the list of results, if your function was defined correctly)* - If there are matching papers, print out each matching paper ID, along with its paper title (retrieved from the `paper_titles` dictionary from Question 2)

Here is an example of an input/output trace from a function and program that meets these requirements: ``` What do you want to search for? data There are 9 papers that match your search. 1960191312 empirical analysis of data breach litigation 2364071307 learning individual behavior using sensor data the case of gps traces and taxi drivers 2529452593 modeling user engagement in mobile content consumption with tapstream data and field experiment 2338895451 understanding user economic behavior in the city using large scale geotagged and crowdsourced data 2273081434 gaussian processes for independence tests with non iid data in causal inference 2601121662 graph structure learning from unlabeled data for early outbreak detection 2575532943 graph structure learning from unlabeled data for event detection 1961666882 identifying emerging novel outbreaks in textual emergency department data 2243328796 predicting bundles of spatial locations from learning revealed preference data ```

Here is another example trace for a situation where the user's term isn't in the dictionary: ``` What do you want to search for? mouse There are 0 papers that match your search.

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

Students also viewed these Databases questions