Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 3 : Should I watch it ? [ 2 5 marks ] Note: This is just a simplified method of doing textual analysis, but
Part : Should I watch it 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, sentscores.txt has been loaded in for
you where each word is assigned a certain score means it's a positive word while means it's a
negative word
Your task is to write a function scorefile 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 element tuple. The first element is the sum of the sentiment scores, rounded to decimal
places. The second element is the word that has the highest impact within the article.
To illustrate how these elements are calculated, refer to the example below:
In the template, we have read in the file sentscores.txt as a variable wordscores. This contains a list of
lists in a format like this viletragicuglypastel This means
"vile" is associated with a score, "tragic" is "pastel" is etc.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started