Class FileEventStream
java.lang.Object
opennlp.tools.ml.model.FileEventStream
- All Implemented Interfaces:
AutoCloseable, opennlp.tools.util.ObjectStream<opennlp.tools.ml.model.Event>
- Direct Known Subclasses:
RealValueFileEventStream
public class FileEventStream
extends Object
implements opennlp.tools.util.ObjectStream<opennlp.tools.ml.model.Event>
Class for using a file of
events as an event stream.
The format of the file is one event per line with
each line consisting of outcome followed by contexts (space delimited).- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionFileEventStream(File file) Instantiates aFileEventStreamvia aFile.FileEventStream(Reader reader) Instantiates aFileEventStreamvia aReader.FileEventStream(String fileName) Instantiates aFileEventStreamfrom the specified file name.FileEventStream(String fileName, String encoding) Instantiates aFileEventStreamfrom the specified file name. -
Method Summary
-
Constructor Details
-
FileEventStream
Instantiates aFileEventStreamfrom the specified file name.- Parameters:
fileName- The name fo the file containing the events.encoding- The name of thecharacter encoding.- Throws:
IOException- Thrown if the specified file can not be read.
-
FileEventStream
Instantiates aFileEventStreamfrom the specified file name.- Parameters:
fileName- The name fo the file containing the events.- Throws:
IOException- Thrown if the specified file can not be read.
-
FileEventStream
Instantiates aFileEventStreamvia aReader.- Parameters:
reader- TheReaderthat holds events.- Throws:
IOException- Thrown if the specified file can not be read.
-
FileEventStream
Instantiates aFileEventStreamvia aFile.- Parameters:
file- TheFilethat holds events.- Throws:
IOException- Thrown if the specified file can not be read.
-
-
Method Details
-
read
Returns the nextEventobject. Calling this method repeatedly until it returnsnullwill return each object from the underlying source exactly once.- Specified by:
readin interfaceopennlp.tools.util.ObjectStream<opennlp.tools.ml.model.Event>- Returns:
- The next object or
nullto signal that the stream is exhausted. - Throws:
IOException- Thrown if there is an error during reading.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceopennlp.tools.util.ObjectStream<opennlp.tools.ml.model.Event>- Throws:
IOException
-
toLine
Generates a string representing the specified event.- Parameters:
event- TheEventfor which a string representation is needed.- Returns:
- A string representing the specified event.
-
reset
- Specified by:
resetin interfaceopennlp.tools.util.ObjectStream<opennlp.tools.ml.model.Event>- Throws:
IOExceptionUnsupportedOperationException
-