Class AbstractEventStream<T>
Base class for IObjectStream<T>s which turn samples into training Events.
public abstract class AbstractEventStream<T> : ObjectStreamBase<Event?>, IObjectStream<Event?>, IDisposable where T : class
Type Parameters
Tthe type of the samples the events are created from
- Inheritance
-
AbstractEventStream<T>
- Implements
- Derived
- Inherited Members
Constructors
AbstractEventStream(IObjectStream<T?>)
Initializes the current instance with a sample stream.
protected AbstractEventStream(IObjectStream<T?> samples)
Parameters
samplesIObjectStream<T>the sample stream.
Methods
CreateEvents(T)
Creates events for the provided sample.
protected abstract IEnumerable<Event> CreateEvents(T sample)
Parameters
sampleTthe sample for which training Events are be created.
Returns
- IEnumerable<Event>
a sequence of training events, or an empty sequence.
Remarks
NOpenNLP: upstream returns an Iterator<Event>. This returns
IEnumerable<T> instead, which is the more usual .NET shape and
spares implementers from handing back an enumerator the caller must dispose.
Read() enumerates it manually, since it yields one event per call.
Dispose(bool)
Releases the resources from this object stream.
protected override void Dispose(bool disposing)
Parameters
disposingbool
Read()
Returns the next object. Calling this method repeatedly until it returns
null will return each object from the underlying source exactly once.
public override sealed Event? Read()
Returns
- Event
the next object or
nullto signal that the stream is exhausted
Exceptions
- IOException
if there is an error during reading
- IOException
if there is an error during reading
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.
public override void Reset()
Exceptions
- IOException
if there is an error during resetting the stream
- NotSupportedException
if reset is not supported on this stream