Class NameFinderME
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
modelTokenNameFinderModel
Fields
CONTINUE
public const string CONTINUE = "cont"
Field Value
DEFAULT_BEAM_SIZE
public const int DEFAULT_BEAM_SIZE = 3
Field Value
OTHER
public const string OTHER = "other"
Field Value
START
public const string START = "start"
Field Value
contextGenerator
protected readonly INameContextGenerator contextGenerator
Field Value
model
protected readonly ISequenceClassificationModel<string>? model
Field Value
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
spansSpan[]
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
tokensstring[]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
tokensstring[]an array of the tokens or words of the sequence, typically a sentence.
additionalContextstring[][]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
spansSpan[]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
probsdouble[]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
languageCodestringthe language of the training data
typestringnull or an override type for all types in the training data
samplesIObjectStream<NameSample>the training data
trainParamsTrainingParametersmachine learning train parameters
factoryTokenNameFinderFactorya TokenNameFinderFactory to get resources from
Returns
- TokenNameFinderModel
the trained TokenNameFinderModel
Exceptions
- IOException
if reading from the IObjectStream<T> fails