The file restaurant_reviews.txt is given to you.

The file contains names of reviewers and their reviews of different restaurants in the comma separated format. The first string is the name of the reviewer followed by a name of a restaurant and its rating. You are required to write a Python program that computes a similarity score between any two reviewers using Euclidean distances. An example data from the restaurant_reviews.txt file is given below:

Pete Wellsworth’s reviews are:
'Rooster and Owl': 3.0,
'El Sapo Cuban Social Club': 4.0,
'Punjab Grill': 3.0,
'Shibumi': 5.0,
'Mama Chang': 3.5
Jay Samuel’s reviews are:
'El Sapo Cuban Social Club':4.5,
'Mama Chang':1.0,
'Shibumi':4.0

The Euclidean distance between Jay Samuel and Pete Wellsworth is computed as follows:

1) Only consider the restaurants that both have reviewed.

2) Take the difference between corresponding reviews.

3) Sum the square of the differences

4) The square root of the sum of differences is the Euclidean score. The shorter the distance the closer the two reviewers.

For our example, this would be: (4.0 - 4.5)2 + (3.5 1.0) 2 + (5.0 4.0) 2 = 0.25 + 6.25 + 1 = 7.5

Euclidean distance is Square Root of 7.5 = 2.7386

Your program should provide the following:

1) Ability to read in a user provided filename which contains restaurant reviews in the comma separated format similar to the given file restaurant_reviews.txt

2) Functionality to compute the similarity between two reviewers provided by the user

3) Functionality to compute the similarity between one user provided reviewer and all other reviewers in the database

A sample run for the two required functionalities is given below (user inputs are in red):

Give the name of the restaurant reviews file: restaurant_reviews.txt
What do you want to do? Input 1 for similarity between two reviewers, or
Input 2 for similarity between one reviewer and all others in the database or 3 to quit: 1
Provide Reviewer1 name: Jay Samuel
Provide Reviewer2 name: Pete Wellsworth
The similarity score between Jay Samuel and Pete Wellsworth is: 2.7386

What do you want to do? Input 1 for similarity between two reviewers, or
Input 2 for similarity between one reviewer and all others in the database or 3 to quit: 2
Provide Reviewer name: Jay Samuel
The Similarity Scores are:
Jay Samuel Tomm Sietsema 1.87
Jay Samuel Corby Kumar 1.50
Jay Samuel Jonathan Golder 2.87
Jay Samuel Pete Wellsworth 2.74
Jay Samuel Brette Anderson 1.58
Jay Samuel Michael Baumer 1.80

What do you want to do? Input 1 for similarity between two reviewers, or
Input 2 for similarity between one reviewer and all others in the database or 3 to quit: 3
Goodbye!

Hint:

a) A good way to convert the file contents to a Python data structure is to create a dictionary. For example the first two lines of the restaurant_reviews.txt file can be stored as a dictionary entry such as the following:

{'Tomm Sietsema': {'Rooster and Owl': 2.5, 'El Sapo Cuban Social Club': 3.5, 'The Godfather': 3.0, 'Shibumi': 3.5, 'Mama Chang': 2.5, 'Punjab Grill': 3.0},'Jonathan Golder': {'Rooster and Owl': 3.0, 'El Sapo Cuban Social Club': 3.5, 'The Godfather': 1.5, 'Shibumi': 5.0, 'Punjab Grill': 3.0, 'Mama Chang': 3.5}}
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.