de.fu_berlin.ties.combi
Class CombinationStrategy

java.lang.Object
  extended by de.fu_berlin.ties.combi.CombinationStrategy
Direct Known Subclasses:
BeginAfterStrategy, BeginEndStrategy, InsideOutsideStrategy, OpenCloseStrategy, TrivialStrategy

public abstract class CombinationStrategy
extends Object

A combination strategy combines sequential classifications. Instances of this class are not thread-safe. Subclasses must also provide a constructor that accepts a Set of valid class names as single argument; otherwise they cannot be loaded via reflection.

Version:
$Revision: 1.14 $, $Date: 2004/09/16 11:12:53 $, $Author: siefkes $
Author:
Christian Siefkes

Field Summary
static String CONFIG_COMBINATION
          Configuration key specifying the combination strategy to use.
 
Constructor Summary
CombinationStrategy(Set<String> theClasses)
          Creates a new instance.
 
Method Summary
abstract  Set<String>[] activeClasses()
          Builds a set array of class names (Strings) to pass to each classifier to consider for the next decision.
abstract  Set<String>[] allClasses()
          Returns an array of immutable sets of all classes (Strings) that can possible occur during classification for each classifier.
static CombinationStrategy createStrategy(Set<String> classNames)
          Factory method that delegates to createStrategy(Set, TiesConfiguration) using the standard configuration.
static CombinationStrategy createStrategy(Set<String> classNames, TiesConfiguration config)
          Factory method that creates a combination strategy based on the CONFIG_COMBINATION key in the provided configuration.
protected  Set getValidClasses()
          Returns the set of valid class names.
 boolean reset()
          Resets the state() of this instance to the initial value CombinationState.OUTSIDE.
protected  boolean resetHook()
          Hook called by the reset() method to query whether the last extraction should be discarded, analogously to CombinationState.isDiscardPreceding().
 CombinationState state()
          The current state (state of the last item).
 String toString()
          Returns a string representation of this object.
abstract  String[] translateCurrentState(CombinationState currentState)
          Translates an expected class to a class name to feed to the classifiers in training mode.
abstract  CombinationState translateResult(PredictionDistribution[] predictions)
          Translates the classes predicted by the classifiers in a decision for the caller.
 void updateState(CombinationState newState)
          Updates the current state (the class of the last item).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONFIG_COMBINATION

public static final String CONFIG_COMBINATION
Configuration key specifying the combination strategy to use.

See Also:
Constant Field Values
Constructor Detail

CombinationStrategy

public CombinationStrategy(Set<String> theClasses)
Creates a new instance.

Parameters:
theClasses - a set of valid class names (String)
Method Detail

createStrategy

public static CombinationStrategy createStrategy(Set<String> classNames)
                                          throws IllegalArgumentException,
                                                 ProcessingException
Factory method that delegates to createStrategy(Set, TiesConfiguration) using the standard configuration.

Parameters:
classNames - a set of valid class names (String)
Returns:
the created strategy
Throws:
IllegalArgumentException - if the value of the CONFIG_COMBINATION key is missing or invalid
ProcessingException - if an error occurred while creating the strategy

createStrategy

public static CombinationStrategy createStrategy(Set<String> classNames,
                                                 TiesConfiguration config)
                                          throws IllegalArgumentException,
                                                 ProcessingException
Factory method that creates a combination strategy based on the CONFIG_COMBINATION key in the provided configuration.

Currently supported values: "BE" for BeginEndStrategy, "BIA" for BeginAfterStrategy, "BIE" for OpenCloseStrategy, "IOB1" for InsideOutsideStrategy with InsideOutsideStrategy.isBStartingAll() set to false, "IOB2" for InsideOutsideStrategy with InsideOutsideStrategy.isBStartingAll() set to true; "Triv" for TrivialStrategy.

Otherwise the value must be the qualified name of a CombinationStrategy subclass accepting a Set (of valid class names) as single argument.

Parameters:
classNames - a set of valid class names (String)
config - the configuration to use
Returns:
the created strategy
Throws:
IllegalArgumentException - if the value of the CONFIG_COMBINATION key is missing or invalid
ProcessingException - if an error occurred while creating the strategy

activeClasses

public abstract Set<String>[] 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 allClasses().

Returns:
a set of class names for each classifier

allClasses

public abstract Set<String>[] 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.

Returns:
an array of immutable sets of class names

translateCurrentState

public abstract 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 translateResult(PredictionDistribution[]).

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

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 abstract CombinationState translateResult(PredictionDistribution[] predictions)
                                          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.

Parameters:
predictions - array containing the prediction distributions of all classifier
Returns:
the translated result
Throws:
IllegalArgumentException - if the specified argument was invalid (not in the set of currently active classes

getValidClasses

protected Set getValidClasses()
Returns the set of valid class names.

Returns:
a set of Strings containing the valid class names

reset

public final boolean reset()
Resets the state() of this instance to the initial value CombinationState.OUTSIDE. Also checks whether the last extraction should be discarded, analogously to CombinationState.isDiscardPreceding(). The default behavior is to always return false, but subclasses can modify this by overwriting the resetHook() method.

Returns:
true iff the last extraction should be discarded

resetHook

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

Returns:
the value of the attribute

state

public CombinationState state()
The current state (state of the last item).

Returns:
the current state

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a textual representation

updateState

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

Parameters:
newState - the state of the last item
Throws:
IllegalArgumentException - if the type of the argument is invalid (not in the set of valid classes or null


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