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.
1 parent 2051c03 commit 35c16deCopy full SHA for 35c16de
src/main/java/info/debatty/java/stringsimilarity/KShingling.java
@@ -3,6 +3,7 @@
3
import java.io.Serializable;
4
import java.security.InvalidParameterException;
5
import java.util.HashSet;
6
+import java.util.regex.Pattern;
7
8
/**
9
* A k-shingling is a set of unique k-grams, used to measure the similarity of
@@ -71,8 +72,9 @@ public final void setK(int k) {
71
72
this.k = k;
73
}
74
75
+ private static final Pattern spaceReg = Pattern.compile("\\s+");
76
public boolean parse(String s) {
- s = s.replaceAll("\\s+", " ");
77
+ s = spaceReg.matcher(s).replaceAll(" ");
78
for (int i = 0; i < (s.length() - k + 1); i++) {
79
this.add(s.substring(i, i+k));
80
0 commit comments