Package opennlp.tools.depparse
Class DependencyEventStream
java.lang.Object
opennlp.tools.depparse.DependencyEventStream
- All Implemented Interfaces:
AutoCloseable,ObjectStream<Event>
Turns
samples into training events: for each
sample the ArcStandardOracle derives the gold transitions, and every transition
becomes one event pairing the configuration features with the encoded transition.
Samples whose tree has no arc-standard derivation, that is non-projective trees, are skipped and counted; the count is logged once the stream is exhausted.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DependencyContextGeneratorprivate static final org.slf4j.Loggerprivate final ObjectStream<DependencySample> private int -
Constructor Summary
ConstructorsConstructorDescriptionDependencyEventStream(ObjectStream<DependencySample> samples, DependencyContextGenerator contextGenerator) Initializes the stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes theObjectStreamand releases all allocated resources.read()Returns the nextObjectStreamobject.voidreset()Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly.
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
samples
-
contextGenerator
-
pending
-
skipped
private int skipped
-
-
Constructor Details
-
DependencyEventStream
DependencyEventStream(ObjectStream<DependencySample> samples, DependencyContextGenerator contextGenerator) Initializes the stream.- Parameters:
samples- The samples to convert. Must not benull.contextGenerator- The feature generator. Must not benull.- Throws:
IllegalArgumentException- Thrown if any parameter isnull.
-
-
Method Details
-
read
Returns the nextObjectStreamobject. Calling this method repeatedly until it returnsnullwill return each object from the underlying source exactly once.Returns the events of one sample at a time and moves on to the next sample once they are exhausted.
- Specified by:
readin interfaceObjectStream<Event>- Returns:
- The next object or
nullto signal that the stream is exhausted. - Throws:
IOException- Thrown if reading the underlying samples fails.
-
reset
Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly. This method can be used to re-read the stream if multiple passes over the objects are required.The implementation of this method is optional.
Also discards buffered events and the skipped sample count.
- Specified by:
resetin interfaceObjectStream<Event>- Throws:
IOException- Thrown if resetting the underlying samples fails.UnsupportedOperationException- Thrown if the underlying samples cannot be reset.
-
close
Closes theObjectStreamand releases all allocated resources. After close was called, it's not allowed to callObjectStream.read()orObjectStream.reset().- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceObjectStream<Event>- Throws:
IOException- Thrown if closing the underlying samples fails.
-