Class POSSampleEventStream
This class reads the POSSamples from the given IObjectStream<T> and converts the POSSamples into Events which can be used by the maxent library for training.
public class POSSampleEventStream : AbstractEventStream<POSSample>, IObjectStream<Event?>, IDisposable
- Inheritance
-
POSSampleEventStream
- Implements
- Inherited Members
Constructors
POSSampleEventStream(IObjectStream<POSSample?>)
Initializes the current instance with given samples and a DefaultPOSContextGenerator.
public POSSampleEventStream(IObjectStream<POSSample?> samples)
Parameters
samplesIObjectStream<POSSample>the samples to create events from
POSSampleEventStream(IObjectStream<POSSample?>, IPOSContextGenerator)
Initializes the current instance with the given samples and the given IPOSContextGenerator.
public POSSampleEventStream(IObjectStream<POSSample?> samples, IPOSContextGenerator cg)
Parameters
samplesIObjectStream<POSSample>the samples to create events from
cgIPOSContextGeneratorthe context generator
Methods
CreateEvents(POSSample)
Creates events for the provided sample.
protected override IEnumerable<Event> CreateEvents(POSSample sample)
Parameters
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.
GenerateEvents(string[], string[], IPOSContextGenerator)
public static IList<Event> GenerateEvents(string[] sentence, string[] tags, IPOSContextGenerator cg)
Parameters
sentencestring[]tagsstring[]cgIPOSContextGenerator
Returns
GenerateEvents(string[], string[], object[]?, IPOSContextGenerator)
public static IList<Event> GenerateEvents(string[] sentence, string[] tags, object[]? additionalContext, IPOSContextGenerator cg)
Parameters
sentencestring[]tagsstring[]additionalContextobject[]cgIPOSContextGenerator