Class NameFinderEventStream
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
dataStreamIObjectStream<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
dataStreamIObjectStream<NameSample>The data stream of events.
typestringnull or overrides the type parameter in the provided samples
contextGeneratorINameContextGeneratorThe context generator used to generate features for the event stream.
codecISequenceCodec<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
tokensstring[]The token for which the context is generated.
prevMapIDictionary<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
sampleNameSamplethe 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
sentencestring[]outcomesstring[]cgINameContextGenerator
Returns
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
namesSpan[]Token spans for each of the names.
typestringnull or overrides the type parameter in the provided samples
lengthintThe 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!