Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with python. This is supposedly a relatively short code (according to my professor), nothing over the top. The code has to read movie

Need help with python. This is supposedly a relatively short code (according to my professor), nothing over the top. The code has to read movie reviews that already have scores from a separate text file and learn from that in order to rate a users review. Thanks! image text in transcribed
The goal of the assignment is to use the provided data file to develop an algorithm that will automatically score the sentiment of a new review that the user inputs. Before a user-input review can be scored, the program would need to execute a training phase based on the reviews that are provided in the data file. The training phase would process the file as follows: 1. Read in a review 2. Assign each word in the review the score attributed to the review. 3. Enter an object into a dictionary where each entry is keyed by the word. The corresponding total score and number of occurrences are grouped as the value (You can create a simple class to store the score and occurrences, or simply store them in a list). If a word already exists in the dictionary, the program would update the score and number of occurrences. For instance, if a review with a score of 3 contains the word "amazing" and the dictionary already contains an entry for that word with 32 as the total score and 8 as the number of occurrences, the dictionary entry would be updated to 35 and 9, respectively. 4. Repeat Step 1 until all data is entered Once the training phase is completed, the program should prompt the user to input a movie review, which it automatically scores based on the overall average score of the words in the review as determined by the training phase. The average score of each word is computed by dividing the total score for the entry by the number of occurrences. Your responsibility is to implement the training phase as detailed in steps 1-4 above. Your implementation must be based on the Python dictionary class. Example output: Enter a review Press return to exit A weak script that ends with a quick and boring finale The review has an average value of 1.79128 Negative Sentiment Enter a review Press return to exit Loved every minute of it The review has an average value of 2.39219 Positive Sentiment

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_2

Step: 3

blur-text-image_3

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

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions