Package generic.lsh.vector
Class WeightFactory
- java.lang.Object
-
- generic.lsh.vector.WeightFactory
-
public class WeightFactory extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description WeightFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetAddend()doublegetCoeff(short i, short t)Given an IDF position and a TF count, build the feature coefficientdoublegetDiffNorm0()doublegetDiffNorm1()doublegetFlipNorm0()doublegetFlipNorm1()intgetIDFSize()doublegetIDFWeight(short val)doublegetScale()intgetSize()intgetTFSize()doublegetTFWeight(short val)doublegetWeightNorm()voidrestoreXml(XmlPullParser parser)Build (deserialize) this object from an XML streamvoidsaveXml(java.io.Writer fwrite)Serialize this object as XML to a Writervoidset(double[] weightArray)Initialize the WeightTable from an array of doublesvoidsetLogarithmicTFWeights()double[]toArray()Condense weight table down to array of doubles
-
-
-
Method Detail
-
getIDFSize
public final int getIDFSize()
- Returns:
- number of weights in the IDF portion of the table
-
getTFSize
public final int getTFSize()
- Returns:
- number of weights in the TF portion of the table
-
getSize
public final int getSize()
- Returns:
- number of floating-point entries needed to serialize the factory
-
getIDFWeight
public final double getIDFWeight(short val)
- Parameters:
val-- Returns:
- the IDF weight at the given position
-
getTFWeight
public final double getTFWeight(short val)
- Parameters:
val- is the term count (-1)- Returns:
- the TF weight for the given count
-
getCoeff
public final double getCoeff(short i, short t)Given an IDF position and a TF count, build the feature coefficient- Parameters:
i- is the IDF positiont- is the TF count- Returns:
- the feature coefficient
-
getWeightNorm
public final double getWeightNorm()
- Returns:
- the weight normalization factor
-
getFlipNorm0
public final double getFlipNorm0()
- Returns:
- the first feature flip penalty parameter
-
getDiffNorm0
public final double getDiffNorm0()
- Returns:
- the first feature drop penalty parameter
-
getFlipNorm1
public final double getFlipNorm1()
- Returns:
- the second feature flip penalty parameter
-
getDiffNorm1
public final double getDiffNorm1()
- Returns:
- the second feature drop penalty parameter
-
getScale
public final double getScale()
- Returns:
- the final score scaling factor
-
getAddend
public final double getAddend()
- Returns:
- the final score addend
-
setLogarithmicTFWeights
public void setLogarithmicTFWeights()
-
saveXml
public void saveXml(java.io.Writer fwrite) throws java.io.IOExceptionSerialize this object as XML to a Writer- Parameters:
fwrite- is the Writer- Throws:
java.io.IOException
-
toArray
public double[] toArray()
Condense weight table down to array of doubles- Returns:
- array of doubles
-
set
public void set(double[] weightArray)
Initialize the WeightTable from an array of doubles- Parameters:
weightArray-
-
restoreXml
public void restoreXml(XmlPullParser parser)
Build (deserialize) this object from an XML stream- Parameters:
parser- is the XML parser
-
-