1
|
package eu.dnetlib.pace.model;
|
2
|
|
3
|
import java.util.List;
|
4
|
import java.util.Map;
|
5
|
|
6
|
import com.google.gson.Gson;
|
7
|
import eu.dnetlib.pace.clustering.*;
|
8
|
|
9
|
public class ClusteringDef {
|
10
|
|
11
|
private Clustering name;
|
12
|
|
13
|
private List<String> fields;
|
14
|
|
15
|
private Map<String, Integer> params;
|
16
|
|
17
|
public ClusteringDef() {}
|
18
|
|
19
|
public Clustering getName() {
|
20
|
return name;
|
21
|
}
|
22
|
|
23
|
public void setName(final Clustering name) {
|
24
|
this.name = name;
|
25
|
}
|
26
|
|
27
|
public ClusteringFunction getClusteringFunction() {
|
28
|
switch (getName()) {
|
29
|
case acronyms:
|
30
|
return new Acronyms(getParams());
|
31
|
case ngrams:
|
32
|
return new Ngrams(getParams());
|
33
|
case ngrampairs:
|
34
|
return new NgramPairs(getParams());
|
35
|
case sortedngrampairs:
|
36
|
return new SortedNgramPairs(getParams());
|
37
|
case suffixprefix:
|
38
|
return new SuffixPrefix(getParams());
|
39
|
case spacetrimmingfieldvalue:
|
40
|
return new SpaceTrimmingFieldValue(getParams());
|
41
|
case immutablefieldvalue:
|
42
|
return new ImmutableFieldValue(getParams());
|
43
|
case personhash:
|
44
|
return new PersonHash(getParams());
|
45
|
case personclustering:
|
46
|
return new PersonClustering(getParams());
|
47
|
case pidclustering:
|
48
|
return new PidClustering(getParams());
|
49
|
default:
|
50
|
return new RandomClusteringFunction(getParams());
|
51
|
}
|
52
|
}
|
53
|
|
54
|
public List<String> getFields() {
|
55
|
return fields;
|
56
|
}
|
57
|
|
58
|
public void setFields(final List<String> fields) {
|
59
|
this.fields = fields;
|
60
|
}
|
61
|
|
62
|
public Map<String, Integer> getParams() {
|
63
|
return params;
|
64
|
}
|
65
|
|
66
|
public void setParams(final Map<String, Integer> params) {
|
67
|
this.params = params;
|
68
|
}
|
69
|
|
70
|
@Override
|
71
|
public String toString() {
|
72
|
return new Gson().toJson(this);
|
73
|
}
|
74
|
|
75
|
}
|