public class SNLSH<E> extends java.lang.Object implements NearestNeighborSearch<SNLSH.AbstractSentence,E>, KNNSearch<SNLSH.AbstractSentence,E>, RNNSearch<SNLSH.AbstractSentence,E>
By default, the query object (reference equality) is excluded from the neighborhood.
You may change this behavior with setIdenticalExcluded. Note that
you may observe weird behavior with String objects. JVM will pool the string literal
objects. So the below variables
String a = "ABC";
String b = "ABC";
String c = "AB" + "C";
are actually equal in reference test a == b == c. With toy data that you
type explicitly in the code, this will cause problems. Fortunately, the data would be
read from secondary storage in production.
LSH| Modifier and Type | Class and Description |
|---|---|
static class |
SNLSH.AbstractSentence |
static class |
SNLSH.SimHash |
| Constructor and Description |
|---|
SNLSH(int bandSize) |
| Modifier and Type | Method and Description |
|---|---|
Neighbor<SNLSH.AbstractSentence,E>[] |
knn(SNLSH.AbstractSentence q,
int k)
Search the k nearest neighbors to the query.
|
Neighbor<SNLSH.AbstractSentence,E> |
nearest(SNLSH.AbstractSentence q)
Search the nearest neighbor to the given sample.
|
void |
put(SNLSH.AbstractSentence sentence,
E v) |
void |
range(SNLSH.AbstractSentence q,
double radius,
java.util.List<Neighbor<SNLSH.AbstractSentence,E>> neighbors)
Search the neighbors in the given radius of query object, i.e.
|
public void put(SNLSH.AbstractSentence sentence, E v)
public Neighbor<SNLSH.AbstractSentence,E>[] knn(SNLSH.AbstractSentence q, int k)
KNNSearchknn in interface KNNSearch<SNLSH.AbstractSentence,E>q - the query key.k - the number of nearest neighbors to search for.public Neighbor<SNLSH.AbstractSentence,E> nearest(SNLSH.AbstractSentence q)
NearestNeighborSearchnearest in interface NearestNeighborSearch<SNLSH.AbstractSentence,E>q - the query key.public void range(SNLSH.AbstractSentence q, double radius, java.util.List<Neighbor<SNLSH.AbstractSentence,E>> neighbors)
RNNSearchrange in interface RNNSearch<SNLSH.AbstractSentence,E>q - the query key.radius - the radius of search range from target.neighbors - the list to store found neighbors in the given range on output.