Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with python. According to the professor this should be a relatively short code. In order to score the users review you have to

Need help with python. According to the professor this should be a relatively short code. In order to score the users review you have to get the average score, so old score+new scoreumber of occurances or something else like that. Also the code learns from a separate text file containing movie reviews that are already scored. An example of a movie review in that file would be: 5 this movie was amazing. The whole goal of this is to be able to score a movie review the user enters.

image text in transcribed

The goal of the assignment is to use the provided data file to develop an algorithm that wi 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 ofoccurrences. 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

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

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

What is block ownership? How does it affect corporate governance?

Answered: 1 week ago