Class NameFinderEventStream

Namespace
NOpenNLP.Tools.Namefind
Assembly
NOpenNLP.Tools.dll

Class for creating an event stream out of data files for training a name finder.

public class NameFinderEventStream : AbstractEventStream<NameSample>, IObjectStream<Event?>, IDisposable
Inheritance
NameFinderEventStream
Implements
Inherited Members

Constructors

NameFinderEventStream(IObjectStream<NameSample?>)

public NameFinderEventStream(IObjectStream<NameSample?> dataStream)

Parameters

dataStream IObjectStream<NameSample>

NameFinderEventStream(IObjectStream<NameSample?>, string?, INameContextGenerator, ISequenceCodec<string>?)

Creates a new name finder event stream using the specified data stream and context generator.

public NameFinderEventStream(IObjectStream<NameSample?> dataStream, string? type, INameContextGenerator contextGenerator, ISequenceCodec<string>? codec)

Parameters

dataStream IObjectStream<NameSample>

The data stream of events.

type string

null or overrides the type parameter in the provided samples

contextGenerator INameContextGenerator

The context generator used to generate features for the event stream.

codec ISequenceCodec<string>

the sequence codec, or null for a BioCodec

Methods

AdditionalContext(string[], IDictionary<string, string>)

Generated previous decision features for each token based on contents of the specified map.

public static string[][] AdditionalContext(string[] tokens, IDictionary<string, string> prevMap)

Parameters

tokens string[]

The token for which the context is generated.

prevMap IDictionary<string, string>

A mapping of tokens to their previous decisions.

Returns

string[][]

An additional context array with features for each token.

CreateEvents(NameSample)

Creates events for the provided sample.

protected override IEnumerable<Event> CreateEvents(NameSample sample)

Parameters

sample NameSample

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[], INameContextGenerator)

public static IList<Event> GenerateEvents(string[] sentence, string[] outcomes, INameContextGenerator cg)

Parameters

sentence string[]
outcomes string[]
cg INameContextGenerator

Returns

IList<Event>

GenerateOutcomes(Span[], string?, int)

Generates the name tag outcomes (start, continue, other) for each token in a sentence with the specified length using the specified name spans.

public static string[] GenerateOutcomes(Span[] names, string? type, int length)

Parameters

names Span[]

Token spans for each of the names.

type string

null or overrides the type parameter in the provided samples

length int

The length of the sentence.

Returns

string[]

An array of start, continue, other outcomes based on the specified names and sentence length.

Remarks

Deprecated: use the BioCodec implementation of the ISequenceValidator<T> instead!