Package edu.berkeley.nlp.lm
Interface ArrayEncodedNgramLanguageModel<W>
- All Superinterfaces:
NgramLanguageModel<W>
- All Known Implementing Classes:
AbstractArrayEncodedNgramLanguageModel
,ArrayEncodedCachingLmWrapper
,ArrayEncodedProbBackoffLm
,KneserNeyLmReaderCallback
,StupidBackoffLm
Top-level interface for an n-gram language model which accepts n-gram in an
array-of-integers encoding. The integers represent words of type
W
in the vocabulary, and the mapping from the vocabulary to
integers is managed by an instance of the WordIndexer
class.- Author:
- adampauls
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Nested classes/interfaces inherited from interface edu.berkeley.nlp.lm.NgramLanguageModel
NgramLanguageModel.StaticMethods
-
Method Summary
Modifier and TypeMethodDescriptionfloat
getLogProb
(int[] ngram) Equivalent togetLogProb(ngram, 0, ngram.length)
float
getLogProb
(int[] ngram, int startPos, int endPos) Calculate language model score of an n-gram.Methods inherited from interface edu.berkeley.nlp.lm.NgramLanguageModel
getLmOrder, getLogProb, getWordIndexer, scoreSentence, setOovWordLogProb
-
Method Details
-
getLogProb
float getLogProb(int[] ngram, int startPos, int endPos) Calculate language model score of an n-gram. Warning: if you pass in an n-gram of length greater thangetLmOrder()
, this call will silently ignore the extra words of context. In other words, if you pass in a 5-gram (endPos-startPos == 5
) to a 3-gram model, it will only score the words fromstartPos + 2
toendPos
.- Parameters:
ngram
- array of words in integer representationstartPos
- start of the portion of the array to be readendPos
- end of the portion of the array to be read.- Returns:
-
getLogProb
float getLogProb(int[] ngram) Equivalent togetLogProb(ngram, 0, ngram.length)
- See Also:
-