edu.cmu.minorthird.text.learn
Class ConfidenceReportingSequenceAnnotator

java.lang.Object
  extended by edu.cmu.minorthird.text.AbstractAnnotator
      extended by edu.cmu.minorthird.text.learn.ConfidenceReportingSequenceAnnotator
All Implemented Interfaces:
Annotator, ExtractorAnnotator, Visible, java.io.Serializable

public class ConfidenceReportingSequenceAnnotator
extends AbstractAnnotator
implements ExtractorAnnotator, java.io.Serializable, Visible

Wraps an Annotator learned by SequenceAnnotatorLearner with code to compute confidences for each extracted span.

Sample use, in code:

 // below, 'ann' might be trained, or pulled off disk - this
 // is the sort of object that the SequenceAnnotatorLearner instances
 // (like CRFAnnotatorLearner and VPHMMLearner) produce
 SequenceAnnotatorLearner.SequenceAnnotator ann = ...;
 ConfidenceReportingSequenceAnnotator crAnn = new ConfidenceReportingSequenceAnnotator(ann);
 crAnn.annotate(textLabels);
 // print the confidence of each extracted span
 for (Span.Looper i=textLabels.instanceIterator(crAnn.getSpanType()); i.hasNext(); ) {
    Span s = i.nextSpan();
    Details d = labels.getDetails(s,crAnn.getSpanType());
    System.out.println("confidence="+d.getConfidence()+" for span "+s);
 }
 

Sample use, from command line:

 # train SequenceAnnotatorLearner.SequenceAnnotator object and save in 'old.ann'
 % java edu.cmu.minorthird.ui.TrainExtractor -labels sample1.train -saveAs old.ann -spanType trueName 
 # convert to a ConfidenceReportingSequenceAnnotator 'new.ann'
 % java edu.cmu.minorthird.text.learn.ConfidenceReportingSequenceAnnotator old.ann new.ann
 # apply the annotator and view the results - the last column is confidence
 % java edu.cmu.minorthird.ui.ApplyAnnotator -labels sample1.test -loadFrom new.ann -saveAs new.labels
 % grep _prediction new.labels
 addToType testStrings[0] 0 12 _prediction 141.0
 addToType testStrings[1] 19 15 _prediction 312.0
 addToType testStrings[2] 8 12 _prediction 188.0
 addToType testStrings[3] 47 11 _prediction 374.0
 
Status: EXPERIMENTAL.

Author:
William Cohen
See Also:
Serialized Form

Constructor Summary
ConfidenceReportingSequenceAnnotator(SequenceAnnotatorLearner.SequenceAnnotator sequenceAnnotator)
           
 
Method Summary
 void doAnnotate(MonotonicTextLabels labels)
          The implementation for this method annotates labels in-line.
 java.lang.String explainAnnotation(TextLabels labels, Span documentSpan)
          The implementation for this method should explain how annotation would be added to some part of the text base.
 java.lang.String getSpanType()
          The spanType used to encode the spans extracted by the ExtractorAnnotator.
static void main(java.lang.String[] args)
          Convert an appropriately trained ExtractorAnnotator to a ConfidenceReportingSequenceAnnotator.
 Viewer toGUI()
          Create a view of this object
 
Methods inherited from class edu.cmu.minorthird.text.AbstractAnnotator
annotate, annotatedCopy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.cmu.minorthird.text.Annotator
annotate, annotatedCopy
 

Constructor Detail

ConfidenceReportingSequenceAnnotator

public ConfidenceReportingSequenceAnnotator(SequenceAnnotatorLearner.SequenceAnnotator sequenceAnnotator)
Method Detail

getSpanType

public java.lang.String getSpanType()
Description copied from interface: ExtractorAnnotator
The spanType used to encode the spans extracted by the ExtractorAnnotator.

Specified by:
getSpanType in interface ExtractorAnnotator

doAnnotate

public void doAnnotate(MonotonicTextLabels labels)
Description copied from class: AbstractAnnotator
The implementation for this method annotates labels in-line.

Specified by:
doAnnotate in class AbstractAnnotator

explainAnnotation

public java.lang.String explainAnnotation(TextLabels labels,
                                          Span documentSpan)
Description copied from class: AbstractAnnotator
The implementation for this method should explain how annotation would be added to some part of the text base.

Specified by:
explainAnnotation in interface Annotator
Specified by:
explainAnnotation in class AbstractAnnotator

toGUI

public Viewer toGUI()
Description copied from interface: Visible
Create a view of this object

Specified by:
toGUI in interface Visible

main

public static void main(java.lang.String[] args)
Convert an appropriately trained ExtractorAnnotator to a ConfidenceReportingSequenceAnnotator. This only works for an ExtractorAnnotator that was trained with a SequenceAnnotatorLearner.