/**
 * CS139 - Programming Fundamentals
 * Department of Computer Science
 * James Madison University
 * @version Spring 2016
 */

PA6: Object Oriented Sentiment Analysis

Introduction

In the previous assignment we developed an application that could automatically determine the sentiment conveyed by some text.

The goal of this assignment is to re-write that application in an object-oriented style. In particular, the utility class SentimentUtils will be replaced by SentimentAnalyzer. The SentimentAnalyzer class will encapsulate a collection of pre-scored reviews along with the code necessary to analyze novel text using the stored review data.

Instructions

UPDATED 4/7 You should download this updated copy of Review.java for use in this project. (It's the same as the previous version except that it provides toString and equals methods which may be helpful for testing.)

You will be able to reuse the ReviewLoader.java file provided for the previous assignment.

You'll need to create the following files:

SentimentAnalyzer.java

The SentimentAnalyzer class will store a collection of review objects in an ArrayList. It will use these stored reviews to determine the sentiment of some provided text. The completed class must conform to the following UML diagram:

SentimentAnalyzer UML

The value of DEFAULT_SCORE must be 2.0. (Note that DEFAULT_SCORE is underlined in the UML diagram above. This indicates that it should be a static field.) This value should be used as the default return value for both evaluateWord and evaluateText.

Each of the three constructors provide a different mechanism for providing an initial (possibly empty) collection of reviews:

The addReview method must add the provided review to the collection of reviews stored by the SentimentAnalyzer object.

The getReviews method must return a shallow copy of the ArrayList of reviews. This means that the ArrayList should be copied, but the Review objects stored in the ArrayList will not be copied. The result will be two different ArrayLists that share references to the same set of Review objects.

The evaluateWord and evaluateText methods must provide exactly the same functionality as they did in the previous assignment.

The toString method must return a string with the following format: "SentimentAnalyzer containing 145 reviews" (where 145 is replaced with the actual number of reviews stored).

The containsWord method should be implemented as a private helper method. (This method only exists to support the operation of evaluateWord, so it isn't necessary to make it accessible outside of this class.)

SentimentAnalyzerTest.java

You must provide JUnit tests for each of the methods in SentimentAnalyzer.java. You should be able to re-purpose many of the tests from the previous assignment with some slight modifications.

Sentiment.java

You will need to re-write Sentiment.java to use SentimentAnalyzer.java instead of SentimentUtils.java. The functionality should remain exactly the same.

Submitting

Part A

Zip SentimentAnalyzer.java and SentimentAnalyzerTest.java along with any additional text files that you require for testing. Submit the .zip file through Web-CAT. You should not include Sentiment.java or any of the Java files that we have provided.

SentimentAnalyzer.java must conform to the CS 139 Style Guide. You are not required to provide Javadoc comments for the methods in SentimentAnalyzerTest.java, but that file should conform to the style guide in all other respects.

Part B

Zip SentimentAnalyzer.java and Sentiment.java and submit through Web-CAT. Your zip file should only contain these two java files. You should not include the Java files that we provided or any testing code. Both SentimentAnalyzer.java and Sentiment.java must conform to the CS 139 Style Guide.

Grading

Your submission will be graded using the following criteria:

Points
Part A Web-CAT Correctness/Testing40
Part A Checkstyle Tests10
Part B Web-CAT Correctness/Testing10
Part B Checkstyle Tests10
Style and Code Organization30

If Web-CAT deducts any points for correctness/testing, for parts A or B you will receive at most 50% of the points for that part.

Once again there will be a penalty for excessive submissions. The first 10 submissions for each part are free. Each submission beyond 10 will result in a .5 reduction in the final score.

Honor Code

This assignment must be completed individually. Your submission must conform to the JMU Honor Code. Authorized help is limited to general discussion on Piazza, the lab assistants assigned to CS 139, and the instructor. Copying work from another student or the Internet is an honor code violation and will be grounds for a reduced or failing grade in the course.