Package edu.berkeley.nlp.lm.values
Class UnrankedUncompressedProbBackoffValueContainer
java.lang.Object
edu.berkeley.nlp.lm.values.UnrankedUncompressedProbBackoffValueContainer
- All Implemented Interfaces:
ProbBackoffValueContainer
,ValueContainer<ProbBackoffPair>
,Serializable
public final class UnrankedUncompressedProbBackoffValueContainer
extends Object
implements ProbBackoffValueContainer
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionUnrankedUncompressedProbBackoffValueContainer
(boolean storePrefixes, long[] numNgramsForEachOrder) -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(int[] ngram, int startPos, int endPos, int ngramOrder, long offset, long contextOffset, int word, ProbBackoffPair val_, long suffixOffset, boolean ngramIsNew) Adds a new value at the specified offset.void
clearStorageForOrder
(int ngramOrder) createFreshValues
(long[] numNgramsForEachOrder_) Creates a fresh value container for copying purposes.final float
getBackoff
(int ngramOrder, long index) void
getFromOffset
(long index, int ngramOrder, ProbBackoffPair outputVal) Gets the value living at a particular offset.final float
getProb
(int ngramOrder, long index) Creates a fresh value of object (useful for passing as an output parameter)long
getSuffixOffset
(long index, int ngramOrder) int
numValueBits
(int ngramOrder) void
Destructively sets internal storage from another object.void
setMap
(NgramMap<ProbBackoffPair> map) Initializes a value container with the map that contains itvoid
setSizeAtLeast
(long size, int ngramOrder) Sets internal storage for size for a particular n-gram orderboolean
void
trim()
Final clean up of storage.void
trimAfterNgram
(int ngramOrder, long size) Clear storage after an n-gram order is complete
-
Constructor Details
-
UnrankedUncompressedProbBackoffValueContainer
public UnrankedUncompressedProbBackoffValueContainer(boolean storePrefixes, long[] numNgramsForEachOrder)
-
-
Method Details
-
createFreshValues
public UnrankedUncompressedProbBackoffValueContainer createFreshValues(long[] numNgramsForEachOrder_) Description copied from interface:ValueContainer
Creates a fresh value container for copying purposes.- Specified by:
createFreshValues
in interfaceValueContainer<ProbBackoffPair>
- Returns:
-
getProb
public final float getProb(int ngramOrder, long index) - Specified by:
getProb
in interfaceProbBackoffValueContainer
-
getFromOffset
Description copied from interface:ValueContainer
Gets the value living at a particular offset.- Specified by:
getFromOffset
in interfaceValueContainer<ProbBackoffPair>
- Parameters:
index
-ngramOrder
-
-
getBackoff
public final float getBackoff(int ngramOrder, long index) - Specified by:
getBackoff
in interfaceProbBackoffValueContainer
-
getScratchValue
Description copied from interface:ValueContainer
Creates a fresh value of object (useful for passing as an output parameter)- Specified by:
getScratchValue
in interfaceProbBackoffValueContainer
- Specified by:
getScratchValue
in interfaceValueContainer<ProbBackoffPair>
- Returns:
-
setFromOtherValues
Description copied from interface:ValueContainer
Destructively sets internal storage from another object.- Specified by:
setFromOtherValues
in interfaceValueContainer<ProbBackoffPair>
- Parameters:
other
-
-
trim
public void trim()Description copied from interface:ValueContainer
Final clean up of storage.- Specified by:
trim
in interfaceValueContainer<ProbBackoffPair>
-
storeSuffixoffsets
public boolean storeSuffixoffsets()- Specified by:
storeSuffixoffsets
in interfaceValueContainer<ProbBackoffPair>
-
numValueBits
public int numValueBits(int ngramOrder) - Specified by:
numValueBits
in interfaceValueContainer<ProbBackoffPair>
-
add
public boolean add(int[] ngram, int startPos, int endPos, int ngramOrder, long offset, long contextOffset, int word, ProbBackoffPair val_, long suffixOffset, boolean ngramIsNew) Description copied from interface:ValueContainer
Adds a new value at the specified offset.- Specified by:
add
in interfaceValueContainer<ProbBackoffPair>
- Parameters:
ngramOrder
- As always, ngramOrder is 0-based (0=unigram)offset
-contextOffset
-word
-val_
-suffixOffset
-- Returns:
- Whether or not the add was successful
-
setSizeAtLeast
public void setSizeAtLeast(long size, int ngramOrder) Description copied from interface:ValueContainer
Sets internal storage for size for a particular n-gram order- Specified by:
setSizeAtLeast
in interfaceValueContainer<ProbBackoffPair>
- Parameters:
size
-ngramOrder
-
-
getSuffixOffset
public long getSuffixOffset(long index, int ngramOrder) - Specified by:
getSuffixOffset
in interfaceProbBackoffValueContainer
-
trimAfterNgram
public void trimAfterNgram(int ngramOrder, long size) Description copied from interface:ValueContainer
Clear storage after an n-gram order is complete- Specified by:
trimAfterNgram
in interfaceValueContainer<ProbBackoffPair>
- Parameters:
ngramOrder
-size
-
-
setMap
Description copied from interface:ValueContainer
Initializes a value container with the map that contains it- Specified by:
setMap
in interfaceValueContainer<ProbBackoffPair>
-
clearStorageForOrder
public void clearStorageForOrder(int ngramOrder) - Specified by:
clearStorageForOrder
in interfaceValueContainer<ProbBackoffPair>
-