Question: Sentiment Analysis is a problem within the field of Artificial Intelligence which seeks to determine the general attitude of a writer given some text



Sentiment Analysis is a problem within the field of Artificial Intelligence which seeks to determine the general attitude of a writer given some text they have written. For instance, we would like the program to recognize that the text "My favourite film all year" is a positive statement while "A giant waste of time" is negative. One algorithm that we can use for this is to assign a number to each word based on how positive or negative that word is, and then score the statement based on the values of the words. But, how do we come up with our word scores in the first place? That's what we will do in this assignment. You are going to search through a file containing movie reviews from the Rotten Tomatoes website which have both a numeric score as well as text. Your program will use this to learn which words are positive and which are negative. The file is called movieReviews.txt and is available on UM Learn. Notice that each review starts with a number 0 through 4 with the following meaning: 0: negative 1: somewhat negative 2: neutral 4: positive You are going to write a program that determines the score for each word in this file, and then uses those word scores to decide if an unlabelled movie review is positive, negative, or neutral. Part A: Learning from Labelled Movie Reviews To begin, your program must compute the average sentiment score for each of the words in the movieReviews.txt file. Download the text file and save it in the same folder where your program will be. Then write a program to do the following: . Set up a new, empty dictionary. Iterate over every review in the text file (there is one review per line). Examine every word in every review within the file. If the word is not yet in your dictionary: Add a new entry into your dictionary for that word. The word itself is the key, and the value to store at this key is a list that contains two items: the sentiment score and the number 1 (meaning that you've seen this word 1 time). Otherwise (if the word is already in your dictionary): Add the new sentiment score to the score that is already stored in the list, and Increase the number of times that you have seen this word. . 3: somewhat positive . .
Step by Step Solution
3.40 Rating (162 Votes )
There are 3 Steps involved in it
Part A Learning from Labelled Movie Reviews In this part of the assignment you will read movie reviews from the movieReviewstxt file calculate the sen... View full answer
Get step-by-step solutions from verified subject matter experts
