edu.illinois.cs.cogcomp.lbj.coref.decoders
Class DecoderWithOptions<ST extends Solution>

java.lang.Object
  extended by edu.illinois.cs.cogcomp.lbj.coref.decoders.DecoderWithOptions<ST>
Type Parameters:
ST - The solution type.
All Implemented Interfaces:
SolutionDecoder<ST>
Direct Known Subclasses:
ChainSolutionDecoder, ChunkDecoder, KeyChainDecoder, MentionDecoder

public abstract class DecoderWithOptions<ST extends Solution>
extends java.lang.Object
implements SolutionDecoder<ST>

Abstract class for decoding some set of predictions into an arbitrary solution type.

Author:
Eric Bengtson

Field Summary
protected  java.util.Map<java.lang.String,java.lang.String> m_options
           
protected  boolean m_train
           
 
Constructor Summary
DecoderWithOptions()
          Construct a decoder.
 
Method Summary
abstract  ST decode(Doc doc)
          Decode a document into a solution.
 boolean getBooleanOption(java.lang.String option)
          Gets the value of the option interpreted as a boolean.
 java.lang.String getOption(java.lang.String option)
          Gets the string value of some option.
 double getRealOption(java.lang.String option, double defaultVal)
          Gets the value of the option interpreted as a real number.
 void processOption(java.lang.String option, java.lang.String value)
          Handles option changes when they happen (when setOption is called).
 void setOption(java.lang.String option, boolean value)
          Sets the option to a boolean value.
 void setOption(java.lang.String option, double value)
          Sets the option to a real value.
 void setOption(java.lang.String option, java.lang.String value)
          Sets the value of some option.
 void setTrain(boolean train)
          Specify whether the algorithm is training during decode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_options

protected java.util.Map<java.lang.String,java.lang.String> m_options

m_train

protected boolean m_train
Constructor Detail

DecoderWithOptions

public DecoderWithOptions()
Construct a decoder.

Method Detail

decode

public abstract ST decode(Doc doc)
Decode a document into a solution.

Specified by:
decode in interface SolutionDecoder<ST extends Solution>
Parameters:
doc - A document to process.
Returns:
A solution representing the result of the decoding.

getOption

public java.lang.String getOption(java.lang.String option)
Gets the string value of some option. Override to provide default values, but be sure to call super.

Parameters:
option - The name of the option to get.
Returns:
the String value for the option p, or null if not defined and no default specified.

getBooleanOption

public boolean getBooleanOption(java.lang.String option)
Gets the value of the option interpreted as a boolean. Override to provide default values, but be sure to call super.

Parameters:
option - The name of the option.
Returns:
the boolean value for option as defined by Boolean.parseBoolean, or false if not defined and no default specified.

getRealOption

public double getRealOption(java.lang.String option,
                            double defaultVal)
Gets the value of the option interpreted as a real number.

Parameters:
option - The name of the option.
defaultVal - The default value.
Returns:
the real value for >option as defined by Double.parseDouble, or defaultVal if not defined.

setOption

public void setOption(java.lang.String option,
                      java.lang.String value)
Sets the value of some option. Also processes the option. If overridden to handle more options, but be sure to call super.setOption(String, String). If super.setOption(String, String) is called, no need to override setOption(String, boolean). However, to add more options, consider overriding processOption instead.

Parameters:
option - The name of the option.
value - The desired value.

setOption

public void setOption(java.lang.String option,
                      boolean value)
Sets the option to a boolean value. If option is already a string "true" or "false", call setOption(String, String) instead. No need to override this method. Override setOption(String, String) instead.

Specified by:
setOption in interface SolutionDecoder<ST extends Solution>
Parameters:
option - The name of the option.
value - The desired value.

setOption

public void setOption(java.lang.String option,
                      double value)
Sets the option to a real value. If option is already a string, call setOption(String, String) instead. No need to override this method. Override setOption(String, String) instead.

Parameters:
option - The name of the option.
value - The desired value.

setTrain

public void setTrain(boolean train)
Specify whether the algorithm is training during decode.

Parameters:
train - Whether training.

processOption

public void processOption(java.lang.String option,
                          java.lang.String value)
Handles option changes when they happen (when setOption is called). Override to create subclass specific options, but be sure to call super.processOptions().

Parameters:
option - The name of the option, which is generally all lowercase.
value - The value, which may be the string representation of a boolean or real value (In a format supported by by Boolean.parseBoolean or Double.parseDouble) or any arbitrary string.