Question: Part 3 : Should I watch it ? [ 2 5 marks ] Note: This is just a simplified method of doing textual analysis, but

Part 3: Should I watch it?[25 marks]
Note: This is just a simplified method of doing textual analysis, but it is a good exposure to see how we
could use code to help us determine certain sentiments.
Even though the movie has been released quite a while ago, your younger cousin has been pestering you
to watch Frozen II with her. You do not really enjoy watching movies but maybe if the movie reviews are
good enough...
In this part, you will be given a few movie reviews to analyse. A file, sent_scores.txt, has been loaded in for
you where each word is assigned a certain score (>0 means it's a positive word while 0 means it's a
negative word).
Your task is to write a function score(file) that takes in the file path of a movie review and output the
corresponding sentiment score and most impactful word within the review.
Input:
file - This is the .txt file that you want to analyse. Ensure that the txt file is in the same folder as
your python file
Output:
A 2-element tuple. The first element is the sum of the sentiment scores, rounded to 2 decimal
places. The second element is the word that has the highest impact within the article.
To illustrate how these 2 elements are calculated, refer to the example below:
In the template, we have read in the file sent_scores.txt as a variable word_scores. This contains a list of
lists in a format like this [['vile','-3.18'],['tragic','-3.15'],['ugly','-3.10'],['pastel','0.47']]. This means
"vile" is associated with a -3.18 score, "tragic" is -3.10, "pastel" is 0.47, etc.
 Part 3: Should I watch it?[25 marks] Note: This is just

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!