calhoun.analysis.crf.io
Class OutputHandlerWriter

java.lang.Object
  extended by calhoun.analysis.crf.io.OutputHandlerWriter
All Implemented Interfaces:
OutputHandler, java.io.Serializable

public class OutputHandlerWriter
extends java.lang.Object
implements OutputHandler

writes output to a file using a TrainingSequenceIO. The name of the output file will be computed from the output location by using the configured FilenameMapper. If no mapper is configured, the output location will be used as the filename.

See Also:
Serialized Form

Constructor Summary
OutputHandlerWriter()
           
 
Method Summary
 FilenameMapper getFilenameMapper()
          gets the mapper which will be used to generate the output filename based on the output location.
 TrainingSequenceIO getResultHandler()
          gets the result handler which will be used to handle the output sequence
 void outputComplete()
          indicates the writing of output is complete.
 void setFilenameMapper(FilenameMapper filenameMapper)
          sets the mapper which will be used to generate the output filename based on the output location.
 void setOutputLocation(java.lang.String location)
          sets the output location to write to.
 void setResultHandler(TrainingSequenceIO resultHandler)
          sets the result handler which will be used to handle the output sequence
 void writeOutput(InputSequence<?> sequence, int[] hiddenStates)
          Writes out a set of predicted hidden states.
 void writeTestOutput(InputSequence<?> sequence, int[] truePath, int[] hiddenStates)
          Writes out a set of hidden states compared with a known true path.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputHandlerWriter

public OutputHandlerWriter()
Method Detail

setOutputLocation

public void setOutputLocation(java.lang.String location)
Description copied from interface: OutputHandler
sets the output location to write to. This is called before any of the write functions are called.

Specified by:
setOutputLocation in interface OutputHandler
Parameters:
location - the location to write the data to. The meaning is implementation dependent.

writeOutput

public void writeOutput(InputSequence<?> sequence,
                        int[] hiddenStates)
                 throws java.io.IOException
Description copied from interface: OutputHandler
Writes out a set of predicted hidden states. The location will have been specified previously with OutputHandler.setOutputLocation(java.lang.String)

Specified by:
writeOutput in interface OutputHandler
Parameters:
sequence - the input sequence on which predictions were made
hiddenStates - an array of state indices for the predicted hidden states.
Throws:
java.io.IOException

writeTestOutput

public void writeTestOutput(InputSequence<?> sequence,
                            int[] truePath,
                            int[] hiddenStates)
                     throws java.io.IOException
Description copied from interface: OutputHandler
Writes out a set of hidden states compared with a known true path. The location will have been specified previously with OutputHandler.setOutputLocation(java.lang.String)

Specified by:
writeTestOutput in interface OutputHandler
Parameters:
sequence - the input sequence on which predictions were made
truePath - an array of hidden states representing the true path.
hiddenStates - an array of state indices for the predicted hidden states.
Throws:
java.io.IOException

outputComplete

public void outputComplete()
                    throws java.io.IOException
Description copied from interface: OutputHandler
indicates the writing of output is complete. The handler can do any final processing and release resources.

Specified by:
outputComplete in interface OutputHandler
Throws:
java.io.IOException

getFilenameMapper

public FilenameMapper getFilenameMapper()
gets the mapper which will be used to generate the output filename based on the output location.

Returns:
the configured filenameMapper

setFilenameMapper

public void setFilenameMapper(FilenameMapper filenameMapper)
sets the mapper which will be used to generate the output filename based on the output location.

Parameters:
filenameMapper - the filenameMapper used to generate the output filename based on the output location.

getResultHandler

public TrainingSequenceIO getResultHandler()
gets the result handler which will be used to handle the output sequence

Returns:
the result handler which will be used to handle the output sequence

setResultHandler

public void setResultHandler(TrainingSequenceIO resultHandler)
sets the result handler which will be used to handle the output sequence

Parameters:
resultHandler - the result handler which will be used to handle the output sequence