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.LmContextInfo
NgramLanguageModel.StaticMethods
lmOrder, 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, setOovWordLogProb
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLmOrder, getWordIndexer, setOovWordLogProb
public AbstractContextEncodedNgramLanguageModel(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 abstract float getLogProb(long contextOffset, int contextOrder, int word, ContextEncodedNgramLanguageModel.LmContextInfo outputContext)
ContextEncodedNgramLanguageModel
getLogProb
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)
ContextEncodedNgramLanguageModel
getOffsetForNgram
in interface ContextEncodedNgramLanguageModel<W>
public abstract int[] getNgramForOffset(long contextOffset, int contextOrder, int word)
ContextEncodedNgramLanguageModel
getNgramForOffset
in interface ContextEncodedNgramLanguageModel<W>