public class NGramLanguageModel extends NGramModel implements LanguageModel
LanguageModel based on a NGramModel
using Laplace smoothing probability estimation to get the probabilities of the ngrams.
See also NGramUtils.calculateLaplaceSmoothingProbability(
opennlp.tools.util.StringList, Iterable, int, Double).| Constructor and Description |
|---|
NGramLanguageModel() |
NGramLanguageModel(double k) |
NGramLanguageModel(InputStream in) |
NGramLanguageModel(InputStream in,
double k) |
NGramLanguageModel(InputStream in,
int n) |
NGramLanguageModel(InputStream in,
int n,
double k) |
NGramLanguageModel(int n) |
NGramLanguageModel(int n,
double k) |
| Modifier and Type | Method and Description |
|---|---|
double |
calculateProbability(StringList sample)
Calculate the probability of a series of tokens (e.g.
|
StringList |
predictNextTokens(StringList tokens)
Predict the most probable output sequence of tokens, given an input sequence of tokens
|
add, add, add, contains, cutoff, equals, getCount, hashCode, iterator, numberOfGrams, remove, serialize, setCount, size, toDictionary, toDictionary, toStringforEach, spliteratorpublic NGramLanguageModel()
public NGramLanguageModel(int n)
public NGramLanguageModel(double k)
public NGramLanguageModel(int n,
double k)
public NGramLanguageModel(InputStream in) throws IOException
IOExceptionpublic NGramLanguageModel(InputStream in, double k) throws IOException
IOExceptionpublic NGramLanguageModel(InputStream in, int n) throws IOException
IOExceptionpublic NGramLanguageModel(InputStream in, int n, double k) throws IOException
IOExceptionpublic double calculateProbability(StringList sample)
LanguageModelcalculateProbability in interface LanguageModelsample - the text tokens to calculate the probability forpublic StringList predictNextTokens(StringList tokens)
LanguageModelpredictNextTokens in interface LanguageModeltokens - a sequence of tokensCopyright © 2017 The Apache Software Foundation. All rights reserved.