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
inStream
Exceptions
NGramLanguageModel(Stream, int)
public NGramLanguageModel(Stream @in, int n)
Parameters
Exceptions
NGramLanguageModel(int)
public NGramLanguageModel(int n)
Parameters
nint
Methods
Add(params string[])
public virtual void Add(params string[] tokens)
Parameters
tokensstring[]
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
tokensStringListthe 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
tokensstring[]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
tokensStringLista 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
tokensstring[]a sequence of tokens
Returns
- string[]
the most probable subsequent token sequence