Class NGramLanguageModel

Namespace
NOpenNLP.Tools.Languagemodel
Assembly
NOpenNLP.Tools.dll

A ILanguageModel based on a NGramModel using Stupid Backoff to get the probabilities of the ngrams.

public class NGramLanguageModel : NGramModel, IEnumerable<StringList>, IEnumerable, ILanguageModel
Inheritance
NGramLanguageModel
Implements
Inherited Members

Constructors

NGramLanguageModel()

public NGramLanguageModel()

NGramLanguageModel(Stream)

public NGramLanguageModel(Stream @in)

Parameters

in Stream

Exceptions

IOException

NGramLanguageModel(Stream, int)

public NGramLanguageModel(Stream @in, int n)

Parameters

in Stream
n int

Exceptions

IOException

NGramLanguageModel(int)

public NGramLanguageModel(int n)

Parameters

n int

Methods

Add(params string[])

public virtual void Add(params string[] tokens)

Parameters

tokens string[]

CalculateProbability(StringList)

Calculate the probability of a series of tokens (e.g. a sentence), given a vocabulary.

[Obsolete("Use CalculateProbability(string[]) instead.")]
public virtual double CalculateProbability(StringList tokens)

Parameters

tokens StringList

the text tokens to calculate the probability for

Returns

double

the probability of the given text tokens in the vocabulary

Remarks

Deprecated: Use CalculateProbability(params string[]) instead.

CalculateProbability(params string[])

Calculate the probability of a series of tokens (e.g. a sentence), given a vocabulary.

public virtual double CalculateProbability(params string[] tokens)

Parameters

tokens string[]

the text tokens to calculate the probability for

Returns

double

the probability of the given text tokens in the vocabulary

PredictNextTokens(StringList)

Predict the most probable output sequence of tokens, given an input sequence of tokens.

[Obsolete("Use PredictNextTokens(string[]) instead.")]
public virtual StringList? PredictNextTokens(StringList tokens)

Parameters

tokens StringList

a sequence of tokens

Returns

StringList

the most probable subsequent token sequence

Remarks

Deprecated: Use PredictNextTokens(params string[]) instead.

PredictNextTokens(params string[])

Predict the most probable output sequence of tokens, given an input sequence of tokens.

public virtual string[]? PredictNextTokens(params string[] tokens)

Parameters

tokens string[]

a sequence of tokens

Returns

string[]

the most probable subsequent token sequence