W
- public class ContextEncodedCachingLmWrapper<T> extends AbstractContextEncodedNgramLanguageModel<T>
ContextEncodedNgramLanguageModel
with a cache.ContextEncodedNgramLanguageModel.DefaultImplementations, ContextEncodedNgramLanguageModel.LmContextInfo
NgramLanguageModel.StaticMethods
lmOrder, oovWordLogProb
Modifier and Type | Method and Description |
---|---|
float |
getLogProb(long contextOffset,
int contextOrder,
int word,
ContextEncodedNgramLanguageModel.LmContextInfo contextOutput)
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.
|
ContextEncodedNgramLanguageModel.LmContextInfo |
getOffsetForNgram(int[] ngram,
int startPos,
int endPos)
Gets the offset which refers to an n-gram.
|
WordIndexer<T> |
getWordIndexer()
Each LM must have a WordIndexer which assigns integer IDs to each word W
in the language.
|
static <T> ContextEncodedCachingLmWrapper<T> |
wrapWithCacheNotThreadSafe(ContextEncodedNgramLanguageModel<T> lm)
This type of caching is only threadsafe if you have one cache wrapper per
thread.
|
static <T> ContextEncodedCachingLmWrapper<T> |
wrapWithCacheNotThreadSafe(ContextEncodedNgramLanguageModel<T> lm,
int cacheBits) |
static <T> ContextEncodedCachingLmWrapper<T> |
wrapWithCacheThreadSafe(ContextEncodedNgramLanguageModel<T> lm)
This type of caching is threadsafe and (internally) maintains a separate
cache for each thread that calls it.
|
static <T> ContextEncodedCachingLmWrapper<T> |
wrapWithCacheThreadSafe(ContextEncodedNgramLanguageModel<T> lm,
int cacheBits) |
getLogProb, scoreSentence
getLmOrder, setOovWordLogProb
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLmOrder, setOovWordLogProb
public static <T> ContextEncodedCachingLmWrapper<T> wrapWithCacheNotThreadSafe(ContextEncodedNgramLanguageModel<T> lm)
T
- lm
- public static <T> ContextEncodedCachingLmWrapper<T> wrapWithCacheNotThreadSafe(ContextEncodedNgramLanguageModel<T> lm, int cacheBits)
public static <T> ContextEncodedCachingLmWrapper<T> wrapWithCacheThreadSafe(ContextEncodedNgramLanguageModel<T> lm)
T
- lm
- public static <T> ContextEncodedCachingLmWrapper<T> wrapWithCacheThreadSafe(ContextEncodedNgramLanguageModel<T> lm, int cacheBits)
public WordIndexer<T> getWordIndexer()
NgramLanguageModel
getWordIndexer
in interface NgramLanguageModel<T>
getWordIndexer
in class AbstractNgramLanguageModel<T>
public ContextEncodedNgramLanguageModel.LmContextInfo getOffsetForNgram(int[] ngram, int startPos, int endPos)
ContextEncodedNgramLanguageModel
getOffsetForNgram
in interface ContextEncodedNgramLanguageModel<T>
getOffsetForNgram
in class AbstractContextEncodedNgramLanguageModel<T>
public int[] getNgramForOffset(long contextOffset, int contextOrder, int word)
ContextEncodedNgramLanguageModel
getNgramForOffset
in interface ContextEncodedNgramLanguageModel<T>
getNgramForOffset
in class AbstractContextEncodedNgramLanguageModel<T>
public float getLogProb(long contextOffset, int contextOrder, int word, ContextEncodedNgramLanguageModel.LmContextInfo contextOutput)
ContextEncodedNgramLanguageModel
getLogProb
in interface ContextEncodedNgramLanguageModel<T>
getLogProb
in class AbstractContextEncodedNgramLanguageModel<T>
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-gramcontextOutput
- 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.