de.fu_berlin.ties.combi
Class BeginEndStrategy

java.lang.Object
  extended by de.fu_berlin.ties.combi.CombinationStrategy
      extended by de.fu_berlin.ties.combi.BeginEndStrategy

public class BeginEndStrategy
extends CombinationStrategy

A combination strategy that uses two classifiers, one to recognize the begin of extractions and one to recognize the end.

Version:
$Revision: 1.25 $, $Date: 2006/10/21 16:04:01 $, $Author: siefkes $
Author:
Christian Siefkes

Field Summary
 
Fields inherited from class de.fu_berlin.ties.combi.CombinationStrategy
CONFIG_COMBINATION
 
Constructor Summary
BeginEndStrategy(Set<String> theClasses, TiesConfiguration conf)
          Creates a new instance.
 
Method Summary
 Set[] activeClasses()
          Builds a set array of class names (Strings) to pass to each classifier to consider for the next decision.
 Set[] allClasses()
          Returns an array of immutable sets of all classes (Strings) that can possible occur during classification for each classifier.
 ContextMap contextForReextractor()
          Thie method can be overwritten to pass objects to a FinalReextractor.
 FinalReextractor initReextractor(Reestimator reestimatorChain)
          This method can be overwritten to initialize a FinalReextractor. This implementation returns a BeginEndReextractor, if configured.
protected  boolean resetHook()
          Hook called by the CombinationStrategy.reset() method to query whether the last extraction should be discarded, analogously to CombinationState.isDiscardPreceding().
 String[] translateCurrentState(CombinationState currentState)
          Translates an expected class to a class name to feed to the classifiers in training mode.
 CombinationState translateResult(PredictionDistribution[] predictions, TokenDetails details)
          Translates the classes predicted by the classifiers in a decision for the caller.
 void updateState(CombinationState newState, PredictionDistribution[] predictions, TokenDetails details)
          Updates the current state (the class of the last item).
 
Methods inherited from class de.fu_berlin.ties.combi.CombinationStrategy
createStrategy, createStrategy, createStrategy, getValidClasses, reset, state, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BeginEndStrategy

public BeginEndStrategy(Set<String> theClasses,
                        TiesConfiguration conf)
Creates a new instance.

Parameters:
theClasses - a set of valid class names (String)
conf - used to configure this instance
Method Detail

activeClasses

public Set[] activeClasses()
Builds a set array of class names (Strings) to pass to each classifier to consider for the next decision. Must be a subset of CombinationStrategy.allClasses().

Specified by:
activeClasses in class CombinationStrategy
Returns:
a set of class names for each classifier

allClasses

public Set[] allClasses()
Returns an array of immutable sets of all classes (Strings) that can possible occur during classification for each classifier. The "background" class (outside any extractions) should be the first member of each set.

Specified by:
allClasses in class CombinationStrategy
Returns:
an array of immutable sets of class names

contextForReextractor

public ContextMap contextForReextractor()
Thie method can be overwritten to pass objects to a FinalReextractor. The default implementation simply returns null. If you overwrite this method, you should typically overwrite the CombinationStrategy.initReextractor(Reestimator) method as well.

Overrides:
contextForReextractor in class CombinationStrategy
Returns:
a map of context objects for the re-extractor, or null

initReextractor

public FinalReextractor initReextractor(Reestimator reestimatorChain)
                                 throws ProcessingException
This method can be overwritten to initialize a FinalReextractor. The default implementation simply returns null. If you overwrite this method, you should typically overwrite the CombinationStrategy.contextForReextractor() method as well. This implementation returns a BeginEndReextractor, if configured. In this case the re-estimator chain must contain a LengthFilter, otherwise this method will throw an IllegalArgumentException.

Overrides:
initReextractor in class CombinationStrategy
Parameters:
reestimatorChain - the chain of re-estimators used -- some implementations might need a specific re-estimator to work
Returns:
the re-extractor to use; or null
Throws:
ProcessingException - if an error occurs during initialization

resetHook

protected boolean resetHook()
Hook called by the CombinationStrategy.reset() method to query whether the last extraction should be discarded, analogously to CombinationState.isDiscardPreceding().

Overrides:
resetHook in class CombinationStrategy
Returns:
the value of the attribute

translateCurrentState

public String[] translateCurrentState(CombinationState currentState)
                               throws IllegalArgumentException
Translates an expected class to a class name to feed to the classifiers in training mode. This method reverses the direction of CombinationStrategy.translateResult(PredictionDistribution[], TokenDetails).

The return value can be feed to the classifiers for training it.

Specified by:
translateCurrentState in class CombinationStrategy
Parameters:
currentState - the current state
Returns:
the array of classes to feed to each classifier for training
Throws:
IllegalArgumentException - if the specified argument is invalid (non-empty string that is not in the set of valid classes, or empty string when null was given in the preceding call)

translateResult

public CombinationState translateResult(PredictionDistribution[] predictions,
                                        TokenDetails details)
                                 throws IllegalArgumentException
Translates the classes predicted by the classifiers in a decision for the caller. The end information might be unreliably/absent for same classes.

Specified by:
translateResult in class CombinationStrategy
Parameters:
predictions - array containing the prediction distributions of all classifier
details - details representing the classified token
Returns:
the translated result
Throws:
IllegalArgumentException - if the specified argument was invalid (not in the set of currently active classes

updateState

public void updateState(CombinationState newState,
                        PredictionDistribution[] predictions,
                        TokenDetails details)
                 throws IllegalArgumentException
Updates the current state (the class of the last item). You must always call this method after classifying (CombinationStrategy.translateResult(PredictionDistribution[], TokenDetails) and/or training (CombinationStrategy.translateCurrentState(CombinationState)) an item.

Overrides:
updateState in class CombinationStrategy
Parameters:
newState - the state of the last item
predictions - array containing the prediction distributions of all classifier for the last item
details - details representing the last item
Throws:
IllegalArgumentException - if the type of the argument is invalid (not in the set of valid classes or null


Copyright © 2003-2007 Christian Siefkes. All Rights Reserved.