Class LemmatizerME

Namespace
NOpenNLP.Tools.Lemmatizer
Assembly
NOpenNLP.Tools.dll

A probabilistic lemmatizer. Tries to predict the induced permutation class for each word depending on its surrounding context. Based on Grzegorz Chrupała. 2008. Towards a Machine-Learning Architecture for Lexical Functional Grammar Parsing. PhD dissertation, Dublin City University. http://grzegorz.chrupala.me/papers/phd-single.pdf

public class LemmatizerME : ILemmatizer
Inheritance
LemmatizerME
Implements
Inherited Members

Constructors

LemmatizerME(LemmatizerModel)

Initializes the current instance with the provided model and the default beam size of 3.

public LemmatizerME(LemmatizerModel model)

Parameters

model LemmatizerModel

the model

Fields

DEFAULT_BEAM_SIZE

public const int DEFAULT_BEAM_SIZE = 3

Field Value

int

LEMMA_NUMBER

public const int LEMMA_NUMBER = 29

Field Value

int

beamSize

protected readonly int beamSize

Field Value

int

Methods

DecodeLemmas(string[], string[])

Decodes the lemma from the word and the induced lemma class.

public static string[] DecodeLemmas(string[] toks, string[] preds)

Parameters

toks string[]

the array of tokens

preds string[]

the predicted lemma classes

Returns

string[]

the array of decoded lemmas

EncodeLemmas(string[], string[])

public static string[] EncodeLemmas(string[] toks, string[] lemmas)

Parameters

toks string[]
lemmas string[]

Returns

string[]

Lemmatize(IList<string>, IList<string>)

Generates a lemma tags for the word and postag returning the result in a list of every possible lemma for each token and postag.

public virtual IList<IList<string>> Lemmatize(IList<string> toks, IList<string> tags)

Parameters

toks IList<string>

an array of the tokens

tags IList<string>

an array of the pos tags

Returns

IList<IList<string>>

a list of every possible lemma for each token in the sequence.

Lemmatize(string[], string[])

Generates lemmas for the word and postag returning the result in an array.

public virtual string[] Lemmatize(string[] toks, string[] tags)

Parameters

toks string[]

an array of the tokens

tags string[]

an array of the pos tags

Returns

string[]

an array of possible lemmas for each token in the sequence.

PredictLemmas(int, string[], string[])

Predict all possible lemmas (using a default upper bound).

public virtual string[][] PredictLemmas(int numLemmas, string[] toks, string[] tags)

Parameters

numLemmas int

the default number of lemmas

toks string[]

the tokens

tags string[]

the postags

Returns

string[][]

a double array containing all posible lemmas for each token and postag pair

PredictSES(string[], string[])

Predict Short Edit Script (automatically induced lemma class).

public virtual string[] PredictSES(string[] toks, string[] tags)

Parameters

toks string[]

the array of tokens

tags string[]

the array of pos tags

Returns

string[]

an array containing the lemma classes

Probs()

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

public virtual double[] Probs()

Returns

double[]

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

Probs(double[])

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

public virtual void Probs(double[] probs)

Parameters

probs double[]

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

TopKLemmaClasses(string[], string[])

public virtual Sequence[] TopKLemmaClasses(string[] sentence, string[] tags)

Parameters

sentence string[]
tags string[]

Returns

Sequence[]

TopKLemmaClasses(string[], string[], double)

public virtual Sequence[] TopKLemmaClasses(string[] sentence, string[] tags, double minSequenceScore)

Parameters

sentence string[]
tags string[]
minSequenceScore double

Returns

Sequence[]

TopKSequences(string[], string[])

public virtual Sequence[] TopKSequences(string[] sentence, string[] tags)

Parameters

sentence string[]
tags string[]

Returns

Sequence[]

TopKSequences(string[], string[], double)

public virtual Sequence[] TopKSequences(string[] sentence, string[] tags, double minSequenceScore)

Parameters

sentence string[]
tags string[]
minSequenceScore double

Returns

Sequence[]

Train(string, IObjectStream<LemmaSample?>, TrainingParameters, LemmatizerFactory)

public static LemmatizerModel Train(string languageCode, IObjectStream<LemmaSample?> samples, TrainingParameters trainParams, LemmatizerFactory posFactory)

Parameters

languageCode string
samples IObjectStream<LemmaSample>
trainParams TrainingParameters
posFactory LemmatizerFactory

Returns

LemmatizerModel