Package edu.berkeley.nlp.lm
Interface ArrayEncodedNgramLanguageModel<W>
-
- All Superinterfaces:
NgramLanguageModel<W>
- All Known Implementing Classes:
AbstractArrayEncodedNgramLanguageModel
,ArrayEncodedCachingLmWrapper
,ArrayEncodedProbBackoffLm
,KneserNeyLmReaderCallback
,StupidBackoffLm
public interface ArrayEncodedNgramLanguageModel<W> extends NgramLanguageModel<W>
Top-level interface for an n-gram language model which accepts n-gram in an array-of-integers encoding. The integers represent words of typeW
in the vocabulary, and the mapping from the vocabulary to integers is managed by an instance of theWordIndexer
class.- Author:
- adampauls
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ArrayEncodedNgramLanguageModel.DefaultImplementations
-
Nested classes/interfaces inherited from interface edu.berkeley.nlp.lm.NgramLanguageModel
NgramLanguageModel.StaticMethods
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description float
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 Detail
-
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:
getLogProb(int[], int, int)
-
-