    001    package calhoun.analysis.crf.io;
    002
    003    import java.io.IOException;
    004
    005    /** writes output to a file using a {@link TrainingSequenceIO}.  The name of the output file will be computed from the output
    006     * location by using the configured {@link FilenameMapper}.  If no mapper is configured, the output location will be used as
    007     * the filename.
    008     */
    009    public class OutputHandlerWriter implements OutputHandler {
    010            private static final long serialVersionUID = -3039234501926777322L;
    011
    012            FilenameMapper filenameMapper;
    013            TrainingSequenceIO resultHandler;
    014            String location;
    015
    016            public void setOutputLocation(String location) {
    017                    this.location = location;
    018            }
    019
    020            public void writeOutput(InputSequence<?> sequence, int[] hiddenStates) throws IOException {
    021                    throw new UnsupportedOperationException();
    022            }
    023
    024            public void writeTestOutput(InputSequence<?> sequence, int[] truePath, int[] hiddenStates) throws IOException {
    025            }
    026
    027            public void outputComplete() throws IOException {
    028            }
    029
    030            /** gets the mapper which will be used to generate the output filename based on the output location.
    031             * @return the configured filenameMapper
    032             */
    033            public FilenameMapper getFilenameMapper() {
    034                    return filenameMapper;
    035            }
    036
    037            /** sets the mapper which will be used to generate the output filename based on the output location.
    038             * @param filenameMapper the filenameMapper used to generate the output filename based on the output location.
    039             */
    040            public void setFilenameMapper(FilenameMapper filenameMapper) {
    041                    this.filenameMapper = filenameMapper;
    042            }
    043
    044            /** gets the result handler which will be used to handle the output sequence
    045             * @return the result handler which will be used to handle the output sequence
    046             */
    047            public TrainingSequenceIO getResultHandler() {
    048                    return resultHandler;
    049            }
    050
    051            /** sets the result handler which will be used to handle the output sequence
    052             * @param resultHandler the result handler which will be used to handle the output sequence
    053             */
    054            public void setResultHandler(TrainingSequenceIO resultHandler) {
    055                    this.resultHandler = resultHandler;
    056            }
    057    }