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, toString
forEach, spliterator
public NGramLanguageModel()
public NGramLanguageModel(int n)
public NGramLanguageModel(double k)
public NGramLanguageModel(int n, double k)
public NGramLanguageModel(InputStream in) throws IOException
IOException
public NGramLanguageModel(InputStream in, double k) throws IOException
IOException
public NGramLanguageModel(InputStream in, int n) throws IOException
IOException
public NGramLanguageModel(InputStream in, int n, double k) throws IOException
IOException
public double calculateProbability(StringList sample)
LanguageModel
calculateProbability
in interface LanguageModel
sample
- the text tokens to calculate the probability forpublic StringList predictNextTokens(StringList tokens)
LanguageModel
predictNextTokens
in interface LanguageModel
tokens
- a sequence of tokensCopyright © 2017 The Apache Software Foundation. All rights reserved.