W
- public class StupidBackoffLm<W> extends AbstractArrayEncodedNgramLanguageModel<W> implements ArrayEncodedNgramLanguageModel<W>, java.io.Serializable
LmReaders.createKneserNeyLmFromTextFiles
, this model returns natural
logarithms instead of log10.ArrayEncodedNgramLanguageModel.DefaultImplementations
NgramLanguageModel.StaticMethods
Modifier and Type | Field and Description |
---|---|
protected NgramMap<LongRef> |
map |
lmOrder, oovWordLogProb
Constructor and Description |
---|
StupidBackoffLm(int lmOrder,
WordIndexer<W> wordIndexer,
NgramMap<LongRef> map,
ConfigOptions opts) |
Modifier and Type | Method and Description |
---|---|
float |
getLogProb(int[] ngram)
Equivalent to
getLogProb(ngram, 0, ngram.length) |
float |
getLogProb(int[] ngram,
int startPos,
int endPos)
Calculate language model score of an n-gram.
|
float |
getLogProb(java.util.List<W> ngram)
Scores an n-gram.
|
NgramMap<LongRef> |
getNgramMap() |
long |
getRawCount(int[] ngram,
int startPos,
int endPos)
Gets the raw count of an n-gram.
|
scoreSentence
getLmOrder, getWordIndexer, setOovWordLogProb
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLmOrder, getWordIndexer, scoreSentence, setOovWordLogProb
public StupidBackoffLm(int lmOrder, WordIndexer<W> wordIndexer, NgramMap<LongRef> map, ConfigOptions opts)
public 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>
getLogProb
in class AbstractArrayEncodedNgramLanguageModel<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.public long getRawCount(int[] ngram, int startPos, int endPos)
ngram
- startPos
- endPos
- public float getLogProb(int[] ngram)
ArrayEncodedNgramLanguageModel
getLogProb(ngram, 0, ngram.length)
getLogProb
in interface ArrayEncodedNgramLanguageModel<W>
getLogProb
in class AbstractArrayEncodedNgramLanguageModel<W>
ArrayEncodedNgramLanguageModel.getLogProb(int[], int, int)
public float getLogProb(java.util.List<W> ngram)
NgramLanguageModel
ArrayEncodedNgramLanguageModel.getLogProb(int[], int, int)
and
ContextEncodedNgramLanguageModel.getLogProb(long, int, int, edu.berkeley.nlp.lm.ContextEncodedNgramLanguageModel.LmContextInfo)
.getLogProb
in interface NgramLanguageModel<W>
getLogProb
in class AbstractArrayEncodedNgramLanguageModel<W>