public class Cosine extends Object implements NormalizedStringDistance, NormalizedStringSimilarity
Modifier and Type | Field and Description |
---|---|
protected int |
k |
Constructor and Description |
---|
Cosine() |
Cosine(int k)
Implements Cosine Similarity between strings.
|
Modifier and Type | Method and Description |
---|---|
double |
distance(String s1,
String s2) |
protected static double |
dotProduct(int[] profile1,
int[] profile2) |
int |
getK()
Return k, the length of k-shingles (aka n-grams)
|
protected static double |
norm(int[] profile)
Compute the norm L2 : sqrt(Sum_i( v_i²)).
|
double |
similarity(String s1,
String s2)
Compute and return a measure of similarity between 2 strings.
|
public Cosine(int k)
k
- public Cosine()
public double similarity(String s1, String s2)
StringSimilarity
similarity
in interface StringSimilarity
protected static double norm(int[] profile)
profile
- protected static double dotProduct(int[] profile1, int[] profile2)
public double distance(String s1, String s2)
distance
in interface StringDistance
public int getK()
Copyright © 2016. All rights reserved.