Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need some help with python. My professor this should be a relatively short code, nothing too long, but I am having a hard time figuring

Need some help with python. My professor this should be a relatively short code, nothing too long, but I am having a hard time figuring it out. An example input file text would be:

1 A series of escapades demonstrating the adage that what is good for the goose is also good for the gander , some of which occasionally amuses but none of which amounts to much of a story . 4 This quiet , introspective and entertaining independent is worth seeking . 1 Even fans of Ismail Merchant 's work , I suspect , would have a hard time sitting through this one . 3 A positively thrilling combination of ethnography and all the intrigue , betrayal , deceit and murder of a Shakespearean tragedy or a juicy soap opera . 

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

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

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

What did they do? What did they say?

Answered: 1 week ago