Question: i think it will help you https://github.com/fnielsen/afinn/blob/master/afinn/data/AFINN-en-165.txt In this project, you will write a program which takes a sentence from the user and calculates the


i think it will help you https://github.com/fnielsen/afinn/blob/master/afinn/data/AFINN-en-165.txt
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 word. 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 the 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 This movie is not boring, on the contrary, the plot is very interesting and the acting is wonderful. Output 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. 4 The most amazing things that can happen to a human being will happen to you, if you just lower your expectations. 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. Important issues about all exams/projects/quizzes: Make changes only between the following comments(DO NOT modify these comments or anything outside the region marked by the comments): # DO NOT EDIT_ANYTHING ABOVE_THIS_LINE o # DO NOT EDIT ANYTHING BELOW THIS LINE Do not add any extra messages message for input/output such as 'Enter an integer:', 'The result is:', etc. Any additional text that appears in the output will cause you to get no . negations ["not", "no", "don't", "didn't", "wasn't" "weren't", "can't", "couldn't", "isn't", 'aren't", "haven't" "hasn't", "hadn't"] # The list of punctuations to trim punctuations from words = "!\"#$%&'()*+,-./:;? punctuations @[\]^_^{|}~" # DO_NOT_EDIT_ANYTHING_ABOVE_THIS_LINE # DO_NOT_EDIT_ANYTHING_BELOW_THIS_LINE print (output sentence) print(total_polarity)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
