W - public abstract class AbstractContextEncodedNgramLanguageModel<W> extends AbstractNgramLanguageModel<W> implements ContextEncodedNgramLanguageModel<W>, java.io.Serializable
ContextEncodedNgramLanguageModel.getLogProb(long, int, int, LmContextInfo),
{@link #getOffsetForNgram(int[], int, int), and {ContextEncodedNgramLanguageModel.DefaultImplementations, ContextEncodedNgramLanguageModel.LmContextInfoNgramLanguageModel.StaticMethodslmOrder, oovWordLogProb| Constructor and Description |
|---|
AbstractContextEncodedNgramLanguageModel(int lmOrder,
WordIndexer<W> wordIndexer,
float oovWordLogProb) |
| Modifier and Type | Method and Description |
|---|---|
float |
getLogProb(java.util.List<W> phrase)
Scores an n-gram.
|
abstract float |
getLogProb(long contextOffset,
int contextOrder,
int word,
ContextEncodedNgramLanguageModel.LmContextInfo outputContext)
Get the score for an n-gram, and also get the context offset of the
n-gram's suffix.
|
abstract int[] |
getNgramForOffset(long contextOffset,
int contextOrder,
int word)
Gets the n-gram referred to by a context-encoding.
|
abstract ContextEncodedNgramLanguageModel.LmContextInfo |
getOffsetForNgram(int[] ngram,
int startPos,
int endPos)
Gets the offset which refers to 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, setOovWordLogProbclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLmOrder, getWordIndexer, setOovWordLogProbpublic AbstractContextEncodedNgramLanguageModel(int lmOrder,
WordIndexer<W> wordIndexer,
float oovWordLogProb)
public float scoreSentence(java.util.List<W> sentence)
NgramLanguageModelscoreSentence in interface NgramLanguageModel<W>public float getLogProb(java.util.List<W> phrase)
NgramLanguageModelArrayEncodedNgramLanguageModel.getLogProb(int[], int, int) and
ContextEncodedNgramLanguageModel.getLogProb(long, int, int, edu.berkeley.nlp.lm.ContextEncodedNgramLanguageModel.LmContextInfo)
.getLogProb in interface NgramLanguageModel<W>public abstract float getLogProb(long contextOffset,
int contextOrder,
int word,
ContextEncodedNgramLanguageModel.LmContextInfo outputContext)
ContextEncodedNgramLanguageModelgetLogProb in interface ContextEncodedNgramLanguageModel<W>contextOffset - Offset of context (prefix) of an n-gramcontextOrder - The (0-based) length of context (i.e.
order == 0 iff context refers to a
unigram).word - Last word of the n-gramoutputContext - Offset of the suffix of the input n-gram. If the parameter is
null it will be ignored. This can be passed to
future queries for efficient access.public abstract ContextEncodedNgramLanguageModel.LmContextInfo getOffsetForNgram(int[] ngram, int startPos, int endPos)
ContextEncodedNgramLanguageModelgetOffsetForNgram in interface ContextEncodedNgramLanguageModel<W>public abstract int[] getNgramForOffset(long contextOffset,
int contextOrder,
int word)
ContextEncodedNgramLanguageModelgetNgramForOffset in interface ContextEncodedNgramLanguageModel<W>