001 package calhoun.analysis.crf.io;
002
003 import java.io.BufferedReader;
004 import java.io.IOException;
005 import java.io.Writer;
006 import java.util.Map;
007
008 /** an input component that can be used with the {@link InputHandlerInterleaved}. This is a regular
009 * input component that also has input and output methods that take a BufferedReader to use when reading data
010 * from the input file. */
011 public interface InterleavedInputComponent extends InputComponentIO {
012
013 /** Read the contents of the sequence in from a reader. Return false if the end of file was reached.
014 * @param r the buffered reader from which the next sequence should be read.
015 * @param output a map to which new components for this input sequence should be added.
016 * @return true if a sequence was read in and the map was populated. false if the end of the sequence was reached. */
017 boolean read(BufferedReader r, Map<String, InputSequence<?>> output) throws IOException;
018
019 /** Output this sequence to the given writer.
020 * @param w a writer to which this sequence should be written
021 * @param data a map containing the data for the sequence to be written */
022 void write(Writer w, Map<String, ? extends InputSequence<?>> data) throws IOException;
023 }