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 anNGramLanguageModelwithDEFAULT_N.NGramLanguageModel(int n) Initializes anNGramLanguageModelwith the givennfor the ngram size.Initializes aNGramLanguageModelinstance via a validInputStream.NGramLanguageModel(InputStream in, int n) Initializes aNGramLanguageModelinstance via a validInputStream. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidAdds further tokens.doublecalculateProbability(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, toStringVon Schnittstelle geerbte Methoden java.lang.Iterable
forEach, spliterator
-
Konstruktordetails
-
NGramLanguageModel
public NGramLanguageModel()Initializes anNGramLanguageModelwithDEFAULT_N. -
NGramLanguageModel
public NGramLanguageModel(int n) Initializes anNGramLanguageModelwith the givennfor 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 aNGramLanguageModelinstance via a validInputStream.- Parameter:
in- TheInputStreamused 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 aNGramLanguageModelinstance via a validInputStream.- Parameter:
in- TheInputStreamused 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:LanguageModelCalculate the probability of a series of tokens (e.g. a sentence), given a vocabulary.- Angegeben von:
calculateProbabilityin SchnittstelleLanguageModel- Parameter:
tokens- the text tokens to calculate theprobabilityfor.- Gibt zurück:
- the probability of the given text tokens in the vocabulary
-
predictNextTokens
Beschreibung aus Schnittstelle kopiert:LanguageModelPredict the most probable output sequence of tokens, given an input sequence oftokens.- Angegeben von:
predictNextTokensin SchnittstelleLanguageModel- Parameter:
tokens- a sequence of tokens- Gibt zurück:
- the most probable subsequent token sequence
-