Package edu.berkeley.nlp.lm
Class ContextEncodedProbBackoffLm<W>
java.lang.Object
edu.berkeley.nlp.lm.AbstractNgramLanguageModel<W>
edu.berkeley.nlp.lm.AbstractContextEncodedNgramLanguageModel<W>
edu.berkeley.nlp.lm.ContextEncodedProbBackoffLm<W>
- Type Parameters:
W-
- All Implemented Interfaces:
ContextEncodedNgramLanguageModel<W>,NgramLanguageModel<W>,Serializable
public class ContextEncodedProbBackoffLm<W>
extends AbstractContextEncodedNgramLanguageModel<W>
implements ContextEncodedNgramLanguageModel<W>, Serializable
Language model implementation which uses Kneser-Ney style backoff
computation.
- Author:
- adampauls
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface edu.berkeley.nlp.lm.ContextEncodedNgramLanguageModel
ContextEncodedNgramLanguageModel.DefaultImplementations, ContextEncodedNgramLanguageModel.LmContextInfoNested classes/interfaces inherited from interface edu.berkeley.nlp.lm.NgramLanguageModel
NgramLanguageModel.StaticMethods -
Field Summary
Fields inherited from class edu.berkeley.nlp.lm.AbstractNgramLanguageModel
lmOrder, oovWordLogProb -
Constructor Summary
ConstructorsConstructorDescriptionContextEncodedProbBackoffLm(int lmOrder, WordIndexer<W> wordIndexer, ContextEncodedNgramMap<ProbBackoffPair> map, ConfigOptions opts) -
Method Summary
Modifier and TypeMethodDescriptionfloatgetLogProb(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.int[]getNgramForOffset(long contextOffset, int contextOrder, int word) Gets the n-gram referred to by a context-encoding.getOffsetForNgram(int[] ngram, int startPos, int endPos) Gets the offset which refers to an n-gram.Methods inherited from class edu.berkeley.nlp.lm.AbstractContextEncodedNgramLanguageModel
getLogProb, scoreSentenceMethods inherited from class edu.berkeley.nlp.lm.AbstractNgramLanguageModel
getLmOrder, getWordIndexer, setOovWordLogProbMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.berkeley.nlp.lm.NgramLanguageModel
getLmOrder, getLogProb, getWordIndexer, scoreSentence, setOovWordLogProb
-
Constructor Details
-
ContextEncodedProbBackoffLm
public ContextEncodedProbBackoffLm(int lmOrder, WordIndexer<W> wordIndexer, ContextEncodedNgramMap<ProbBackoffPair> map, ConfigOptions opts)
-
-
Method Details
-
getLogProb
public float getLogProb(long contextOffset, int contextOrder, int word, ContextEncodedNgramLanguageModel.LmContextInfo outputContext) Description copied from interface:ContextEncodedNgramLanguageModelGet the score for an n-gram, and also get the context offset of the n-gram's suffix.- Specified by:
getLogProbin interfaceContextEncodedNgramLanguageModel<W>- Specified by:
getLogProbin classAbstractContextEncodedNgramLanguageModel<W>- Parameters:
contextOffset- Offset of context (prefix) of an n-gramcontextOrder- The (0-based) length ofcontext(i.e.order == 0iffcontextrefers to a unigram).word- Last word of the n-gramoutputContext- Offset of the suffix of the input n-gram. If the parameter isnullit will be ignored. This can be passed to future queries for efficient access.- Returns:
-
getOffsetForNgram
public ContextEncodedNgramLanguageModel.LmContextInfo getOffsetForNgram(int[] ngram, int startPos, int endPos) Description copied from interface:ContextEncodedNgramLanguageModelGets the offset which refers to an n-gram. If the n-gram is not in the model, then it returns the shortest suffix of the n-gram which is. This operation is not necessarily fast.- Specified by:
getOffsetForNgramin interfaceContextEncodedNgramLanguageModel<W>- Specified by:
getOffsetForNgramin classAbstractContextEncodedNgramLanguageModel<W>
-
getNgramForOffset
public int[] getNgramForOffset(long contextOffset, int contextOrder, int word) Description copied from interface:ContextEncodedNgramLanguageModelGets the n-gram referred to by a context-encoding. This operation is not necessarily fast.- Specified by:
getNgramForOffsetin interfaceContextEncodedNgramLanguageModel<W>- Specified by:
getNgramForOffsetin classAbstractContextEncodedNgramLanguageModel<W>
-
getNgramMap
-