W
- public class ArrayEncodedProbBackoffLm<W> extends AbstractArrayEncodedNgramLanguageModel<W> implements ArrayEncodedNgramLanguageModel<W>, java.io.Serializable
ContextEncodedProbBackoffLm
,
which stores a trie for which the last word points to its suffix. This was
done because it simplifies the code significantly, without significantly
changing speed or memory usage.ArrayEncodedNgramLanguageModel.DefaultImplementations
NgramLanguageModel.StaticMethods
lmOrder, oovWordLogProb
Constructor and Description |
---|
ArrayEncodedProbBackoffLm(int lmOrder,
WordIndexer<W> wordIndexer,
NgramMap<ProbBackoffPair> 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<ProbBackoffPair> |
getNgramMap() |
scoreSentence
getLmOrder, getWordIndexer, setOovWordLogProb
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLmOrder, getWordIndexer, scoreSentence, setOovWordLogProb
public ArrayEncodedProbBackoffLm(int lmOrder, WordIndexer<W> wordIndexer, NgramMap<ProbBackoffPair> 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 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>
public NgramMap<ProbBackoffPair> getNgramMap()