Package edu.berkeley.nlp.lm.values
Interface ValueContainer<V>
- Type Parameters:
V-
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
CompressibleValueContainer<V>,ProbBackoffValueContainer
- All Known Implementing Classes:
CompressibleProbBackoffValueContainer,CountValueContainer,KneserNeyCountValueContainer,PhraseTableValueContainer,UncompressedProbBackoffValueContainer,UnrankedUncompressedProbBackoffValueContainer
Manages storage of arbitrary values in an NgramMap
- Author:
- adampauls
-
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(int[] ngram, int startPos, int endPos, int ngramOrder, long offset, long contextOffset, int word, V val, long suffixOffset, boolean ngramIsNew) Adds a new value at the specified offset.voidclearStorageForOrder(int ngramOrder) createFreshValues(long[] numNgramsForEachOrder) Creates a fresh value container for copying purposes.voidgetFromOffset(long offset, int ngramOrder, V outputVal) Gets the value living at a particular offset.Creates a fresh value of object (useful for passing as an output parameter)intnumValueBits(int ngramOrder) voidsetFromOtherValues(ValueContainer<V> other) Destructively sets internal storage from another object.voidInitializes a value container with the map that contains itvoidsetSizeAtLeast(long size, int ngramOrder) Sets internal storage for size for a particular n-gram orderbooleanvoidtrim()Final clean up of storage.voidtrimAfterNgram(int ngramOrder, long size) Clear storage after an n-gram order is complete
-
Method Details
-
add
boolean add(int[] ngram, int startPos, int endPos, int ngramOrder, long offset, long contextOffset, int word, V val, long suffixOffset, boolean ngramIsNew) Adds a new value at the specified offset.- Parameters:
ngramOrder- As always, ngramOrder is 0-based (0=unigram)offset-contextOffset-word-val-suffixOffset-- Returns:
- Whether or not the add was successful
-
setSizeAtLeast
void setSizeAtLeast(long size, int ngramOrder) Sets internal storage for size for a particular n-gram order- Parameters:
size-ngramOrder-
-
createFreshValues
Creates a fresh value container for copying purposes.- Returns:
-
getFromOffset
Gets the value living at a particular offset.- Parameters:
offset-ngramOrder-
-
setFromOtherValues
Destructively sets internal storage from another object.- Parameters:
other-
-
trimAfterNgram
void trimAfterNgram(int ngramOrder, long size) Clear storage after an n-gram order is complete- Parameters:
ngramOrder-size-
-
trim
void trim()Final clean up of storage. -
getScratchValue
V getScratchValue()Creates a fresh value of object (useful for passing as an output parameter)- Returns:
-
setMap
Initializes a value container with the map that contains it -
clearStorageForOrder
void clearStorageForOrder(int ngramOrder) -
storeSuffixoffsets
boolean storeSuffixoffsets() -
numValueBits
int numValueBits(int ngramOrder)
-