0
|
1 package de.mpiwg.anteater.results;
|
|
2
|
|
3 import java.util.ArrayList;
|
|
4 import java.util.HashMap;
|
|
5 import java.util.List;
|
|
6 import java.util.Map;
|
|
7
|
|
8 import de.mpiwg.anteater.AnteaterConfiguration;
|
|
9 import de.mpiwg.anteater.text.TextInformation;
|
|
10
|
|
11 public abstract class AResultManager<E extends IResult<?,?>> {
|
|
12
|
|
13 private AnteaterConfiguration configuration;
|
|
14
|
|
15 public AResultManager(AnteaterConfiguration configuration) {
|
|
16 this.configuration = configuration;
|
|
17 }
|
|
18
|
|
19 protected abstract List<AnnotationTag> getSpecificSummaryTags(List<E> results, int textIndex);
|
|
20 protected abstract List<AnnotationTag> getSpecificSuppleInfTags(List<E> applicants, int textIndex);
|
|
21
|
|
22 public List<AnnotationTag> getSummaryTags(List<E> results, int textIndex) {
|
|
23 return getSpecificSummaryTags(results, textIndex);
|
|
24 }
|
|
25
|
|
26 public List<AnnotationTag> getSuppleInfTags(List<E> results, int textIndex) {
|
|
27 return getSpecificSuppleInfTags(results, textIndex);
|
|
28 }
|
|
29
|
|
30 public Map<TextInformation, List<E>> sortResultsByText(List<E> results) {
|
|
31 configuration.getLogger().logMessage(getClass().getSimpleName(), "Sorting results by texts.");
|
|
32
|
|
33 Map<TextInformation, List<E>> resultsPerText = new HashMap<TextInformation, List<E>>();
|
|
34
|
|
35 for (E r : results) {
|
|
36
|
|
37 List<E> appResults = resultsPerText.get(r.getTextInfo());
|
|
38 if (appResults == null) {
|
|
39 appResults = new ArrayList<E>();
|
|
40 resultsPerText.put(r.getTextInfo(), appResults);
|
|
41 }
|
|
42 appResults.add(r);
|
|
43 }
|
|
44
|
|
45 return resultsPerText;
|
|
46 }
|
|
47
|
|
48 public List<E> getPredictedResults(List<E> results) {
|
|
49 List<E> predictedResults = new ArrayList<E>();
|
|
50
|
|
51 if (results == null)
|
|
52 return predictedResults;
|
|
53
|
|
54 for (E r : results) {
|
|
55 if (r.getPrediction() >= 1.0)
|
|
56 predictedResults.add(r);
|
|
57 }
|
|
58 return predictedResults;
|
|
59 }
|
|
60 }
|