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 longcalcUniqueHash()doublecompare(LSHVector op2, VectorCompare data)voidcompareCounts(LSHVector op2, VectorCompare data)doublecompareDetail(LSHVector op2, java.lang.StringBuilder buf)booleanequals(java.lang.Object obj)Eclipse-generated equals method.HashEntry[]getEntries()HashEntrygetEntry(int i)doublegetLength()inthashCode()Uses the existingcalcUniqueHash()method to determine hash value.intnumEntries()voidrestoreBase64(java.io.Reader input, char[] buffer, WeightFactory wfactory, IDFLookup idflookup, int[] decode)voidrestoreSQL(java.lang.String sql, WeightFactory wfactory, IDFLookup idflookup)voidrestoreXml(XmlPullParser parser, WeightFactory wfactory, IDFLookup idflookup)voidsaveBase64(java.lang.StringBuilder buffer, char[] encoder)java.lang.StringsaveSQL()voidsaveXml(java.io.Writer fwrite)voidsetHashEntries(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:
hashCodein classjava.lang.Object- Returns:
-
equals
public boolean equals(java.lang.Object obj)
Eclipse-generated equals method. Only the hash attribute is necessary.- Overrides:
equalsin 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:
numEntriesin interfaceLSHVector
-
getEntries
public HashEntry[] getEntries()
- Specified by:
getEntriesin interfaceLSHVector
-
compare
public double compare(LSHVector op2, VectorCompare data)
-
compareCounts
public void compareCounts(LSHVector op2, VectorCompare data)
- Specified by:
compareCountsin interfaceLSHVector
-
compareDetail
public double compareDetail(LSHVector op2, java.lang.StringBuilder buf)
- Specified by:
compareDetailin interfaceLSHVector
-
restoreXml
public void restoreXml(XmlPullParser parser, WeightFactory wfactory, IDFLookup idflookup)
- Specified by:
restoreXmlin interfaceLSHVector
-
restoreSQL
public void restoreSQL(java.lang.String sql, WeightFactory wfactory, IDFLookup idflookup) throws java.io.IOException- Specified by:
restoreSQLin 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:
restoreBase64in 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:
saveBase64in interfaceLSHVector
-
calcUniqueHash
public long calcUniqueHash()
- Specified by:
calcUniqueHashin interfaceLSHVector
-
-