Skip to content

Commit a995ee8

Browse files
committed
Example of Jaccard.similarity(profile1, profile2)
1 parent 6239d06 commit a995ee8

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/main/java/info/debatty/java/stringsimilarity/Jaccard.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,21 @@ public double similarity(String s1, String s2) {
6969
return similarity(ks.getProfile(s1), ks.getProfile(s2));
7070
}
7171

72+
/**
73+
* Compute and return the Jaccard index similarity between two string profiles.
74+
*
75+
* E.g:
76+
* ks = new KShingling(4)
77+
* profile1 = ks.getProfile("My String")
78+
* profile2 = ks.getProfile("My other string")
79+
* similarity = jaccard.similarity(profile1, profile2)
80+
*
81+
* @param profile1
82+
* @param profile2
83+
* @return
84+
*/
7285
public double similarity(HashMap<String,Integer> profile1,
73-
HashMap<String,Integer> profile2) {
86+
HashMap<String,Integer> profile2) {
7487
Set<String> set1 = profile1.keySet();
7588
Set<String> set2 = profile2.keySet();
7689

src/main/java/info/debatty/java/stringsimilarity/SorensenDice.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
package info.debatty.java.stringsimilarity;
2626

27-
import java.util.HashMap;
2827
import java.util.HashSet;
2928
import java.util.Set;
3029

0 commit comments

Comments
 (0)