Skip to content

Commit

Permalink
Add qGram.distance(profile1, profile2). Fix issue #32
Browse files Browse the repository at this point in the history
  • Loading branch information
tdebatty committed Feb 2, 2017
1 parent d20cc9d commit 0ba9ffa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/info/debatty/java/stringsimilarity/QGram.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ public final double distance(final String s1, final String s2) {
Map<String, Integer> profile1 = getProfile(s1);
Map<String, Integer> profile2 = getProfile(s2);

return distance(profile1, profile2);
}

/**
* Compute QGram distance using precomputed profiles.
*
* @param profile1
* @param profile2
* @return
*/
public final double distance(
final Map<String, Integer> profile1,
final Map<String, Integer> profile2) {

Set<String> union = new HashSet<String>();
union.addAll(profile1.keySet());
union.addAll(profile2.keySet());
Expand Down

0 comments on commit 0ba9ffa

Please sign in to comment.