Class NameFinderME

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

Class for creating a maximum-entropy-based name finder.

public class NameFinderME : ITokenNameFinder
Inheritance
NameFinderME
Implements
Inherited Members

Constructors

NameFinderME(TokenNameFinderModel)

public NameFinderME(TokenNameFinderModel model)

Parameters

model TokenNameFinderModel

Fields

CONTINUE

public const string CONTINUE = "cont"

Field Value

string

DEFAULT_BEAM_SIZE

public const int DEFAULT_BEAM_SIZE = 3

Field Value

int

OTHER

public const string OTHER = "other"

Field Value

string

START

public const string START = "start"

Field Value

string

contextGenerator

protected readonly INameContextGenerator contextGenerator

Field Value

INameContextGenerator

model

protected readonly ISequenceClassificationModel<string>? model

Field Value

ISequenceClassificationModel<string>

Methods

ClearAdaptiveData()

Forgets all adaptive data which was collected during previous calls to one of the find methods.

This method is typical called at the end of a document.

public virtual void ClearAdaptiveData()

DropOverlappingSpans(Span[])

Removes spans with are intersecting or crossing in anyway.

The following rules are used to remove the spans:
Identical spans: The first span in the array after sorting it remains
Intersecting spans: The first span after sorting remains
Contained spans: All spans which are contained by another are removed

public static Span[] DropOverlappingSpans(Span[] spans)

Parameters

spans Span[]

Returns

Span[]

non-overlapping spans

Find(string[])

Generates name tags for the given sequence, typically a sentence, returning token spans for any identified names.

public virtual Span[] Find(string[] tokens)

Parameters

tokens string[]

an array of the tokens or words of the sequence, typically a sentence.

Returns

Span[]

an array of spans for each of the names identified.

Find(string[], string[][])

Generates name tags for the given sequence, typically a sentence, returning token spans for any identified names.

public virtual Span[] Find(string[] tokens, string[][] additionalContext)

Parameters

tokens string[]

an array of the tokens or words of the sequence, typically a sentence.

additionalContext string[][]

features which are based on context outside of the sentence but which should also be used.

Returns

Span[]

an array of spans for each of the names identified.

Probs()

Returns an array with the probabilities of the last decoded sequence. The sequence was determined based on the previous call to Find(string[], string[][]).

public virtual double[] Probs()

Returns

double[]

An array with the same number of probabilities as tokens were sent to Find(string[], string[][]) when it was last called.

Probs(Span[])

Returns an array of probabilities for each of the specified spans which is the arithmetic mean of the probabilities for each of the outcomes which make up the span.

public virtual double[] Probs(Span[] spans)

Parameters

spans Span[]

The spans of the names for which probabilities are desired.

Returns

double[]

an array of probabilities for each of the specified spans.

Probs(double[])

Populates the specified array with the probabilities of the last decoded sequence. The sequence was determined based on the previous call to Find(string[], string[][]). The specified array should be at least as large as the number of tokens in the previous call to Find(string[], string[][]).

public virtual void Probs(double[] probs)

Parameters

probs double[]

An array used to hold the probabilities of the last decoded sequence.

Train(string, string?, IObjectStream<NameSample?>, TrainingParameters, TokenNameFinderFactory)

Trains a name finder model.

public static TokenNameFinderModel Train(string languageCode, string? type, IObjectStream<NameSample?> samples, TrainingParameters trainParams, TokenNameFinderFactory factory)

Parameters

languageCode string

the language of the training data

type string

null or an override type for all types in the training data

samples IObjectStream<NameSample>

the training data

trainParams TrainingParameters

machine learning train parameters

factory TokenNameFinderFactory

a TokenNameFinderFactory to get resources from

Returns

TokenNameFinderModel

the trained TokenNameFinderModel

Exceptions

IOException

if reading from the IObjectStream<T> fails