blob: fe6370ec46d8c8937474ae184b648cc05c3eda17 [file] [log] [blame]
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00001import static org.junit.Assert.*;
2
Joachim Bingelcd30ed12014-12-03 16:14:13 +00003import java.io.IOException;
4import java.util.ArrayList;
5
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00006import org.junit.Test;
7
Joachim Bingelcd30ed12014-12-03 16:14:13 +00008import de.ids_mannheim.korap.query.serialize.QuerySerializer;
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00009import de.ids_mannheim.korap.util.QueryException;
10
Joachim Bingelcd30ed12014-12-03 16:14:13 +000011import com.fasterxml.jackson.core.JsonProcessingException;
12import com.fasterxml.jackson.databind.JsonNode;
13import com.fasterxml.jackson.databind.ObjectMapper;
14
15/**
16 * Tests for JSON-LD serialization of Cosmas II queries.
17 * @author Joachim Bingel (bingel@ids-mannheim.de)
18 * @version 1.0
19 */
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000020public class CosmasTreeTest {
Joachim Bingel8fbdfa72014-12-04 10:33:34 +000021
Michael Hanlbaf1a5e2014-05-15 19:51:40 +000022
Joachim Bingelcd30ed12014-12-03 16:14:13 +000023 String query;
24 ArrayList<JsonNode> operands;
25
26 QuerySerializer qs = new QuerySerializer();
27 ObjectMapper mapper = new ObjectMapper();
28 JsonNode res;
Joachim Bingel8fbdfa72014-12-04 10:33:34 +000029
Joachim Bingelcd30ed12014-12-03 16:14:13 +000030 @Test
31 public void testContext() throws QueryException, JsonProcessingException, IOException {
32 String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld";
33 query = "foo";
34 qs.setQuery(query, "cosmas2");
35 res = mapper.readTree(qs.toJSON());
36 assertEquals(contextString, res.get("@context").asText());
37 }
Joachim Bingel8fbdfa72014-12-04 10:33:34 +000038
39
Joachim Bingelcd30ed12014-12-03 16:14:13 +000040 @Test
41 public void testSingleToken() throws QueryException, JsonProcessingException, IOException {
42 query = "der";
43 qs.setQuery(query, "cosmas2");
44 res = mapper.readTree(qs.toJSON());
45 assertEquals("korap:token", res.at("/query/@type").asText());
46 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
47 assertEquals("der", res.at("/query/wrap/key").asText());
48 assertEquals("orth", res.at("/query/wrap/layer").asText());
49 assertEquals("match:eq", res.at("/query/wrap/match").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +000050
Joachim Bingelcd30ed12014-12-03 16:14:13 +000051 query = "&Mann";
52 qs.setQuery(query, "cosmas2");
53 res = mapper.readTree(qs.toJSON());
54 assertEquals("korap:token", res.at("/query/@type").asText());
55 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
56 assertEquals("Mann", res.at("/query/wrap/key").asText());
57 assertEquals("lemma", res.at("/query/wrap/layer").asText());
58 assertEquals("match:eq", res.at("/query/wrap/match").asText());
59 }
Joachim Bingelcd30ed12014-12-03 16:14:13 +000060
Joachim Bingel8fbdfa72014-12-04 10:33:34 +000061
62
Joachim Bingelcd30ed12014-12-03 16:14:13 +000063 @Test
64 public void testWildcardToken() throws QueryException, JsonProcessingException, IOException {
65 query = "*der";
66 qs.setQuery(query, "cosmas2");
67 res = mapper.readTree(qs.toJSON());
68 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
69 assertEquals("type:wildcard", res.at("/query/wrap/type").asText());
70 assertEquals("*der", res.at("/query/wrap/key").asText());
71 assertEquals("orth", res.at("/query/wrap/layer").asText());
72 assertEquals("match:eq", res.at("/query/wrap/match").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +000073
Joachim Bingelcd30ed12014-12-03 16:14:13 +000074 query = "*de*?r";
75 qs.setQuery(query, "cosmas2");
76 res = mapper.readTree(qs.toJSON());
77 assertEquals("*de*?r", res.at("/query/wrap/key").asText());
78 }
Joachim Bingel8fbdfa72014-12-04 10:33:34 +000079 //
Joachim Bingelcd30ed12014-12-03 16:14:13 +000080 @Test
81 public void testCaseSensitivityFlag() throws QueryException, JsonProcessingException, IOException {
82 query = "$deutscher";
83 qs.setQuery(query, "cosmas2");
84 res = mapper.readTree(qs.toJSON());
85 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
86 assertEquals("deutscher", res.at("/query/wrap/key").asText());
87 assertEquals(true, res.at("/query/wrap/caseInsensitive").asBoolean());
88 assertEquals("orth", res.at("/query/wrap/layer").asText());
89 assertEquals("match:eq", res.at("/query/wrap/match").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +000090
Joachim Bingelcd30ed12014-12-03 16:14:13 +000091 query = "$deutscher Bundestag";
92 qs.setQuery(query, "cosmas2");
93 res = mapper.readTree(qs.toJSON());
94 assertEquals("korap:group", res.at("/query/@type").asText());
95 assertEquals("operation:sequence", res.at("/query/operation").asText());
96 assertEquals("korap:term", res.at("/query/operands/0/wrap/@type").asText());
97 assertEquals("deutscher", res.at("/query/operands/0/wrap/key").asText());
98 assertEquals(true, res.at("/query/operands/0/wrap/caseInsensitive").asBoolean());
99 assertEquals("orth", res.at("/query/operands/0/wrap/layer").asText());
100 assertEquals("match:eq", res.at("/query/operands/0/wrap/match").asText());
101 assertEquals("Bundestag", res.at("/query/operands/1/wrap/key").asText());
102 assertEquals(true, res.at("/query/operands/1/wrap/caseInsensitive").isMissingNode());
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000103 }
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000104
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000105 @Test
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000106 public void testMORPH() throws QueryException, JsonProcessingException, IOException {
107 query = "MORPH(p=V)";
108 qs.setQuery(query, "cosmas2");
109 res = mapper.readTree(qs.toJSON());
110 assertEquals("korap:token", res.at("/query/@type").asText());
111 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
112 assertEquals("V", res.at("/query/wrap/key").asText());
113 assertEquals("p", res.at("/query/wrap/layer").asText());
114 assertEquals("match:eq", res.at("/query/wrap/match").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000115
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000116 query = "MORPH(V)";
117 qs.setQuery(query, "cosmas2");
118 res = mapper.readTree(qs.toJSON());
119 assertEquals("korap:token", res.at("/query/@type").asText());
120 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
121 assertEquals("V", res.at("/query/wrap/key").asText());
122 assertEquals("match:eq", res.at("/query/wrap/match").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000123
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000124 query = "MORPH(tt/p=V)";
125 qs.setQuery(query, "cosmas2");
126 res = mapper.readTree(qs.toJSON());
127 assertEquals("korap:token", res.at("/query/@type").asText());
128 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
129 assertEquals("V", res.at("/query/wrap/key").asText());
130 assertEquals("p", res.at("/query/wrap/layer").asText());
131 assertEquals("tt", res.at("/query/wrap/foundry").asText());
132 assertEquals("match:eq", res.at("/query/wrap/match").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000133
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000134 query = "MORPH(mate/m=temp:pres)";
135 qs.setQuery(query, "cosmas2");
136 res = mapper.readTree(qs.toJSON());
137 assertEquals("korap:token", res.at("/query/@type").asText());
138 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
139 assertEquals("temp", res.at("/query/wrap/key").asText());
140 assertEquals("pres", res.at("/query/wrap/value").asText());
141 assertEquals("m", res.at("/query/wrap/layer").asText());
142 assertEquals("mate", res.at("/query/wrap/foundry").asText());
143 assertEquals("match:eq", res.at("/query/wrap/match").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000144
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000145 query = "MORPH(tt/p=V & mate/m!=temp:pres)";
146 qs.setQuery(query, "cosmas2");
147 res = mapper.readTree(qs.toJSON());
148 assertEquals("korap:token", res.at("/query/@type").asText());
149 assertEquals("korap:termGroup", res.at("/query/wrap/@type").asText());
150 assertEquals("V", res.at("/query/wrap/operands/0/key").asText());
151 assertEquals("p", res.at("/query/wrap/operands/0/layer").asText());
152 assertEquals("tt", res.at("/query/wrap/operands/0/foundry").asText());
153 assertEquals("match:eq", res.at("/query/wrap/operands/0/match").asText());
154 assertEquals("temp", res.at("/query/wrap/operands/1/key").asText());
155 assertEquals("pres", res.at("/query/wrap/operands/1/value").asText());
156 assertEquals("m", res.at("/query/wrap/operands/1/layer").asText());
157 assertEquals("mate", res.at("/query/wrap/operands/1/foundry").asText());
158 assertEquals("match:ne", res.at("/query/wrap/operands/1/match").asText());
Joachim Bingel9a202ab2014-10-07 12:35:17 +0000159 }
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000160
Joachim Bingel9a202ab2014-10-07 12:35:17 +0000161 @Test
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000162 public void testSequence() throws QueryException, JsonProcessingException, IOException {
163 query = "der Mann";
164 qs.setQuery(query, "cosmas2");
165 res = mapper.readTree(qs.toJSON());
166 assertEquals("korap:group", res.at("/query/@type").asText());
167 assertEquals("operation:sequence", res.at("/query/operation").asText());
168 assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
169 assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText());
170 assertEquals(true, res.at("/query/operands/2").isMissingNode());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000171
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000172 query = "der Mann schläft";
173 qs.setQuery(query, "cosmas2");
174 res = mapper.readTree(qs.toJSON());
175 assertEquals("korap:group", res.at("/query/@type").asText());
176 assertEquals("operation:sequence", res.at("/query/operation").asText());
177 assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
178 assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText());
179 assertEquals("schläft", res.at("/query/operands/2/wrap/key").asText());
180 assertEquals(true, res.at("/query/operands/3").isMissingNode());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000181
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000182 query = "der Mann schläft lang";
183 qs.setQuery(query, "cosmas2");
184 res = mapper.readTree(qs.toJSON());
185 assertEquals("korap:group", res.at("/query/@type").asText());
186 assertEquals("operation:sequence", res.at("/query/operation").asText());
187 assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
188 assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText());
189 assertEquals("schläft", res.at("/query/operands/2/wrap/key").asText());
190 assertEquals("lang", res.at("/query/operands/3/wrap/key").asText());
191 assertEquals(true, res.at("/query/operands/4").isMissingNode());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000192
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000193 query = "der #ELEM(W)";
194 qs.setQuery(query, "cosmas2");
195 res = mapper.readTree(qs.toJSON());
196 assertEquals("korap:group", res.at("/query/@type").asText());
197 assertEquals("operation:sequence", res.at("/query/operation").asText());
198 assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
199 assertEquals("w", res.at("/query/operands/1/key").asText());
200 assertEquals("korap:span", res.at("/query/operands/1/@type").asText());
201 assertEquals(true, res.at("/query/operands/2").isMissingNode());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000202
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000203 query = "der #ELEM(W) Mann";
204 qs.setQuery(query, "cosmas2");
205 res = mapper.readTree(qs.toJSON());
206 assertEquals("korap:group", res.at("/query/@type").asText());
207 assertEquals("operation:sequence", res.at("/query/operation").asText());
208 assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
209 assertEquals("w", res.at("/query/operands/1/key").asText());
210 assertEquals("korap:span", res.at("/query/operands/1/@type").asText());
211 assertEquals("Mann", res.at("/query/operands/2/wrap/key").asText());
212 assertEquals(true, res.at("/query/operands/3").isMissingNode());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000213
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000214 query = "der MORPH(p=ADJA) Mann";
215 qs.setQuery(query, "cosmas2");
216 res = mapper.readTree(qs.toJSON());
217 assertEquals("korap:group", res.at("/query/@type").asText());
218 assertEquals("operation:sequence", res.at("/query/operation").asText());
219 assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
220 assertEquals("ADJA", res.at("/query/operands/1/wrap/key").asText());
221 assertEquals("p", res.at("/query/operands/1/wrap/layer").asText());
222 assertEquals("Mann", res.at("/query/operands/2/wrap/key").asText());
223 assertEquals(true, res.at("/query/operands/3").isMissingNode());
224 }
225
226 @Test
227 public void testOPOR() throws QueryException, JsonProcessingException, IOException {
228 query = "Sonne oder Mond";
229 qs.setQuery(query, "cosmas2");
230 res = mapper.readTree(qs.toJSON());
231 assertEquals("korap:group", res.at("/query/@type").asText());
232 assertEquals("operation:or", res.at("/query/operation").asText());
233 assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText());
234 assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText());
235 assertEquals(true, res.at("/query/operands/2").isMissingNode());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000236
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000237 query = "(Sonne scheint) oder Mond";
238 qs.setQuery(query, "cosmas2");
239 res = mapper.readTree(qs.toJSON());
240 assertEquals("korap:group", res.at("/query/@type").asText());
241 assertEquals("operation:or", res.at("/query/operation").asText());
242 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
243 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
244 assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key").asText());
245 assertEquals("scheint", res.at("/query/operands/0/operands/1/wrap/key").asText());
246 assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText());
247 assertEquals(true, res.at("/query/operands/2").isMissingNode());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000248
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000249 query = "(Sonne scheint) oder (Mond scheint)";
250 qs.setQuery(query, "cosmas2");
251 res = mapper.readTree(qs.toJSON());
252 assertEquals("korap:group", res.at("/query/@type").asText());
253 assertEquals("operation:or", res.at("/query/operation").asText());
254 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
255 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
256 assertEquals("korap:group", res.at("/query/operands/1/@type").asText());
257 assertEquals("operation:sequence", res.at("/query/operands/1/operation").asText());
258 assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key").asText());
259 assertEquals("scheint", res.at("/query/operands/0/operands/1/wrap/key").asText());
260 assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key").asText());
261 assertEquals("scheint", res.at("/query/operands/1/operands/1/wrap/key").asText());
262 assertEquals(true, res.at("/query/operands/2").isMissingNode());
263 }
264
265 @Test
266 public void testOPORAND() throws QueryException, JsonProcessingException, IOException {
267 query = "(Sonne oder Mond) und scheint";
268 qs.setQuery(query, "cosmas2");
269 res = mapper.readTree(qs.toJSON());
270 assertEquals("korap:group", res.at("/query/@type").asText());
271 assertEquals("operation:sequence", res.at("/query/operation").asText());
272 assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText());
273 assertEquals("t", res.at("/query/distances/0/key").asText());
274 assertEquals(0, res.at("/query/distances/0/min").asInt());
275 assertEquals(0, res.at("/query/distances/0/max").asInt());
276 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
277 assertEquals("operation:or", res.at("/query/operands/0/operation").asText());
278 assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key").asText());
279 assertEquals("Mond", res.at("/query/operands/0/operands/1/wrap/key").asText());
280 assertEquals("korap:token", res.at("/query/operands/1/@type").asText());
281 assertEquals("scheint", res.at("/query/operands/1/wrap/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000282
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000283 query = "scheint und (Sonne oder Mond)";
284 qs.setQuery(query, "cosmas2");
285 res = mapper.readTree(qs.toJSON());
286 assertEquals("korap:group", res.at("/query/@type").asText());
287 assertEquals("operation:sequence", res.at("/query/operation").asText());
288 assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText());
289 assertEquals("t", res.at("/query/distances/0/key").asText());
290 assertEquals(0, res.at("/query/distances/0/min").asInt());
291 assertEquals(0, res.at("/query/distances/0/max").asInt());
292 assertEquals("korap:token", res.at("/query/operands/0/@type").asText());
293 assertEquals("scheint", res.at("/query/operands/0/wrap/key").asText());
294 assertEquals("korap:group", res.at("/query/operands/1/@type").asText());
295 assertEquals("operation:or", res.at("/query/operands/1/operation").asText());
296 assertEquals("Sonne", res.at("/query/operands/1/operands/0/wrap/key").asText());
297 assertEquals("Mond", res.at("/query/operands/1/operands/1/wrap/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000298
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000299 query = "Regen und scheint und (Sonne oder Mond)";
300 qs.setQuery(query, "cosmas2");
301 res = mapper.readTree(qs.toJSON());
302 assertEquals("korap:group", res.at("/query/@type").asText());
303 assertEquals("operation:sequence", res.at("/query/operation").asText());
304 assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText());
305 assertEquals("t", res.at("/query/distances/0/key").asText());
306 assertEquals(0, res.at("/query/distances/0/min").asInt());
307 assertEquals(0, res.at("/query/distances/0/max").asInt());
308 assertEquals("korap:token", res.at("/query/operands/0/@type").asText());
309 assertEquals("Regen", res.at("/query/operands/0/wrap/key").asText());
310 assertEquals("korap:group", res.at("/query/@type").asText());
311 assertEquals("operation:sequence", res.at("/query/operation").asText());
312 assertEquals("cosmas:distance", res.at("/query/operands/1/distances/0/@type").asText());
313 assertEquals("t", res.at("/query/operands/1/distances/0/key").asText());
314 assertEquals(0, res.at("/query/operands/1/distances/0/min").asInt());
315 assertEquals(0, res.at("/query/operands/1/distances/0/max").asInt());
316 assertEquals("scheint", res.at("/query/operands/1/operands/0/wrap/key").asText());
317 assertEquals("korap:group", res.at("/query/operands/1/operands/1/@type").asText());
318 assertEquals("operation:or", res.at("/query/operands/1/operands/1/operation").asText());
319 assertEquals("Sonne", res.at("/query/operands/1/operands/1/operands/0/wrap/key").asText());
320 assertEquals("Mond", res.at("/query/operands/1/operands/1/operands/1/wrap/key").asText());
Joachim Bingel8c640e42014-02-07 16:20:47 +0000321 }
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000322
Joachim Bingel8c640e42014-02-07 16:20:47 +0000323 @Test
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000324 public void testOPNOT() throws QueryException, JsonProcessingException, IOException {
325 query = "Sonne nicht Mond";
326 qs.setQuery(query, "cosmas2");
327 res = mapper.readTree(qs.toJSON());
328 assertEquals("korap:group", res.at("/query/@type").asText());
329 assertEquals("operation:sequence", res.at("/query/operation").asText());
330 assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText());
331 assertEquals("t", res.at("/query/distances/0/key").asText());
332 assertEquals(0, res.at("/query/distances/0/min").asInt());
333 assertEquals(0, res.at("/query/distances/0/max").asInt());
334 assertEquals(true, res.at("/query/distances/0/exclude").asBoolean());
335 assertEquals("korap:token", res.at("/query/operands/0/@type").asText());
336 assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText());
337 assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000338
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000339 query = "Sonne nicht Mond nicht Sterne";
340 qs.setQuery(query, "cosmas2");
341 res = mapper.readTree(qs.toJSON());
342 assertEquals("korap:group", res.at("/query/@type").asText());
343 assertEquals("operation:sequence", res.at("/query/operation").asText());
344 assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText());
345 assertEquals("t", res.at("/query/distances/0/key").asText());
346 assertEquals(0, res.at("/query/distances/0/min").asInt());
347 assertEquals(0, res.at("/query/distances/0/max").asInt());
348 assertEquals(true, res.at("/query/distances/0/exclude").asBoolean());
349 assertEquals("korap:token", res.at("/query/operands/0/@type").asText());
350 assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText());
351 assertEquals("korap:group", res.at("/query/operands/1/@type").asText());
352 assertEquals("operation:sequence", res.at("/query/operands/1/operation").asText());
353 assertEquals("cosmas:distance", res.at("/query/operands/1/distances/0/@type").asText());
354 assertEquals("t", res.at("/query/operands/1/distances/0/key").asText());
355 assertEquals(0, res.at("/query/operands/1/distances/0/min").asInt());
356 assertEquals(0, res.at("/query/operands/1/distances/0/max").asInt());
357 assertEquals(true, res.at("/query/operands/1/distances/0/exclude").asBoolean());
358 assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key").asText());
359 assertEquals("Sterne", res.at("/query/operands/1/operands/1/wrap/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000360
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000361 query = "(Sonne nicht Mond) nicht Sterne";
362 qs.setQuery(query, "cosmas2");
363 res = mapper.readTree(qs.toJSON());
364 assertEquals("korap:group", res.at("/query/@type").asText());
365 assertEquals("operation:sequence", res.at("/query/operation").asText());
366 assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText());
367 assertEquals("t", res.at("/query/distances/0/key").asText());
368 assertEquals(0, res.at("/query/distances/0/min").asInt());
369 assertEquals(0, res.at("/query/distances/0/max").asInt());
370 assertEquals(true, res.at("/query/distances/0/exclude").asBoolean());
371 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
372 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
373 assertEquals("cosmas:distance", res.at("/query/operands/0/distances/0/@type").asText());
374 assertEquals("t", res.at("/query/operands/0/distances/0/key").asText());
375 assertEquals(0, res.at("/query/operands/0/distances/0/min").asInt());
376 assertEquals(0, res.at("/query/operands/0/distances/0/max").asInt());
377 assertEquals(true, res.at("/query/operands/0/distances/0/exclude").asBoolean());
378 assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key").asText());
379 assertEquals("Mond", res.at("/query/operands/0/operands/1/wrap/key").asText());
380 assertEquals("korap:token", res.at("/query/operands/1/@type").asText());
381 assertEquals("Sterne", res.at("/query/operands/1/wrap/key").asText());
Joachim Bingelffd65e32014-01-22 14:22:57 +0000382 }
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000383
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000384 @Test
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000385 public void testOPPROX() throws QueryException, JsonProcessingException, IOException {
386 query = "Sonne /+w1:4 Mond";
387 qs.setQuery(query, "cosmas2");
388 res = mapper.readTree(qs.toJSON());
389 assertEquals("korap:reference", res.at("/query/@type").asText());
390 assertEquals("operation:focus", res.at("/query/operation").asText());
391 assertEquals(129, res.at("/query/classRef/0").asInt());
392 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
393 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
394 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
395 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
396 assertEquals(1, res.at("/query/operands/0/distances/0/boundary/min").asInt());
397 assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt());
398 assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
399 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
400 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
401 assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
402 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
403 assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
404 assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
405 assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000406
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000407 query = "Sonne /+w1:4,s0,p1:3 Mond";
408 qs.setQuery(query, "cosmas2");
409 res = mapper.readTree(qs.toJSON());
410 assertEquals("korap:reference", res.at("/query/@type").asText());
411 assertEquals("operation:focus", res.at("/query/operation").asText());
412 assertEquals(129, res.at("/query/classRef/0").asInt());
413 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
414 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
415 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
416 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
417 assertEquals(1, res.at("/query/operands/0/distances/0/boundary/min").asInt());
418 assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt());
419 assertEquals("s", res.at("/query/operands/0/distances/1/key").asText());
420 assertEquals(0, res.at("/query/operands/0/distances/1/boundary/min").asInt());
421 assertEquals("p", res.at("/query/operands/0/distances/2/key").asText());
422 assertEquals(1, res.at("/query/operands/0/distances/2/boundary/min").asInt());
423 assertEquals(3, res.at("/query/operands/0/distances/2/boundary/max").asInt());
424 assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
425 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
426 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
427 assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
428 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
429 assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
430 assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
431 assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000432
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000433 query = "Sonne /+w4 Mond";
434 qs.setQuery(query, "cosmas2");
435 res = mapper.readTree(qs.toJSON());
436 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
437 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
438 assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt());
439 assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000440
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000441 query = "Sonne /-w4 Mond";
442 qs.setQuery(query, "cosmas2");
443 res = mapper.readTree(qs.toJSON());
444 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
445 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
446 assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt());
447 assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt());
448 assertEquals("Mond", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
449 assertEquals("Sonne", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000450
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000451 query = "Sonne /w4 Mond";
452 qs.setQuery(query, "cosmas2");
453 res = mapper.readTree(qs.toJSON());
454 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
455 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
456 assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt());
457 assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt());
458 assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
459 assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
460 assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean());
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000461 }
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000462
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000463 @Test
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000464 public void testOPPROXNested() throws QueryException, JsonProcessingException, IOException {
465 query = "Sonne /+w1:4 Mond /+w1:7 Sterne";
466 qs.setQuery(query, "cosmas2");
467 res = mapper.readTree(qs.toJSON());
468 assertEquals("korap:reference", res.at("/query/@type").asText());
469 assertEquals("operation:focus", res.at("/query/operation").asText());
470 assertEquals(129, res.at("/query/classRef/0").asInt());
471 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
472 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
473 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
474 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
475 assertEquals(1, res.at("/query/operands/0/distances/0/boundary/min").asInt());
476 assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt());
477 assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
478 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
479 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
480 assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
481 assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
482 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
483 assertEquals("korap:reference", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
484 assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/classRef/0").asInt());
485 assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operands/0/operation").asText());
486 assertEquals("operation:sequence", res.at("/query/operands/0/operands/1/operands/0/operands/0/operation").asText());
487 assertEquals("w", res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/key").asText());
488 assertEquals(1, res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/boundary/min").asInt());
489 assertEquals(7, res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/boundary/max").asInt());
490 assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/classOut").asInt());
491 assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
492 assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/classOut").asInt());
493 assertEquals("Sterne", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000494
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000495 query = "Sonne /+w1:4 Mond /-w1:7 Sterne";
496 qs.setQuery(query, "cosmas2");
497 res = mapper.readTree(qs.toJSON());
498 assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
499 assertEquals("Sterne", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
500 assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000501
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000502 query = "Sonne /-w4 Mond /+w2 Sterne";
503 qs.setQuery(query, "cosmas2");
504 res = mapper.readTree(qs.toJSON());
505 assertEquals("korap:reference", res.at("/query/@type").asText());
506 assertEquals("operation:focus", res.at("/query/operation").asText());
507 assertEquals(129, res.at("/query/classRef/0").asInt());
508 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
509 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
510 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
511 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
512 assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt());
513 assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt());
514 assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
515 assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText());
516 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
517 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
518 assertEquals("Sonne", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
519 assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
520 assertEquals("korap:reference", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
521 assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/classRef/0").asInt());
522 assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
523 assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operands/0/operands/0/operation").asText());
524 assertEquals("w", res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/key").asText());
525 assertEquals(0, res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/boundary/min").asInt());
526 assertEquals(2, res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/boundary/max").asInt());
527 assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/classOut").asInt());
528 assertEquals("Mond", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
529 assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/classOut").asInt());
530 assertEquals("Sterne", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
531
532 }
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000533
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000534 @Test
535 public void testOPIN() throws QueryException, JsonProcessingException, IOException {
536 query = "wegen #IN <s>";
537 qs.setQuery(query, "cosmas2");
538 res = mapper.readTree(qs.toJSON());
539 assertEquals("korap:reference", res.at("/query/@type").asText());
540 assertEquals("operation:focus", res.at("/query/operation").asText());
541 assertEquals(130, res.at("/query/classRef/0").asInt());
542 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
543 assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000544 assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck/0").asText());
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000545 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
546 assertEquals("operation:position", res.at("/query/operands/0/operands/0/operation").asText());
547 assertEquals(true, res.at("/query/operands/0/operands/0/frames/0").isMissingNode());
548 assertEquals(129, res.at("/query/operands/0/classIn/0").asInt());
549 assertEquals(130, res.at("/query/operands/0/classIn/1").asInt());
550 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
551 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
552 assertEquals(129, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
553 assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText());
554 assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/operands/0/key").asText());
555 assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
556 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
557 assertEquals(130, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
558 assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/1/operands/0/@type").asText());
559 assertEquals("wegen", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000560
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000561 query = "wegen #IN(L) <s>";
562 qs.setQuery(query, "cosmas2");
563 res = mapper.readTree(qs.toJSON());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000564 assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck/0").asText());
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000565 assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText());
566 assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000567
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000568 query = "wegen #IN(F) <s>";
569 qs.setQuery(query, "cosmas2");
570 res = mapper.readTree(qs.toJSON());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000571 assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck/0").asText());
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000572 assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
573 assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000574
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000575 query = "wegen #IN(FI) <s>";
576 qs.setQuery(query, "cosmas2");
577 res = mapper.readTree(qs.toJSON());
578 assertEquals("classRefCheck:unequals", res.at("/query/operands/0/classRefCheck/0").asText());
579 assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck/1").asText());
580 assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
581 assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000582
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000583 query = "wegen #IN(FE) <s>";
584 qs.setQuery(query, "cosmas2");
585 res = mapper.readTree(qs.toJSON());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000586 assertEquals("classRefCheck:equals", res.at("/query/operands/0/classRefCheck/0").asText());
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000587 assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
588 assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000589
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000590 query = "wegen #IN(%, L) <s>";
591 qs.setQuery(query, "cosmas2");
592 res = mapper.readTree(qs.toJSON());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000593 assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck/0").asText());
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000594 assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText());
595 assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode());
596 assertEquals(true, res.at("/query/operands/0/operands/0/exclude").asBoolean());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000597
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000598 query = "wegen #IN(FE,ALL,%,MIN) <s>";
599 qs.setQuery(query, "cosmas2");
600 res = mapper.readTree(qs.toJSON());
601 assertEquals(true, res.at("/query/reset").asBoolean());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000602 assertEquals("classRefCheck:equals", res.at("/query/operands/0/classRefCheck/0").asText());
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000603 assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
604 assertEquals(true, res.at("/query/operands/0/operands/0/exclude").asBoolean());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000605
Joachim Bingeld5161a12014-01-08 11:15:49 +0000606 }
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000607
Joachim Bingeld5161a12014-01-08 11:15:49 +0000608 @Test
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000609 public void testOPOV() throws QueryException, JsonProcessingException, IOException {
610 query = "wegen #OV <s>";
611 qs.setQuery(query, "cosmas2");
612 res = mapper.readTree(qs.toJSON());
613 assertEquals("korap:reference", res.at("/query/@type").asText());
614 assertEquals("operation:focus", res.at("/query/operation").asText());
615 assertEquals(130, res.at("/query/classRef/0").asInt());
616 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
617 assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000618 assertEquals("classRefCheck:intersects", res.at("/query/operands/0/classRefCheck/0").asText());
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000619 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
620 assertEquals("operation:position", res.at("/query/operands/0/operands/0/operation").asText());
621 assertEquals(true, res.at("/query/operands/0/operands/0/frames/0").isMissingNode());
622 assertEquals(129, res.at("/query/operands/0/classIn/0").asInt());
623 assertEquals(130, res.at("/query/operands/0/classIn/1").asInt());
624 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
625 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
626 assertEquals(129, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
627 assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText());
628 assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/operands/0/key").asText());
629 assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
630 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
631 assertEquals(130, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
632 assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/1/operands/0/@type").asText());
633 assertEquals("wegen", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000634
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000635 query = "wegen #OV(L) <s>";
636 qs.setQuery(query, "cosmas2");
637 res = mapper.readTree(qs.toJSON());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000638 assertEquals("classRefCheck:intersects", res.at("/query/operands/0/classRefCheck/0").asText());
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000639 assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText());
640 assertEquals("frames:overlapsLeft", res.at("/query/operands/0/operands/0/frames/1").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000641
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000642 query = "wegen #OV(F) <s>";
643 qs.setQuery(query, "cosmas2");
644 res = mapper.readTree(qs.toJSON());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000645 assertEquals("classRefCheck:intersects", res.at("/query/operands/0/classRefCheck/0").asText());
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000646 assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
647 assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000648
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000649 query = "wegen #OV(FI) <s>";
650 qs.setQuery(query, "cosmas2");
651 res = mapper.readTree(qs.toJSON());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000652 assertEquals("classRefCheck:unequals", res.at("/query/operands/0/classRefCheck/0").asText());
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000653 assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000654
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000655 query = "wegen #OV(FE) <s>";
656 qs.setQuery(query, "cosmas2");
657 res = mapper.readTree(qs.toJSON());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000658 assertEquals("classRefCheck:equals", res.at("/query/operands/0/classRefCheck/0").asText());
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000659 assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
660 }
661
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000662
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000663 @Test
664 public void testBEG_END() throws QueryException, JsonProcessingException, IOException {
665 query = "#BEG(der /w3:5 Mann)";
666 qs.setQuery(query, "cosmas2");
667 res = mapper.readTree(qs.toJSON());
668 assertEquals("korap:reference", res.at("/query/@type").asText());
669 assertEquals("operation:focus", res.at("/query/operation").asText());
670 assertEquals(0, res.at("/query/spanRef/0").asInt());
671 assertEquals(1, res.at("/query/spanRef/1").asInt());
672 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
673 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
674 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
675 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
676 assertEquals(3, res.at("/query/operands/0/distances/0/boundary/min").asInt());
677 assertEquals(5, res.at("/query/operands/0/distances/0/boundary/max").asInt());
678 assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean());
679 assertEquals("korap:token", res.at("/query/operands/0/operands/0/@type").asText());
680 assertEquals("der", res.at("/query/operands/0/operands/0/wrap/key").asText());
681 assertEquals("Mann", res.at("/query/operands/0/operands/1/wrap/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000682
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000683 query = "#BEG(der /w3:5 Mann) /+w10 kommt";
684 qs.setQuery(query, "cosmas2");
685 res = mapper.readTree(qs.toJSON());
686 assertEquals("korap:reference", res.at("/query/@type").asText());
687 assertEquals("operation:focus", res.at("/query/operation").asText());
688 assertEquals(129, res.at("/query/classRef/0").asInt());
689 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
690 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
691 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
692 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
693 assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt());
694 assertEquals(10, res.at("/query/operands/0/distances/0/boundary/max").asInt());
695 assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
696 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
697 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
698 assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
699 assertEquals("korap:reference", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
700 assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
701 assertEquals(0, res.at("/query/operands/0/operands/0/operands/0/spanRef/0").asInt());
702 assertEquals(1, res.at("/query/operands/0/operands/0/operands/0/spanRef/1").asInt());
703 assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText());
704 assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operands/0/operands/0/operation").asText());
705 assertEquals("korap:distance", res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/@type").asText());
706 assertEquals("w", res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/key").asText());
707 assertEquals(3, res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/boundary/min").asInt());
708 assertEquals(5, res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/boundary/max").asInt());
709 assertEquals(false, res.at("/query/operands/0/operands/0/operands/0/operands/0/inOrder").asBoolean());
710 assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/@type").asText());
711 assertEquals("der", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
712 assertEquals("Mann", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/wrap/key").asText());
713 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
714 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
715 assertEquals("korap:token", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
716 assertEquals("kommt", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000717
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000718 query = "kommt /+w10 #BEG(der /w3:5 Mann)";
719 qs.setQuery(query, "cosmas2");
720 res = mapper.readTree(qs.toJSON());
721 assertEquals("korap:reference", res.at("/query/@type").asText());
722 assertEquals("operation:focus", res.at("/query/operation").asText());
723 assertEquals(129, res.at("/query/classRef/0").asInt());
724 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
725 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
726 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
727 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
728 assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt());
729 assertEquals(10, res.at("/query/operands/0/distances/0/boundary/max").asInt());
730 assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
731 assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText());
732 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
733 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
734 assertEquals("korap:reference", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
735 assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operands/0/operation").asText());
736 assertEquals(0, res.at("/query/operands/0/operands/1/operands/0/spanRef/0").asInt());
737 assertEquals(1, res.at("/query/operands/0/operands/1/operands/0/spanRef/1").asInt());
738 assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/operands/0/@type").asText());
739 assertEquals("operation:sequence", res.at("/query/operands/0/operands/1/operands/0/operands/0/operation").asText());
740 assertEquals("korap:distance", res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/@type").asText());
741 assertEquals("w", res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/key").asText());
742 assertEquals(3, res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/boundary/min").asInt());
743 assertEquals(5, res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/boundary/max").asInt());
744 assertEquals(false, res.at("/query/operands/0/operands/1/operands/0/operands/0/inOrder").asBoolean());
745 assertEquals("korap:token", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/@type").asText());
746 assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/wrap/key").asText());
747 assertEquals("Mann", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/wrap/key").asText());
748 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
749 assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
750 assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
751 assertEquals("kommt", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000752
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000753 query = "#END(der /w3:5 Mann)";
754 qs.setQuery(query, "cosmas2");
755 res = mapper.readTree(qs.toJSON());
756 assertEquals("korap:reference", res.at("/query/@type").asText());
757 assertEquals("operation:focus", res.at("/query/operation").asText());
758 assertEquals(-1, res.at("/query/spanRef/0").asInt());
759 assertEquals(1, res.at("/query/spanRef/1").asInt());
760 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
761 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
762 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
763 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
764 assertEquals(3, res.at("/query/operands/0/distances/0/boundary/min").asInt());
765 assertEquals(5, res.at("/query/operands/0/distances/0/boundary/max").asInt());
766 assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean());
767 assertEquals("korap:token", res.at("/query/operands/0/operands/0/@type").asText());
768 assertEquals("der", res.at("/query/operands/0/operands/0/wrap/key").asText());
769 assertEquals("Mann", res.at("/query/operands/0/operands/1/wrap/key").asText());
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000770 }
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000771
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000772 @Test
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000773 public void testELEM() throws QueryException, JsonProcessingException, IOException {
774 query = "#ELEM(S)";
775 qs.setQuery(query, "cosmas2");
776 res = mapper.readTree(qs.toJSON());
777 assertEquals("korap:span", res.at("/query/@type").asText());
778 assertEquals("s", res.at("/query/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000779
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000780 query = "#ELEM(W ANA=N)";
781 qs.setQuery(query, "cosmas2");
782 res = mapper.readTree(qs.toJSON());
783 assertEquals("korap:span", res.at("/query/@type").asText());
784 assertEquals("w", res.at("/query/key").asText());
785 assertEquals("korap:term", res.at("/query/attr/@type").asText());
786 assertEquals("N", res.at("/query/attr/key").asText());
787 assertEquals("p", res.at("/query/attr/layer").asText());
788 assertEquals("match:eq", res.at("/query/attr/match").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000789
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000790 query = "#ELEM(W ANA != 'N V')";
791 qs.setQuery(query, "cosmas2");
792 res = mapper.readTree(qs.toJSON());
793 assertEquals("korap:span", res.at("/query/@type").asText());
794 assertEquals("w", res.at("/query/key").asText());
795 assertEquals("korap:termGroup", res.at("/query/attr/@type").asText());
796 assertEquals("relation:and", res.at("/query/attr/relation").asText());
797 assertEquals("korap:term", res.at("/query/attr/operands/0/@type").asText());
798 assertEquals("N", res.at("/query/attr/operands/0/key").asText());
799 assertEquals("p", res.at("/query/attr/operands/0/layer").asText());
800 assertEquals("match:ne", res.at("/query/attr/operands/0/match").asText());
801 assertEquals("korap:term", res.at("/query/attr/operands/1/@type").asText());
802 assertEquals("V", res.at("/query/attr/operands/1/key").asText());
803 assertEquals("p", res.at("/query/attr/operands/1/layer").asText());
804 assertEquals("match:ne", res.at("/query/attr/operands/1/match").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000805
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000806 query = "#ELEM(W ANA != 'N A V' Genre = Sport)";
807 qs.setQuery(query, "cosmas2");
808 res = mapper.readTree(qs.toJSON());
809 assertEquals("korap:span", res.at("/query/@type").asText());
810 assertEquals("w", res.at("/query/key").asText());
811 assertEquals("korap:termGroup", res.at("/query/attr/@type").asText());
812 assertEquals("relation:and", res.at("/query/attr/relation").asText());
813 assertEquals("korap:termGroup", res.at("/query/attr/operands/0/@type").asText());
814 assertEquals("relation:and", res.at("/query/attr/operands/0/relation").asText());
815 assertEquals("N", res.at("/query/attr/operands/0/operands/0/key").asText());
816 assertEquals("A", res.at("/query/attr/operands/0/operands/1/key").asText());
817 assertEquals("V", res.at("/query/attr/operands/0/operands/2/key").asText());
818 assertEquals("Genre", res.at("/query/attr/operands/1/layer").asText());
819 assertEquals("Sport", res.at("/query/attr/operands/1/key").asText());
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000820
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000821 query = "#ELEM(W ANA != 'N A V' Genre != 'Sport Politik')";
822 qs.setQuery(query, "cosmas2");
823 res = mapper.readTree(qs.toJSON());
824 assertEquals("korap:span", res.at("/query/@type").asText());
825 assertEquals("w", res.at("/query/key").asText());
826 assertEquals("korap:termGroup", res.at("/query/attr/@type").asText());
827 assertEquals("relation:and", res.at("/query/attr/relation").asText());
828 assertEquals("korap:termGroup", res.at("/query/attr/operands/0/@type").asText());
829 assertEquals("relation:and", res.at("/query/attr/operands/0/relation").asText());
830 assertEquals("korap:termGroup", res.at("/query/attr/operands/1/@type").asText());
831 assertEquals("relation:and", res.at("/query/attr/operands/1/relation").asText());
832 assertEquals("N", res.at("/query/attr/operands/0/operands/0/key").asText());
833 assertEquals("A", res.at("/query/attr/operands/0/operands/1/key").asText());
834 assertEquals("V", res.at("/query/attr/operands/0/operands/2/key").asText());
835 assertEquals("match:ne", res.at("/query/attr/operands/0/operands/2/match").asText());
836 assertEquals("Genre", res.at("/query/attr/operands/1/operands/0/layer").asText());
837 assertEquals("Sport", res.at("/query/attr/operands/1/operands/0/key").asText());
838 assertEquals("Genre", res.at("/query/attr/operands/1/operands/1/layer").asText());
839 assertEquals("Politik", res.at("/query/attr/operands/1/operands/1/key").asText());
840 assertEquals("match:ne", res.at("/query/attr/operands/1/operands/1/match").asText());
841 }
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000842 @Test
843 public void testOPALL() throws QueryException, JsonProcessingException, IOException {
844 query = "#ALL(gehen /w1:10 voran)";
845 qs.setQuery(query, "cosmas2");
846 res = mapper.readTree(qs.toJSON());
847 assertEquals("korap:group", res.at("/query/@type").asText());
848 assertEquals("operation:sequence", res.at("/query/operation").asText());
849 assertEquals("gehen", res.at("/query/operands/0/wrap/key").asText());
850 assertEquals("voran", res.at("/query/operands/1/wrap/key").asText());
851 assertEquals("korap:distance", res.at("/query/distances/0/@type").asText());
852 assertEquals("w", res.at("/query/distances/0/key").asText());
853 assertEquals(1, res.at("/query/distances/0/boundary/min").asInt());
854 assertEquals(10, res.at("/query/distances/0/boundary/max").asInt());
855
856 query = "#ALL(gehen /w1:10 (voran /w1:4 schnell))";
857 qs.setQuery(query, "cosmas2");
858 res = mapper.readTree(qs.toJSON());
859 assertEquals("korap:group", res.at("/query/@type").asText());
860 assertEquals("operation:sequence", res.at("/query/operation").asText());
861 assertEquals("korap:distance", res.at("/query/distances/0/@type").asText());
862 assertEquals("w", res.at("/query/distances/0/key").asText());
863 assertEquals(1, res.at("/query/distances/0/boundary/min").asInt());
864 assertEquals(10, res.at("/query/distances/0/boundary/max").asInt());
865 assertEquals("gehen", res.at("/query/operands/0/wrap/key").asText());
866 assertEquals("korap:group", res.at("/query/operands/1/@type").asText());
867 assertEquals("operation:sequence", res.at("/query/operands/1/operation").asText());
868 assertEquals("korap:distance", res.at("/query/operands/1/distances/0/@type").asText());
869 assertEquals("w", res.at("/query/operands/1/distances/0/key").asText());
870 assertEquals(1, res.at("/query/operands/1/distances/0/boundary/min").asInt());
871 assertEquals(4, res.at("/query/operands/1/distances/0/boundary/max").asInt());
872 assertEquals("voran", res.at("/query/operands/1/operands/0/wrap/key").asText());
873 assertEquals("schnell", res.at("/query/operands/1/operands/1/wrap/key").asText());
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000874
875
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000876 }
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000877
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000878 @Test
879 public void testOPNHIT() throws QueryException, JsonProcessingException, IOException {
880 query = "#NHIT(gehen /w1:10 voran)";
881 qs.setQuery(query, "cosmas2");
882 res = mapper.readTree(qs.toJSON());
883 assertEquals("korap:reference", res.at("/query/@type").asText());
884 assertEquals("operation:focus", res.at("/query/operation").asText());
885 assertEquals(129, res.at("/query/classRef/0").asInt());
886 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
887 assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
888 assertEquals("classRefOp:inversion",res.at("/query/operands/0/classRefOp").asText());
889 assertEquals(130, res.at("/query/operands/0/classIn/0").asInt());
890 assertEquals(131, res.at("/query/operands/0/classIn/1").asInt());
891 assertEquals(129, res.at("/query/operands/0/classOut").asInt());
892 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
893 assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operation").asText());
894 assertEquals("korap:distance", res.at("/query/operands/0/operands/0/distances/0/@type").asText());
895 assertEquals("w", res.at("/query/operands/0/operands/0/distances/0/key").asText());
896 assertEquals(1, res.at("/query/operands/0/operands/0/distances/0/boundary/min").asInt());
897 assertEquals(10, res.at("/query/operands/0/operands/0/distances/0/boundary/max").asInt());
898 assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
899 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
900 assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
901 assertEquals(131, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
902 assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText());
903 assertEquals("gehen", res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
904 assertEquals("voran", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000905
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000906 query = "#NHIT(gehen /w1:10 voran /w1:10 Beispiel)";
907 qs.setQuery(query, "cosmas2");
908 res = mapper.readTree(qs.toJSON());
909 assertEquals("korap:reference", res.at("/query/@type").asText());
910 assertEquals("operation:focus", res.at("/query/operation").asText());
911 assertEquals(129, res.at("/query/classRef/0").asInt());
912 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
913 assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
914 assertEquals("classRefOp:inversion",res.at("/query/operands/0/classRefOp").asText());
915 assertEquals(130, res.at("/query/operands/0/classIn/0").asInt());
916 assertEquals(131, res.at("/query/operands/0/classIn/1").asInt());
917 assertEquals(129, res.at("/query/operands/0/classOut").asInt());
918 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
919 assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operation").asText());
920 assertEquals("korap:distance", res.at("/query/operands/0/operands/0/distances/0/@type").asText());
921 assertEquals("w", res.at("/query/operands/0/operands/0/distances/0/key").asText());
922 assertEquals(1, res.at("/query/operands/0/operands/0/distances/0/boundary/min").asInt());
923 assertEquals(10, res.at("/query/operands/0/operands/0/distances/0/boundary/max").asInt());
924 assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
925 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
926 assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
927 assertEquals(131, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
928 assertEquals("gehen", res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
929 assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operands/1/operands/0/operation").asText());
930 assertEquals(132, res.at("/query/operands/0/operands/0/operands/1/operands/0/classRef/0").asInt());
931 assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operation").asText());
932 assertEquals(132, res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/0/classOut").asInt());
933 assertEquals("voran", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
934 assertEquals(132, res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/1/classOut").asInt());
935 assertEquals("Beispiel", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000936
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000937 }
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000938
Joachim Bingel8fbdfa72014-12-04 10:33:34 +0000939 @Test
940 public void testOPBED() throws QueryException, JsonProcessingException, IOException {
941 query = "#BED(der , sa)";
942 qs.setQuery(query, "cosmas2");
943 res = mapper.readTree(qs.toJSON());
944 assertEquals("korap:reference", res.at("/query/@type").asText());
945 assertEquals("operation:focus", res.at("/query/operation").asText());
946 assertEquals(129, res.at("/query/classRef/0").asInt());
947 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
948 assertEquals("operation:position", res.at("/query/operands/0/operation").asText());
949 assertEquals("frames:startswith", res.at("/query/operands/0/frames/0").asText());
950 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
951 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
952 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
953 assertEquals("korap:token", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
954 assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
955 assertEquals("korap:span", res.at("/query/operands/0/operands/0/@type").asText());
956 assertEquals("s", res.at("/query/operands/0/operands/0/key").asText());
957
958 query = "#BED(der Mann , +pe)";
959 qs.setQuery(query, "cosmas2");
960 res = mapper.readTree(qs.toJSON());
961 assertEquals("korap:reference", res.at("/query/@type").asText());
962 assertEquals("operation:focus", res.at("/query/operation").asText());
963 assertEquals(129, res.at("/query/classRef/0").asInt());
964 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
965 assertEquals("operation:position", res.at("/query/operands/0/operation").asText());
966 assertEquals("frames:matches", res.at("/query/operands/0/frames/0").asText());
967 assertEquals("korap:reference", res.at("/query/operands/0/operands/0/@type").asText());
968 assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operation").asText());
969 assertEquals(-1, res.at("/query/operands/0/operands/0/spanRef/0").asInt());
970 assertEquals(1, res.at("/query/operands/0/operands/0/spanRef/1").asInt());
971 assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
972 assertEquals("p", res.at("/query/operands/0/operands/0/operands/0/key").asText());
973 assertEquals("korap:reference", res.at("/query/operands/0/operands/1/@type").asText());
974 assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operation").asText());
975 assertEquals(0, res.at("/query/operands/0/operands/1/spanRef/0").asInt());
976 assertEquals(1, res.at("/query/operands/0/operands/1/spanRef/1").asInt());
977 assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
978 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/0/operation").asText());
979 assertEquals(129, res.at("/query/operands/0/operands/1/operands/0/classOut").asInt());
980 assertEquals("operation:sequence", res.at("/query/operands/0/operands/1/operands/0/operands/0/operation").asText());
981 assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/wrap/key").asText());
982 assertEquals("Mann", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/wrap/key").asText());
983
984 query = "#BED(der Mann , sa,-pa)";
985 qs.setQuery(query, "cosmas2");
986 res = mapper.readTree(qs.toJSON());
987 assertEquals("korap:reference", res.at("/query/@type").asText());
988 assertEquals("operation:focus", res.at("/query/operation").asText());
989 assertEquals(129, res.at("/query/classRef/0").asInt());
990 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
991 assertEquals("operation:position", res.at("/query/operands/0/operation").asText());
992 assertEquals("frames:matches", res.at("/query/operands/0/frames/0").asText());
993
994 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
995 assertEquals("operation:position", res.at("/query/operands/0/operands/0/operation").asText());
996 assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText());
997 assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
998 assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/key").asText());
999 assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
1000 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
1001 assertEquals(129, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
1002 assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operands/1/operands/0/operation").asText());
1003 assertEquals("der", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/wrap/key").asText());
1004 assertEquals("Mann", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/1/wrap/key").asText());
1005
1006 assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText());
1007 assertEquals("operation:position", res.at("/query/operands/0/operands/1/operation").asText());
1008 assertEquals("frames:startswith", res.at("/query/operands/0/operands/1/frames/0").asText());
1009 assertEquals(true, res.at("/query/operands/0/operands/1/exclude").asBoolean());
1010 assertEquals("korap:span", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
1011 assertEquals("p", res.at("/query/operands/0/operands/1/operands/0/key").asText());
1012 assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/1/@type").asText());
1013 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/1/operation").asText());
1014 assertEquals(130, res.at("/query/operands/0/operands/1/operands/1/classOut").asInt());
1015 assertEquals("operation:sequence", res.at("/query/operands/0/operands/1/operands/1/operands/0/operation").asText());
1016 assertEquals("der", res.at("/query/operands/0/operands/1/operands/1/operands/0/operands/0/wrap/key").asText());
1017 assertEquals("Mann", res.at("/query/operands/0/operands/1/operands/1/operands/0/operands/1/wrap/key").asText());
1018
1019 }
1020
1021 @Test
1022 public void testColonSeparatedConditions() throws QueryException, JsonProcessingException, IOException {
1023 query = "der:sa";
1024 qs.setQuery(query, "cosmas2");
1025 res = mapper.readTree(qs.toJSON());
1026 assertEquals("korap:reference", res.at("/query/@type").asText());
1027 assertEquals("operation:focus", res.at("/query/operation").asText());
1028 assertEquals(129, res.at("/query/classRef/0").asInt());
1029 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
1030 assertEquals("operation:position", res.at("/query/operands/0/operation").asText());
1031 assertEquals("frames:startswith", res.at("/query/operands/0/frames/0").asText());
1032 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
1033 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
1034 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
1035 assertEquals("korap:token", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
1036 assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
1037 assertEquals("korap:span", res.at("/query/operands/0/operands/0/@type").asText());
1038 assertEquals("s", res.at("/query/operands/0/operands/0/key").asText());
1039
1040 query = "der:sa,-pa";
1041 qs.setQuery(query, "cosmas2");
1042 res = mapper.readTree(qs.toJSON());
1043 assertEquals("korap:reference", res.at("/query/@type").asText());
1044 assertEquals("operation:focus", res.at("/query/operation").asText());
1045 assertEquals(129, res.at("/query/classRef/0").asInt());
1046 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
1047 assertEquals("operation:position", res.at("/query/operands/0/operation").asText());
1048 assertEquals("frames:matches", res.at("/query/operands/0/frames/0").asText());
1049 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
1050 assertEquals("operation:position", res.at("/query/operands/0/operands/0/operation").asText());
1051 assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText());
1052 assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
1053 assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/key").asText());
1054 assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
1055 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
1056 assertEquals(129, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
1057 assertEquals("der", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
1058 assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText());
1059 assertEquals("operation:position", res.at("/query/operands/0/operands/1/operation").asText());
1060 assertEquals("frames:startswith", res.at("/query/operands/0/operands/1/frames/0").asText());
1061 assertEquals(true, res.at("/query/operands/0/operands/1/exclude").asBoolean());
1062 assertEquals("korap:span", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
1063 assertEquals("p", res.at("/query/operands/0/operands/1/operands/0/key").asText());
1064 assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/1/@type").asText());
1065 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/1/operation").asText());
1066 assertEquals(130, res.at("/query/operands/0/operands/1/operands/1/classOut").asInt());
1067 assertEquals("der", res.at("/query/operands/0/operands/1/operands/1/operands/0/wrap/key").asText());
1068
1069 query = "der:sa,-pa,+te";
1070 qs.setQuery(query, "cosmas2");
1071 res = mapper.readTree(qs.toJSON());
1072 assertEquals("korap:reference", res.at("/query/@type").asText());
1073 assertEquals("operation:focus", res.at("/query/operation").asText());
1074 assertEquals(129, res.at("/query/classRef/0").asInt());
1075 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
1076 assertEquals("operation:position", res.at("/query/operands/0/operation").asText());
1077 assertEquals("frames:matches", res.at("/query/operands/0/frames/0").asText());
1078 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
1079 assertEquals("operation:position", res.at("/query/operands/0/operands/0/operation").asText());
1080 assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText());
1081 assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
1082 assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/key").asText());
1083 assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
1084 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
1085 assertEquals(129, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
1086 assertEquals("der", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
1087 assertEquals("korap:reference", res.at("/query/operands/0/operands/1/@type").asText());
1088 assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operation").asText());
1089 assertEquals(130, res.at("/query/operands/0/operands/1/classRef/0").asInt());
1090 assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
1091 assertEquals("operation:position", res.at("/query/operands/0/operands/1/operands/0/operation").asText());
1092 assertEquals("frames:matches", res.at("/query/operands/0/operands/1/operands/0/frames/0").asText());
1093 assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/operands/0/@type").asText());
1094 assertEquals("operation:position", res.at("/query/operands/0/operands/1/operands/0/operands/0/operation").asText());
1095 assertEquals("frames:startswith", res.at("/query/operands/0/operands/1/operands/0/operands/0/frames/0").asText());
1096 assertEquals(true, res.at("/query/operands/0/operands/1/operands/0/operands/0/exclude").asBoolean());
1097 assertEquals("korap:span", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/@type").asText());
1098 assertEquals("p", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/key").asText());
1099 assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/@type").asText());
1100 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operation").asText());
1101 assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/classOut").asInt());
1102 assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
1103 assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/operands/1/@type").asText());
1104 assertEquals("operation:position", res.at("/query/operands/0/operands/1/operands/0/operands/1/operation").asText());
1105 assertEquals("frames:matches", res.at("/query/operands/0/operands/1/operands/0/operands/1/frames/0").asText());
1106 assertEquals("korap:reference", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/@type").asText());
1107 assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/operation").asText());
1108 assertEquals(-1, res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/spanRef/0").asInt());
1109 assertEquals(1, res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/spanRef/1").asInt());
1110 assertEquals("korap:span", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/operands/0/@type").asText());
1111 assertEquals("t", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/operands/0/key").asText());
1112 assertEquals("korap:reference", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/@type").asText());
1113 assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operation").asText());
1114 assertEquals(0, res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/spanRef/0").asInt());
1115 assertEquals(1, res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/spanRef/1").asInt());
1116 assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/@type").asText());
1117 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/operation").asText());
1118 assertEquals(131, res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/classOut").asInt());
1119 assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/operands/0/wrap/key").asText());
1120 }
1121}