Package opennlp.tools.languagemodel
Klasse NGramLanguageModel
java.lang.Object
opennlp.tools.ngram.NGramModel
opennlp.tools.languagemodel.NGramLanguageModel
- Alle implementierten Schnittstellen:
Iterable<StringList>
,LanguageModel
A
LanguageModel
based on a NGramModel
using Stupid Backoff to get
the probabilities of the ngrams.-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungInitializes anNGramLanguageModel
withDEFAULT_N
.NGramLanguageModel
(int n) Initializes anNGramLanguageModel
with the givenn
for the ngram size.Initializes aNGramLanguageModel
instance via a validInputStream
.NGramLanguageModel
(InputStream in, int n) Initializes aNGramLanguageModel
instance via a validInputStream
. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
Adds further tokens.double
calculateProbability
(String... tokens) Calculate the probability of a series of tokens (e.g. a sentence), given a vocabulary.String[]
predictNextTokens
(String... tokens) Predict the most probable output sequence of tokens, given an input sequence oftokens
.Von Klasse geerbte Methoden opennlp.tools.ngram.NGramModel
add, add, add, contains, cutoff, equals, getCount, hashCode, iterator, numberOfGrams, remove, serialize, setCount, size, toDictionary, toDictionary, toString
Von Schnittstelle geerbte Methoden java.lang.Iterable
forEach, spliterator
-
Konstruktordetails
-
NGramLanguageModel
public NGramLanguageModel()Initializes anNGramLanguageModel
withDEFAULT_N
. -
NGramLanguageModel
public NGramLanguageModel(int n) Initializes anNGramLanguageModel
with the givenn
for the ngram size.- Parameter:
n
- The size of the ngrams to be used. Must be greater than0
.- Löst aus:
IllegalArgumentException
- Thrown if one of the arguments was invalid.
-
NGramLanguageModel
Initializes aNGramLanguageModel
instance via a validInputStream
.- Parameter:
in
- TheInputStream
used for loading the model.- Löst aus:
IOException
- Thrown if IO errors occurred during initialization.IllegalArgumentException
- Thrown if one of the arguments was invalid.
-
NGramLanguageModel
Initializes aNGramLanguageModel
instance via a validInputStream
.- Parameter:
in
- TheInputStream
used for loading the model.n
- The size of the ngrams to be used. Must be greater than0
.- Löst aus:
IOException
- Thrown if IO errors occurred during initialization.IllegalArgumentException
- Thrown if one of the arguments was invalid.
-
-
Methodendetails
-
add
Adds further tokens.- Parameter:
tokens
- Text elements to add to theNGramLanguageModel
.
-
calculateProbability
Beschreibung aus Schnittstelle kopiert:LanguageModel
Calculate the probability of a series of tokens (e.g. a sentence), given a vocabulary.- Angegeben von:
calculateProbability
in SchnittstelleLanguageModel
- Parameter:
tokens
- the text tokens to calculate theprobability
for.- Gibt zurück:
- the probability of the given text tokens in the vocabulary
-
predictNextTokens
Beschreibung aus Schnittstelle kopiert:LanguageModel
Predict the most probable output sequence of tokens, given an input sequence oftokens
.- Angegeben von:
predictNextTokens
in SchnittstelleLanguageModel
- Parameter:
tokens
- a sequence of tokens- Gibt zurück:
- the most probable subsequent token sequence
-