W
- public abstract class AbstractArrayEncodedNgramLanguageModel<W> extends AbstractNgramLanguageModel<W> implements ArrayEncodedNgramLanguageModel<W>, java.io.Serializable
getLogProb(int[], int, int)
.ArrayEncodedNgramLanguageModel.DefaultImplementations
NgramLanguageModel.StaticMethods
lmOrder, oovWordLogProb
Constructor and Description |
---|
AbstractArrayEncodedNgramLanguageModel(int lmOrder,
WordIndexer<W> wordIndexer,
float oovWordLogProb) |
Modifier and Type | Method and Description |
---|---|
float |
getLogProb(int[] ngram)
Equivalent to
getLogProb(ngram, 0, ngram.length) |
abstract float |
getLogProb(int[] ngram,
int startPos,
int endPos)
Calculate language model score of an n-gram.
|
float |
getLogProb(java.util.List<W> phrase)
Scores an n-gram.
|
float |
scoreSentence(java.util.List<W> sentence)
Scores a complete sentence, taking appropriate care with the start- and
end-of-sentence symbols.
|
getLmOrder, getWordIndexer, setOovWordLogProb
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLmOrder, getWordIndexer, setOovWordLogProb
public AbstractArrayEncodedNgramLanguageModel(int lmOrder, WordIndexer<W> wordIndexer, float oovWordLogProb)
public float scoreSentence(java.util.List<W> sentence)
NgramLanguageModel
scoreSentence
in interface NgramLanguageModel<W>
public float getLogProb(java.util.List<W> phrase)
NgramLanguageModel
ArrayEncodedNgramLanguageModel.getLogProb(int[], int, int)
and
ContextEncodedNgramLanguageModel.getLogProb(long, int, int, edu.berkeley.nlp.lm.ContextEncodedNgramLanguageModel.LmContextInfo)
.getLogProb
in interface NgramLanguageModel<W>
public float getLogProb(int[] ngram)
ArrayEncodedNgramLanguageModel
getLogProb(ngram, 0, ngram.length)
getLogProb
in interface ArrayEncodedNgramLanguageModel<W>
ArrayEncodedNgramLanguageModel.getLogProb(int[], int, int)
public abstract float getLogProb(int[] ngram, int startPos, int endPos)
ArrayEncodedNgramLanguageModel
getLmOrder()
,
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 from startPos + 2
to endPos
.getLogProb
in interface ArrayEncodedNgramLanguageModel<W>
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.