Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this section, we are providing you with two data files movies.json and ratings.json in JSON data format. The first data file is movie information

In this section, we are providing you with two data files movies.json and ratings.json in JSON data format. The first data file is movie information directly from IMDB, including rating for some movies but not all. The second file is ratings from Twitter. Be careful: Not all movies in movies.json have a rating in ratings.json, and not all movies in ratings.json has relevant info in movies.json. The data can be read in its entirety with the following five lines of code:

import json

if __name__ == "__main__":

movies = json.loads(open("movies.json").read())

ratings = json.loads(open("ratings.json").read())

Both files store data in a dictionary. The first dictionary has movie ids as keys and a second dictionary containing an attribute list for the movie as a value. For example: print (movies['3520029'])

(movie with id '3520029') produces the output:

{'genre': ['Sci-Fi', 'Action', 'Adventure'], 'movie_year': 2010, '

name': 'TRON: Legacy', 'rating': 6.8, 'numvotes': 254865}

In this homework, assume you are given these two files called movies.json and ratings.json. Read the data in from these files.

Ask the user for a year range: min year and max year, and two weights: w1 and w2.

Find all movies in movies made between min and max years (inclusive of both min and max years).

For each movie, compute the combined rating for the movie as follows: (w1* imdb_rating + w2 * average_twitter_rating)/(w1+w2) where the imdb_rating comes from movies and average_twitter_rating is the average rating from ratings.

If a movie is not rated in Twitter, or if the Twitter rating has fewer than 3 entries, skip the movie.

Now, repeatedly ask the user for a genre of movie and return the best and worst movies in that genre based on the years given and the rating you calculated.

Repeat until the user enters stop.

A sample output of your program is given below (the second lines for each movie has a tab at the start of the line, and the rating is given in {:.2f} format.):

The movie.json:image text in transcribedThe rating.json:image text in transcribed

The example of the output:

Min year => 2000

2000

Max year => 2016

2016

Weight for IMDB => 0.7

0.7

Weight for Twitter => 0.3

0.3

What genre do you want to see? sci-fi

sci-fi

Best: Released in 2014, Interstellar has a rating of 8.70

Worst: Released in 2015, Fantastic Four has a rating of 4.72

What genre do you want to see? drame

drame

No Drame movie found in 2000 through 2016

What genre do you want to see? drama

drama

Best:Released in 2008, The Dark Knight has a rating of 9.20

Worst: Released in 2012, Spring Breakers has a rating of 4.91

What genre do you want to see? stop

stop

a -10" 6p e.. 29 4 8ealn]5m 2-nga" , 53Jyva 4 dme nari" a4-11-00" eee ,menr 7-ni4t12-[-0 v2[tyr--giD.. 9 ,1 t 1 a19e yn--mig ] r,e.. e r"" Vl - aue erom ,en-m s8 ,dvar ," tr enr omu n44eHegm-.. h 2 3-B,40 eu" 1cm" 9 , rn-9" p41 , y3se m2rB3mo!" any e ,va.. h A,a-11 0 a H 0 e Fid.. F C gar6v Dr 2n-2m" te" rn-00 n-?--6 t [1182" .181 1.1 ,5 er e504.. r a e 7 d511 eeli " .. ,,a" DC" ndo--u -gw,--n-g m-nc mgar.. gvt.. gm2gaa ngs.. e .. e.. all dt-396 .. yv-11-88e5-n402" ea1392 dm ,v0.. mri 91.. e u .. m,i26-6 ...- eenmy? ," ndin e 7 0 r" 5 r t d 0 1 1 00 rnv2-d300" .1 9 ent" i40ng9 n a e 0 n10 n- 000 e 4 0.1 g>2 m02m82tno3 v92enlerm5 ,002e 2.1 y..]se" 3dr--ey0 ,y3uee se".. rse.. s e .. .. 20s.! ev.1 9 1.1 9 4ryt mmv2.. v 2 7 m m m a m v 3trmvemveem6 avemv.1 1.1.1 vinvinea6 a -10" 6p e.. 29 4 8ealn]5m 2-nga" , 53Jyva 4 dme nari" a4-11-00" eee ,menr 7-ni4t12-[-0 v2[tyr--giD.. 9 ,1 t 1 a19e yn--mig ] r,e.. e r"" Vl - aue erom ,en-m s8 ,dvar ," tr enr omu n44eHegm-.. h 2 3-B,40 eu" 1cm" 9 , rn-9" p41 , y3se m2rB3mo!" any e ,va.. h A,a-11 0 a H 0 e Fid.. F C gar6v Dr 2n-2m" te" rn-00 n-?--6 t [1182" .181 1.1 ,5 er e504.. r a e 7 d511 eeli " .. ,,a" DC" ndo--u -gw,--n-g m-nc mgar.. gvt.. gm2gaa ngs.. e .. e.. all dt-396 .. yv-11-88e5-n402" ea1392 dm ,v0.. mri 91.. e u .. m,i26-6 ...- eenmy? ," ndin e 7 0 r" 5 r t d 0 1 1 00 rnv2-d300" .1 9 ent" i40ng9 n a e 0 n10 n- 000 e 4 0.1 g>2 m02m82tno3 v92enlerm5 ,002e 2.1 y..]se" 3dr--ey0 ,y3uee se".. rse.. s e .. .. 20s.! ev.1 9 1.1 9 4ryt mmv2.. v 2 7 m m m a m v 3trmvemveem6 avemv.1 1.1.1 vinvinea6

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 Analytics And Quality Management Fundamental Tools

Authors: Joseph Nguyen

1st Edition

B0CNGG3Y2W, 979-8862833232

More Books

Students also viewed these Databases questions

Question

Identify and describe the two major symptoms of bipolar disorder.

Answered: 1 week ago