|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fu_berlin.ties.combi.CombinationStrategy
public abstract class CombinationStrategy
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.
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[] |
activeClasses()
Builds a set array of class names (Strings) to pass to each classifier to consider for the next decision. |
abstract 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 . |
static CombinationStrategy |
createStrategy(Set<String> classNames)
Factory method that delegates to createStrategy(Set, TiesConfiguration) using the
standard configuration. |
static CombinationStrategy |
createStrategy(Set<String> classNames,
String combinationName,
TiesConfiguration config)
Factory method that creates a combination strategy based on the provided combinationName . |
static CombinationStrategy |
createStrategy(Set<String> classNames,
TiesConfiguration config)
Factory method that delegates to createStrategy(Set, String, TiesConfiguration) using
the CONFIG_COMBINATION key in the provided configuration. |
protected Set<String> |
getValidClasses()
Returns the set of valid class names. |
FinalReextractor |
initReextractor(Reestimator reestimatorChain)
This method can be overwritten to initialize a FinalReextractor . |
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,
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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String CONFIG_COMBINATION
Constructor Detail |
---|
public CombinationStrategy(Set<String> theClasses)
theClasses
- a set of valid class names (String)Method Detail |
---|
public static CombinationStrategy createStrategy(Set<String> classNames) throws IllegalArgumentException, ProcessingException
createStrategy(Set, TiesConfiguration)
using the
standard configuration.
classNames
- a set of valid class names (String)
IllegalArgumentException
- if the value of the
CONFIG_COMBINATION
key is missing or invalid
ProcessingException
- if an error occurred while creating the
strategypublic static CombinationStrategy createStrategy(Set<String> classNames, TiesConfiguration config) throws IllegalArgumentException, ProcessingException
createStrategy(Set, String, TiesConfiguration)
using
the CONFIG_COMBINATION
key in the provided configuration.
classNames
- a set of valid class names (String)config
- the configuration to use
IllegalArgumentException
- if the value of the
CONFIG_COMBINATION
key is missing or invalid
ProcessingException
- if an error occurred while creating the
strategypublic static CombinationStrategy createStrategy(Set<String> classNames, String combinationName, TiesConfiguration config) throws IllegalArgumentException, ProcessingException
combinationName
.
Currently supported named:
"BE" for BeginEndStrategy
,
"BIA" for BeginAfterStrategy
,
"BIE1" for OpenCloseStrategy
with
OpenCloseStrategy.isUsingBE()
set to false
,
"BIE2" for OpenCloseStrategy
with
OpenCloseStrategy.isUsingBE()
set to true
,
"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 first argument and a TiesConfiguration
as second
argument.
classNames
- a set of valid class names (String)combinationName
- the name of the configuration to use, as
explained aboveconfig
- used to configure the combination strategy
IllegalArgumentException
- if the combinationName
is null
or invalid
ProcessingException
- if an error occurred while creating the
strategypublic abstract Set[] activeClasses()
allClasses()
.
public abstract Set[] allClasses()
public ContextMap contextForReextractor()
FinalReextractor
. The default implementation simply returns
null
. If you overwrite this method, you should typically
overwrite the initReextractor(Reestimator)
method as well.
null
protected Set<String> getValidClasses()
public FinalReextractor initReextractor(Reestimator reestimatorChain) throws ProcessingException
FinalReextractor
.
The default implementation simply returns null
.
If you overwrite this method, you should typically overwrite the
contextForReextractor()
method as well.
reestimatorChain
- the chain of re-estimators used -- some
implementations might need a specific re-estimator to work
null
ProcessingException
- if an error occurs during initializationpublic final boolean reset()
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.
true
iff the last extraction should be discardedprotected boolean resetHook()
reset()
method to query whether the last
extraction should be discarded, analogously to
CombinationState.isDiscardPreceding()
.
public CombinationState state()
public String toString()
toString
in class Object
public abstract String[] translateCurrentState(CombinationState currentState) throws IllegalArgumentException
translateResult(PredictionDistribution[], TokenDetails)
.
The return value can be feed to the classifiers for training it.
currentState
- the current state
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)public abstract CombinationState translateResult(PredictionDistribution[] predictions, TokenDetails details) throws IllegalArgumentException
predictions
- array containing the prediction distributions of
all classifierdetails
- details representing the classified token
IllegalArgumentException
- if the specified argument was invalid
(not in the set of currently active classes
public void updateState(CombinationState newState, PredictionDistribution[] predictions, TokenDetails details) throws IllegalArgumentException
translateResult(PredictionDistribution[], TokenDetails)
and/or
training (translateCurrentState(CombinationState)
) an item.
newState
- the state of the last itempredictions
- array containing the prediction distributions of
all classifier for the last itemdetails
- details representing the last item
IllegalArgumentException
- if the
type of the argument is invalid
(not in the set of valid classes or
null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |