-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMappings.java
56 lines (42 loc) · 1.55 KB
/
Mappings.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package eu.slipo.triplegeo.ml.mappings;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* Contains mappings for each column (field) of a CSV file. Member {@link Mappings#fields}
* contains a {@link LinkedHashMap} for each column. The column name is the key.
* LinkedHashMap contains the probability that the column matches to each predicate.
* Predicates are in decreasing probability order.
*
* Probability may be low for all. We are interested in its relative value for different
* predicates.
*/
public class Mappings {
public static class Field {
private String name;
private Map<String, Double> predicates;
public Field(String name, Map<String, Double> predicates) {
this.name = name;
this.predicates = Collections.unmodifiableMap(predicates);
}
public String getName() {
return name;
}
public Map<String, Double> getPredicates() {
return predicates;
}
}
private List<Field> fields = new ArrayList<Field>();
public void addField(String name, LinkedHashMap<String, Double> predicates) {
fields.add(new Field(name, predicates));
}
public Map<String, Double> getFieldPredicates(String name) {
Field field = fields.stream().filter(f -> f.name.equals(name)).findFirst().orElse(null);
return field == null ? null : field.predicates;
}
public List<Field> getFields() {
return this.fields;
}
}