edu.mit.jmwe.harness.result
Class SentenceResult<T extends IToken,S extends IMarkedSentence<T>>

java.lang.Object
  extended by edu.mit.jmwe.harness.result.SentenceResult<T,S>
Type Parameters:
T - the token type
S - the sentence type
All Implemented Interfaces:
IBaseResult, ISentenceResult<T,S>

public class SentenceResult<T extends IToken,S extends IMarkedSentence<T>>
extends Object
implements ISentenceResult<T,S>

Default implementation of the ISentenceResult interface.

Since:
jMWE 1.0.0
Version:
$Id: SentenceResult.java 639 2011-09-26 21:03:51Z markaf $
Author:
Nidhi Kulkarni

Constructor Summary
SentenceResult(List<IMWE<T>> answer, List<IMWE<T>> retrieved, S sentence)
          Constructs a sentence result from a list of answer multi-word expressions and a list of multi-word expressions found by the detector.
SentenceResult(List<IMWE<T>> answer, List<IMWE<T>> retrieved, S sentence, boolean reallocate)
          Constructs a sentence result from a list of answer multi-word expressions and a list of multi-word expressions found by the detector.
 
Method Summary
 List<IMWE<T>> getAnswers()
          Returns the answer multi-word expression in the sentence.
 List<IMWE<T>> getFalseNegatives()
          Returns a list of the false negatives.
 List<IMWE<T>> getFalsePositives()
          Returns a list of the false positives.
 List<IMWE<T>> getFound()
          Returns the multi-word expression found by the detector in the sentence.
 double getFScore()
          Returns the F1 score, a double between zero and 1, inclusive.
 double getPrecision()
          Returns the precision, a double between zero and 1, inclusive.
 double getRecall()
          Returns the recall, a double between zero and 1, inclusive.
 S getSentence()
          Returns the sentence corresponding to this result.
 int getTotalAnswers()
          Returns the total number of answers.
 int getTotalCorrect()
          Returns the total number of items correctly identified.
 int getTotalFound()
          Returns the total number items found.
 List<IMWE<T>> getTruePositives()
          Returns a list of the true positives.
static
<T extends IToken,S extends IMarkedSentence<T>>
void
printTable(StringBuilder sb, ISentenceResult<T,S> result, Formatter f)
          Prints a table of the correct, false negative and false positive expressions found by the detector in columns.
 String toString()
           
static
<T extends IToken,S extends IMarkedSentence<T>>
String
toString(ISentenceResult<T,S> result, S sentence, boolean table)
          Creates a graphical representation of the multi-word expressions found by the detector for a given sentence.
static
<T extends IToken,U extends IMarkedSentence<T>>
String
toString(ISentenceResult<T,U> result, U sentence)
          Creates a graphical representation of the multi-word expressions found by the detector for a given sentence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SentenceResult

public SentenceResult(List<IMWE<T>> answer,
                      List<IMWE<T>> retrieved,
                      S sentence)
Constructs a sentence result from a list of answer multi-word expressions and a list of multi-word expressions found by the detector. Finds and stores the false negatives, false positives, and true positives by comparing the given lists. Reallocates new internal lists for the answer and retrieved lists, and so subsequent changes to the source lists will not affect this object.

Parameters:
answer - a non-null list of answer multi-word expressions.
retrieved - a non-null list of multi-word expressions found by the detector.
Throws:
NullPointerException - if either list is null
Since:
jMWE 1.0.0

SentenceResult

public SentenceResult(List<IMWE<T>> answer,
                      List<IMWE<T>> retrieved,
                      S sentence,
                      boolean reallocate)
Constructs a sentence result from a list of answer multi-word expressions and a list of multi-word expressions found by the detector. Finds and stores the false negatives, false positives, and true positives by comparing the given lists. If no reallocation is requested, this constructor reuses the given lists, and so subsequent changes to the source list will affect this object.

Parameters:
answer - a non-null list of answer multi-word expressions.
retrieved - a non-null list of multi-word expressions found by the detector.
reallocate - If true, will allocate new internal lists for the answer and retrieved lists.
Throws:
NullPointerException - if either list is null
Since:
jMWE 1.0.0
Method Detail

getSentence

public S getSentence()
Description copied from interface: ISentenceResult
Returns the sentence corresponding to this result.

Specified by:
getSentence in interface ISentenceResult<T extends IToken,S extends IMarkedSentence<T>>
Returns:
the sentence corresponding to this result.

getFalseNegatives

public List<IMWE<T>> getFalseNegatives()
Description copied from interface: ISentenceResult
Returns a list of the false negatives. Should return the empty list if there are no false negatives. Should never return null.

Specified by:
getFalseNegatives in interface ISentenceResult<T extends IToken,S extends IMarkedSentence<T>>
Returns:
a list of false negatives. Should return the empty list if there are no false negatives. Should never return null.

getFalsePositives

public List<IMWE<T>> getFalsePositives()
Description copied from interface: ISentenceResult
Returns a list of the false positives. Should return the empty list if there are no false positives. Should never return null.

