2019-08-09 10:08:34 +02:00
|
|
|
package eu.dnetlib.pace.tree;
|
|
|
|
|
|
|
|
import com.wcohen.ss.AbstractStringDistance;
|
|
|
|
import eu.dnetlib.pace.tree.support.AbstractComparator;
|
|
|
|
import eu.dnetlib.pace.tree.support.ComparatorClass;
|
2019-10-08 14:53:52 +02:00
|
|
|
import eu.dnetlib.pace.config.Config;
|
2019-08-09 10:08:34 +02:00
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
@ComparatorClass("mustBeDifferent")
|
|
|
|
public class MustBeDifferent extends AbstractComparator {
|
|
|
|
|
2019-11-21 09:37:56 +01:00
|
|
|
public MustBeDifferent(Map<String,String> params){
|
2019-08-09 10:08:34 +02:00
|
|
|
super(params, new com.wcohen.ss.Levenstein());
|
|
|
|
}
|
|
|
|
|
|
|
|
public MustBeDifferent(final double weight) {
|
|
|
|
super(weight, new com.wcohen.ss.JaroWinkler());
|
|
|
|
}
|
|
|
|
|
|
|
|
protected MustBeDifferent(final double weight, final AbstractStringDistance ssalgo) {
|
|
|
|
super(weight, ssalgo);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-10-08 14:53:52 +02:00
|
|
|
public double distance(final String a, final String b, final Config conf) {
|
2019-08-09 10:08:34 +02:00
|
|
|
return !a.equals(b) ? 1.0 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public double getWeight() {
|
|
|
|
return super.weight;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected double normalize(final double d) {
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|