refactor number parsing
This commit is contained in:
parent
9cc353e981
commit
c18478147e
|
@ -1,10 +1,11 @@
|
||||||
package net.filebot.similarity;
|
package net.filebot.similarity;
|
||||||
|
|
||||||
|
import static net.filebot.util.StringUtilities.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import uk.ac.shef.wit.simmetrics.similaritymetrics.AbstractStringMetric;
|
import uk.ac.shef.wit.simmetrics.similaritymetrics.AbstractStringMetric;
|
||||||
import uk.ac.shef.wit.simmetrics.similaritymetrics.QGramsDistance;
|
import uk.ac.shef.wit.simmetrics.similaritymetrics.QGramsDistance;
|
||||||
|
@ -34,8 +35,6 @@ public class NumericSimilarityMetric implements SimilarityMetric {
|
||||||
|
|
||||||
private static class NumberTokeniser implements InterfaceTokeniser {
|
private static class NumberTokeniser implements InterfaceTokeniser {
|
||||||
|
|
||||||
private static final Pattern DIGIT = Pattern.compile("\\d+");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<String> tokenizeToArrayList(String s) {
|
public ArrayList<String> tokenizeToArrayList(String s) {
|
||||||
ArrayList<String> tokens = new ArrayList<String>();
|
ArrayList<String> tokens = new ArrayList<String>();
|
||||||
|
@ -51,7 +50,7 @@ public class NumericSimilarityMetric implements SimilarityMetric {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDelimiters() {
|
public String getDelimiters() {
|
||||||
return "\\D+";
|
return NON_DIGIT.pattern();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue