1
|
package eu.dnetlib.pace.distance;
|
2
|
|
3
|
import com.wcohen.ss.AbstractStringDistance;
|
4
|
|
5
|
/**
|
6
|
* The Class JaroWinklerTitle.
|
7
|
*/
|
8
|
public class JaroWinklerTitle extends SecondStringDistanceAlgo {
|
9
|
|
10
|
/**
|
11
|
* Instantiates a new jaro winkler title.
|
12
|
*
|
13
|
* @param weight
|
14
|
* the weight
|
15
|
*/
|
16
|
public JaroWinklerTitle(final double weight) {
|
17
|
super(weight, new com.wcohen.ss.JaroWinkler());
|
18
|
}
|
19
|
|
20
|
/**
|
21
|
* Instantiates a new jaro winkler title.
|
22
|
*
|
23
|
* @param weight
|
24
|
* the weight
|
25
|
* @param ssalgo
|
26
|
* the ssalgo
|
27
|
*/
|
28
|
protected JaroWinklerTitle(final double weight, final AbstractStringDistance ssalgo) {
|
29
|
super(weight, ssalgo);
|
30
|
}
|
31
|
|
32
|
/*
|
33
|
* (non-Javadoc)
|
34
|
*
|
35
|
* @see eu.dnetlib.pace.distance.SecondStringDistanceAlgo#distance(java.lang.String, java.lang.String)
|
36
|
*/
|
37
|
@Override
|
38
|
public double distance(final String a, final String b) {
|
39
|
String ca = cleanup(a);
|
40
|
String cb = cleanup(b);
|
41
|
|
42
|
boolean check = checkNumbers(ca, cb);
|
43
|
return check ? 0.5 : normalize(ssalgo.score(ca, cb));
|
44
|
}
|
45
|
|
46
|
/*
|
47
|
* (non-Javadoc)
|
48
|
*
|
49
|
* @see eu.dnetlib.pace.distance.DistanceAlgo#getWeight()
|
50
|
*/
|
51
|
@Override
|
52
|
public double getWeight() {
|
53
|
return super.weight;
|
54
|
}
|
55
|
|
56
|
/*
|
57
|
* (non-Javadoc)
|
58
|
*
|
59
|
* @see eu.dnetlib.pace.distance.SecondStringDistanceAlgo#normalize(double)
|
60
|
*/
|
61
|
@Override
|
62
|
protected double normalize(final double d) {
|
63
|
return d;
|
64
|
}
|
65
|
|
66
|
}
|