1 package ixa.kaflib;
2
3 import java.io.Serializable;
4 import java.util.ArrayList;
5 import java.util.List;
6
7
8
9
10 public class Factuality implements Serializable {
11
12 Term word;
13 ArrayList<FactualityPart> factualityParts = new ArrayList<FactualityPart>();
14
15 public Factuality(Term word) {
16 this.word = word;
17 }
18
19 public Term getWord() {
20 return word;
21 }
22
23 public void setWord(Term word) {
24 this.word = word;
25 }
26
27 public ArrayList<FactualityPart> getFactualityParts() {
28 return factualityParts;
29 }
30
31 public void addFactualityPart(FactualityPart part) {
32 this.factualityParts.add(part);
33 }
34
35 public void addFactualityPart(String prediction, double confidence) {
36 this.addFactualityPart(new FactualityPart(prediction, confidence));
37 }
38
39 public String getId() {
40 return word.getWFs().get(0).getId();
41 }
42
43 public List<WF> getWFs() {
44 return word.getWFs();
45 }
46
47 public FactualityPart getMaxPart() {
48 FactualityPart ret = null;
49 double base = 0;
50
51 for (FactualityPart p : factualityParts) {
52 if (p.getConfidence() > base) {
53 ret = p;
54 base = p.getConfidence();
55 }
56 }
57
58 return ret;
59 }
60
61 public class FactualityPart {
62
63 String prediction;
64 double confidence;
65
66 public FactualityPart(String prediction, double confidence) {
67 this.prediction = prediction;
68 this.confidence = confidence;
69 }
70
71 public String getPrediction() {
72 return prediction;
73 }
74
75 public void setPrediction(String prediction) {
76 this.prediction = prediction;
77 }
78
79 public double getConfidence() {
80 return confidence;
81 }
82
83 public void setConfidence(double confidence) {
84 this.confidence = confidence;
85 }
86
87 @Override
88 public String toString() {
89 return "FactualityPart{" +
90 "prediction='" + prediction + '\'' +
91 ", confidence=" + confidence +
92 '}';
93 }
94 }
95
96 }