com.aliasi.tag
Class MarginalTaggerEvaluator<E>

java.lang.Object
  extended by com.aliasi.tag.MarginalTaggerEvaluator<E>
Type Parameters:
E - Type of tokens in the tagging.
All Implemented Interfaces:
Handler, ObjectHandler<Tagging<E>>

public class MarginalTaggerEvaluator<E>
extends Object
implements ObjectHandler<Tagging<E>>

A MarginalTaggerEvaluator evaluates marginal taggers either directly or by adding their outputs.

Test cases may be added directly using the method addCase(Tagging,TagLattice), where the tagging is a reference gold-standard tagging and the tag lattice the system response tagging.

Test cases may be added indirectly using the method handle(Tagging). With this use, the contained tagger in the evaluator is used to generate the response tag lattice, which is then added along with the reference tagging.

The tagger may be set in the constructor, or may be set using the method setTagger(MarginalTagger). The tagger must be non-null in order for a call to the handle method to succeed.

The token-by-token evaluation is available through the method perTokenEvaluation(), which returns a classifier evaluator. The items for the classifier evaluator are the tokens, and their classification is determined by the marginal probability assignments for those tags by the tag lattice. If the marginal tagger evaluator stores tokens, they will be available as part of the returned evaluator.

Since:
LingPipe3.9
Version:
3.9.1
Author:
Bob Carpenter

Constructor Summary
MarginalTaggerEvaluator(MarginalTagger<E> tagger, Set<String> tagSet, boolean storeTokens)
          Construct an evaluator for the specified marginal tagger, using the specifed tag set and flag indicating whether or not to store input tokens.
 
Method Summary
 void addCase(Tagging<E> referenceTagging, TagLattice<E> responseLattice)
          Add a case for evaluation consisting of the gold-standard reference tagging and a lattice representing the output of a marginal tagger.
 void handle(Tagging<E> referenceTagging)
          Add a test case consisting of the specified reference tagging along with the lattice output of the marginal tagger being evaluated on the tokens of the reference tagging.
 String lastCaseToString(int maxTagsPerToken)
           
 ConditionalClassifierEvaluator<E> perTokenEval()
          Returns the tagger evaluation on a per-token basis.
 ClassifierEvaluator<E,ConditionalClassification> perTokenEvaluation()
          Deprecated. Use perTokenEval() instead.
 void setTagger(MarginalTagger<E> tagger)
          Set the tagger for this tagger evaluated to the specified tagger.
 boolean storeTokens()
          Returns true if this evaluator is storing input tokens.
 MarginalTagger<E> tagger()
          Returns the tagger for this evaluator.
 Set<String> tagSet()
          Returns an unmodifiable view of the tags used by this evaluator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MarginalTaggerEvaluator

public MarginalTaggerEvaluator(MarginalTagger<E> tagger,
                               Set<String> tagSet,
                               boolean storeTokens)
Construct an evaluator for the specified marginal tagger, using the specifed tag set and flag indicating whether or not to store input tokens.

Parameters:
tagger - The tagger to use or null if all cases are added directly or the tagger's specified later.
tagSet - Complete set of tags found in reference and response taggings.
storeTokens - Flag set to true to store input tokens for return during classification.
Method Detail

tagger

public MarginalTagger<E> tagger()
Returns the tagger for this evaluator. The tagger may be null.

Returns:
Tagger for this evaluator.

setTagger

public void setTagger(MarginalTagger<E> tagger)
Set the tagger for this tagger evaluated to the specified tagger.

Parameters:
tagger - Tagger to be evaluated.

storeTokens

public boolean storeTokens()
Returns true if this evaluator is storing input tokens.

Returns:
Whether or not this evaluator stores tokens.

tagSet

public Set<String> tagSet()
Returns an unmodifiable view of the tags used by this evaluator.

Returns:
Tags for this evaluator.

addCase

public void addCase(Tagging<E> referenceTagging,
                    TagLattice<E> responseLattice)
Add a case for evaluation consisting of the gold-standard reference tagging and a lattice representing the output of a marginal tagger.

Parameters:
referenceTagging - Reference gold-standard tagging.
responseLattice - System response.
Throws:
IllegalArgumentException - If the reference tagging is not the same length as the response.

handle

public void handle(Tagging<E> referenceTagging)
Add a test case consisting of the specified reference tagging along with the lattice output of the marginal tagger being evaluated on the tokens of the reference tagging.

Specified by:
handle in interface ObjectHandler<Tagging<E>>
Parameters:
referenceTagging - Reference tagging to evaluate

lastCaseToString

public String lastCaseToString(int maxTagsPerToken)

perTokenEvaluation

@Deprecated
public ClassifierEvaluator<E,ConditionalClassification> perTokenEvaluation()
Deprecated. Use perTokenEval() instead.

Returns the tagger evaluation on a per-token basis.

Returns:
Evaluation of the tagger as a classifier.

perTokenEval

public ConditionalClassifierEvaluator<E> perTokenEval()
Returns the tagger evaluation on a per-token basis.

Returns:
Evaluation of the tagger as a classifier.