Class Classifier

java.lang.Object
  extended by Classifier

public class Classifier
extends java.lang.Object

Class that classifies messages based on their mood.

Version:
10/15/15
Author:
Dave Reed

Constructor Summary
Classifier(java.lang.String posFile, java.lang.String negFile)
          Constructs a Classifier for determining the mood of messages.
 
Method Summary
 java.lang.String classify(java.lang.String message)
          Classifies a message with respect to its mood.
 int negativity(java.lang.String message)
          Determines the negativity (number of unique negative terms) of a message
 int positivity(java.lang.String message)
          Determines the positivity (number of unique positive terms) of a message
 void processFile(java.lang.String filename)
          Process a file and displays the file name and the number of lines from that file of each type: positive, negative, and neutral.
 
Methods inherited from class
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Classifier

public Classifier(java.lang.String posFile,
                  java.lang.String negFile)
           throws java.io.FileNotFoundException
Constructs a Classifier for determining the mood of messages.

Parameters:
posFile - the name of the file containing positive terms
negFile - the name of the file containing negative terms
Throws:
java.io.FileNotFoundException
Method Detail

classify

public java.lang.String classify(java.lang.String message)
Classifies a message with respect to its mood.

Parameters:
message - the message to be rated
Returns:
either "positive", "negative", or "neutral", depending on whether the positivity of message is >, <, or == to the negativity

negativity

public int negativity(java.lang.String message)
Determines the negativity (number of unique negative terms) of a message

Parameters:
message - the message to be rated
Returns:
the number of unique negative terms that appear in message

positivity

public int positivity(java.lang.String message)
Determines the positivity (number of unique positive terms) of a message

Parameters:
message - the message to be rated
Returns:
the number of unique positive terms that appear in message

processFile

public void processFile(java.lang.String filename)
                 throws java.io.FileNotFoundException
Process a file and displays the file name and the number of lines from that file of each type: positive, negative, and neutral. For example:

File name: test.txt
# of positive lines = 42
# of negative lines = 28
# of neutral lines = 22

Parameters:
filename - the name of a file containing lines of text to be processed
Throws:
java.io.FileNotFoundException