Project

General

Profile

1
package eu.dnetlib.pace.distance.algo;
2

    
3

    
4
public class YearLevenstein extends SubStringLevenstein {
5

    
6
	public YearLevenstein(double w) {
7
		super(w);
8
	}
9

    
10
	public YearLevenstein(double w, int limit) {
11
		super(w, limit);	
12
	}
13
	
14
	@Override
15
	public double distance(String a, String b) {
16
		boolean check = checkLength(a) && checkLength(b);
17
		if (check) {
18
			if (a.equals(b)) {
19
				return 1.0;
20
			} else {
21
				return 0.5;
22
			}
23
		} else {
24
			return 1.0;
25
		}
26
	}
27
	
28
	protected boolean checkLength(String s) {
29
		return getNumbers(s).length() == limit;
30
	}
31
	
32
	@Override
33
	public double getWeight() {
34
		return super.weight;
35
	}
36

    
37
}
(21-21/21)