Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

-Write in java -Link to movieReviews.txt: https://uploadfiles.io/3j31e The purpose of this assignment is to be able to input the text of a movie review and

-Write in java

-Link to movieReviews.txt: https://uploadfiles.io/3j31e

The purpose of this assignment is to be able to input the text of a movie review and determine if it is a positive or negative review, that is, does the reviewer like or dislike the movie. Sentiment Analysis is a Big Data problem which seeks to determine the general attitude of a writer given some text they have written. For instance, we would like to have a program that could look at the text The film was a breath of fresh air and realize that it was a positive statement while It made me want to poke out my eye balls is negative.1 One simple (but, regretfully, not very effective) algorithm that we can use for this is to assign a numeric value to words based on how positive or negative that word is and then score the statement based on the average value of the words. To create numerical values for words, the program will read a file of over 8,000 movie reviews that have a rating number from 0 to 4 along with the text of a review. For each word in the reviews, the program will keep the sum of the ratings and the number of times the word occurred. The average goodness of the word can be calculated by dividing the sum of the ratings where that word appears by the number of times the word appeared.

image text in transcribed

image text in transcribed

image text in transcribed

COMP163 Movie Review Evaluation he purpose of this assignment is to be able to input the text of a movie review and determine if it is a positive or negative review, that is, does the reviewer like or dislike the movie. Sentiment Analysis isa Big Data problem which seeks to determine the general attitude of a writer given some text they have written. For instance, we would like to have a program that could look at the text "The film was a breath of fresh air" and realize that it was a positive statement while "It made me want to poke out my eye balls" is negative.1 One simple (but, regretfully, not very effective) algorithm that we can use for this is to assign a numeric value to words based on how positive or negative that word is and then score the statement based on the average value of the words. To create numerical values for words, the program will read a file of over 8,000 movie reviews that have a rating number from 0 to 4 along with the text of a review. For each word in the reviews, the program will keep the sum of the ratings and the number of times the word occurred. The average goodness" of the word can be calculated by dividing the sum of the ratings where that word appears by the number of times the word a Information about a word should be kept in the class WordValue. The WordValue class needs to keep two class instance variables to hold: The number of times the word has been used. . The sum of the review ratings where the word was used A constructor method should be written to set the use count to one and initialize the sum to a parameter. Two additional methods are needed: public void addRating (int rating) which increments the use count by one and adds the rating to the sum. public double avgRating () which returns the average rating (sum divided by the use count). In a separate class (and therefore a separate file) the main program has two major parts. The first reads the file moviereviews.txt and builds a dictionary of WordValue objects. The second part reads a review from the keyboard and determines if it is a positive or negative review The dictionary of words is best kept in a hash table. The hash table can be created in Java by: java .util. Hashtable dict = new java.util.Hashtable (18000) A hash table works like a dictionary where each object has a key or name. When you put an object in the dictionary, you give it both the WordValue object to store in the dictionary and a key String to find it. You can then retrieve the object by giving it the key String. The hash table class has two methods of interest to this program, put and get. The put method has two parameters, the key String and the WordValue object to be saved in the dictionary get method of a hash table retrieves the previously st previously stored with this key String, the method returns null. In this program the key is a word from the review. The ored object with this key String. If no object was COMP163 Movie Review Evaluation he purpose of this assignment is to be able to input the text of a movie review and determine if it is a positive or negative review, that is, does the reviewer like or dislike the movie. Sentiment Analysis isa Big Data problem which seeks to determine the general attitude of a writer given some text they have written. For instance, we would like to have a program that could look at the text "The film was a breath of fresh air" and realize that it was a positive statement while "It made me want to poke out my eye balls" is negative.1 One simple (but, regretfully, not very effective) algorithm that we can use for this is to assign a numeric value to words based on how positive or negative that word is and then score the statement based on the average value of the words. To create numerical values for words, the program will read a file of over 8,000 movie reviews that have a rating number from 0 to 4 along with the text of a review. For each word in the reviews, the program will keep the sum of the ratings and the number of times the word occurred. The average goodness" of the word can be calculated by dividing the sum of the ratings where that word appears by the number of times the word a Information about a word should be kept in the class WordValue. The WordValue class needs to keep two class instance variables to hold: The number of times the word has been used. . The sum of the review ratings where the word was used A constructor method should be written to set the use count to one and initialize the sum to a parameter. Two additional methods are needed: public void addRating (int rating) which increments the use count by one and adds the rating to the sum. public double avgRating () which returns the average rating (sum divided by the use count). In a separate class (and therefore a separate file) the main program has two major parts. The first reads the file moviereviews.txt and builds a dictionary of WordValue objects. The second part reads a review from the keyboard and determines if it is a positive or negative review The dictionary of words is best kept in a hash table. The hash table can be created in Java by: java .util. Hashtable dict = new java.util.Hashtable (18000) A hash table works like a dictionary where each object has a key or name. When you put an object in the dictionary, you give it both the WordValue object to store in the dictionary and a key String to find it. You can then retrieve the object by giving it the key String. The hash table class has two methods of interest to this program, put and get. The put method has two parameters, the key String and the WordValue object to be saved in the dictionary get method of a hash table retrieves the previously st previously stored with this key String, the method returns null. In this program the key is a word from the review. The ored object with this key String. If no object was

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

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions