| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 1 | package de.ids_mannheim.korap.query; |
| 2 | |
| 3 | import java.io.IOException; |
| 4 | import java.util.Map; |
| 5 | |
| Akron | 700c1eb | 2015-09-25 16:57:30 +0200 | [diff] [blame] | 6 | import org.apache.lucene.index.LeafReaderContext; |
| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 7 | import org.apache.lucene.index.Term; |
| 8 | import org.apache.lucene.index.TermContext; |
| 9 | import org.apache.lucene.search.spans.SpanQuery; |
| 10 | import org.apache.lucene.search.spans.Spans; |
| 11 | import org.apache.lucene.util.Bits; |
| Eliza Margaretha | 609fcc6 | 2014-02-13 14:10:20 +0000 | [diff] [blame] | 12 | import org.apache.lucene.util.ToStringUtils; |
| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 13 | |
| Eliza Margaretha | 371eab3 | 2014-10-29 14:53:37 +0000 | [diff] [blame] | 14 | import de.ids_mannheim.korap.query.spans.DistanceExclusionSpans; |
| 15 | import de.ids_mannheim.korap.query.spans.ElementDistanceExclusionSpans; |
| Eliza Margaretha | 795937c | 2014-02-06 13:08:28 +0000 | [diff] [blame] | 16 | import de.ids_mannheim.korap.query.spans.ElementDistanceSpans; |
| 17 | import de.ids_mannheim.korap.query.spans.TokenDistanceSpans; |
| Eliza Margaretha | 795937c | 2014-02-06 13:08:28 +0000 | [diff] [blame] | 18 | import de.ids_mannheim.korap.query.spans.UnorderedElementDistanceSpans; |
| 19 | import de.ids_mannheim.korap.query.spans.UnorderedTokenDistanceSpans; |
| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 20 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 21 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 22 | * SpanDistanceQuery calculates the distance between two spans and |
| 23 | * compares it |
| 24 | * to the distance constraints. The distance constraints are specified |
| 25 | * as a {@link DistanceConstraint} instance having various properties: |
| 26 | * the distance |
| 27 | * unit, the order of the spans (ordered or unordered), co-occurrence |
| 28 | * (i.e. the |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 29 | * spans should co-occur or not), minimum and maximum distance. <br/> |
| 30 | * <br/> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 31 | * The distance unit can be a word (token), a sentence or a paragraph. |
| 32 | * The |
| 33 | * resulting spans typically stretch from the starting position of a |
| 34 | * former span |
| Eliza Margaretha | 8551e5b | 2014-12-15 16:46:18 +0000 | [diff] [blame] | 35 | * to the end position of the latter span. <br/> |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 36 | * <br/> |
| 37 | * Query examples: |
| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 38 | * |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 39 | * <ol> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 40 | * <li>Search two terms x and y which are separated by minimum two and |
| 41 | * maximum |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 42 | * three other words. The order of x and y does not matter. |
| 43 | * |
| 44 | * <pre> |
| 45 | * DistanceConstraint dc = new DistanceConstraint(2, 3, false, false); |
| 46 | * </pre> |
| 47 | * |
| 48 | * </li> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 49 | * <li>Search two terms x and y which are separated by minimum two and |
| 50 | * maximum |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 51 | * three other words. X must precede y. |
| 52 | * |
| 53 | * <pre> |
| 54 | * DistanceConstraint dc = new DistanceConstraint(2, 3, true, false); |
| 55 | * </pre> |
| 56 | * |
| 57 | * </li> |
| 58 | * <li> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 59 | * Search term x which do not occur with term y in minimum two and |
| 60 | * maximum three |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 61 | * other words. X must precede y. |
| 62 | * |
| 63 | * <pre> |
| 64 | * DistanceConstraint dc = new DistanceConstraint(2, 3, true, true); |
| 65 | * </pre> |
| 66 | * |
| 67 | * </li> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 68 | * <li>Search two terms x and y separated by minimum one and maximum |
| 69 | * two |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 70 | * sentences. X must precede y. |
| 71 | * |
| 72 | * <pre> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 73 | * SpanElementQuery e = new SpanElementQuery("tokens", |
| 74 | * "s"); |
| 75 | * DistanceConstraint dc = new DistanceConstraint(e, 2, 3, true, |
| 76 | * false); |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 77 | * </pre> |
| 78 | * |
| 79 | * </li> |
| 80 | * </ol> |
| 81 | * |
| 82 | * SpanDistanceQuery examples: |
| 83 | * |
| 84 | * <ol> |
| 85 | * <li> |
| 86 | * |
| 87 | * <pre> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 88 | * SpanDistanceQuery sq = new SpanDistanceQuery(new SpanTermQuery(new |
| 89 | * Term( |
| 90 | * "tokens", x)), new SpanTermQuery(new |
| 91 | * Term("tokens", y)), dc, true); |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 92 | * </pre> |
| 93 | * |
| 94 | * </li> |
| 95 | * <li> |
| 96 | * |
| 97 | * <pre> |
| 98 | * SpanDistanceQuery sq = new SpanDistanceQuery( |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 99 | * new SpanElementQuery("tokens", "s"), new |
| 100 | * SpanElementQuery("tokens", y), |
| 101 | * dc, true); |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 102 | * </pre> |
| 103 | * |
| 104 | * </li> |
| 105 | * </ol> |
| 106 | * |
| 107 | * |
| 108 | * @author margaretha |
| Eliza Margaretha | 6f98920 | 2016-10-14 21:48:29 +0200 | [diff] [blame] | 109 | */ |
| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 110 | public class SpanDistanceQuery extends SimpleSpanQuery { |
| Eliza Margaretha | db29287 | 2014-02-03 09:36:43 +0000 | [diff] [blame] | 111 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 112 | private boolean exclusion; |
| 113 | private boolean isOrdered; |
| 114 | private int minDistance, maxDistance; |
| 115 | private SpanElementQuery elementQuery; // element distance unit (sentence or |
| Eliza Margaretha | 6f98920 | 2016-10-14 21:48:29 +0200 | [diff] [blame] | 116 | // paragraph) |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 117 | private String distanceUnit; |
| 118 | private String spanName; |
| 119 | private DistanceConstraint constraint; |
| 120 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 121 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 122 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 123 | * Constructs a SpanDistanceQuery comparing the distance between |
| 124 | * the spans |
| 125 | * of the two specified spanqueries and based-on the given |
| 126 | * distance |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 127 | * constraints. |
| 128 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 129 | * @param firstClause |
| 130 | * a span query |
| 131 | * @param secondClause |
| 132 | * a span query |
| 133 | * @param constraint |
| 134 | * a DistanceConstraint containing all the constraints |
| 135 | * required for the distance query |
| 136 | * @param collectPayloads |
| 137 | * a boolean flag representing the value |
| 138 | * <code>true</code> if payloads are to be collected, |
| 139 | * otherwise |
| 140 | * <code>false</code>. |
| Eliza Margaretha | 8551e5b | 2014-12-15 16:46:18 +0000 | [diff] [blame] | 141 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 142 | public SpanDistanceQuery (SpanQuery firstClause, SpanQuery secondClause, |
| 143 | DistanceConstraint constraint, |
| 144 | boolean collectPayloads) { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 145 | super(firstClause, secondClause, collectPayloads); |
| 146 | |
| 147 | if (constraint == null) { |
| 148 | throw new IllegalArgumentException( |
| 149 | "Distance constraint cannot be null."); |
| 150 | } |
| 151 | |
| 152 | this.constraint = constraint; |
| 153 | this.minDistance = constraint.getMinDistance(); |
| 154 | this.maxDistance = constraint.getMaxDistance(); |
| 155 | this.isOrdered = constraint.isOrdered(); |
| 156 | this.exclusion = constraint.isExclusion(); |
| 157 | this.distanceUnit = constraint.getUnit(); |
| 158 | |
| 159 | if (constraint.getElementQuery() != null) { |
| 160 | spanName = "spanElementDistance"; |
| 161 | this.elementQuery = constraint.getElementQuery(); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 162 | } |
| 163 | else { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 164 | spanName = "spanDistance"; |
| 165 | } |
| Eliza Margaretha | 609fcc6 | 2014-02-13 14:10:20 +0000 | [diff] [blame] | 166 | } |
| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 167 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 168 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 169 | @Override |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 170 | public String toString (String field) { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 171 | StringBuilder sb = new StringBuilder(); |
| 172 | sb.append(this.spanName); |
| 173 | sb.append("("); |
| 174 | sb.append(firstClause.toString(field)); |
| 175 | sb.append(", "); |
| 176 | sb.append(secondClause.toString(field)); |
| 177 | sb.append(", "); |
| 178 | sb.append("[("); |
| 179 | sb.append(distanceUnit); |
| 180 | sb.append("["); |
| 181 | sb.append(minDistance); |
| 182 | sb.append(":"); |
| 183 | sb.append(maxDistance); |
| 184 | sb.append("], "); |
| 185 | sb.append(isOrdered ? "ordered, " : "notOrdered, "); |
| 186 | sb.append(exclusion ? "excluded)])" : "notExcluded)])"); |
| 187 | sb.append(ToStringUtils.boost(getBoost())); |
| 188 | return sb.toString(); |
| 189 | } |
| Eliza Margaretha | 83b9537 | 2014-01-23 09:18:07 +0000 | [diff] [blame] | 190 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 191 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 192 | @Override |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 193 | public SpanDistanceQuery clone () { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 194 | SpanDistanceQuery spanDistanceQuery = new SpanDistanceQuery( |
| 195 | (SpanQuery) firstClause.clone(), |
| 196 | (SpanQuery) secondClause.clone(), this.constraint, |
| 197 | this.collectPayloads); |
| Eliza Margaretha | 83b9537 | 2014-01-23 09:18:07 +0000 | [diff] [blame] | 198 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 199 | if (this.elementQuery != null) { |
| 200 | spanDistanceQuery.setElementQuery(this.elementQuery); |
| 201 | } |
| 202 | spanDistanceQuery.setBoost(getBoost()); |
| 203 | return spanDistanceQuery; |
| 204 | } |
| Eliza Margaretha | 83b9537 | 2014-01-23 09:18:07 +0000 | [diff] [blame] | 205 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 206 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 207 | @Override |
| Akron | 700c1eb | 2015-09-25 16:57:30 +0200 | [diff] [blame] | 208 | public Spans getSpans (LeafReaderContext context, Bits acceptDocs, |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 209 | Map<Term, TermContext> termContexts) throws IOException { |
| Eliza Margaretha | 83b9537 | 2014-01-23 09:18:07 +0000 | [diff] [blame] | 210 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 211 | if (this.elementQuery != null) { |
| 212 | if (isExclusion()) { |
| 213 | return new ElementDistanceExclusionSpans(this, context, |
| Eliza Margaretha | 9544978 | 2014-12-16 16:23:37 +0000 | [diff] [blame] | 214 | acceptDocs, termContexts); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 215 | } |
| 216 | else if (isOrdered) { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 217 | return new ElementDistanceSpans(this, context, acceptDocs, |
| 218 | termContexts); |
| 219 | } |
| 220 | return new UnorderedElementDistanceSpans(this, context, acceptDocs, |
| 221 | termContexts); |
| Eliza Margaretha | 8e274e3 | 2014-01-28 15:09:30 +0000 | [diff] [blame] | 222 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 223 | } |
| 224 | else if (isExclusion()) { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 225 | return new DistanceExclusionSpans(this, context, acceptDocs, |
| Eliza Margaretha | 9544978 | 2014-12-16 16:23:37 +0000 | [diff] [blame] | 226 | termContexts); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 227 | } |
| 228 | else if (isOrdered) { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 229 | return new TokenDistanceSpans(this, context, acceptDocs, |
| 230 | termContexts); |
| 231 | } |
| 232 | return new UnorderedTokenDistanceSpans(this, context, acceptDocs, |
| 233 | termContexts); |
| 234 | } |
| Eliza Margaretha | 609fcc6 | 2014-02-13 14:10:20 +0000 | [diff] [blame] | 235 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 236 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 237 | /** |
| Eliza Margaretha | 8551e5b | 2014-12-15 16:46:18 +0000 | [diff] [blame] | 238 | * Returns the minimum distance constraint. |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 239 | * |
| Eliza Margaretha | 8551e5b | 2014-12-15 16:46:18 +0000 | [diff] [blame] | 240 | * @return the minimum distance constraint |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 241 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 242 | public int getMinDistance () { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 243 | return minDistance; |
| 244 | } |
| Eliza Margaretha | 609fcc6 | 2014-02-13 14:10:20 +0000 | [diff] [blame] | 245 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 246 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 247 | /** |
| Eliza Margaretha | 8551e5b | 2014-12-15 16:46:18 +0000 | [diff] [blame] | 248 | * Sets the minimum distance constraint. |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 249 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 250 | * @param minDistance |
| 251 | * the minimum distance constraint |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 252 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 253 | public void setMinDistance (int minDistance) { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 254 | this.minDistance = minDistance; |
| 255 | } |
| 256 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 257 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 258 | /** |
| Eliza Margaretha | 8551e5b | 2014-12-15 16:46:18 +0000 | [diff] [blame] | 259 | * Returns the maximum distance. |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 260 | * |
| Eliza Margaretha | 8551e5b | 2014-12-15 16:46:18 +0000 | [diff] [blame] | 261 | * @return the maximum distance constraint |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 262 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 263 | public int getMaxDistance () { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 264 | return maxDistance; |
| 265 | } |
| 266 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 267 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 268 | /** |
| Eliza Margaretha | 8551e5b | 2014-12-15 16:46:18 +0000 | [diff] [blame] | 269 | * Sets a maximum distance. |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 270 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 271 | * @param maxDistance |
| 272 | * the maximum distance |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 273 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 274 | public void setMaxDistance (int maxDistance) { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 275 | this.maxDistance = maxDistance; |
| 276 | } |
| 277 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 278 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 279 | /** |
| Eliza Margaretha | 8551e5b | 2014-12-15 16:46:18 +0000 | [diff] [blame] | 280 | * Returns the element query used as the distance unit. |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 281 | * |
| 282 | * @return the element distance unit |
| 283 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 284 | public SpanElementQuery getElementQuery () { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 285 | return elementQuery; |
| 286 | } |
| 287 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 288 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 289 | /** |
| Eliza Margaretha | 8551e5b | 2014-12-15 16:46:18 +0000 | [diff] [blame] | 290 | * Sets the specified element query used as the distance unit. |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 291 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 292 | * @param elementQuery |
| 293 | * the SpanElementQuery used as the distance unit |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 294 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 295 | public void setElementQuery (SpanElementQuery elementQuery) { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 296 | this.elementQuery = elementQuery; |
| 297 | } |
| 298 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 299 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 300 | /** |
| 301 | * Tells weather the second sub-span should co-occur or not. |
| Eliza Margaretha | 8551e5b | 2014-12-15 16:46:18 +0000 | [diff] [blame] | 302 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 303 | * @return a boolean with <code>true</code> if the second sub-span |
| 304 | * should |
| Eliza Margaretha | 8551e5b | 2014-12-15 16:46:18 +0000 | [diff] [blame] | 305 | * <em>not</em> co-occur, <code>false</code> otherwise. |
| 306 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 307 | public boolean isExclusion () { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 308 | return exclusion; |
| 309 | } |
| 310 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 311 | |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 312 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 313 | * Sets <code>true</code> if the second sub-span should |
| 314 | * <em>not</em> |
| Eliza Margaretha | 8551e5b | 2014-12-15 16:46:18 +0000 | [diff] [blame] | 315 | * co-occur, <code>false</code> otherwise. |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 316 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 317 | * @param exclusion |
| 318 | * a boolean with value <code>true</code> if the second |
| 319 | * sub-span should <em>not</em> co-occur, |
| 320 | * <code>false</code> |
| 321 | * otherwise. |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 322 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 323 | public void setExclusion (boolean exclusion) { |
| Eliza Margaretha | 7ebd6d9 | 2014-12-02 11:48:36 +0000 | [diff] [blame] | 324 | this.exclusion = exclusion; |
| 325 | } |
| Eliza Margaretha | 609fcc6 | 2014-02-13 14:10:20 +0000 | [diff] [blame] | 326 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 327 | |
| Eliza Margaretha | 9544978 | 2014-12-16 16:23:37 +0000 | [diff] [blame] | 328 | /** |
| 329 | * Tells whether the spans must occur in order or not. |
| 330 | * |
| 331 | * @return <code>true</code> if the spans must occur in order, |
| 332 | * <code>false</code> otherwise. |
| 333 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 334 | public boolean isOrdered () { |
| Eliza Margaretha | 9544978 | 2014-12-16 16:23:37 +0000 | [diff] [blame] | 335 | return isOrdered; |
| 336 | } |
| 337 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 338 | |
| Eliza Margaretha | 9544978 | 2014-12-16 16:23:37 +0000 | [diff] [blame] | 339 | /** |
| 340 | * Sets whether the spans must occur in order or not. |
| 341 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 342 | * @param isOrdered |
| 343 | * <code>true</code> if the spans must occur in order, |
| 344 | * <code>false</code> otherwise. |
| Eliza Margaretha | 9544978 | 2014-12-16 16:23:37 +0000 | [diff] [blame] | 345 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 346 | public void setOrder (boolean isOrdered) { |
| Eliza Margaretha | 9544978 | 2014-12-16 16:23:37 +0000 | [diff] [blame] | 347 | this.isOrdered = isOrdered; |
| 348 | } |
| 349 | |
| Eliza Margaretha | a2603fa | 2014-01-22 10:59:25 +0000 | [diff] [blame] | 350 | } |