@Immutable public class Cosine extends ShingleBased implements NormalizedStringDistance, NormalizedStringSimilarity
Constructor and Description |
---|
Cosine()
Implements Cosine Similarity between strings.
|
Cosine(int k)
Implements Cosine Similarity between strings.
|
Modifier and Type | Method and Description |
---|---|
double |
distance(String s1,
String s2)
Return 1.0 - similarity.
|
double |
similarity(Map<String,Integer> profile1,
Map<String,Integer> profile2) |
double |
similarity(String s1,
String s2)
Compute the cosine similarity between strings.
|
getK, getProfile
public Cosine(int k)
k
- public Cosine()
public final double similarity(String s1, String s2)
similarity
in interface StringSimilarity
s1
- The first string to compare.s2
- The second string to compare.NullPointerException
- if s1 or s2 is null.public final double distance(String s1, String s2)
distance
in interface StringDistance
s1
- The first string to compare.s2
- The second string to compare.NullPointerException
- if s1 or s2 is null.Copyright © 2017. All rights reserved.