Skip to content

Commit 289e082

Browse files
committed
Fix issue #35
1 parent 5159b4e commit 289e082

File tree

1 file changed

+3
-7
lines changed
  • src/main/java/info/debatty/java/stringsimilarity

1 file changed

+3
-7
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,13 @@ public final double similarity(final String s1, final String s2) {
9191
Map<String, Integer> profile1 = getProfile(s1);
9292
Map<String, Integer> profile2 = getProfile(s2);
9393

94+
9495
Set<String> union = new HashSet<String>();
9596
union.addAll(profile1.keySet());
9697
union.addAll(profile2.keySet());
9798

98-
int inter = 0;
99-
100-
for (String key : union) {
101-
if (profile1.containsKey(key) && profile2.containsKey(key)) {
102-
inter++;
103-
}
104-
}
99+
int inter = profile1.keySet().size() + profile2.keySet().size()
100+
- union.size();
105101

106102
return 1.0 * inter / union.size();
107103
}

0 commit comments

Comments
 (0)