1   package ixa.kaflib;
2   
3   import java.io.Serializable;
4   
5   
6   /** The coreference layer creates clusters of term spans (which we call mentions) which share the same referent. For instance, “London” and “the capital city of England” are two mentions referring to the same entity. It is said that those mentions corefer. */
7   public class Timex3 implements TLinkReferable, Serializable {
8   
9       /** Timex3's ID (required) */
10      private String timex3id;
11  
12      /** Timex3's type (required)*/
13      private String type;
14  
15      private Timex3 beginPoint;
16  
17      private Timex3 endPoint;
18  
19      private String quant;
20  
21      private String freq;
22  
23      /** Timex3's functionInDocument */
24      private String functionInDocument;
25  
26      private Boolean temporalFunction;
27  
28      /** Timex3's value */
29      private String value;
30  
31      private String valueFromFunction;
32  
33      private String mod;
34  
35      private String anchorTimeId;
36  
37      private String comment;
38  
39      private Span<WF> span;
40  
41      /** Mentions to the same entity (at least one required) */
42      //private List<Span<WF>> mentions;
43  
44      Timex3(String timex3id, String type){
45  	this.timex3id = timex3id;
46  	this.type = type;
47  	//this.mentions = new ArrayList<Span<WF>>();
48      }
49  
50      /*
51      Timex3(String timex3id, List<Span<WF>> mentions) {
52  	if (mentions.size() < 1) {
53  	    throw new IllegalStateException("Timex3 must contain at least one reference span");
54  	}
55  	if (mentions.get(0).size() < 1) {
56  	   throw new IllegalStateException("Timex3' reference's spans must contain at least one target");
57  	}
58  	this.timex3id = timex3id;
59  	this.mentions = mentions;
60      }
61      */
62  
63      /*
64      Timex3(Timex3 timex3, HashMap<String, WF> WFs) {
65  	this.timex3id = timex3.timex3id;
66  	this.type = timex3.type;
67  
68  	String id = timex3.getId();
69  	this.mentions = new ArrayList<Span<WF>>();
70  	for (Span<WF> span : timex3.getSpans()) {
71  
72  	    List<WF> targets = span.getTargets();
73  	    List<WF> copiedTargets = new ArrayList<WF>();
74  	    for (WF wf : targets) {
75  		WF copiedWF = WFs.get(wf.getId());
76  		if (copiedWF == null) {
77  		    throw new IllegalStateException("Term not found when copying " + id);
78  		}
79  		copiedTargets.add(copiedWF);
80  	    }
81  	    if (span.hasHead()) {
82  		WF copiedHead = WFs.get(span.getHead().getId());
83  		this.mentions.add(new Span<WF>(copiedTargets, copiedHead));
84  	    }
85  	    else {
86  		this.mentions.add(new Span<WF>(copiedTargets));
87  	    }
88  	}
89      }
90      */
91  
92      public String getId() {
93  	return timex3id;
94      }
95  
96      void setId(String id) {
97  	this.timex3id = id;
98      }
99  
100     public String getType() {
101 	return type;
102     }
103 
104     public void setType(String type){
105 	this.type = type;
106     }
107 
108     public boolean hasBeginPoint() {
109 	return this.beginPoint != null;
110     }
111 
112     public Timex3 getBeginPoint() {
113 	return this.beginPoint;
114     }
115 
116     public void setBeginPoint(Timex3 beginPoint) {
117 	this.beginPoint = beginPoint;
118     }
119 
120     public boolean hasEndPoint() {
121 	return this.endPoint != null;
122     }
123 
124     public Timex3 getEndPoint() {
125 	return this.endPoint;
126     }
127 
128     public void setEndPoint(Timex3 endPoint) {
129 	this.endPoint = endPoint;
130     }
131 
132     public boolean hasFreq() {
133 	return this.freq != null;
134     }
135 
136     public String getFreq() {
137 	return this.freq;
138     }
139 
140     public void setFreq(String freq) {
141 	this.freq = freq;
142     }
143 
144     public boolean hasQuant() {
145 	return this.quant != null;
146     }
147 
148     public String getQuant() {
149 	return this.quant;
150     }
151 
152     public void setQuant(String quant) {
153 	this.quant = quant;
154     }
155 
156     public boolean hasFunctionInDocument() {
157 	return this.functionInDocument != null;
158     }
159 
160     public String getFunctionInDocument() {
161 	return this.functionInDocument;
162     }
163 
164     public void setFunctionInDocument(String functionInDocument) {
165 	this.functionInDocument = functionInDocument;
166     }
167 
168     public boolean hasTemporalFunction() {
169 	return this.temporalFunction != null;
170     }
171 
172     public Boolean getTemporalFunction() {
173 	return this.temporalFunction;
174     }
175 
176     public void setTemporalFunction(Boolean temporalFunction) {
177 	this.temporalFunction = temporalFunction;
178     }
179 
180     public boolean hasValue() {
181 	return this.value != null;
182     }
183 
184     public String getValue() {
185 	return value;
186     }
187 
188     public void setValue(String value){
189 	this.value = value;
190     }
191 
192     public boolean hasValueFromFunction() {
193 	return this.valueFromFunction != null;
194     }
195 
196     public String getValueFromFunction() {
197 	return this.valueFromFunction;
198     }
199 
200     public void setValueFromFunction(String valueFromFunction) {
201 	this.valueFromFunction = valueFromFunction;
202     }
203 
204     public boolean hasMod() {
205 	return this.mod != null;
206     }
207 
208     public String getMod() {
209 	return this.mod;
210     }
211 
212     public void setMod(String mod) {
213 	this.mod = mod;
214     }
215 
216     public boolean hasAnchorTimeId() {
217 	return this.anchorTimeId != null;
218     }
219 
220     public String getAnchorTimeId() {
221 	return this.anchorTimeId;
222     }
223 
224     public void setAnchorTimeId(String anchorTimeId) {
225 	this.anchorTimeId = anchorTimeId;
226     }
227 
228     public boolean hasComment() {
229 	return this.comment != null;
230     }
231 
232     public String getComment() {
233 	return this.comment;
234     }
235 
236     public void setComment(String comment) {
237 	this.comment = comment;
238     }
239 
240     public boolean hasSpan() {
241 	return this.span != null;
242     }
243 
244     public Span<WF> getSpan() {
245 	return this.span;
246     }
247 
248     public void setSpan(Span<WF> span) {
249 	this.span = span;
250     }
251 
252     public String getSpanStr(Span<WF> span) {
253 	String str = "";
254 	for (WF wf : span.getTargets()) {
255 	    if (!str.isEmpty()) {
256 		str += " ";
257 	    }
258 	    str += wf.getForm();
259 	}
260 	return str;
261     }
262 
263     /** Returns the term targets of the first span. When targets of other spans are needed getReferences() method should be used. */
264     /*
265     public List<WF> getWFs() {
266 	if (this.mentions.size()>0){
267 	    return this.mentions.get(0).getTargets();
268 	}
269 	else{
270 	    return null;
271 	}
272     }
273     */
274 
275     /** Adds a term to the first span. */
276     /*
277     public void addWF(WF wf) {
278 	this.mentions.get(0).addTarget(wf);
279     }
280     */
281 
282     /** Adds a term to the first span. */
283     /*
284     public void addWF(WF wf, boolean isHead) {
285 	this.mentions.get(0).addTarget(wf, isHead);
286     }
287 
288     public List<Span<WF>> getSpans() {
289 	return this.mentions;
290     }
291 
292     public void addSpan(Span<WF> span) {
293 	this.mentions.add(span);
294     }
295 
296     public String getSpanStr(Span<WF> span) {
297 	String str = "";
298 	for (WF wf : span.getTargets()) {
299 	    if (!str.isEmpty()) {
300 		str += " ";
301 	    }
302 	    str += wf.getForm();
303 	}
304 	return str;
305     }
306     */
307 
308 }