Answered step by step
Verified Expert Solution
Link Copied!
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 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.
image text in transcribed

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

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students explore these related Databases questions