| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 1 | package de.ids_mannheim.korap.query.spans; |
| 2 | |
| 3 | import java.io.IOException; |
| Eliza Margaretha | d28469f | 2014-03-10 12:42:21 +0000 | [diff] [blame] | 4 | import java.util.ArrayList; |
| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 5 | import java.util.Collection; |
| 6 | |
| 7 | import org.apache.lucene.search.spans.Spans; |
| 8 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 9 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 10 | * CandidateSpan stores the current state of a Lucene {@link Spans}, |
| 11 | * which is an |
| 12 | * enumeration. CandidateSpan is used for various purposes, such as |
| 13 | * for |
| 14 | * collecting spans which will be used in a latter process or next |
| 15 | * matching. |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 16 | * |
| 17 | * @author margaretha |
| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 18 | * */ |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 19 | public class CandidateSpan implements Comparable<CandidateSpan>, Cloneable { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 20 | protected int doc, start, end; |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 21 | private long cost; |
| 22 | private Collection<byte[]> payloads = new ArrayList<>(); |
| 23 | private int position; |
| 24 | private CandidateSpan childSpan; // used for example for multiple distance |
| 25 | // with unordered constraint |
| 26 | protected short spanId; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 27 | private short leftId, rightId; |
| 28 | private int leftStart, leftEnd; |
| 29 | private int rightStart, rightEnd; |
| 30 | |
| Eliza Margaretha | 9738c39 | 2014-02-03 17:04:53 +0000 | [diff] [blame] | 31 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 32 | /** |
| 33 | * Constructs a CandidateSpan for the given Span. |
| 34 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 35 | * @param span |
| 36 | * a Span |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 37 | * @throws IOException |
| 38 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 39 | public CandidateSpan (Spans span) throws IOException { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 40 | this.doc = span.doc(); |
| 41 | this.start = span.start(); |
| 42 | this.end = span.end(); |
| 43 | this.cost = span.cost(); |
| 44 | if (span.isPayloadAvailable()) |
| 45 | setPayloads(span.getPayload()); |
| 46 | } |
| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 47 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 48 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 49 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 50 | * Constructs a CandidateSpan for the given Span and element |
| 51 | * position (where |
| 52 | * the span is included in a document). The element position is |
| 53 | * important |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 54 | * for the matching process in {@link ElementDistanceSpans}. |
| 55 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 56 | * @param span |
| 57 | * a Span |
| 58 | * @param position |
| 59 | * an element position |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 60 | * @throws IOException |
| 61 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 62 | public CandidateSpan (Spans span, int position) throws IOException { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 63 | this(span); |
| 64 | this.position = position; |
| 65 | } |
| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 66 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 67 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 68 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 69 | * Constructs a CandidateSpan from all the given variables which |
| 70 | * are |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 71 | * properties of a Span. |
| 72 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 73 | * @param start |
| 74 | * the start position of a span |
| 75 | * @param end |
| 76 | * the end position of a span |
| 77 | * @param doc |
| 78 | * the document including the span |
| 79 | * @param cost |
| 80 | * the cost of finding a span |
| 81 | * @param payloads |
| 82 | * the payloads of a span |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 83 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 84 | public CandidateSpan (int start, int end, int doc, long cost, |
| 85 | Collection<byte[]> payloads) { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 86 | this.start = start; |
| 87 | this.end = end; |
| 88 | this.doc = doc; |
| 89 | this.cost = cost; |
| 90 | if (payloads != null) |
| 91 | setPayloads(payloads); |
| 92 | } |
| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 93 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 94 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 95 | @Override |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 96 | protected CandidateSpan clone () throws CloneNotSupportedException { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 97 | return new CandidateSpan(this.start, this.end, this.doc, this.cost, |
| 98 | this.payloads); |
| 99 | } |
| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 100 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 101 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 102 | /** |
| 103 | * Returns the document number containing the CandidateSpan. |
| 104 | * |
| 105 | * @return the document number |
| 106 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 107 | public int getDoc () { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 108 | return doc; |
| 109 | } |
| Eliza Margaretha | 8e274e3 | 2014-01-28 15:09:30 +0000 | [diff] [blame] | 110 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 111 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 112 | /** |
| 113 | * Sets the document number containing the CandidateSpan. |
| 114 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 115 | * @param doc |
| 116 | * the document number |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 117 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 118 | public void setDoc (int doc) { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 119 | this.doc = doc; |
| 120 | } |
| Eliza Margaretha | 8e274e3 | 2014-01-28 15:09:30 +0000 | [diff] [blame] | 121 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 122 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 123 | /** |
| 124 | * Returns the start position of the CandidateSpan. |
| 125 | * |
| 126 | * @return the start position |
| 127 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 128 | public int getStart () { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 129 | return start; |
| 130 | } |
| Eliza Margaretha | 6651fc3 | 2014-02-18 14:57:47 +0000 | [diff] [blame] | 131 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 132 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 133 | /** |
| 134 | * Sets the start position of the CandidateSpan. |
| 135 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 136 | * @param start |
| 137 | * the start position |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 138 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 139 | public void setStart (int start) { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 140 | this.start = start; |
| 141 | } |
| Eliza Margaretha | 6651fc3 | 2014-02-18 14:57:47 +0000 | [diff] [blame] | 142 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 143 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 144 | /** |
| 145 | * Returns the end position of the CandidateSpan. |
| 146 | * |
| 147 | * @return the end position |
| 148 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 149 | public int getEnd () { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 150 | return end; |
| 151 | } |
| Eliza Margaretha | e7938d3 | 2014-07-29 12:12:15 +0000 | [diff] [blame] | 152 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 153 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 154 | /** |
| 155 | * Sets the end position of the CandidateSpan. |
| 156 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 157 | * @param end |
| 158 | * the end position |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 159 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 160 | public void setEnd (int end) { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 161 | this.end = end; |
| 162 | } |
| Eliza Margaretha | e7938d3 | 2014-07-29 12:12:15 +0000 | [diff] [blame] | 163 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 164 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 165 | /** |
| 166 | * Returns the payloads of the CandidateSpan. |
| 167 | * |
| 168 | * @return the payloads |
| 169 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 170 | public Collection<byte[]> getPayloads () { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 171 | return payloads; |
| 172 | } |
| Eliza Margaretha | e7938d3 | 2014-07-29 12:12:15 +0000 | [diff] [blame] | 173 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 174 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 175 | /** |
| 176 | * Sets the payloads of the CandidateSpan. |
| 177 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 178 | * @param payloads |
| 179 | * the payloads |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 180 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 181 | public void setPayloads (Collection<byte[]> payloads) { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 182 | |
| 183 | for (byte[] b : payloads) { |
| 184 | if (b == null) |
| 185 | this.payloads.add(null); |
| 186 | else |
| 187 | this.payloads.add(b.clone()); |
| 188 | } |
| 189 | } |
| 190 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 191 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 192 | /** |
| 193 | * Returns the cost of finding the CandidateSpan. |
| 194 | * |
| 195 | * @return the cost |
| 196 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 197 | public long getCost () { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 198 | return cost; |
| 199 | } |
| 200 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 201 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 202 | /** |
| 203 | * Sets the cost of finding the CandidateSpan. |
| 204 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 205 | * @param cost |
| 206 | * the cost |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 207 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 208 | public void setCost (long cost) { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 209 | this.cost = cost; |
| 210 | } |
| 211 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 212 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 213 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 214 | * Returns the element position number containing the |
| 215 | * CandidateSpan. |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 216 | * |
| 217 | * @return the element position number |
| 218 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 219 | public int getPosition () { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 220 | return position; |
| 221 | } |
| 222 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 223 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 224 | /** |
| 225 | * Sets the element position number containing the CandidateSpan. |
| 226 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 227 | * @param position |
| 228 | * the element position number |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 229 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 230 | public void setPosition (int position) { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 231 | this.position = position; |
| 232 | } |
| 233 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 234 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 235 | /** |
| 236 | * Returns a child/sub Span of the CandidateSpan. |
| 237 | * |
| 238 | * @return a child/sub span of the CandidateSpan |
| 239 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 240 | public CandidateSpan getChildSpan () { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 241 | return childSpan; |
| 242 | } |
| 243 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 244 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 245 | /** |
| 246 | * Sets the child/sub span of the CandidateSpan. |
| 247 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 248 | * @param childSpan |
| 249 | * a child/sub span of the CandidateSpan |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 250 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 251 | public void setChildSpan (CandidateSpan childSpan) { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 252 | this.childSpan = childSpan; |
| 253 | } |
| 254 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 255 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 256 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 257 | * Returns the span id of another Span related to the |
| 258 | * CandidateSpan. Only |
| 259 | * CandidateSpan of particular Spans such as |
| 260 | * {@link AttributeSpans} having |
| 261 | * this property. For instance, an AttributeSpan has a spanId of |
| 262 | * the element |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 263 | * it belongs to. |
| 264 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 265 | * @return the span id of another Span related to the |
| 266 | * CandidateSpan |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 267 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 268 | public short getSpanId () { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 269 | return spanId; |
| 270 | } |
| 271 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 272 | |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 273 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 274 | * Sets the span id of another Span related to the CandidateSpan. |
| 275 | * Only |
| 276 | * CandidateSpan of particular Spans such as |
| 277 | * {@link AttributeSpans} having |
| 278 | * this property. For instance, an AttributeSpan has a spanId of |
| 279 | * the element |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 280 | * it belongs to. |
| 281 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 282 | * @param spanId |
| 283 | * the span id of another Span related to the |
| 284 | * CandidateSpan |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 285 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 286 | public void setSpanId (short spanId) { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 287 | this.spanId = spanId; |
| 288 | } |
| 289 | |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 290 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 291 | public short getLeftId () { |
| 292 | return leftId; |
| 293 | } |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 294 | |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 295 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 296 | public void setLeftId (short leftId) { |
| 297 | this.leftId = leftId; |
| 298 | } |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 299 | |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 300 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 301 | public short getRightId () { |
| 302 | return rightId; |
| 303 | } |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 304 | |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 305 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 306 | public void setRightId (short rightId) { |
| 307 | this.rightId = rightId; |
| 308 | } |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 309 | |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 310 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 311 | public int getLeftStart () { |
| 312 | return leftStart; |
| 313 | } |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 314 | |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 315 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 316 | public void setLeftStart (int leftStart) { |
| 317 | this.leftStart = leftStart; |
| 318 | } |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 319 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 320 | |
| 321 | public int getLeftEnd () { |
| 322 | return leftEnd; |
| 323 | } |
| 324 | |
| 325 | |
| 326 | public void setLeftEnd (int leftEnd) { |
| 327 | this.leftEnd = leftEnd; |
| 328 | } |
| 329 | |
| 330 | |
| 331 | public int getRightStart () { |
| 332 | return rightStart; |
| 333 | } |
| 334 | |
| 335 | |
| 336 | public void setRightStart (int rightStart) { |
| 337 | this.rightStart = rightStart; |
| 338 | } |
| 339 | |
| 340 | |
| 341 | public int getRightEnd () { |
| 342 | return rightEnd; |
| 343 | } |
| 344 | |
| 345 | |
| 346 | public void setRightEnd (int rightEnd) { |
| 347 | this.rightEnd = rightEnd; |
| 348 | } |
| 349 | |
| 350 | |
| 351 | @Override |
| 352 | public int compareTo (CandidateSpan o) { |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 353 | if (this.doc == o.doc) { |
| 354 | if (this.getStart() == o.getStart()) { |
| 355 | if (this.getEnd() == o.getEnd()) |
| 356 | return 0; |
| 357 | if (this.getEnd() > o.getEnd()) |
| 358 | return 1; |
| 359 | else |
| 360 | return -1; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 361 | } |
| 362 | else if (this.getStart() < o.getStart()) |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 363 | return -1; |
| 364 | else |
| 365 | return 1; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 366 | } |
| 367 | else if (this.doc < o.doc) |
| Eliza Margaretha | 609a5be | 2014-12-18 16:52:20 +0000 | [diff] [blame] | 368 | return -1; |
| 369 | else |
| 370 | return 1; |
| 371 | } |
| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 372 | } |