W - public class ArrayEncodedCachingLmWrapper<W> extends AbstractArrayEncodedNgramLanguageModel<W>
ArrayEncodedNgramLanguageModel with a cache.ArrayEncodedNgramLanguageModel.DefaultImplementationsNgramLanguageModel.StaticMethodslmOrder, oovWordLogProb| Modifier and Type | Method and Description |
|---|---|
float |
getLogProb(int[] ngram,
int startPos,
int endPos)
Calculate language model score of an n-gram.
|
static <W> ArrayEncodedCachingLmWrapper<W> |
wrapWithCacheNotThreadSafe(ArrayEncodedNgramLanguageModel<W> lm)
To use this wrapper in a multithreaded environment, you should create one
wrapper per thread.
|
static <W> ArrayEncodedCachingLmWrapper<W> |
wrapWithCacheNotThreadSafe(ArrayEncodedNgramLanguageModel<W> lm,
int cacheBits) |
static <W> ArrayEncodedCachingLmWrapper<W> |
wrapWithCacheThreadSafe(ArrayEncodedNgramLanguageModel<W> lm)
This type of caching is threadsafe and (internally) maintains a separate
cache for each thread that calls it.
|
static <W> ArrayEncodedCachingLmWrapper<W> |
wrapWithCacheThreadSafe(ArrayEncodedNgramLanguageModel<W> lm,
int cacheBits) |
getLogProb, getLogProb, scoreSentencegetLmOrder, getWordIndexer, setOovWordLogProbclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLmOrder, getWordIndexer, setOovWordLogProbpublic static <W> ArrayEncodedCachingLmWrapper<W> wrapWithCacheNotThreadSafe(ArrayEncodedNgramLanguageModel<W> lm)
T - lm - public static <W> ArrayEncodedCachingLmWrapper<W> wrapWithCacheNotThreadSafe(ArrayEncodedNgramLanguageModel<W> lm, int cacheBits)
public static <W> ArrayEncodedCachingLmWrapper<W> wrapWithCacheThreadSafe(ArrayEncodedNgramLanguageModel<W> lm)
W - lm - public static <W> ArrayEncodedCachingLmWrapper<W> wrapWithCacheThreadSafe(ArrayEncodedNgramLanguageModel<W> lm, int cacheBits)
public float getLogProb(int[] ngram,
int startPos,
int endPos)
ArrayEncodedNgramLanguageModelgetLmOrder(),
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.