Package edu.berkeley.nlp.lm
Interface NgramLanguageModel<W>
- Type Parameters:
W-
- All Known Subinterfaces:
ArrayEncodedNgramLanguageModel<W>,ContextEncodedNgramLanguageModel<W>
- All Known Implementing Classes:
AbstractArrayEncodedNgramLanguageModel,AbstractContextEncodedNgramLanguageModel,AbstractNgramLanguageModel,ArrayEncodedCachingLmWrapper,ArrayEncodedProbBackoffLm,ContextEncodedCachingLmWrapper,ContextEncodedProbBackoffLm,KneserNeyLmReaderCallback,StupidBackoffLm
public interface NgramLanguageModel<W>
Base interface for an n-gram language model, which exposes only inefficient
convenience methods. See
ContextEncodedNgramLanguageModel and
ArrayEncodedNgramLanguageModel for more efficient accessors.- Author:
- adampauls
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionintMaximum size of n-grams stored by the model.floatgetLogProb(List<W> ngram) Scores an n-gram.Each LM must have a WordIndexer which assigns integer IDs to each word W in the language.floatscoreSentence(List<W> sentence) Scores a complete sentence, taking appropriate care with the start- and end-of-sentence symbols.voidsetOovWordLogProb(float logProb) Sets the (log) probability for an OOV word.
-
Method Details
-
getLmOrder
int getLmOrder()Maximum size of n-grams stored by the model.- Returns:
-
getWordIndexer
WordIndexer<W> getWordIndexer()Each LM must have a WordIndexer which assigns integer IDs to each word W in the language.- Returns:
-
scoreSentence
Scores a complete sentence, taking appropriate care with the start- and end-of-sentence symbols. This is a convenience method and will generally be inefficient.- Returns:
-
getLogProb
Scores an n-gram. This is a convenience method and will generally be relatively inefficient. More efficient versions are available inArrayEncodedNgramLanguageModel.getLogProb(int[], int, int)andContextEncodedNgramLanguageModel.getLogProb(long, int, int, edu.berkeley.nlp.lm.ContextEncodedNgramLanguageModel.LmContextInfo). -
setOovWordLogProb
void setOovWordLogProb(float logProb) Sets the (log) probability for an OOV word. Note that this is in general different from the log prob of theunktag probability.
-