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. SeeContextEncodedNgramLanguageModelandArrayEncodedNgramLanguageModelfor more efficient accessors.- Author:
- adampauls
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classNgramLanguageModel.StaticMethods
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intgetLmOrder()Maximum size of n-grams stored by the model.floatgetLogProb(java.util.List<W> ngram)Scores an n-gram.WordIndexer<W>getWordIndexer()Each LM must have a WordIndexer which assigns integer IDs to each word W in the language.floatscoreSentence(java.util.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 Detail
-
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
float scoreSentence(java.util.List<W> sentence)
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
float getLogProb(java.util.List<W> ngram)
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.
-
-