com.aliasi.sentences
Class SentenceEvaluation

java.lang.Object
  extended by com.aliasi.sentences.SentenceEvaluation

public class SentenceEvaluation
extends Object

A SentenceEvaluation stores and reports the results of evaluating a set of reference sentence chunkings and response sentence chunkings. Evaluation results are available through the method chunkingEvaluation(), which returns the evaluation of the sentences as chunkings, and the method endBoundaryEvaluation(), which returns the evaluation of the sentences chunkings solely on the basis of the end boundary index of the sentence.

Since:
LingPipe2.1
Version:
3.8
Author:
Bob Carpenter

Constructor Summary
SentenceEvaluation()
          Construct a sentence evaluation.
 
Method Summary
 void addCase(Chunking referenceChunking, Chunking responseChunking)
          Add the case corresponding to the specified reference and response chunkings.
 ChunkingEvaluation chunkingEvaluation()
          Return the chunking evaluation for this sentence evaluation.
 PrecisionRecallEvaluation endBoundaryEvaluation()
          Returns a precision/recall evaluation based on the end boundaries in the reference and response cases.
 Set<ChunkAndCharSeq> falseNegativeEndBoundaries()
          Return the set of chunks and character sequences whose end boundaries are in reference but not the response chunking.
 Set<ChunkAndCharSeq> falsePositiveEndBoundaries()
          Return the set of chunks and character sequences whose end boundaries are in response but not the reference chunking.
 String lastCaseToString(int lineLength)
          Returns a formatted listing for the last case that was evaluated, showing the underlying character sequence for the chunkings, annotated with the sentence boundaries from the reference and response chunking, with linebreaks inserted every lineLength characters.
static String sentenceCaseToString(Chunking referenceChunking, Chunking responseChunking, int lineLength)
          Given a pair of reference and response chunkings, returns a string showing the underlying character sequence chunking pair, annotated with the sentence boundaries from each chunking, with linebreaks inserted every lineLength characters.
 Set<ChunkAndCharSeq> truePositiveEndBoundaries()
          Return the set of chunks and character sequences whose end boundaries are in both the reference and response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SentenceEvaluation

public SentenceEvaluation()
Construct a sentence evaluation.

Method Detail

addCase

public void addCase(Chunking referenceChunking,
                    Chunking responseChunking)
Add the case corresponding to the specified reference and response chunkings. The chunkings should only contain sentence chunks with chunk type SentenceChunker.SENTENCE_CHUNK_TYPE.

Parameters:
referenceChunking - The reference chunking.
responseChunking - The response chunking.
Throws:
IllegalArgumentException - If the reference chunking and response chunking are not over the same characters or if either contains chunks of type other than SentenceChunker.SENTENCE_CHUNK_TYPE.

chunkingEvaluation

public ChunkingEvaluation chunkingEvaluation()
Return the chunking evaluation for this sentence evaluation. This is the evaluation based purely on the chunks and their matching, not on any sentence-specific evaluation

Returns:
The chunking evaluation for this sentence evaluation.

endBoundaryEvaluation

public PrecisionRecallEvaluation endBoundaryEvaluation()
Returns a precision/recall evaluation based on the end boundaries in the reference and response cases. End boundaries in the response and the reference are true positives, those in the response but not the reference are false positives, and those in the reference but not the response are false negatives.


truePositiveEndBoundaries

public Set<ChunkAndCharSeq> truePositiveEndBoundaries()
Return the set of chunks and character sequences whose end boundaries are in both the reference and response.

Returns:
The set of true-positive end-boundary chunks.

falsePositiveEndBoundaries

public Set<ChunkAndCharSeq> falsePositiveEndBoundaries()
Return the set of chunks and character sequences whose end boundaries are in response but not the reference chunking.

Returns:
The set of false-positive end-boundary chunks.

falseNegativeEndBoundaries

public Set<ChunkAndCharSeq> falseNegativeEndBoundaries()
Return the set of chunks and character sequences whose end boundaries are in reference but not the response chunking.

Returns:
The set of false-negative end-boundary chunks.

lastCaseToString

public String lastCaseToString(int lineLength)
Returns a formatted listing for the last case that was evaluated, showing the underlying character sequence for the chunkings, annotated with the sentence boundaries from the reference and response chunking, with linebreaks inserted every lineLength characters. The lineLength must be a positive integer.

Parameters:
lineLength - The line length of the formatted string.
Throws:
IllegalArgumentException - If the lineLength is < 1.
IllegalStateException - If no cases have been evaluated.

sentenceCaseToString

public static String sentenceCaseToString(Chunking referenceChunking,
                                          Chunking responseChunking,
                                          int lineLength)
Given a pair of reference and response chunkings, returns a string showing the underlying character sequence chunking pair, annotated with the sentence boundaries from each chunking, with linebreaks inserted every lineLength characters. The chunkings should only contain sentence chunks with chunk type SentenceChunker.SENTENCE_CHUNK_TYPE. The lineLength must be a positive integer.

Parameters:
referenceChunking - The reference chunking.
responseChunking - The response chunking.
lineLength - The line length of the formatted string.
Throws:
IllegalArgumentException - If the reference chunking and response chunking are not over the same characters or if either contains chunks of type other than SentenceChunker.SENTENCE_CHUNK_TYPE, or if the lineLength is < 1.