Class POSSampleEventStream

Namespace
NOpenNLP.Tools.Postag
Assembly
NOpenNLP.Tools.dll

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

samples IObjectStream<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

samples IObjectStream<POSSample>

the samples to create events from

cg IPOSContextGenerator

the context generator

Methods

CreateEvents(POSSample)

Creates events for the provided sample.

protected override IEnumerable<Event> CreateEvents(POSSample sample)

Parameters

sample POSSample

the 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.

GenerateEvents(string[], string[], IPOSContextGenerator)

public static IList<Event> GenerateEvents(string[] sentence, string[] tags, IPOSContextGenerator cg)

Parameters

sentence string[]
tags string[]
cg IPOSContextGenerator

Returns

IList<Event>

GenerateEvents(string[], string[], object[]?, IPOSContextGenerator)

public static IList<Event> GenerateEvents(string[] sentence, string[] tags, object[]? additionalContext, IPOSContextGenerator cg)

Parameters

sentence string[]
tags string[]
additionalContext object[]
cg IPOSContextGenerator

Returns

IList<Event>