We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 4f03e34 + 25ac055 commit 2b2930eCopy full SHA for 2b2930e
src/main/java/info/debatty/java/stringsimilarity/KShingling.java
@@ -4,7 +4,7 @@
4
import java.security.InvalidParameterException;
5
import java.util.ArrayList;
6
import java.util.HashSet;
7
-import java.util.Set;
+import java.util.regex.Pattern;
8
9
/**
10
* A k-shingling is a set of unique k-grams, used to measure the similarity of
@@ -73,8 +73,9 @@ public final void setK(int k) {
73
this.k = k;
74
}
75
76
+ private static final Pattern spaceReg = Pattern.compile("\\s+");
77
public boolean parse(String s) {
- s = s.replaceAll("\\s+", " ");
78
+ s = spaceReg.matcher(s).replaceAll(" ");
79
for (int i = 0; i < (s.length() - k + 1); i++) {
80
this.add(s.substring(i, i+k));
81
0 commit comments