Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Content is below abandoned -2 abandons -2 abhorred -3 abhorrent -3 abilities 2 ability 2 aboard 1 aborted -1 aborts -1 abuse -3 abused -3
Content is below
abandoned -2 abandons -2
abhorred -3 abhorrent -3
abilities 2 ability 2 aboard 1 aborted -1 aborts -1
abuse -3 abused -3
acceptable 1
amazing 4
asss -4
awesome 4
bastardd -5
bitchh -5
breathtaking 5
Please, CODE WITH PYTHON In this project, you will write a program which takes a sentence from the user and calculates the polarity score of this sentence. The polarity score of a sentence is computed as the sum of the polarity scores of the words in this sentence. To obtain the polarity score of words, you are given a file named "AFINN-en-165.txt" which consists of words and their polarity scores. In this file, each line contains a word and its polarity score. To calculate the polarity of a sentence, you will split this sentence into words. For each word, if this word is found in the file, you will take the score of this word and add it to the score of the sentence; otherwise, you will ignore this wor However, the polarity score of a word must be negated if a negation comes before this word (e.g. the score of "not boring" must be 3 since the score of "boring" is - 3 and "not" comes before "boring"). The list of negations can be found in program. We have provided you with a string of all the puncutations that can occur in a sentence (punctuation), so that you can strip each word from any punctuation. You will output the sentence such that words with known polarity are uppercase and the rest remain unchanged and the polarity score of this sentence. The code that prints the sentence and the polarity score separated by a newline is provided. Do not change it. Examples Input Output This movie is not boring, on the contrary, the plot is very interesting and the acting is wonderful. This movie is NOT BORING, on the contrary, the plot is very INTERESTING and the acting is WONDERFUL 9 The most amazing things that can happen to a human being will happen to you, if you just lower your expectations The most AMAZING things that can happen to a human being will happen to you, if you just lower your expectations. 4 If you don't apologize, I will not accept any more calls. If you DON'T APOLOGIZE, I will NOT ACCEPT any more calls. 0 Explanation: For the input: "This movie is not boring, on the contrary, the plot is very interesting and the acting is wonderful.". the words "boring", "interesting" and "wonderful" are found in the file. Their polarity scores are as follows: not boring: 3 (since boring: -3) interesting: 2 wonderful: 4 Thus, the polarity score of the sentence becomes 9 and in the output these words are uppercase
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