@DefaultImplementation(value=CosineVectorSimilarity.class) public interface VectorSimilarity
Compute the similarity between sparse vectors.
Modifier and Type | Method and Description |
---|---|
boolean |
isSparse()
Query whether this similarity function is sparse (returns 0 for vectors with disjoint key sets).
|
boolean |
isSymmetric()
Query whether this similarity function is symmetric.
|
double |
similarity(SparseVector vec1,
SparseVector vec2)
Compute the similarity between two vectors.
|
double similarity(SparseVector vec1, SparseVector vec2)
Compute the similarity between two vectors.
vec1
- The left vector to compare.vec2
- The right vector to compare.boolean isSparse()
Query whether this similarity function is sparse (returns 0 for vectors with disjoint key sets).
true
iff similarity(SparseVector, SparseVector)
will always return true when applied to two vectors with no keys in common.boolean isSymmetric()
Query whether this similarity function is symmetric. Symmetric similarity functions return the same result when called on (A,B) and (B,A).
true
if the function is symmetric.