001    package calhoun.analysis.crf.io;
002    
003    import java.io.IOException;
004    import java.io.Serializable;
005    
006    /** handles outputting of results from predictions. */
007    public interface OutputHandler extends Serializable {
008    
009            /** sets the output location to write to.  This is called before any of the write functions are called.
010             * @param location the location to write the data to.  The meaning is implementation dependent.
011             */
012            void setOutputLocation(String location);
013            
014            /** Writes out a set of predicted hidden states.  The location will have been specified previously with {@link #setOutputLocation}
015             * @param sequence the input sequence on which predictions were made
016             * @param hiddenStates an array of state indices for the predicted hidden states.
017             */
018            void writeOutput(InputSequence<?> sequence, int[] hiddenStates) throws IOException;
019    
020            /** Writes out a set of hidden states compared with a known true path.  The location will have been specified previously with {@link #setOutputLocation}
021             * @param sequence the input sequence on which predictions were made
022             * @param truePath an array of hidden states representing the true path.
023             * @param hiddenStates an array of state indices for the predicted hidden states.
024             */
025            void writeTestOutput(InputSequence<?> sequence, int[] truePath, int[] hiddenStates) throws IOException;
026    
027            /** indicates the writing of output is complete.  The handler can do any final processing and release resources.
028             */
029            void outputComplete() throws IOException;
030    }