blob: 6085218cab52ff4cbf5c398eb1b9534438cf36a5 [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
8import de.ids_mannheim.korap.query.serialize.CosmasTree;
Joachim Bingelcd30ed12014-12-03 16:14:13 +00009import de.ids_mannheim.korap.query.serialize.QuerySerializer;
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000010import de.ids_mannheim.korap.util.QueryException;
11
Joachim Bingelcd30ed12014-12-03 16:14:13 +000012import com.fasterxml.jackson.core.JsonProcessingException;
13import com.fasterxml.jackson.databind.JsonNode;
14import com.fasterxml.jackson.databind.ObjectMapper;
15
16/**
17 * Tests for JSON-LD serialization of Cosmas II queries.
18 * @author Joachim Bingel (bingel@ids-mannheim.de)
19 * @version 1.0
20 */
21
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000022public class CosmasTreeTest {
23
Michael Hanlbaf1a5e2014-05-15 19:51:40 +000024
Joachim Bingelcd30ed12014-12-03 16:14:13 +000025 String query;
26 ArrayList<JsonNode> operands;
27
28 QuerySerializer qs = new QuerySerializer();
29 ObjectMapper mapper = new ObjectMapper();
30 JsonNode res;
31
32 @Test
33 public void testContext() throws QueryException, JsonProcessingException, IOException {
34 String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld";
35 query = "foo";
36 qs.setQuery(query, "cosmas2");
37 res = mapper.readTree(qs.toJSON());
38 assertEquals(contextString, res.get("@context").asText());
39 }
40
41
42 @Test
43 public void testSingleToken() throws QueryException, JsonProcessingException, IOException {
44 query = "der";
45 qs.setQuery(query, "cosmas2");
46 res = mapper.readTree(qs.toJSON());
47 assertEquals("korap:token", res.at("/query/@type").asText());
48 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
49 assertEquals("der", res.at("/query/wrap/key").asText());
50 assertEquals("orth", res.at("/query/wrap/layer").asText());
51 assertEquals("match:eq", res.at("/query/wrap/match").asText());
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000052
Joachim Bingelcd30ed12014-12-03 16:14:13 +000053 query = "&Mann";
54 qs.setQuery(query, "cosmas2");
55 res = mapper.readTree(qs.toJSON());
56 assertEquals("korap:token", res.at("/query/@type").asText());
57 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
58 assertEquals("Mann", res.at("/query/wrap/key").asText());
59 assertEquals("lemma", res.at("/query/wrap/layer").asText());
60 assertEquals("match:eq", res.at("/query/wrap/match").asText());
61 }
62
63
64
65 @Test
66 public void testWildcardToken() throws QueryException, JsonProcessingException, IOException {
67 query = "*der";
68 qs.setQuery(query, "cosmas2");
69 res = mapper.readTree(qs.toJSON());
70 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
71 assertEquals("type:wildcard", res.at("/query/wrap/type").asText());
72 assertEquals("*der", res.at("/query/wrap/key").asText());
73 assertEquals("orth", res.at("/query/wrap/layer").asText());
74 assertEquals("match:eq", res.at("/query/wrap/match").asText());
75
76 query = "*de*?r";
77 qs.setQuery(query, "cosmas2");
78 res = mapper.readTree(qs.toJSON());
79 assertEquals("*de*?r", res.at("/query/wrap/key").asText());
80 }
81//
82 @Test
83 public void testCaseSensitivityFlag() throws QueryException, JsonProcessingException, IOException {
84 query = "$deutscher";
85 qs.setQuery(query, "cosmas2");
86 res = mapper.readTree(qs.toJSON());
87 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
88 assertEquals("deutscher", res.at("/query/wrap/key").asText());
89 assertEquals(true, res.at("/query/wrap/caseInsensitive").asBoolean());
90 assertEquals("orth", res.at("/query/wrap/layer").asText());
91 assertEquals("match:eq", res.at("/query/wrap/match").asText());
92
93 query = "$deutscher Bundestag";
94 qs.setQuery(query, "cosmas2");
95 res = mapper.readTree(qs.toJSON());
96 assertEquals("korap:group", res.at("/query/@type").asText());
97 assertEquals("operation:sequence", res.at("/query/operation").asText());
98 assertEquals("korap:term", res.at("/query/operands/0/wrap/@type").asText());
99 assertEquals("deutscher", res.at("/query/operands/0/wrap/key").asText());
100 assertEquals(true, res.at("/query/operands/0/wrap/caseInsensitive").asBoolean());
101 assertEquals("orth", res.at("/query/operands/0/wrap/layer").asText());
102 assertEquals("match:eq", res.at("/query/operands/0/wrap/match").asText());
103 assertEquals("Bundestag", res.at("/query/operands/1/wrap/key").asText());
104 assertEquals(true, res.at("/query/operands/1/wrap/caseInsensitive").isMissingNode());
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000105 }
106
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000107 @Test
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000108 public void testMORPH() throws QueryException, JsonProcessingException, IOException {
109 query = "MORPH(p=V)";
110 qs.setQuery(query, "cosmas2");
111 res = mapper.readTree(qs.toJSON());
112 assertEquals("korap:token", res.at("/query/@type").asText());
113 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
114 assertEquals("V", res.at("/query/wrap/key").asText());
115 assertEquals("p", res.at("/query/wrap/layer").asText());
116 assertEquals("match:eq", res.at("/query/wrap/match").asText());
117
118 query = "MORPH(V)";
119 qs.setQuery(query, "cosmas2");
120 res = mapper.readTree(qs.toJSON());
121 assertEquals("korap:token", res.at("/query/@type").asText());
122 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
123 assertEquals("V", res.at("/query/wrap/key").asText());
124 assertEquals("match:eq", res.at("/query/wrap/match").asText());
125
126 query = "MORPH(tt/p=V)";
127 qs.setQuery(query, "cosmas2");
128 res = mapper.readTree(qs.toJSON());
129 assertEquals("korap:token", res.at("/query/@type").asText());
130 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
131 assertEquals("V", res.at("/query/wrap/key").asText());
132 assertEquals("p", res.at("/query/wrap/layer").asText());
133 assertEquals("tt", res.at("/query/wrap/foundry").asText());
134 assertEquals("match:eq", res.at("/query/wrap/match").asText());
135
136 query = "MORPH(mate/m=temp:pres)";
137 qs.setQuery(query, "cosmas2");
138 res = mapper.readTree(qs.toJSON());
139 assertEquals("korap:token", res.at("/query/@type").asText());
140 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
141 assertEquals("temp", res.at("/query/wrap/key").asText());
142 assertEquals("pres", res.at("/query/wrap/value").asText());
143 assertEquals("m", res.at("/query/wrap/layer").asText());
144 assertEquals("mate", res.at("/query/wrap/foundry").asText());
145 assertEquals("match:eq", res.at("/query/wrap/match").asText());
146
147 query = "MORPH(tt/p=V & mate/m!=temp:pres)";
148 qs.setQuery(query, "cosmas2");
149 res = mapper.readTree(qs.toJSON());
150 assertEquals("korap:token", res.at("/query/@type").asText());
151 assertEquals("korap:termGroup", res.at("/query/wrap/@type").asText());
152 assertEquals("V", res.at("/query/wrap/operands/0/key").asText());
153 assertEquals("p", res.at("/query/wrap/operands/0/layer").asText());
154 assertEquals("tt", res.at("/query/wrap/operands/0/foundry").asText());
155 assertEquals("match:eq", res.at("/query/wrap/operands/0/match").asText());
156 assertEquals("temp", res.at("/query/wrap/operands/1/key").asText());
157 assertEquals("pres", res.at("/query/wrap/operands/1/value").asText());
158 assertEquals("m", res.at("/query/wrap/operands/1/layer").asText());
159 assertEquals("mate", res.at("/query/wrap/operands/1/foundry").asText());
160 assertEquals("match:ne", res.at("/query/wrap/operands/1/match").asText());
Joachim Bingel9a202ab2014-10-07 12:35:17 +0000161 }
162
163 @Test
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000164 public void testSequence() throws QueryException, JsonProcessingException, IOException {
165 query = "der Mann";
166 qs.setQuery(query, "cosmas2");
167 res = mapper.readTree(qs.toJSON());
168 assertEquals("korap:group", res.at("/query/@type").asText());
169 assertEquals("operation:sequence", res.at("/query/operation").asText());
170 assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
171 assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText());
172 assertEquals(true, res.at("/query/operands/2").isMissingNode());
Joachim Bingel0207d5e2014-02-12 14:18:41 +0000173
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000174 query = "der Mann schläft";
175 qs.setQuery(query, "cosmas2");
176 res = mapper.readTree(qs.toJSON());
177 assertEquals("korap:group", res.at("/query/@type").asText());
178 assertEquals("operation:sequence", res.at("/query/operation").asText());
179 assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
180 assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText());
181 assertEquals("schläft", res.at("/query/operands/2/wrap/key").asText());
182 assertEquals(true, res.at("/query/operands/3").isMissingNode());
183
184 query = "der Mann schläft lang";
185 qs.setQuery(query, "cosmas2");
186 res = mapper.readTree(qs.toJSON());
187 assertEquals("korap:group", res.at("/query/@type").asText());
188 assertEquals("operation:sequence", res.at("/query/operation").asText());
189 assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
190 assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText());
191 assertEquals("schläft", res.at("/query/operands/2/wrap/key").asText());
192 assertEquals("lang", res.at("/query/operands/3/wrap/key").asText());
193 assertEquals(true, res.at("/query/operands/4").isMissingNode());
194
195 query = "der #ELEM(W)";
196 qs.setQuery(query, "cosmas2");
197 res = mapper.readTree(qs.toJSON());
198 assertEquals("korap:group", res.at("/query/@type").asText());
199 assertEquals("operation:sequence", res.at("/query/operation").asText());
200 assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
201 assertEquals("w", res.at("/query/operands/1/key").asText());
202 assertEquals("korap:span", res.at("/query/operands/1/@type").asText());
203 assertEquals(true, res.at("/query/operands/2").isMissingNode());
204
205 query = "der #ELEM(W) Mann";
206 qs.setQuery(query, "cosmas2");
207 res = mapper.readTree(qs.toJSON());
208 assertEquals("korap:group", res.at("/query/@type").asText());
209 assertEquals("operation:sequence", res.at("/query/operation").asText());
210 assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
211 assertEquals("w", res.at("/query/operands/1/key").asText());
212 assertEquals("korap:span", res.at("/query/operands/1/@type").asText());
213 assertEquals("Mann", res.at("/query/operands/2/wrap/key").asText());
214 assertEquals(true, res.at("/query/operands/3").isMissingNode());
215
216 query = "der MORPH(p=ADJA) Mann";
217 qs.setQuery(query, "cosmas2");
218 res = mapper.readTree(qs.toJSON());
219 assertEquals("korap:group", res.at("/query/@type").asText());
220 assertEquals("operation:sequence", res.at("/query/operation").asText());
221 assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
222 assertEquals("ADJA", res.at("/query/operands/1/wrap/key").asText());
223 assertEquals("p", res.at("/query/operands/1/wrap/layer").asText());
224 assertEquals("Mann", res.at("/query/operands/2/wrap/key").asText());
225 assertEquals(true, res.at("/query/operands/3").isMissingNode());
226 }
227
228 @Test
229 public void testOPOR() throws QueryException, JsonProcessingException, IOException {
230 query = "Sonne oder Mond";
231 qs.setQuery(query, "cosmas2");
232 res = mapper.readTree(qs.toJSON());
233 assertEquals("korap:group", res.at("/query/@type").asText());
234 assertEquals("operation:or", res.at("/query/operation").asText());
235 assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText());
236 assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText());
237 assertEquals(true, res.at("/query/operands/2").isMissingNode());
238
239 query = "(Sonne scheint) oder Mond";
240 qs.setQuery(query, "cosmas2");
241 res = mapper.readTree(qs.toJSON());
242 assertEquals("korap:group", res.at("/query/@type").asText());
243 assertEquals("operation:or", res.at("/query/operation").asText());
244 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
245 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
246 assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key").asText());
247 assertEquals("scheint", res.at("/query/operands/0/operands/1/wrap/key").asText());
248 assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText());
249 assertEquals(true, res.at("/query/operands/2").isMissingNode());
250
251 query = "(Sonne scheint) oder (Mond scheint)";
252 qs.setQuery(query, "cosmas2");
253 res = mapper.readTree(qs.toJSON());
254 assertEquals("korap:group", res.at("/query/@type").asText());
255 assertEquals("operation:or", res.at("/query/operation").asText());
256 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
257 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
258 assertEquals("korap:group", res.at("/query/operands/1/@type").asText());
259 assertEquals("operation:sequence", res.at("/query/operands/1/operation").asText());
260 assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key").asText());
261 assertEquals("scheint", res.at("/query/operands/0/operands/1/wrap/key").asText());
262 assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key").asText());
263 assertEquals("scheint", res.at("/query/operands/1/operands/1/wrap/key").asText());
264 assertEquals(true, res.at("/query/operands/2").isMissingNode());
265 }
266
267 @Test
268 public void testOPORAND() throws QueryException, JsonProcessingException, IOException {
269 query = "(Sonne oder Mond) und scheint";
270 qs.setQuery(query, "cosmas2");
271 res = mapper.readTree(qs.toJSON());
272 assertEquals("korap:group", res.at("/query/@type").asText());
273 assertEquals("operation:sequence", res.at("/query/operation").asText());
274 assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText());
275 assertEquals("t", res.at("/query/distances/0/key").asText());
276 assertEquals(0, res.at("/query/distances/0/min").asInt());
277 assertEquals(0, res.at("/query/distances/0/max").asInt());
278 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
279 assertEquals("operation:or", res.at("/query/operands/0/operation").asText());
280 assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key").asText());
281 assertEquals("Mond", res.at("/query/operands/0/operands/1/wrap/key").asText());
282 assertEquals("korap:token", res.at("/query/operands/1/@type").asText());
283 assertEquals("scheint", res.at("/query/operands/1/wrap/key").asText());
284
285 query = "scheint und (Sonne oder Mond)";
286 qs.setQuery(query, "cosmas2");
287 res = mapper.readTree(qs.toJSON());
288 assertEquals("korap:group", res.at("/query/@type").asText());
289 assertEquals("operation:sequence", res.at("/query/operation").asText());
290 assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText());
291 assertEquals("t", res.at("/query/distances/0/key").asText());
292 assertEquals(0, res.at("/query/distances/0/min").asInt());
293 assertEquals(0, res.at("/query/distances/0/max").asInt());
294 assertEquals("korap:token", res.at("/query/operands/0/@type").asText());
295 assertEquals("scheint", res.at("/query/operands/0/wrap/key").asText());
296 assertEquals("korap:group", res.at("/query/operands/1/@type").asText());
297 assertEquals("operation:or", res.at("/query/operands/1/operation").asText());
298 assertEquals("Sonne", res.at("/query/operands/1/operands/0/wrap/key").asText());
299 assertEquals("Mond", res.at("/query/operands/1/operands/1/wrap/key").asText());
300
301 query = "Regen und scheint und (Sonne oder Mond)";
302 qs.setQuery(query, "cosmas2");
303 res = mapper.readTree(qs.toJSON());
304 assertEquals("korap:group", res.at("/query/@type").asText());
305 assertEquals("operation:sequence", res.at("/query/operation").asText());
306 assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText());
307 assertEquals("t", res.at("/query/distances/0/key").asText());
308 assertEquals(0, res.at("/query/distances/0/min").asInt());
309 assertEquals(0, res.at("/query/distances/0/max").asInt());
310 assertEquals("korap:token", res.at("/query/operands/0/@type").asText());
311 assertEquals("Regen", res.at("/query/operands/0/wrap/key").asText());
312 assertEquals("korap:group", res.at("/query/@type").asText());
313 assertEquals("operation:sequence", res.at("/query/operation").asText());
314 assertEquals("cosmas:distance", res.at("/query/operands/1/distances/0/@type").asText());
315 assertEquals("t", res.at("/query/operands/1/distances/0/key").asText());
316 assertEquals(0, res.at("/query/operands/1/distances/0/min").asInt());
317 assertEquals(0, res.at("/query/operands/1/distances/0/max").asInt());
318 assertEquals("scheint", res.at("/query/operands/1/operands/0/wrap/key").asText());
319 assertEquals("korap:group", res.at("/query/operands/1/operands/1/@type").asText());
320 assertEquals("operation:or", res.at("/query/operands/1/operands/1/operation").asText());
321 assertEquals("Sonne", res.at("/query/operands/1/operands/1/operands/0/wrap/key").asText());
322 assertEquals("Mond", res.at("/query/operands/1/operands/1/operands/1/wrap/key").asText());
Joachim Bingel8c640e42014-02-07 16:20:47 +0000323 }
324
325 @Test
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000326 public void testOPNOT() throws QueryException, JsonProcessingException, IOException {
327 query = "Sonne nicht Mond";
328 qs.setQuery(query, "cosmas2");
329 res = mapper.readTree(qs.toJSON());
330 assertEquals("korap:group", res.at("/query/@type").asText());
331 assertEquals("operation:sequence", res.at("/query/operation").asText());
332 assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText());
333 assertEquals("t", res.at("/query/distances/0/key").asText());
334 assertEquals(0, res.at("/query/distances/0/min").asInt());
335 assertEquals(0, res.at("/query/distances/0/max").asInt());
336 assertEquals(true, res.at("/query/distances/0/exclude").asBoolean());
337 assertEquals("korap:token", res.at("/query/operands/0/@type").asText());
338 assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText());
339 assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText());
Joachim Bingeld73a1852014-12-01 11:06:23 +0000340
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000341 query = "Sonne nicht Mond nicht Sterne";
342 qs.setQuery(query, "cosmas2");
343 res = mapper.readTree(qs.toJSON());
344 assertEquals("korap:group", res.at("/query/@type").asText());
345 assertEquals("operation:sequence", res.at("/query/operation").asText());
346 assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText());
347 assertEquals("t", res.at("/query/distances/0/key").asText());
348 assertEquals(0, res.at("/query/distances/0/min").asInt());
349 assertEquals(0, res.at("/query/distances/0/max").asInt());
350 assertEquals(true, res.at("/query/distances/0/exclude").asBoolean());
351 assertEquals("korap:token", res.at("/query/operands/0/@type").asText());
352 assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText());
353 assertEquals("korap:group", res.at("/query/operands/1/@type").asText());
354 assertEquals("operation:sequence", res.at("/query/operands/1/operation").asText());
355 assertEquals("cosmas:distance", res.at("/query/operands/1/distances/0/@type").asText());
356 assertEquals("t", res.at("/query/operands/1/distances/0/key").asText());
357 assertEquals(0, res.at("/query/operands/1/distances/0/min").asInt());
358 assertEquals(0, res.at("/query/operands/1/distances/0/max").asInt());
359 assertEquals(true, res.at("/query/operands/1/distances/0/exclude").asBoolean());
360 assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key").asText());
361 assertEquals("Sterne", res.at("/query/operands/1/operands/1/wrap/key").asText());
362
363 query = "(Sonne nicht Mond) nicht Sterne";
364 qs.setQuery(query, "cosmas2");
365 res = mapper.readTree(qs.toJSON());
366 assertEquals("korap:group", res.at("/query/@type").asText());
367 assertEquals("operation:sequence", res.at("/query/operation").asText());
368 assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText());
369 assertEquals("t", res.at("/query/distances/0/key").asText());
370 assertEquals(0, res.at("/query/distances/0/min").asInt());
371 assertEquals(0, res.at("/query/distances/0/max").asInt());
372 assertEquals(true, res.at("/query/distances/0/exclude").asBoolean());
373 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
374 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
375 assertEquals("cosmas:distance", res.at("/query/operands/0/distances/0/@type").asText());
376 assertEquals("t", res.at("/query/operands/0/distances/0/key").asText());
377 assertEquals(0, res.at("/query/operands/0/distances/0/min").asInt());
378 assertEquals(0, res.at("/query/operands/0/distances/0/max").asInt());
379 assertEquals(true, res.at("/query/operands/0/distances/0/exclude").asBoolean());
380 assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key").asText());
381 assertEquals("Mond", res.at("/query/operands/0/operands/1/wrap/key").asText());
382 assertEquals("korap:token", res.at("/query/operands/1/@type").asText());
383 assertEquals("Sterne", res.at("/query/operands/1/wrap/key").asText());
Joachim Bingelffd65e32014-01-22 14:22:57 +0000384 }
385
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000386 @Test
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000387 public void testOPPROX() throws QueryException, JsonProcessingException, IOException {
388 query = "Sonne /+w1:4 Mond";
389 qs.setQuery(query, "cosmas2");
390 res = mapper.readTree(qs.toJSON());
391 assertEquals("korap:reference", res.at("/query/@type").asText());
392 assertEquals("operation:focus", res.at("/query/operation").asText());
393 assertEquals(129, res.at("/query/classRef/0").asInt());
394 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
395 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
396 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
397 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
398 assertEquals(1, res.at("/query/operands/0/distances/0/boundary/min").asInt());
399 assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt());
400 assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
401 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
402 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
403 assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
404 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
405 assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
406 assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
407 assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000408
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000409 query = "Sonne /+w1:4,s0,p1:3 Mond";
410 qs.setQuery(query, "cosmas2");
411 res = mapper.readTree(qs.toJSON());
412 assertEquals("korap:reference", res.at("/query/@type").asText());
413 assertEquals("operation:focus", res.at("/query/operation").asText());
414 assertEquals(129, res.at("/query/classRef/0").asInt());
415 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
416 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
417 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
418 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
419 assertEquals(1, res.at("/query/operands/0/distances/0/boundary/min").asInt());
420 assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt());
421 assertEquals("s", res.at("/query/operands/0/distances/1/key").asText());
422 assertEquals(0, res.at("/query/operands/0/distances/1/boundary/min").asInt());
423 assertEquals("p", res.at("/query/operands/0/distances/2/key").asText());
424 assertEquals(1, res.at("/query/operands/0/distances/2/boundary/min").asInt());
425 assertEquals(3, res.at("/query/operands/0/distances/2/boundary/max").asInt());
426 assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
427 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
428 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
429 assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
430 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
431 assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
432 assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
433 assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingeld5161a12014-01-08 11:15:49 +0000434
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000435 query = "Sonne /+w4 Mond";
436 qs.setQuery(query, "cosmas2");
437 res = mapper.readTree(qs.toJSON());
438 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
439 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
440 assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt());
441 assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt());
Joachim Bingel896067a2014-11-07 19:02:27 +0000442
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000443 query = "Sonne /-w4 Mond";
444 qs.setQuery(query, "cosmas2");
445 res = mapper.readTree(qs.toJSON());
446 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
447 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
448 assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt());
449 assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt());
450 assertEquals("Mond", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
451 assertEquals("Sonne", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingel896067a2014-11-07 19:02:27 +0000452
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000453 query = "Sonne /w4 Mond";
454 qs.setQuery(query, "cosmas2");
455 res = mapper.readTree(qs.toJSON());
456 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
457 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
458 assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt());
459 assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt());
460 assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
461 assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
462 assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean());
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000463 }
464
465 @Test
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000466 public void testOPPROXNested() throws QueryException, JsonProcessingException, IOException {
467 query = "Sonne /+w1:4 Mond /+w1:7 Sterne";
468 qs.setQuery(query, "cosmas2");
469 res = mapper.readTree(qs.toJSON());
470 assertEquals("korap:reference", res.at("/query/@type").asText());
471 assertEquals("operation:focus", res.at("/query/operation").asText());
472 assertEquals(129, res.at("/query/classRef/0").asInt());
473 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
474 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
475 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
476 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
477 assertEquals(1, res.at("/query/operands/0/distances/0/boundary/min").asInt());
478 assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt());
479 assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
480 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
481 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
482 assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
483 assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
484 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
485 assertEquals("korap:reference", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
486 assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/classRef/0").asInt());
487 assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operands/0/operation").asText());
488 assertEquals("operation:sequence", res.at("/query/operands/0/operands/1/operands/0/operands/0/operation").asText());
489 assertEquals("w", res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/key").asText());
490 assertEquals(1, res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/boundary/min").asInt());
491 assertEquals(7, res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/boundary/max").asInt());
492 assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/classOut").asInt());
493 assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
494 assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/classOut").asInt());
495 assertEquals("Sterne", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000496
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000497 query = "Sonne /+w1:4 Mond /-w1:7 Sterne";
498 qs.setQuery(query, "cosmas2");
499 res = mapper.readTree(qs.toJSON());
500 assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
501 assertEquals("Sterne", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
502 assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingeld5161a12014-01-08 11:15:49 +0000503
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000504 query = "Sonne /-w4 Mond /+w2 Sterne";
505 qs.setQuery(query, "cosmas2");
506 res = mapper.readTree(qs.toJSON());
507 assertEquals("korap:reference", res.at("/query/@type").asText());
508 assertEquals("operation:focus", res.at("/query/operation").asText());
509 assertEquals(129, res.at("/query/classRef/0").asInt());
510 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
511 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
512 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
513 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
514 assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt());
515 assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt());
516 assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
517 assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText());
518 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
519 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
520 assertEquals("Sonne", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
521 assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
522 assertEquals("korap:reference", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
523 assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/classRef/0").asInt());
524 assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
525 assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operands/0/operands/0/operation").asText());
526 assertEquals("w", res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/key").asText());
527 assertEquals(0, res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/boundary/min").asInt());
528 assertEquals(2, res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/boundary/max").asInt());
529 assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/classOut").asInt());
530 assertEquals("Mond", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
531 assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/classOut").asInt());
532 assertEquals("Sterne", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
533
534 }
535
536 @Test
537 public void testOPIN() throws QueryException, JsonProcessingException, IOException {
538 query = "wegen #IN <s>";
539 qs.setQuery(query, "cosmas2");
540 res = mapper.readTree(qs.toJSON());
541 assertEquals("korap:reference", res.at("/query/@type").asText());
542 assertEquals("operation:focus", res.at("/query/operation").asText());
543 assertEquals(130, res.at("/query/classRef/0").asInt());
544 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
545 assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
546 assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck").asText());
547 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
548 assertEquals("operation:position", res.at("/query/operands/0/operands/0/operation").asText());
549 assertEquals(true, res.at("/query/operands/0/operands/0/frames/0").isMissingNode());
550 assertEquals(129, res.at("/query/operands/0/classIn/0").asInt());
551 assertEquals(130, res.at("/query/operands/0/classIn/1").asInt());
552 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
553 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
554 assertEquals(129, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
555 assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText());
556 assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/operands/0/key").asText());
557 assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
558 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
559 assertEquals(130, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
560 assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/1/operands/0/@type").asText());
561 assertEquals("wegen", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
562
563 query = "wegen #IN(L) <s>";
564 qs.setQuery(query, "cosmas2");
565 res = mapper.readTree(qs.toJSON());
566 assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck").asText());
567 assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText());
568 assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode());
569
570 query = "wegen #IN(F) <s>";
571 qs.setQuery(query, "cosmas2");
572 res = mapper.readTree(qs.toJSON());
573 assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck").asText());
574 assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
575 assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode());
576
577 query = "wegen #IN(FI) <s>";
578 qs.setQuery(query, "cosmas2");
579 res = mapper.readTree(qs.toJSON());
580 assertEquals("classRefCheck:unequals", res.at("/query/operands/0/classRefCheck/0").asText());
581 assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck/1").asText());
582 assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
583 assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode());
584
585 query = "wegen #IN(FE) <s>";
586 qs.setQuery(query, "cosmas2");
587 res = mapper.readTree(qs.toJSON());
588 assertEquals("classRefCheck:equals", res.at("/query/operands/0/classRefCheck").asText());
589 assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
590 assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode());
591
592 query = "wegen #IN(%, L) <s>";
593 qs.setQuery(query, "cosmas2");
594 res = mapper.readTree(qs.toJSON());
595 assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck").asText());
596 assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText());
597 assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode());
598 assertEquals(true, res.at("/query/operands/0/operands/0/exclude").asBoolean());
599
600 query = "wegen #IN(FE,ALL,%,MIN) <s>";
601 qs.setQuery(query, "cosmas2");
602 res = mapper.readTree(qs.toJSON());
603 assertEquals(true, res.at("/query/reset").asBoolean());
604 assertEquals("classRefCheck:equals", res.at("/query/operands/0/classRefCheck").asText());
605 assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
606 assertEquals(true, res.at("/query/operands/0/operands/0/exclude").asBoolean());
Joachim Bingeld5161a12014-01-08 11:15:49 +0000607
608 }
609
610 @Test
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000611 public void testOPOV() throws QueryException, JsonProcessingException, IOException {
612 query = "wegen #OV <s>";
613 qs.setQuery(query, "cosmas2");
614 res = mapper.readTree(qs.toJSON());
615 assertEquals("korap:reference", res.at("/query/@type").asText());
616 assertEquals("operation:focus", res.at("/query/operation").asText());
617 assertEquals(130, res.at("/query/classRef/0").asInt());
618 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
619 assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
620 assertEquals("classRefCheck:intersects", res.at("/query/operands/0/classRefCheck").asText());
621 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
622 assertEquals("operation:position", res.at("/query/operands/0/operands/0/operation").asText());
623 assertEquals(true, res.at("/query/operands/0/operands/0/frames/0").isMissingNode());
624 assertEquals(129, res.at("/query/operands/0/classIn/0").asInt());
625 assertEquals(130, res.at("/query/operands/0/classIn/1").asInt());
626 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
627 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
628 assertEquals(129, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
629 assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText());
630 assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/operands/0/key").asText());
631 assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
632 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
633 assertEquals(130, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
634 assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/1/operands/0/@type").asText());
635 assertEquals("wegen", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
Joachim Bingeld5161a12014-01-08 11:15:49 +0000636
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000637 query = "wegen #OV(L) <s>";
638 qs.setQuery(query, "cosmas2");
639 res = mapper.readTree(qs.toJSON());
640 assertEquals("classRefCheck:intersects", res.at("/query/operands/0/classRefCheck").asText());
641 assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText());
642 assertEquals("frames:overlapsLeft", res.at("/query/operands/0/operands/0/frames/1").asText());
Joachim Bingel92f9c9c2014-06-25 15:01:17 +0000643
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000644 query = "wegen #OV(F) <s>";
645 qs.setQuery(query, "cosmas2");
646 res = mapper.readTree(qs.toJSON());
647 assertEquals("classRefCheck:intersects", res.at("/query/operands/0/classRefCheck").asText());
648 assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
649 assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode());
650
651 query = "wegen #OV(FI) <s>";
652 qs.setQuery(query, "cosmas2");
653 res = mapper.readTree(qs.toJSON());
654 assertEquals("classRefCheck:unequals", res.at("/query/operands/0/classRefCheck").asText());
655 assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
656
657 query = "wegen #OV(FE) <s>";
658 qs.setQuery(query, "cosmas2");
659 res = mapper.readTree(qs.toJSON());
660 assertEquals("classRefCheck:equals", res.at("/query/operands/0/classRefCheck").asText());
661 assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
662 }
663
664
665 @Test
666 public void testBEG_END() throws QueryException, JsonProcessingException, IOException {
667 query = "#BEG(der /w3:5 Mann)";
668 qs.setQuery(query, "cosmas2");
669 res = mapper.readTree(qs.toJSON());
670 assertEquals("korap:reference", res.at("/query/@type").asText());
671 assertEquals("operation:focus", res.at("/query/operation").asText());
672 assertEquals(0, res.at("/query/spanRef/0").asInt());
673 assertEquals(1, res.at("/query/spanRef/1").asInt());
674 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
675 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
676 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
677 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
678 assertEquals(3, res.at("/query/operands/0/distances/0/boundary/min").asInt());
679 assertEquals(5, res.at("/query/operands/0/distances/0/boundary/max").asInt());
680 assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean());
681 assertEquals("korap:token", res.at("/query/operands/0/operands/0/@type").asText());
682 assertEquals("der", res.at("/query/operands/0/operands/0/wrap/key").asText());
683 assertEquals("Mann", res.at("/query/operands/0/operands/1/wrap/key").asText());
684
685 query = "#BEG(der /w3:5 Mann) /+w10 kommt";
686 qs.setQuery(query, "cosmas2");
687 res = mapper.readTree(qs.toJSON());
688 assertEquals("korap:reference", res.at("/query/@type").asText());
689 assertEquals("operation:focus", res.at("/query/operation").asText());
690 assertEquals(129, res.at("/query/classRef/0").asInt());
691 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
692 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
693 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
694 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
695 assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt());
696 assertEquals(10, res.at("/query/operands/0/distances/0/boundary/max").asInt());
697 assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
698 assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
699 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
700 assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
701 assertEquals("korap:reference", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
702 assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
703 assertEquals(0, res.at("/query/operands/0/operands/0/operands/0/spanRef/0").asInt());
704 assertEquals(1, res.at("/query/operands/0/operands/0/operands/0/spanRef/1").asInt());
705 assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText());
706 assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operands/0/operands/0/operation").asText());
707 assertEquals("korap:distance", res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/@type").asText());
708 assertEquals("w", res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/key").asText());
709 assertEquals(3, res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/boundary/min").asInt());
710 assertEquals(5, res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/boundary/max").asInt());
711 assertEquals(false, res.at("/query/operands/0/operands/0/operands/0/operands/0/inOrder").asBoolean());
712 assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/@type").asText());
713 assertEquals("der", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
714 assertEquals("Mann", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/wrap/key").asText());
715 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
716 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
717 assertEquals("korap:token", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
718 assertEquals("kommt", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
719
720 query = "kommt /+w10 #BEG(der /w3:5 Mann)";
721 qs.setQuery(query, "cosmas2");
722 res = mapper.readTree(qs.toJSON());
723 assertEquals("korap:reference", res.at("/query/@type").asText());
724 assertEquals("operation:focus", res.at("/query/operation").asText());
725 assertEquals(129, res.at("/query/classRef/0").asInt());
726 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
727 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
728 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
729 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
730 assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt());
731 assertEquals(10, res.at("/query/operands/0/distances/0/boundary/max").asInt());
732 assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
733 assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText());
734 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
735 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
736 assertEquals("korap:reference", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
737 assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operands/0/operation").asText());
738 assertEquals(0, res.at("/query/operands/0/operands/1/operands/0/spanRef/0").asInt());
739 assertEquals(1, res.at("/query/operands/0/operands/1/operands/0/spanRef/1").asInt());
740 assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/operands/0/@type").asText());
741 assertEquals("operation:sequence", res.at("/query/operands/0/operands/1/operands/0/operands/0/operation").asText());
742 assertEquals("korap:distance", res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/@type").asText());
743 assertEquals("w", res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/key").asText());
744 assertEquals(3, res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/boundary/min").asInt());
745 assertEquals(5, res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/boundary/max").asInt());
746 assertEquals(false, res.at("/query/operands/0/operands/1/operands/0/operands/0/inOrder").asBoolean());
747 assertEquals("korap:token", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/@type").asText());
748 assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/wrap/key").asText());
749 assertEquals("Mann", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/wrap/key").asText());
750 assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
751 assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
752 assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
753 assertEquals("kommt", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
754
755 query = "#END(der /w3:5 Mann)";
756 qs.setQuery(query, "cosmas2");
757 res = mapper.readTree(qs.toJSON());
758 assertEquals("korap:reference", res.at("/query/@type").asText());
759 assertEquals("operation:focus", res.at("/query/operation").asText());
760 assertEquals(-1, res.at("/query/spanRef/0").asInt());
761 assertEquals(1, res.at("/query/spanRef/1").asInt());
762 assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
763 assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
764 assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
765 assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
766 assertEquals(3, res.at("/query/operands/0/distances/0/boundary/min").asInt());
767 assertEquals(5, res.at("/query/operands/0/distances/0/boundary/max").asInt());
768 assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean());
769 assertEquals("korap:token", res.at("/query/operands/0/operands/0/@type").asText());
770 assertEquals("der", res.at("/query/operands/0/operands/0/wrap/key").asText());
771 assertEquals("Mann", res.at("/query/operands/0/operands/1/wrap/key").asText());
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000772 }
773
774 @Test
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000775 public void testELEM() throws QueryException, JsonProcessingException, IOException {
776 query = "#ELEM(S)";
777 qs.setQuery(query, "cosmas2");
778 res = mapper.readTree(qs.toJSON());
779 assertEquals("korap:span", res.at("/query/@type").asText());
780 assertEquals("s", res.at("/query/key").asText());
Joachim Bingel89cceac2014-01-08 15:51:08 +0000781
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000782 query = "#ELEM(W ANA=N)";
783 qs.setQuery(query, "cosmas2");
784 res = mapper.readTree(qs.toJSON());
785 assertEquals("korap:span", res.at("/query/@type").asText());
786 assertEquals("w", res.at("/query/key").asText());
787 assertEquals("korap:term", res.at("/query/attr/@type").asText());
788 assertEquals("N", res.at("/query/attr/key").asText());
789 assertEquals("p", res.at("/query/attr/layer").asText());
790 assertEquals("match:eq", res.at("/query/attr/match").asText());
Joachim Bingel87480d02014-01-17 14:07:46 +0000791
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000792 query = "#ELEM(W ANA != 'N V')";
793 qs.setQuery(query, "cosmas2");
794 res = mapper.readTree(qs.toJSON());
795 assertEquals("korap:span", res.at("/query/@type").asText());
796 assertEquals("w", res.at("/query/key").asText());
797 assertEquals("korap:termGroup", res.at("/query/attr/@type").asText());
798 assertEquals("relation:and", res.at("/query/attr/relation").asText());
799 assertEquals("korap:term", res.at("/query/attr/operands/0/@type").asText());
800 assertEquals("N", res.at("/query/attr/operands/0/key").asText());
801 assertEquals("p", res.at("/query/attr/operands/0/layer").asText());
802 assertEquals("match:ne", res.at("/query/attr/operands/0/match").asText());
803 assertEquals("korap:term", res.at("/query/attr/operands/1/@type").asText());
804 assertEquals("V", res.at("/query/attr/operands/1/key").asText());
805 assertEquals("p", res.at("/query/attr/operands/1/layer").asText());
806 assertEquals("match:ne", res.at("/query/attr/operands/1/match").asText());
Joachim Bingel87480d02014-01-17 14:07:46 +0000807
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000808 query = "#ELEM(W ANA != 'N A V' Genre = Sport)";
809 qs.setQuery(query, "cosmas2");
810 res = mapper.readTree(qs.toJSON());
811 assertEquals("korap:span", res.at("/query/@type").asText());
812 assertEquals("w", res.at("/query/key").asText());
813 assertEquals("korap:termGroup", res.at("/query/attr/@type").asText());
814 assertEquals("relation:and", res.at("/query/attr/relation").asText());
815 assertEquals("korap:termGroup", res.at("/query/attr/operands/0/@type").asText());
816 assertEquals("relation:and", res.at("/query/attr/operands/0/relation").asText());
817 assertEquals("N", res.at("/query/attr/operands/0/operands/0/key").asText());
818 assertEquals("A", res.at("/query/attr/operands/0/operands/1/key").asText());
819 assertEquals("V", res.at("/query/attr/operands/0/operands/2/key").asText());
820 assertEquals("Genre", res.at("/query/attr/operands/1/layer").asText());
821 assertEquals("Sport", res.at("/query/attr/operands/1/key").asText());
822
823 query = "#ELEM(W ANA != 'N A V' Genre != 'Sport Politik')";
824 qs.setQuery(query, "cosmas2");
825 res = mapper.readTree(qs.toJSON());
826 assertEquals("korap:span", res.at("/query/@type").asText());
827 assertEquals("w", res.at("/query/key").asText());
828 assertEquals("korap:termGroup", res.at("/query/attr/@type").asText());
829 assertEquals("relation:and", res.at("/query/attr/relation").asText());
830 assertEquals("korap:termGroup", res.at("/query/attr/operands/0/@type").asText());
831 assertEquals("relation:and", res.at("/query/attr/operands/0/relation").asText());
832 assertEquals("korap:termGroup", res.at("/query/attr/operands/1/@type").asText());
833 assertEquals("relation:and", res.at("/query/attr/operands/1/relation").asText());
834 assertEquals("N", res.at("/query/attr/operands/0/operands/0/key").asText());
835 assertEquals("A", res.at("/query/attr/operands/0/operands/1/key").asText());
836 assertEquals("V", res.at("/query/attr/operands/0/operands/2/key").asText());
837 assertEquals("match:ne", res.at("/query/attr/operands/0/operands/2/match").asText());
838 assertEquals("Genre", res.at("/query/attr/operands/1/operands/0/layer").asText());
839 assertEquals("Sport", res.at("/query/attr/operands/1/operands/0/key").asText());
840 assertEquals("Genre", res.at("/query/attr/operands/1/operands/1/layer").asText());
841 assertEquals("Politik", res.at("/query/attr/operands/1/operands/1/key").asText());
842 assertEquals("match:ne", res.at("/query/attr/operands/1/operands/1/match").asText());
843 }
844// @Test
845// public void testOPALL() throws QueryException {
846// query="#ALL(gehen /w1:10 voran)";
847// String all1 =
848// "{@type=korap:group, operation=operation:sequence, " +
849// "operands=[" +
850// "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
851// "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
852// "], inOrder=false, " +
853// "distances=[" +
854// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
855// "]" +
856// "}";
857// ct = new CosmasTree(query);
858// map = ct.getRequestMap().get("query").toString();
859// assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", ""));
860//
861// query="#ALL(gehen /w1:10 (voran /w1:4 schnell))";
862// String all2 =
863// "{@type=korap:group, operation=operation:sequence, " +
864// "operands=[" +
865// "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
866// "{@type=korap:group, operation=operation:sequence, operands=[" +
867// "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}," +
868// "{@type=korap:token, wrap={@type=korap:term, key=schnell, layer=orth, match=match:eq}}" +
869// "], inOrder=false, " +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000870// "distances=[" +
871// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
872// "]" +
873// "}" +
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000874// "], inOrder=false, " +
875// "distances=[" +
876// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
877// "]" +
878// "}";
879// ct = new CosmasTree(query);
880// map = ct.getRequestMap().get("query").toString();
881// assertEquals(all2.replaceAll(" ", ""), map.replaceAll(" ", ""));
882// }
883//
884// @Test
885// public void testOPNHIT() throws QueryException {
886// query="#NHIT(gehen /w1:10 voran)";
887// String nhit1 =
888// "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
889// "{@type=korap:group, operation=operation:class, classRefOp=classRefOp:inversion, classIn=[130,131], classOut=129, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000890// "{@type=korap:group, operation=operation:sequence, " +
891// "operands=[" +
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000892// "{@type=korap:group, operation=operation:class, class=130 , classOut=130, operands=[" +
893// "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
894// "]}," +
895// "{@type=korap:group, operation=operation:class, class=131 , classOut=131, operands=[" +
896// "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
897// "]}" +
898// "], inOrder=false, " +
899// "distances=[" +
900// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
901// "]" +
902// "}" +
903// "]}" +
904// "]}";
905// ct = new CosmasTree(query);
906// map = ct.getRequestMap().get("query").toString();
907// assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", ""));
908//
909//// query="#NHIT(gehen %w1:10 voran)";
910//// String nhit2 =
911//// "{@type=korap:reference, operation=operation:focus, classRef=129, operands=[" +
912//// "{@type=korap:group, operation=operation:sequence, " +
913//// "operands=[" +
914//// "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
915//// "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" +
916//// "{@type=korap:group, operation=operation:repetition, operands=[" +
917//// "{@type=korap:token}" +
918//// "], boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}}" +
919//// "]}," +
920//// "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
921//// "], inOrder=false, " +
922//// "distances=[" +
923//// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
924//// "]" +
925//// "}" +
926//// "]}";
927//// ct = new CosmasTree(query);
928//// map = ct.getRequestMap().get("query").toString();
929//// assertEquals(nhit2.replaceAll(" ", ""), map.replaceAll(" ", ""));
930//
931// query="#NHIT(gehen /+w1:10 voran /w1:10 Beispiel)";
932// String nhit3 =
933// "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
934// "{@type=korap:group, operation=operation:class, classRefOp=classRefOp:inversion, classIn=[130,131], classOut=129, operands=[" +
935// "{@type=korap:group, operation=operation:sequence, " +
936// "operands=[" +
937// "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
938// "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000939// "]}," +
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000940// "{@type=korap:group, operation=operation:class, class=131, classOut=131, operands=[" +
941// "{@type=korap:reference, operation=operation:focus, classRef=[132], operands=[" +
942// "{@type=korap:group, operation=operation:sequence, " +
943// "operands=[" +
944// "{@type=korap:group, operation=operation:class, class=132, classOut=132, operands=[" +
945// "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
946// "]}," +
947// "{@type=korap:group, operation=operation:class, class=132, classOut=132, operands=[" +
948// "{@type=korap:token, wrap={@type=korap:term, key=Beispiel, layer=orth, match=match:eq}}" +
949// "]}" +
950// "], inOrder=false, " +
951// "distances=[" +
952// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
953// "]" +
954// "}" +
955// "]}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000956// "]}" +
957// "], inOrder=true, " +
958// "distances=[" +
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000959// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000960// "]" +
961// "}" +
962// "]}" +
963// "]}";
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000964// ct = new CosmasTree(query);
965// map = ct.getRequestMap().get("query").toString();
966// assertEquals(nhit3.replaceAll(" ", ""), map.replaceAll(" ", ""));
967// }
968//
969// @Test
970// public void testOPBED() throws QueryException {
971// query = "#BED(der , sa)";
972// String bed1 =
973// "{@type=korap:reference, operation=operation:focus, classRef=[129], operands= [" +
974// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
975// "{@type=korap:span, key=s}," +
976// "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
977// "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000978// "]}" +
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000979// "], frame=frame:startswith}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000980// "]}";
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000981// ct = new CosmasTree(query);
982// map = ct.getRequestMap().get("query").toString();
983// assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", ""));
984//
985// query = "#BED(der Mann , +pe)";
986// String bed2 =
987// "{@type=korap:reference, operation=operation:focus, classRef=[129], operands= [" +
988// "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
989// "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
990// "{@type=korap:span, key=p}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000991// "]}," +
Joachim Bingelcd30ed12014-12-03 16:14:13 +0000992// "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
993// "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
994// "{@type=korap:group, operation=operation:sequence, operands=[" +
995// "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000996// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
997// "]}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000998// "]}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000999// "]}" +
Joachim Bingelcd30ed12014-12-03 16:14:13 +00001000// "], frame=frame:matches}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +00001001// "]}";
Joachim Bingel03dfd952014-07-30 08:08:53 +00001002// ct = new CosmasTree(query);
1003// map = ct.getRequestMap().get("query").toString();
Joachim Bingelcd30ed12014-12-03 16:14:13 +00001004// assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1005//
1006// query = "#BED(der Mann , sa,-pa)";
1007// String bed3 =
1008// "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
1009// "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1010// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1011// "{@type=korap:span, key=s}," +
1012// "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
1013// "{@type=korap:group, operation=operation:sequence, operands=[" +
1014// "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1015// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1016// "]}" +
1017// "]}" +
1018// "], frame=frame:startswith}," +
1019// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1020// "{@type=korap:span, key=p}," +
1021// "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
1022// "{@type=korap:group, operation=operation:sequence, operands=[" +
1023// "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1024// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1025// "]}" +
1026// "]}" +
1027// "], frame=frame:startswith, exclude=true}" +
1028// "], frame=frame:matches}" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001029// "]}";
1030// ct = new CosmasTree(query);
1031// map = ct.getRequestMap().get("query").toString();
Joachim Bingelcd30ed12014-12-03 16:14:13 +00001032// assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", ""));
1033// }
1034//
1035// @Test
1036// public void testColonSeparatedConditions() throws QueryException {
1037//
1038// query = "Der:sa";
1039// String col1 =
1040// "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
1041// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1042// "{@type=korap:span, key=s}," +
1043// "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
1044// "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
1045// "]}" +
1046// "], frame=frame:startswith}" +
1047// "]}";
1048// ct = new CosmasTree(query);
1049// map = ct.getRequestMap().get("query").toString();
1050// assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1051//
1052// query = "Mann:sa,-pa,+te";
1053// String col2 =
1054// "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
1055// "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1056// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1057// "{@type=korap:span, key=s}," +
1058// "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
1059// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1060// "]}" +
1061// "], frame=frame:startswith}," +
1062// "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
1063// "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1064// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1065// "{@type=korap:span, key=p}," +
1066// "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
1067// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1068// "]}" +
1069// "], frame=frame:startswith, exclude=true}," +
1070// "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1071// "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
1072// "{@type=korap:span, key=t}" +
1073// "]}," +
1074// "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
1075// "{@type=korap:group, operation=operation:class, class=131, classOut=131, operands=[" +
1076// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1077// "]}" +
1078// "]}" +
1079// "], frame=frame:matches}" +
1080// "], frame=frame:matches}" +
1081// "]}" +
1082// "], frame=frame:matches}" +
1083// "]}";
1084// ct = new CosmasTree(query);
1085// map = ct.getRequestMap().get("query").toString();
1086// assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1087//
1088// query = "Mann:sa,-pa,+te,se";
1089// expected =
1090// "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
1091// "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1092// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1093// "{@type=korap:span, key=s}," +
1094// "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
1095// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1096// "]}" +
1097// "], frame=frame:startswith}," +
1098// "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
1099// "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1100// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1101// "{@type=korap:span, key=p}," +
1102// "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
1103// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1104// "]}" +
1105// "], frame=frame:startswith, exclude=true}," +
1106// "{@type=korap:reference, operation=operation:focus, classRef=[131], operands=[" +
1107// "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1108// "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1109// "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
1110// "{@type=korap:span, key=t}" +
1111// "]}," +
1112// "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
1113// "{@type=korap:group, operation=operation:class, class=131, classOut=131, operands=[" +
1114// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1115// "]}" +
1116// "]}" +
1117// "], frame=frame:matches}," +
1118// "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1119// "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
1120// "{@type=korap:span, key=s}" +
1121// "]}," +
1122// "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
1123// "{@type=korap:group, operation=operation:class, class=132, classOut=132, operands=[" +
1124// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1125// "]}" +
1126// "]}" +
1127// "], frame=frame:matches}" +
1128// "], frame=frame:matches}" +
1129// "]}" +
1130// "], frame=frame:matches}" +
1131// "]}" +
1132// "], frame=frame:matches}" +
1133// "]}";
1134// ct = new CosmasTree(query);
1135// map = ct.getRequestMap().get("query").toString();
1136// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1137// }
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00001138}
Joachim Bingelcd30ed12014-12-03 16:14:13 +00001139
1140
1141
1142
1143
1144
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00001145