Specified by:
getFalsePositives in interface ISentenceResult<T extends IToken,S extends IMarkedSentence<T>>
Returns:
a list of false positives. Should return the empty list if there are no false positives. Should never return null.

getTruePositives

public List<IMWE<T>> getTruePositives()
Description copied from interface: ISentenceResult
Returns a list of the true positives. Should return the empty list if there are no true positives. Should never return null.

Specified by:
getTruePositives in interface ISentenceResult<T extends IToken,S extends IMarkedSentence<T>>
Returns:
a list of true positives. Should return the empty list if there are no true positives. Should never return null.

getAnswers

public List<IMWE<T>> getAnswers()
Description copied from interface: ISentenceResult
Returns the answer multi-word expression in the sentence. Should return the empty list if there are no answer multi-word expressions. Should never return null.

Specified by:
getAnswers in interface ISentenceResult<T extends IToken,S extends IMarkedSentence<T>>
Returns:
a list of the answer multi-word expression in the sentence. Should return the empty list if there are no answer multi-word expression. Should never return null.

getFound

public List<IMWE<T>> getFound()
Description copied from interface: ISentenceResult
Returns the multi-word expression found by the detector in the sentence. Should return the empty list if the detector found no multi-word expressions. Should never return null.

Specified by:
getFound in interface ISentenceResult<T extends IToken,S extends IMarkedSentence<T>>
Returns:
a list of the multi-word expression found by the detector in the sentence. Should return the empty list if the detector found no multi-word expressions. Should never return null.

getPrecision

public double getPrecision()
Description copied from interface: IBaseResult
Returns the precision, a double between zero and 1, inclusive.

Specified by:
getPrecision in interface IBaseResult
Returns:
the precision, a double between zero and 1, inclusive.

getRecall

public double getRecall()
Description copied from interface: IBaseResult
Returns the recall, a double between zero and 1, inclusive.

Specified by:
getRecall in interface IBaseResult
Returns:
the recall, a double between zero and 1, inclusive.

getFScore

public double getFScore()
Description copied from interface: IBaseResult
Returns the F1 score, a double between zero and 1, inclusive. The F1 score, or f-measure, is the harmonic mean of the precision and the recall.

Specified by:
getFScore in interface IBaseResult
Returns:
the F1 score, a double between zero and 1, inclusive.

getTotalAnswers

public int getTotalAnswers()
Description copied from interface: IBaseResult
Returns the total number of answers.

Specified by:
getTotalAnswers in interface IBaseResult

getTotalCorrect

public int getTotalCorrect()
Description copied from interface: IBaseResult
Returns the total number of items correctly identified.

Specified by:
getTotalCorrect in interface IBaseResult

getTotalFound

public int getTotalFound()
Description copied from interface: IBaseResult
Returns the total number items found.

Specified by:
getTotalFound in interface IBaseResult

toString

public String toString()
Overrides:
toString in class Object

toString

public static <T extends IToken,U extends IMarkedSentence<T>> String toString(ISentenceResult<T,U> result,
                                                                              U sentence)
Creates a graphical representation of the multi-word expressions found by the detector for a given sentence. Prints the sentence and each multi-word expression the detector finds on its own line under the corresponding tokens in the sentence. Underneath the sentence, prints out the correct, false negative, and false positive multi-word expressions in columns.

Type Parameters:
T - the type of tokens in the sentence and its associated multi-word expressions
U - the type of sentence. Is parameterized by tokens of type T.
Parameters:
result - the sentence result obtained after running the detector over the sentence
sentence - the sentence the detector is run over
Returns:
a graphical representation of the multi-word expressions found by the detector for a given sentence.
Since:
jMWE 1.0.0

toString

public static <T extends IToken,S extends IMarkedSentence<T>> String toString(ISentenceResult<T,S> result,
                                                                              S sentence,
                                                                              boolean table)
Creates a graphical representation of the multi-word expressions found by the detector for a given sentence. Prints the sentence and each multi-word expression the detector finds on its own line under the corresponding tokens in the sentence. May or may not print out the correct, false negative, and false positive multi-word expressions in columns under the sentence depending on the value of the table flag.

Type Parameters:
T - the type of tokens in the sentence and its associated multi-word expressions
S - the type of sentence. Is parameterized by tokens of type T.
Parameters:
result - the sentence result obtained after running the detector over the sentence
sentence - the sentence the detector is run over
table - if true, prints the correct, false negative, and false positive expressions in columns under the sentence.
Returns:
a graphical representation of the multi-word expressions found by the detector for a given sentence.
Since:
jMWE 1.0.0

printTable

public static <T extends IToken,S extends IMarkedSentence<T>> void printTable(StringBuilder sb,
                                                                              ISentenceResult<T,S> result,
                                                                              Formatter f)
Prints a table of the correct, false negative and false positive expressions found by the detector in columns.

Type Parameters:
T - the type of tokens in the sentence and its associated multi-word expressions
S - the type of sentence. Is parameterized by tokens of type T.
Parameters:
sb - the string builder to which the table should be written
result - the result to be written
f - the formatter to be used
Since:
jMWE 1.0.0


Copyright © 2011 Massachusetts Institute of Technology. All Rights Reserved.