de.fu_berlin.ties.combi
Class CombinationStrategy

java.lang.Object
  extended byde.fu_berlin.ties.combi.CombinationStrategy
Direct Known Subclasses:
BeginAfterStrategy, InsideOutsideStrategy, OpenCloseStrategy

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.2 $, $Date: 2004/03/23 17:27:07 $, $Author: siefkes $
Author:
Christian Siefkes

Field Summary
static String CONFIG_COMBINATION
          Configuration key specifying the combination strategy to use.
 
Constructor Summary
CombinationStrategy(Set theClasses)
          Creates a new instance.
 
Method Summary
abstract  Set activeClasses()
          Builds a set of class names (Strings) to pass to the classifier to consider for the next decision.
abstract  Set allClasses()
          Returns an immutable set of all classes (Strings) that can possible occur during classification.
static CombinationStrategy createStrategy(Set classNames)
          Factory method that delegates to createStrategy(Set, TiesConfiguration) using the standard configuration.
static CombinationStrategy createStrategy(Set 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.
 void reset()
          Resets the state() of this instance to the initial value CombinationState.OUTSIDE.
 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 in a class name to feed to the classifier in training mode.
abstract  CombinationState translateResult(String predictedClass)
          Translates the class predicted by the classifier 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 theClasses)
Creates a new instance.

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

createStrategy

public static CombinationStrategy createStrategy(Set classNames)
                                          throws IllegalArgumentException
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

createStrategy

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

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

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

activeClasses

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

Returns:
a set of class names

allClasses

public abstract Set allClasses()
Returns an immutable set of all classes (Strings) that can possible occur during classification.

Returns:
an immutable set of class names

translateCurrentState

public abstract String translateCurrentState(CombinationState currentState)
                                      throws IllegalArgumentException
Translates an expected class in a class name to feed to the classifier in training mode. This method reverses the direction of translateResult(String).

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

Parameters:
currentState - the current state
Returns:
the class to feed to the 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(String predictedClass)
                                          throws IllegalArgumentException
Translates the class predicted by the classifier in a decision for the caller. The end information might be unreliably/absend for same classes.

Parameters:
predictedClass - the class predicted by the 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 void reset()
Resets the state() of this instance to the initial value CombinationState.OUTSIDE.


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.

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(String) 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.