1
|
|
|
package br.ufrj.ppgi.greco.kettle.silk; |
2
|
|
|
|
3
|
|
|
import java.util.ArrayList; |
4
|
|
|
import java.util.LinkedHashMap; |
5
|
|
|
import java.util.List; |
6
|
|
|
|
7
|
|
|
import javax.xml.bind.annotation.XmlElement; |
8
|
|
|
import javax.xml.bind.annotation.XmlRootElement; |
9
|
|
|
import javax.xml.bind.annotation.XmlTransient; |
10
|
|
|
import javax.xml.bind.annotation.XmlAttribute; |
11
|
|
|
|
12
|
|
|
@XmlRootElement(name = "Compare") |
13
|
|
|
public class Metric { |
14
|
|
|
|
15
|
|
|
@XmlAttribute |
16
|
|
|
private String id; |
17
|
|
|
|
18
|
|
|
@XmlAttribute |
19
|
|
|
private String required; |
20
|
|
|
|
21
|
|
|
@XmlAttribute |
22
|
|
|
private String weight; |
23
|
|
|
|
24
|
|
|
@XmlAttribute |
25
|
|
|
private String metric; |
26
|
|
|
|
27
|
|
|
@XmlAttribute |
28
|
|
|
private String threshold; |
29
|
|
|
|
30
|
|
|
@XmlAttribute |
31
|
|
|
private String indexing; |
32
|
|
|
|
33
|
|
|
@XmlElement(name = "Input") |
34
|
|
|
private List<Input> inputs = new ArrayList<>(); |
35
|
|
|
|
36
|
|
|
@XmlElement(name = "Param") |
37
|
|
|
private List<Param> params = new ArrayList<>(); |
38
|
|
|
|
39
|
|
|
@XmlTransient |
40
|
|
|
public static final LinkedHashMap<String, String> metrics = new LinkedHashMap<String, String>() { |
41
|
|
|
{ |
42
|
|
|
put("Jaro distance", "jaro"); |
43
|
|
|
put("Jaro-Winkler distance", "jaroWinkler"); |
44
|
|
|
put("Levenshtein distance", "levenshteinDistance"); |
45
|
|
|
put("Normalized Levenshtein distance", "levenshtein"); |
46
|
|
|
put("Substring", "substring"); |
47
|
|
|
put("qGrams", "qGrams"); |
48
|
|
|
|
49
|
|
|
put("Constant", "constant"); |
50
|
|
|
put("Equality", "equality"); |
51
|
|
|
put("Inequality", "inequality"); |
52
|
|
|
put("Lower Than", "lowerThan"); |
53
|
|
|
put("Relaxed Equality", "relaxedEquality"); |
54
|
|
|
|
55
|
|
|
put("Date", "date"); |
56
|
|
|
put("Date Time", "dateTime"); |
57
|
|
|
put("Geographical Distance", "wgs84"); |
58
|
|
|
put("Inside numeric interval", "insideNumericInterval"); |
59
|
|
|
put("Numeric similarity", "num"); |
60
|
|
|
|
61
|
|
|
put("Centroid distance", "CentroidDistanceMetric"); |
62
|
|
|
put("Crosses", "CrossesMetric"); |
63
|
|
|
put("Disjoint", "DisjointMetric"); |
64
|
|
|
put("Intersects", "IntersectsMetric"); |
65
|
|
|
put("Min distance", "MinDistanceMetric"); |
66
|
|
|
put("Relate", "RelateMetric"); |
67
|
|
|
put("Spatial Contains", "SContainsMetric"); |
68
|
|
|
put("Spatial Equals", "SEqualsMetric"); |
69
|
|
|
put("Touches", "TouchesMetric"); |
70
|
|
|
put("Within", "WithinMetric"); |
71
|
|
|
|
72
|
|
|
put("After", "AfterMetric"); |
73
|
|
|
put("Before", "BeforeMetric"); |
74
|
|
|
put("Days distance", "DaysDistanceMetric"); |
75
|
|
|
put("During", "DuringMetric"); |
76
|
|
|
put("Finishes", "FinishesMetric"); |
77
|
|
|
put("Hours distance", "HoursDistanceMetric"); |
78
|
|
|
put("is Finished By", "isFinishedByMetric"); |
79
|
|
|
put("is Met By", "IsMetByMetric"); |
80
|
|
|
put("is Overlapped By", "IsOverlappedByMetric"); |
81
|
|
|
put("is Started By", "IsStartedByMetric"); |
82
|
|
|
put("Meets", "MeetsMetric"); |
83
|
|
|
put("Millisecs distance", "MillisecsDistanceMetric"); |
84
|
|
|
put("Mins distance", "MinsDistanceMetric"); |
85
|
|
|
put("Months distance", "MonthsDistanceMetric"); |
86
|
|
|
put("Secs distance", "SecsDistanceMetric"); |
87
|
|
|
put("Starts", "StartsMetric"); |
88
|
|
|
put("Temporal Contains", "TContainsMetric"); |
89
|
|
|
put("Temporal Equals", "TEqualsMetric"); |
90
|
|
|
put("Temporal Overlaps", "TOverlapsMetric"); |
91
|
|
|
put("Years distance", "YearsDistanceMetric"); |
92
|
|
|
|
93
|
|
|
put("Cosine", "consine"); |
94
|
|
|
put("Dice Coefficient", "dice"); |
95
|
|
|
put("Jaccard", "jaccard"); |
96
|
|
|
put("Soft Jaccard", "softjaccard"); |
97
|
|
|
put("Token-wise distance", "tokenwiseDistance"); |
98
|
|
|
} |
99
|
|
|
}; |
100
|
|
|
|
101
|
|
|
public Metric() { |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public Metric(int id, String metric) { |
105
|
|
|
this.id = getMetric(metric) + id; |
106
|
|
|
this.required = "false"; |
107
|
|
|
this.metric = getMetric(metric); |
108
|
|
|
this.weight = "1"; |
109
|
|
|
this.threshold = "0.0"; |
110
|
|
|
this.indexing = "true"; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public Metric(String id, String required, String weight, String metric, String threshold, |
114
|
|
|
String indexing) { |
115
|
|
|
this.id = id; |
116
|
|
|
this.required = required; |
117
|
|
|
this.metric = getMetric(metric); |
118
|
|
|
this.weight = weight; |
119
|
|
|
this.threshold = threshold; |
120
|
|
|
this.indexing = indexing; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public void addInput(Input input) { |
124
|
|
|
this.inputs.add(input); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public void addParam(Param param) { |
128
|
|
|
this.params.add(param); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
public static String[] getMetricsNames(){ |
132
|
|
|
return metrics.keySet().toArray(new String[0]); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
public String getMetric(String metric) { |
136
|
|
|
return metrics.get(metric); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
} |