Package generic.lsh.vector
Class LSHCosineVector
- java.lang.Object
-
- generic.lsh.vector.LSHCosineVector
-
- All Implemented Interfaces:
LSHVector
- Direct Known Subclasses:
LSHCosineVectorAccum
public class LSHCosineVector extends java.lang.Object implements LSHVector
-
-
Constructor Summary
Constructors Constructor Description LSHCosineVector()
LSHCosineVector(int[] feature, WeightFactory wfactory, IDFLookup idflookup)
Install a set of features as an int[].
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
calcUniqueHash()
double
compare(LSHVector op2, VectorCompare data)
void
compareCounts(LSHVector op2, VectorCompare data)
double
compareDetail(LSHVector op2, java.lang.StringBuilder buf)
boolean
equals(java.lang.Object obj)
Eclipse-generated equals method.HashEntry[]
getEntries()
HashEntry
getEntry(int i)
double
getLength()
int
hashCode()
Uses the existingcalcUniqueHash()
method to determine hash value.int
numEntries()
void
restoreBase64(java.io.Reader input, char[] buffer, WeightFactory wfactory, IDFLookup idflookup, int[] decode)
void
restoreSQL(java.lang.String sql, WeightFactory wfactory, IDFLookup idflookup)
void
restoreXml(XmlPullParser parser, WeightFactory wfactory, IDFLookup idflookup)
void
saveBase64(java.lang.StringBuilder buffer, char[] encoder)
java.lang.String
saveSQL()
void
saveXml(java.io.Writer fwrite)
void
setHashEntries(HashEntry[] entries)
Install hashes and weights directly.
-
-
-
Constructor Detail
-
LSHCosineVector
public LSHCosineVector()
-
LSHCosineVector
public LSHCosineVector(int[] feature, WeightFactory wfactory, IDFLookup idflookup)
Install a set of features as an int[]. Each integer is a hash. The integers MUST already be sorted. The same integer can occur more than once in the array (term frequency (TF) > 1). Weights are determined by TF and Inverse Document Frequency (IDF) of individual features- Parameters:
feature
- is the sorted array of integer hasheswfactory
- is the container of weighting informationidflookup
- is the container of IDF information
-
-
Method Detail
-
hashCode
public int hashCode()
Uses the existingcalcUniqueHash()
method to determine hash value.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
-
equals
public boolean equals(java.lang.Object obj)
Eclipse-generated equals method. Only the hash attribute is necessary.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
-- Returns:
-
setHashEntries
public void setHashEntries(HashEntry[] entries)
Install hashes and weights directly. Length is automatically calculated. The entries must already be sorted on the hash- Parameters:
entries
-
-
numEntries
public int numEntries()
- Specified by:
numEntries
in interfaceLSHVector
-
getEntries
public HashEntry[] getEntries()
- Specified by:
getEntries
in interfaceLSHVector
-
compare
public double compare(LSHVector op2, VectorCompare data)
-
compareCounts
public void compareCounts(LSHVector op2, VectorCompare data)
- Specified by:
compareCounts
in interfaceLSHVector
-
compareDetail
public double compareDetail(LSHVector op2, java.lang.StringBuilder buf)
- Specified by:
compareDetail
in interfaceLSHVector
-
restoreXml
public void restoreXml(XmlPullParser parser, WeightFactory wfactory, IDFLookup idflookup)
- Specified by:
restoreXml
in interfaceLSHVector
-
restoreSQL
public void restoreSQL(java.lang.String sql, WeightFactory wfactory, IDFLookup idflookup) throws java.io.IOException
- Specified by:
restoreSQL
in interfaceLSHVector
- Throws:
java.io.IOException
-
restoreBase64
public void restoreBase64(java.io.Reader input, char[] buffer, WeightFactory wfactory, IDFLookup idflookup, int[] decode) throws java.io.IOException
- Specified by:
restoreBase64
in interfaceLSHVector
- Throws:
java.io.IOException
-
saveXml
public void saveXml(java.io.Writer fwrite) throws java.io.IOException
-
saveBase64
public void saveBase64(java.lang.StringBuilder buffer, char[] encoder)
- Specified by:
saveBase64
in interfaceLSHVector
-
calcUniqueHash
public long calcUniqueHash()
- Specified by:
calcUniqueHash
in interfaceLSHVector
-
-