2019-08-09 10:08:34 +02:00
|
|
|
package eu.dnetlib.pace.tree;
|
|
|
|
|
|
|
|
import com.wcohen.ss.AbstractStringDistance;
|
2019-10-29 16:38:42 +01:00
|
|
|
import eu.dnetlib.pace.config.Config;
|
2019-08-09 10:08:34 +02:00
|
|
|
import eu.dnetlib.pace.tree.support.AbstractComparator;
|
|
|
|
import eu.dnetlib.pace.tree.support.ComparatorClass;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
//case class JaroWinkler(w: Double) extends SecondStringDistanceAlgo(w, new com.wcohen.ss.JaroWinkler())
|
|
|
|
@ComparatorClass("jaroWinkler")
|
|
|
|
public class JaroWinkler extends AbstractComparator {
|
|
|
|
|
2019-11-21 09:37:56 +01:00
|
|
|
public JaroWinkler(Map<String, String> params){
|
2019-08-09 10:08:34 +02:00
|
|
|
super(params, new com.wcohen.ss.JaroWinkler());
|
|
|
|
}
|
|
|
|
|
|
|
|
public JaroWinkler(double weight) {
|
|
|
|
super(weight, new com.wcohen.ss.JaroWinkler());
|
|
|
|
}
|
|
|
|
|
|
|
|
protected JaroWinkler(double weight, AbstractStringDistance ssalgo) {
|
|
|
|
super(weight, ssalgo);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-10-29 16:38:42 +01:00
|
|
|
public double distance(String a, String b, final Config conf) {
|
2019-08-09 10:08:34 +02:00
|
|
|
String ca = cleanup(a);
|
|
|
|
String cb = cleanup(b);
|
|
|
|
|
|
|
|
return normalize(ssalgo.score(ca, cb));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public double getWeight() {
|
|
|
|
return super.weight;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected double normalize(double d) {
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|