Package opennlp.tools.ml.model
Class RealValueFileEventStream
- java.lang.Object
-
- opennlp.tools.ml.model.FileEventStream
-
- opennlp.tools.ml.model.RealValueFileEventStream
-
- All Implemented Interfaces:
AutoCloseable
,ObjectStream<Event>
public class RealValueFileEventStream extends FileEventStream
Class for using a file of real-valuedevents
as anevent stream
. The format of the file is one event per line with each line consisting of outcome followed by contexts (space delimited).- See Also:
Event
,FileEventStream
-
-
Constructor Summary
Constructors Constructor Description RealValueFileEventStream(File file)
Instantiates aRealValueFileEventStream
via aFile
.RealValueFileEventStream(String fileName)
Instantiates aRealValueFileEventStream
from the specified file name.RealValueFileEventStream(String fileName, String encoding)
Instantiates aRealValueFileEventStream
from the specified file name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static float[]
parseContexts(String[] contexts)
Parses the specified contexts and re-populates context array with features and returns the values for these features.Event
read()
Returns the nextObjectStream
object.-
Methods inherited from class opennlp.tools.ml.model.FileEventStream
close, reset, toLine
-
-
-
-
Constructor Detail
-
RealValueFileEventStream
public RealValueFileEventStream(String fileName) throws IOException
Instantiates aRealValueFileEventStream
from 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.
-
RealValueFileEventStream
public RealValueFileEventStream(String fileName, String encoding) throws IOException
Instantiates aRealValueFileEventStream
from 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.
-
RealValueFileEventStream
public RealValueFileEventStream(File file) throws IOException
Instantiates aRealValueFileEventStream
via aFile
.- Parameters:
file
- TheFile
that holds events.- Throws:
IOException
- Thrown if the specified file can not be read.
-
-
Method Detail
-
parseContexts
public static float[] parseContexts(String[] contexts)
Parses the specified contexts and re-populates context array with features and returns the values for these features. If all values are unspecified, thennull
is returned.- Parameters:
contexts
- The contexts with real values specified.- Returns:
- The value for each context or null if all values are unspecified.
-
read
public Event read() throws IOException
Description copied from interface:ObjectStream
Returns the nextObjectStream
object. Calling this method repeatedly until it returnsnull
will return each object from the underlying source exactly once.- Specified by:
read
in interfaceObjectStream<Event>
- Overrides:
read
in classFileEventStream
- Returns:
- The next object or
null
to signal that the stream is exhausted. - Throws:
IOException
- Thrown if there is an error during reading.
-
-