blob: 8f03dd88f9732f19dee1dd073ad2c0b549c26716 [file] [log] [blame]
Joachim Bingel4eacdd32014-10-22 15:49:47 +00001import static org.junit.Assert.*;
2
3import java.io.IOException;
4import java.util.ArrayList;
5import java.util.Arrays;
6import java.util.Iterator;
7
8import org.junit.Test;
9
10import com.fasterxml.jackson.core.JsonPointer;
11import com.fasterxml.jackson.core.JsonProcessingException;
12import com.fasterxml.jackson.databind.JsonNode;
13import com.fasterxml.jackson.databind.ObjectMapper;
14import com.google.common.collect.Lists;
15
16
17import de.ids_mannheim.korap.query.serialize.QuerySerializer;
18import de.ids_mannheim.korap.util.QueryException;
19
20public class PoliqarpPlusTreeJSONTest {
21
22 String map;
23 String expected;
24 String metaExpected;
25 String metaMap;
26 String query;
27 ArrayList<JsonNode> operands;
28
29 QuerySerializer qs = new QuerySerializer();
30 ObjectMapper mapper = new ObjectMapper();
31 JsonNode res;
32
33 @Test
34 public void testContext() throws QueryException, JsonProcessingException, IOException {
35 query = "foo";
36 String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld";
37 qs.setQuery(query, "poliqarpplus");
38 res = mapper.readTree(qs.toJSON());
39 assertEquals(contextString, res.get("@context").asText());
40 }
41
42
43
44 @Test
45 public void testSingleTokens() throws QueryException, JsonProcessingException, IOException {
46 query = "[base=Mann]";
47 qs.setQuery(query, "poliqarpplus");
48 res = mapper.readTree(qs.toJSON());
49 assertEquals("korap:token", res.at("/query/@type").asText());
50 assertEquals("Mann", res.at("/query/wrap/key").asText());
51 assertEquals("lemma", res.at("/query/wrap/layer").asText());
52 assertEquals("match:eq", res.at("/query/wrap/match").asText());
53
54 query = "[orth!=Frau]";
55 qs.setQuery(query, "poliqarpplus");
56 res = mapper.readTree(qs.toJSON());
57 assertEquals("korap:token", res.at("/query/@type").asText());
58 assertEquals("Frau", res.at("/query/wrap/key").asText());
59 assertEquals("orth", res.at("/query/wrap/layer").asText());
60 assertEquals("match:ne", res.at("/query/wrap/match").asText());
61
62 query = "[p!=NN]";
63 qs.setQuery(query, "poliqarpplus");
64 res = mapper.readTree(qs.toJSON());
65 assertEquals("korap:token", res.at("/query/@type").asText());
66 assertEquals("NN", res.at("/query/wrap/key").asText());
67 assertEquals("p", res.at("/query/wrap/layer").asText());
68 assertEquals("match:ne", res.at("/query/wrap/match").asText());
69
70 query = "[!p!=NN]";
71 qs.setQuery(query, "poliqarpplus");
72 res = mapper.readTree(qs.toJSON());
73 assertEquals("korap:token", res.at("/query/@type").asText());
74 assertEquals("NN", res.at("/query/wrap/key").asText());
75 assertEquals("p", res.at("/query/wrap/layer").asText());
76 assertEquals("match:eq", res.at("/query/wrap/match").asText());
77
78 query = "[base=schland/x]";
79 qs.setQuery(query, "poliqarpplus");
80 res = mapper.readTree(qs.toJSON());
81 assertEquals("korap:token", res.at("/query/@type").asText());
82 assertEquals(".*?schland.*?", res.at("/query/wrap/key").asText());
83 assertEquals("lemma", res.at("/query/wrap/layer").asText());
84 assertEquals("type:regex", res.at("/query/wrap/type").asText());
85 assertEquals("match:eq", res.at("/query/wrap/match").asText());
86 }
87
88 @Test
89 public void testValue() throws QueryException, JsonProcessingException, IOException {
90 query = "[mate/m=temp:pres]";
91 qs.setQuery(query, "poliqarpplus");
92 res = mapper.readTree(qs.toJSON());
93 assertEquals("korap:token", res.at("/query/@type").asText());
94 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
95 assertEquals("temp", res.at("/query/wrap/key").asText());
96 assertEquals("pres", res.at("/query/wrap/value").asText());
97 assertEquals("m", res.at("/query/wrap/layer").asText());
98 assertEquals("mate", res.at("/query/wrap/foundry").asText());
99 assertEquals("match:eq", res.at("/query/wrap/match").asText());
100 }
101
102 @Test
103 public void testRegex() throws QueryException, JsonProcessingException, IOException {
104 query = "[orth=\"M(a|ä)nn(er)?\"]";
105 qs.setQuery(query, "poliqarpplus");
106 res = mapper.readTree(qs.toJSON());
107 assertEquals("korap:token", res.at("/query/@type").asText());
108 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
109 assertEquals("M(a|ä)nn(er)?", res.at("/query/wrap/key").asText());
110 assertEquals("type:regex", res.at("/query/wrap/type").asText());
111 assertEquals("orth", res.at("/query/wrap/layer").asText());
112 assertEquals("match:eq", res.at("/query/wrap/match").asText());
113
114 query = "[orth=\"M(a|ä)nn(er)?\"/x]";
115 qs.setQuery(query, "poliqarpplus");
116 res = mapper.readTree(qs.toJSON());
117 assertEquals("korap:token", res.at("/query/@type").asText());
118 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
119 assertEquals(".*?M(a|ä)nn(er)?.*?", res.at("/query/wrap/key").asText());
120 assertEquals("type:regex", res.at("/query/wrap/type").asText());
121 assertEquals("orth", res.at("/query/wrap/layer").asText());
122 assertEquals("match:eq", res.at("/query/wrap/match").asText());
123
124 query = "\".*?Mann.*?\"";
125 qs.setQuery(query, "poliqarpplus");
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(".*?Mann.*?", res.at("/query/wrap/key").asText());
130 assertEquals("type:regex", res.at("/query/wrap/type").asText());
131 assertEquals("orth", res.at("/query/wrap/layer").asText());
132 assertEquals("match:eq", res.at("/query/wrap/match").asText());
133
134 query = "z.B./x";
135 qs.setQuery(query, "poliqarpplus");
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(".*?z\\.B\\..*?", res.at("/query/wrap/key").asText());
140 assertEquals("type:regex", res.at("/query/wrap/type").asText());
141 assertEquals("orth", res.at("/query/wrap/layer").asText());
142 assertEquals("match:eq", res.at("/query/wrap/match").asText());
143
144 }
145
146 @Test
147 public void testCaseSensitivityFlag() throws QueryException, JsonProcessingException, IOException {
148 query = "[orth=deutscher/i]";
149 qs.setQuery(query, "poliqarpplus");
150 res = mapper.readTree(qs.toJSON());
151 assertEquals("korap:token", res.at("/query/@type").asText());
152 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
153 assertEquals("deutscher", res.at("/query/wrap/key").asText());
154 assertEquals("true", res.at("/query/wrap/caseInsensitive").asText());
155 assertEquals("orth", res.at("/query/wrap/layer").asText());
156 assertEquals("match:eq", res.at("/query/wrap/match").asText());
157
158 query = "deutscher/i";
159 qs.setQuery(query, "poliqarpplus");
160 res = mapper.readTree(qs.toJSON());
161 assertEquals("korap:token", res.at("/query/@type").asText());
162 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
163 assertEquals("deutscher", res.at("/query/wrap/key").asText());
164 assertEquals("true", res.at("/query/wrap/caseInsensitive").asText());
165 assertEquals("orth", res.at("/query/wrap/layer").asText());
166 assertEquals("match:eq", res.at("/query/wrap/match").asText());
167
168 query = "deutscher/I";
169 qs.setQuery(query, "poliqarpplus");
170 res = mapper.readTree(qs.toJSON());
171 assertEquals("korap:token", res.at("/query/@type").asText());
172 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
173 assertEquals("deutscher", res.at("/query/wrap/key").asText());
174 assertEquals("false", res.at("/query/wrap/caseInsensitive").asText());
175 assertEquals("orth", res.at("/query/wrap/layer").asText());
176 assertEquals("match:eq", res.at("/query/wrap/match").asText());
177
178 query = "[orth=deutscher/i][orth=Bundestag]";
179 qs.setQuery(query, "poliqarpplus");
180 res = mapper.readTree(qs.toJSON());
181 assertEquals("korap:group", res.at("/query/@type").asText());
182 assertEquals("operation:sequence", res.at("/query/operation").asText());
183 operands = Lists.newArrayList(res.at("/query/operands").elements());
184 assertEquals("korap:token", operands.get(0).at("/@type").asText());
185 assertEquals("deutscher", operands.get(0).at("/wrap/key").asText());
186 assertEquals("orth", operands.get(0).at("/wrap/layer").asText());
187 assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
188 assertEquals("true", operands.get(0).at("/wrap/caseInsensitive").asText());
189 assertEquals("korap:token", operands.get(1).at("/@type").asText());
190 assertEquals("Bundestag", operands.get(1).at("/wrap/key").asText());
191 assertEquals("orth", operands.get(1).at("/wrap/layer").asText());
192 assertEquals("match:eq", operands.get(1).at("/wrap/match").asText());
193 assertEquals(true, operands.get(1).at("/wrap/caseInsensitive").isMissingNode());
194
195 query = "deutscher/i Bundestag";
196 qs.setQuery(query, "poliqarpplus");
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 operands = Lists.newArrayList(res.at("/query/operands").elements());
201 assertEquals("korap:token", operands.get(0).at("/@type").asText());
202 assertEquals("deutscher", operands.get(0).at("/wrap/key").asText());
203 assertEquals("orth", operands.get(0).at("/wrap/layer").asText());
204 assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
205 assertEquals("true", operands.get(0).at("/wrap/caseInsensitive").asText());
206 assertEquals("korap:token", operands.get(1).at("/@type").asText());
207 assertEquals("Bundestag", operands.get(1).at("/wrap/key").asText());
208 assertEquals("orth", operands.get(1).at("/wrap/layer").asText());
209 assertEquals("match:eq", operands.get(1).at("/wrap/match").asText());
210 assertEquals(true, operands.get(1).at("/wrap/caseInsensitive").isMissingNode());
211 }
212
213 @Test
214 public void testSpans() throws QueryException, JsonProcessingException, IOException {
215 query = "<s>";
216 qs.setQuery(query, "poliqarpplus");
217 res = mapper.readTree(qs.toJSON());
218 assertEquals("korap:span", res.at("/query/@type").asText());
219 assertEquals("s", res.at("/query/key").asText());
220
221 query = "<vp>";
222 qs.setQuery(query, "poliqarpplus");
223 res = mapper.readTree(qs.toJSON());
224 assertEquals("korap:span", res.at("/query/@type").asText());
225 assertEquals("vp", res.at("/query/key").asText());
226
227 query = "<cnx/c=vp>";
228 qs.setQuery(query, "poliqarpplus");
229 res = mapper.readTree(qs.toJSON());
230 assertEquals("korap:span", res.at("/query/@type").asText());
231 assertEquals("vp", res.at("/query/key").asText());
232 assertEquals("cnx", res.at("/query/foundry").asText());
233 assertEquals("c", res.at("/query/layer").asText());
234
235 query = "<cnx/c!=vp>";
236 qs.setQuery(query, "poliqarpplus");
237 res = mapper.readTree(qs.toJSON());
238 assertEquals("korap:span", res.at("/query/@type").asText());
239 assertEquals("vp", res.at("/query/key").asText());
240 assertEquals("cnx", res.at("/query/foundry").asText());
241 assertEquals("c", res.at("/query/layer").asText());
242 assertEquals("match:ne", res.at("/query/match").asText());
243
244 query = "<cnx/c!=vp class!=header>";
245 qs.setQuery(query, "poliqarpplus");
246 res = mapper.readTree(qs.toJSON());
247 assertEquals("korap:span", res.at("/query/@type").asText());
248 assertEquals("vp", res.at("/query/key").asText());
249 assertEquals("cnx", res.at("/query/foundry").asText());
250 assertEquals("c", res.at("/query/layer").asText());
251 assertEquals("match:ne", res.at("/query/match").asText());
252 assertEquals("class", res.at("/query/attr/key").asText());
253 assertEquals("header", res.at("/query/attr/value").asText());
254 assertEquals("match:ne", res.at("/query/attr/match").asText());
255
256 query = "<cnx/c!=vp !(class!=header)>";
257 qs.setQuery(query, "poliqarpplus");
258 res = mapper.readTree(qs.toJSON());
259 assertEquals("korap:span", res.at("/query/@type").asText());
260 assertEquals("vp", res.at("/query/key").asText());
261 assertEquals("cnx", res.at("/query/foundry").asText());
262 assertEquals("c", res.at("/query/layer").asText());
263 assertEquals("match:ne", res.at("/query/match").asText());
264 assertEquals("class", res.at("/query/attr/key").asText());
265 assertEquals("header", res.at("/query/attr/value").asText());
266 assertEquals("match:eq", res.at("/query/attr/match").asText());
267
268 query = "<cnx/c!=vp !(class=header & id=7)>";
269 qs.setQuery(query, "poliqarpplus");
270 res = mapper.readTree(qs.toJSON());
271 assertEquals("korap:span", res.at("/query/@type").asText());
272 assertEquals("vp", res.at("/query/key").asText());
273 assertEquals("cnx", res.at("/query/foundry").asText());
274 assertEquals("c", res.at("/query/layer").asText());
275 assertEquals("match:ne", res.at("/query/match").asText());
276 assertEquals("korap:termGroup", res.at("/query/attr/@type").asText());
277 assertEquals("relation:and", res.at("/query/attr/relation").asText());
278 operands = Lists.newArrayList( res.at("/query/attr/operands").elements());
279 assertEquals("korap:term", operands.get(0).at("/@type").asText());
280 assertEquals("class", operands.get(0).at("/key").asText());
281 assertEquals("header", operands.get(0).at("/value").asText());
282 assertEquals("match:ne", operands.get(0).at("/match").asText());
283 assertEquals("korap:term", operands.get(1).at("/@type").asText());
284 assertEquals("id", operands.get(1).at("/key").asText());
285 assertEquals("7", operands.get(1).at("/value").asText());
286 assertEquals("match:ne", operands.get(1).at("/match").asText());
287 }
288
289 @Test
290 public void testDistances() throws QueryException, JsonProcessingException, IOException {
291 query = "[base=der][][base=Mann]";
292 qs.setQuery(query, "poliqarpplus");
293 res = mapper.readTree(qs.toJSON());
294 qs.setQuery(query, "poliqarpplus");
295 res = mapper.readTree(qs.toJSON());
296 assertEquals("korap:group", res.at("/query/@type").asText());
297 assertEquals("operation:sequence", res.at("/query/operation").asText());
298 assertEquals("true", res.at("/query/inOrder").asText());
299 assertEquals("korap:distance", res.at("/query/distances").elements().next().at("/@type").asText());
300 assertEquals("w", res.at("/query/distances").elements().next().at("/key").asText());
301 assertEquals("korap:boundary", res.at("/query/distances").elements().next().at("/boundary/@type").asText());
302 assertEquals("2", res.at("/query/distances").elements().next().at("/boundary/min").asText());
303 assertEquals("2", res.at("/query/distances").elements().next().at("/boundary/max").asText());
304 operands = Lists.newArrayList(res.at("/query/operands").elements());
305 assertEquals("korap:token", operands.get(0).at("/@type").asText());
306 assertEquals("der", operands.get(0).at("/wrap/key").asText());
307 assertEquals("lemma", operands.get(0).at("/wrap/layer").asText());
308 assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
309 assertEquals("korap:token", operands.get(1).at("/@type").asText());
310 assertEquals("Mann", operands.get(1).at("/wrap/key").asText());
311 assertEquals("lemma", operands.get(1).at("/wrap/layer").asText());
312 assertEquals("match:eq", operands.get(1).at("/wrap/match").asText());
313
314 query = "[base=der][][][base=Mann]";
315 qs.setQuery(query, "poliqarpplus");
316 res = mapper.readTree(qs.toJSON());
317 qs.setQuery(query, "poliqarpplus");
318 res = mapper.readTree(qs.toJSON());
319 assertEquals("korap:group", res.at("/query/@type").asText());
320 assertEquals("operation:sequence", res.at("/query/operation").asText());
321 assertEquals("true", res.at("/query/inOrder").asText());
322 assertEquals("korap:distance", res.at("/query/distances").elements().next().at("/@type").asText());
323 assertEquals("w", res.at("/query/distances").elements().next().at("/key").asText());
324 assertEquals("korap:boundary", res.at("/query/distances").elements().next().at("/boundary/@type").asText());
325 assertEquals("3", res.at("/query/distances").elements().next().at("/boundary/min").asText());
326 assertEquals("3", res.at("/query/distances").elements().next().at("/boundary/max").asText());
327 operands = Lists.newArrayList(res.at("/query/operands").elements());
328 assertEquals("korap:token", operands.get(0).at("/@type").asText());
329 assertEquals("der", operands.get(0).at("/wrap/key").asText());
330 assertEquals("lemma", operands.get(0).at("/wrap/layer").asText());
331 assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
332 assertEquals("korap:token", operands.get(1).at("/@type").asText());
333 assertEquals("Mann", operands.get(1).at("/wrap/key").asText());
334 assertEquals("lemma", operands.get(1).at("/wrap/layer").asText());
335 assertEquals("match:eq", operands.get(1).at("/wrap/match").asText());
336
337 query = "[base=der][][]?[base=Mann]";
338 qs.setQuery(query, "poliqarpplus");
339 res = mapper.readTree(qs.toJSON());
340 qs.setQuery(query, "poliqarpplus");
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("true", res.at("/query/inOrder").asText());
345 assertEquals("korap:distance", res.at("/query/distances").elements().next().at("/@type").asText());
346 assertEquals("w", res.at("/query/distances").elements().next().at("/key").asText());
347 assertEquals("korap:boundary", res.at("/query/distances").elements().next().at("/boundary/@type").asText());
348 assertEquals("2", res.at("/query/distances").elements().next().at("/boundary/min").asText());
349 assertEquals("3", res.at("/query/distances").elements().next().at("/boundary/max").asText());
350 operands = Lists.newArrayList(res.at("/query/operands").elements());
351 assertEquals("korap:token", operands.get(0).at("/@type").asText());
352 assertEquals("der", operands.get(0).at("/wrap/key").asText());
353 assertEquals("lemma", operands.get(0).at("/wrap/layer").asText());
354 assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
355 assertEquals("korap:token", operands.get(1).at("/@type").asText());
356 assertEquals("Mann", operands.get(1).at("/wrap/key").asText());
357 assertEquals("lemma", operands.get(1).at("/wrap/layer").asText());
358 assertEquals("match:eq", operands.get(1).at("/wrap/match").asText());
359 }
360//
361// // [base=der][]{2,5}[base=Mann][]?[][base=Frau] nested distances=
362// String et5 =
363// "{@type=korap:group, operation=operation:sequence," +
364// "operands=[" +
365// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
366// "{@type=korap:group, operation=operation:sequence, " +
367// "operands=[" +
368// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," +
369// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Frau, match=match:eq}}" +
370// "], inOrder=true, distances=[" +
371// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=3}, min=2, max=3}" +
372// "]}" +
373// "], inOrder=true, distances=[" +
374// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=6}, min=3, max=6}" +
375// "]}";
376// ppt = new PoliqarpPlusTree("[base=der][]{2,5}[base=Mann][]?[][base=Frau]");
377// map = ppt.getRequestMap().get("query").toString();
378// assertEquals(et5.replaceAll(" ", ""), map.replaceAll(" ", ""));
379//
380// // [base=der][]*[base=Mann]
381// String et6 =
382// "{@type=korap:group, operation=operation:sequence, " +
383// "operands=[" +
384// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
385// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
386// "], inOrder=true, distances=[" +
387// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1}, min=1}" +
388// "]}";
389// ppt = new PoliqarpPlusTree("[base=der][]*[base=Mann]");
390// map = ppt.getRequestMap().get("query").toString();
391// assertEquals(et6.replaceAll(" ", ""), map.replaceAll(" ", ""));
392//
393// // [base=der][]+[base=Mann]
394// String et7 =
395// "{@type=korap:group, operation=operation:sequence, " +
396// "operands=[" +
397// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
398// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
399// "], inOrder=true, distances=[" +
400// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2}, min=2}" +
401// "]}";
402// ppt = new PoliqarpPlusTree("[base=der][]+[base=Mann]");
403// map = ppt.getRequestMap().get("query").toString();
404// assertEquals(et7.replaceAll(" ", ""), map.replaceAll(" ", ""));
405//
406// // [base=der][]+[base=Mann]
407// String et8 =
408// "{@type=korap:group, operation=operation:sequence, " +
409// "operands=[" +
410// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
411// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
412// "], inOrder=true, distances=[" +
413// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=103}, min=2, max=103}" +
414// "]}";
415// ppt = new PoliqarpPlusTree("[base=der][]{1,102}[base=Mann]");
416// map = ppt.getRequestMap().get("query").toString();
417// assertEquals(et8.replaceAll(" ", ""), map.replaceAll(" ", ""));
418//
419// // [base=geht][base=der][]*[base=Mann]
420// String et9 =
421// "{@type=korap:group, operation=operation:sequence, operands=[" +
422// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=geht, match=match:eq}}," +
423// "{@type=korap:group, operation=operation:sequence, " +
424// "operands=[" +
425// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
426// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
427// "], inOrder=true, distances=[" +
428// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1}, min=1}" +
429// "]}" +
430// "]}";
431// ppt = new PoliqarpPlusTree("[base=geht][base=der][]*[base=Mann]");
432// map = ppt.getRequestMap().get("query").toString();
433// assertEquals(et9.replaceAll(" ", ""), map.replaceAll(" ", ""));
434//
435// query = "[base=geht][base=der][]*[base=Mann][base=da]";
436// expected =
437// "{@type=korap:group, operation=operation:sequence, operands=[" +
438// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=geht, match=match:eq}}," +
439// "{@type=korap:group, operation=operation:sequence, " +
440// "operands=[" +
441// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
442// "{@type=korap:group, operation=operation:sequence, operands=[" +
443// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," +
444// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=da, match=match:eq}}" +
445// "]}" +
446// "], inOrder=true, distances=[" +
447// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1}, min=1}" +
448// "]}" +
449// "]}";
450// ppt = new PoliqarpPlusTree(query);
451// map = ppt.getRequestMap().get("query").toString();
452// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
453//
454// query = "[base=geht][base=der][]*contains(<s>,<np>)";
455// expected =
456// "{@type=korap:group, operation=operation:sequence, operands=[" +
457// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=geht, match=match:eq}}," +
458// "{@type=korap:group, operation=operation:sequence, " +
459// "operands=[" +
460// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
461// "{@type=korap:group, operation=operation:position, frames=[frames:contains], operands=[" +
462// "{@type=korap:span, key=s}," +
463// "{@type=korap:span, key=np}" +
464// "], frame=frame:contains}" +
465// "], inOrder=true, distances=[" +
466// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1}, min=1}" +
467// "]}" +
468// "]}";
469// ppt = new PoliqarpPlusTree(query);
470// map = ppt.getRequestMap().get("query").toString();
471// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
472// }
473//
474// @Test
475// public void testDistancesWithClass() throws QueryException {
476// query = "[base=der]{1:[]}[base=Mann]";
477// expected =
478// "{@type=korap:group, operation=operation:sequence, operands=[" +
479// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
480// "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
481// "{@type=korap:token}" +
482// "]}," +
483// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
484// "]}";
485// ppt = new PoliqarpPlusTree(query);
486// map = ppt.getRequestMap().get("query").toString();
487// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
488//
489// query = "{1:[]}[base=der][base=Mann]";
490// expected =
491// "{@type=korap:group, operation=operation:sequence, operands=[" +
492// "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
493// "{@type=korap:token}" +
494// "]}," +
495// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
496// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
497// "]}";
498// ppt = new PoliqarpPlusTree(query);
499// map = ppt.getRequestMap().get("query").toString();
500// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
501// }
502//
503// @Test
504// public void testLeadingTrailingEmptyTokens() throws QueryException {
505// // startswith(<s>, [][base=Mann]
506// String et1 =
507// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
508// "{@type=korap:span, key=s}," +
509// "{@type=korap:group, operation=operation:sequence, operands=[" +
510// "{@type=korap:token}," +
511// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
512// "]}" +
513// "], frame=frame:startswith}";
514// ppt = new PoliqarpPlusTree("startswith(<s>, [][base=Mann])");
515// map = ppt.getRequestMap().get("query").toString();
516// assertEquals(et1.replaceAll(" ", ""), map.replaceAll(" ", ""));
517//
518// query = "[][base=Mann]";
519// expected =
520// "{@type=korap:group, operation=operation:sequence, operands=[" +
521// "{@type=korap:token}," +
522// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
523// "]}";
524// ppt = new PoliqarpPlusTree(query);
525// map = ppt.getRequestMap().get("query").toString();
526// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
527//
528// query = "[][][base=Mann]";
529// expected =
530// "{@type=korap:group, operation=operation:sequence, operands=[" +
531// "{@type=korap:group, operation=operation:repetition, operands=[" +
532// "{@type=korap:token}" +
533// "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}," +
534// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
535// "]}";
536// ppt = new PoliqarpPlusTree(query);
537// map = ppt.getRequestMap().get("query").toString();
538// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
539//
540// query = "[][]*[base=Mann]";
541// expected =
542// "{@type=korap:group, operation=operation:sequence, operands=[" +
543// "{@type=korap:group, operation=operation:repetition, operands=[" +
544// "{@type=korap:token}" +
545// "], boundary={@type=korap:boundary, min=1}, min=1}," +
546// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
547// "]}";
548// ppt = new PoliqarpPlusTree(query);
549// map = ppt.getRequestMap().get("query").toString();
550// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
551//
552// query = "[][]*[base=Mann][][]";
553// expected =
554// "{@type=korap:group, operation=operation:sequence, operands=[" +
555// "{@type=korap:group, operation=operation:repetition, operands=[" +
556// "{@type=korap:token}" +
557// "], boundary={@type=korap:boundary, min=1}, min=1}," +
558// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," +
559// "{@type=korap:group, operation=operation:repetition, operands=[" +
560// "{@type=korap:token}" +
561// "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}" +
562// "]}";
563// ppt = new PoliqarpPlusTree(query);
564// map = ppt.getRequestMap().get("query").toString();
565// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
566//
567// query = "[][]*contains(<s>, <np>)[][]";
568// expected =
569// "{@type=korap:group, operation=operation:sequence, operands=[" +
570// "{@type=korap:group, operation=operation:repetition, operands=[" +
571// "{@type=korap:token}" +
572// "], boundary={@type=korap:boundary, min=1}, min=1}," +
573// "{@type=korap:group, operation=operation:position, frames=[frames:contains], operands=[" +
574// "{@type=korap:span, key=s}," +
575// "{@type=korap:span, key=np}" +
576// "], frame=frame:contains}," +
577// "{@type=korap:group, operation=operation:repetition, operands=[" +
578// "{@type=korap:token}" +
579// "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}" +
580// "]}";
581// ppt = new PoliqarpPlusTree(query);
582// map = ppt.getRequestMap().get("query").toString();
583// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
584// }
585//
586// @Test
587// public void testCoordinatedFields() throws QueryException {
588// // [base=Mann&(cas=N|cas=A)]
589// String cof1 =
590// "{@type=korap:token, wrap=" +
591// "{@type=korap:termGroup, relation=relation:and, operands=[" +
592// "{@type=korap:term, layer=lemma, key=Mann, match=match:eq}," +
593// "{@type=korap:termGroup, relation=relation:or, operands=[" +
594// "{@type=korap:term, layer=cas, key=N, match=match:eq}," +
595// "{@type=korap:term, layer=cas, key=A, match=match:eq}" +
596// "]}" +
597// "]}" +
598// "}";
599// ppt = new PoliqarpPlusTree("[base=Mann&(cas=N|cas=A)]");
600// map = ppt.getRequestMap().get("query").toString();
601// assertEquals(cof1.replaceAll(" ", ""), map.replaceAll(" ", ""));
602//
603//
604// assertEquals(
605// new PoliqarpPlusTree(" [ base=Mann & ( cas=N | cas=A)] ").getRequestMap().get("query").toString(),
606// new PoliqarpPlusTree("[base=Mann &(cas=N|cas=A)]").getRequestMap().get("query").toString()
607// );
608//
609// // [base=Mann&cas=N&gen=m]
610// String cof2 =
611// "{@type=korap:token, wrap=" +
612// "{@type=korap:termGroup, relation=relation:and, operands=[" +
613// "{@type=korap:term, layer=lemma, key=Mann, match=match:eq}," +
614// "{@type=korap:termGroup, relation=relation:and, operands=[" +
615// "{@type=korap:term, layer=cas, key=N, match=match:eq}," +
616// "{@type=korap:term, layer=gen, key=m, match=match:eq}" +
617// "]}" +
618// "]}" +
619// "}";
620// ppt = new PoliqarpPlusTree("[base=Mann&cas=N&gen=m]");
621// map = ppt.getRequestMap().get("query").toString();
622// assertEquals(cof2.replaceAll(" ", ""), map.replaceAll(" ", ""));
623// }
624//
625// @Test
626// public void testOccurrence() throws QueryException {
627// // [base=foo]*
628// String occ1 = "{@type=korap:group, operation=operation:repetition, operands=[" +
629// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
630// "], boundary={@type=korap:boundary, min=0}, min=0}";
631// ppt = new PoliqarpPlusTree("[base=foo]*");
632// map = ppt.getRequestMap().get("query").toString();
633// assertEquals(occ1.replaceAll(" ", ""), map.replaceAll(" ", ""));
634//
635// // [base=foo]*[base=bar]
636// String occ2 =
637// "{@type=korap:group, operation=operation:sequence, operands=[" +
638// "{@type=korap:group, operation=operation:repetition, operands=[" +
639// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
640// "], boundary={@type=korap:boundary, min=0}, min=0 }," +
641// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}" +
642// "]}";
643// ppt = new PoliqarpPlusTree("[base=foo]*[base=bar]");
644// map = ppt.getRequestMap().get("query").toString();
645// assertEquals(occ2.replaceAll(" ", ""), map.replaceAll(" ", ""));
646//
647// // [base=bar][base=foo]*
648// String occ3 =
649// "{@type=korap:group, operation=operation:sequence, operands=[" +
650// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
651// "{@type=korap:group, operation=operation:repetition, operands=[" +
652// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
653// "], boundary={@type=korap:boundary, min=0}, min=0 }" +
654// "]}";
655// ppt = new PoliqarpPlusTree("[base=bar][base=foo]*");
656// map = ppt.getRequestMap().get("query").toString();
657// assertEquals(occ3.replaceAll(" ", ""), map.replaceAll(" ", ""));
658//
659// // ([base=bar][base=foo])*
660// String occ4 =
661// "{@type=korap:group, operation=operation:repetition, operands=[" +
662// "{@type=korap:group, operation=operation:sequence, operands=[" +
663// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
664// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
665// "]}" +
666// "], boundary={@type=korap:boundary, min=0}, min=0}" ;
667// ppt = new PoliqarpPlusTree("([base=bar][base=foo])*");
668// map = ppt.getRequestMap().get("query").toString();
669// assertEquals(occ4.replaceAll(" ", ""), map.replaceAll(" ", ""));
670//
671// // <s>([base=bar][base=foo])*
672// String occ5 =
673// "{@type=korap:group, operation=operation:sequence, operands=[" +
674// "{@type=korap:span, key=s}," +
675// "{@type=korap:group, operation=operation:repetition, operands=[" +
676// "{@type=korap:group, operation=operation:sequence, operands=[" +
677// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
678// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
679// "]}" +
680// "], boundary={@type=korap:boundary, min=0}, min=0 }" +
681// "]}" ;
682// ppt = new PoliqarpPlusTree("<s>([base=bar][base=foo])*");
683// map = ppt.getRequestMap().get("query").toString();
684// assertEquals(occ5.replaceAll(" ", ""), map.replaceAll(" ", ""));
685//
686// // <s><np>([base=bar][base=foo])*
687// String occ6 =
688// "{@type=korap:group, operation=operation:sequence, operands=[" +
689// "{@type=korap:span, key=s}," +
690// "{@type=korap:span, key=np}," +
691// "{@type=korap:group, operation=operation:repetition, operands=[" +
692// "{@type=korap:group, operation=operation:sequence, operands=[" +
693// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
694// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
695// "]}" +
696// "], boundary={@type=korap:boundary, min=0}, min=0 }" +
697// "]}" ;
698// ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*");
699// map = ppt.getRequestMap().get("query").toString();
700// assertEquals(occ6.replaceAll(" ", ""), map.replaceAll(" ", ""));
701//
702// // <s><np>([base=bar][base=foo])*[p=NN]
703// // comment: embedded sequence shouldn't really be here, but does not really hurt, either. (?)
704// // really hard to get this behaviour out of the PQPlus grammar...
705// String occ7 =
706// "{@type=korap:group, operation=operation:sequence, operands=[" +
707// "{@type=korap:span, key=s}," +
708// "{@type=korap:span, key=np}," +
709// "{@type=korap:group, operation=operation:repetition, operands=[" +
710// "{@type=korap:group, operation=operation:sequence, operands=[" +
711// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
712// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
713// "]}" +
714// "], boundary={@type=korap:boundary, min=0}, min=0 }," +
715// "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}" +
716// "]}" ;
717// ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*[p=NN]");
718// map = ppt.getRequestMap().get("query").toString();
719// assertEquals(occ7.replaceAll(" ", ""), map.replaceAll(" ", ""));
720//
721// // ([base=bar][base=foo])*[p=NN]
722// String occ8 =
723// "{@type=korap:group, operation=operation:sequence, operands=[" +
724// "{@type=korap:group, operation=operation:repetition, operands=[" +
725// "{@type=korap:group, operation=operation:sequence, operands=[" +
726// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
727// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
728// "]}" +
729// "], boundary={@type=korap:boundary, min=0}, min=0 }," +
730// "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}" +
731// "]}" ;
732// ppt = new PoliqarpPlusTree("([base=bar][base=foo])*[p=NN]");
733// map = ppt.getRequestMap().get("query").toString();
734// assertEquals(occ8.replaceAll(" ", ""), map.replaceAll(" ", ""));
735//
736// // [base=foo]+
737// String occ9 = "{@type=korap:group, operation=operation:repetition, operands=[" +
738// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
739// "], boundary={@type=korap:boundary, min=1}, min=1}";
740// ppt = new PoliqarpPlusTree("[base=foo]+");
741// map = ppt.getRequestMap().get("query").toString();
742// assertEquals(occ9.replaceAll(" ", ""), map.replaceAll(" ", ""));
743//
744// // [base=foo]?
745// String occ10 = "{@type=korap:group, operation=operation:repetition, operands=[" +
746// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
747// "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}";
748// ppt = new PoliqarpPlusTree("[base=foo]?");
749// map = ppt.getRequestMap().get("query").toString();
750// assertEquals(occ10.replaceAll(" ", ""), map.replaceAll(" ", ""));
751//
752// // [base=foo]{2,5}
753// String occ11 = "{@type=korap:group, operation=operation:repetition, operands=[" +
754// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
755// "], boundary={@type=korap:boundary, min=2, max=5}, min=2, max=5}";
756// ppt = new PoliqarpPlusTree("[base=foo]{2,5}");
757// map = ppt.getRequestMap().get("query").toString();
758// assertEquals(occ11.replaceAll(" ", ""), map.replaceAll(" ", ""));
759//
760// // [base=foo]{2}
761// String occ12 = "{@type=korap:group, operation=operation:repetition, operands=[" +
762// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
763// "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}";
764// ppt = new PoliqarpPlusTree("[base=foo]{2}");
765// map = ppt.getRequestMap().get("query").toString();
766// assertEquals(occ12.replaceAll(" ", ""), map.replaceAll(" ", ""));
767//
768// // [base=foo]{2}
769// String occ13 = "{@type=korap:group, operation=operation:repetition, operands=[" +
770// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
771// "], boundary={@type=korap:boundary, min=2}, min=2}";
772// ppt = new PoliqarpPlusTree("[base=foo]{2,}");
773// map = ppt.getRequestMap().get("query").toString();
774// assertEquals(occ13.replaceAll(" ", ""), map.replaceAll(" ", ""));
775//
776// // [base=foo]{2}
777// String occ14 = "{@type=korap:group, operation=operation:repetition, operands=[" +
778// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
779// "], boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}";
780// ppt = new PoliqarpPlusTree("[base=foo]{,2}");
781// map = ppt.getRequestMap().get("query").toString();
782// assertEquals(occ14.replaceAll(" ", ""), map.replaceAll(" ", ""));
783// }
784//
785// @Test
786// public void testTokenSequence() throws QueryException {
787// // [base=Mann][orth=Frau]
788// String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" +
789// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " +
790// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}" +
791// "]}";
792// assertTrue(equalsQueryContent(seq1, "[base=Mann][orth=Frau]"));
793//
794// // [base=Mann][orth=Frau][p=NN]
795// String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" +
796// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " +
797// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}, " +
798// "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}" +
799// "]}";
800// assertTrue(equalsQueryContent(seq2, "[base=Mann][orth=Frau][p=NN]"));
801// }
802//
803// @Test
804// public void testDisjSegments() throws QueryException {
805// // ([base=der]|[base=das])[base=Schild]
806// String disj1 =
807// "{@type=korap:group, operation=operation:sequence, operands=[" +
808// "{@type=korap:group, operation=operation:or, operands=[" +
809// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
810// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=das, match=match:eq}}" +
811// "]}," +
812// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Schild, match=match:eq}}" +
813// "]}";
814// ppt = new PoliqarpPlusTree("([base=der]|[base=das])[base=Schild]");
815// map = ppt.getRequestMap().get("query").toString();
816// assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", ""));
817//
818// // [base=Schild]([base=der]|[base=das])
819// String disj2 =
820// "{@type=korap:group, operation=operation:sequence, operands=[" +
821// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Schild, match=match:eq}}," +
822// "{@type=korap:group, operation=operation:or, operands=[" +
823// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
824// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=das, match=match:eq}}" +
825// "]}" +
826// "]}";
827// ppt = new PoliqarpPlusTree("[base=Schild]([base=der]|[base=das])");
828// map = ppt.getRequestMap().get("query").toString();
829// assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", ""));
830//
831// // "([orth=der][base=katze])|([orth=eine][base=baum])"
832// String disj3 =
833// "{@type=korap:group, operation=operation:or, operands=[" +
834// "{@type=korap:group, operation=operation:sequence, operands=[" +
835// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
836// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=katze, match=match:eq}}" +
837// "]}," +
838// "{@type=korap:group, operation=operation:sequence, operands=[" +
839// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=eine, match=match:eq}}," +
840// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=baum, match=match:eq}}" +
841// "]}" +
842// "]}";
843// ppt = new PoliqarpPlusTree("([orth=der][base=katze])|([orth=eine][base=baum])");
844// map = ppt.getRequestMap().get("query").toString();
845// assertEquals(disj3.replaceAll(" ", ""), map.replaceAll(" ", ""));
846//
847// // "[orth=der][base=katze]|[orth=eine][base=baum]"
848// String disj4 =
849// "{@type=korap:group, operation=operation:or, operands=[" +
850// "{@type=korap:group, operation=operation:sequence, operands=[" +
851// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
852// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=katze, match=match:eq}}" +
853// "]}," +
854// "{@type=korap:group, operation=operation:sequence, operands=[" +
855// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=eine, match=match:eq}}," +
856// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=baum, match=match:eq}}" +
857// "]}" +
858// "]}";
859// ppt = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=eine][base=baum]");
860// map = ppt.getRequestMap().get("query").toString();
861// assertEquals(disj4.replaceAll(" ", ""), map.replaceAll(" ", ""));
862//
863// PoliqarpPlusTree ppt1 = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=eine][base=baum]");
864// PoliqarpPlusTree ppt2 = new PoliqarpPlusTree("([orth=der][base=katze])|([orth=eine][base=baum])");
865// assertEquals(ppt1.getRequestMap().toString(), ppt2.getRequestMap().toString());
866//
867// // "[orth=der][base=katze]|[orth=der][base=hund]|[orth=der][base=baum]"
868// String disj5 =
869// "{@type=korap:group, operation=operation:or, operands=[" +
870// "{@type=korap:group, operation=operation:sequence, operands=[" +
871// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
872// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=katze, match=match:eq}}" +
873// "]}," +
874// "{@type=korap:group, operation=operation:sequence, operands=[" +
875// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
876// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=hund, match=match:eq}}" +
877// "]}," +
878// "{@type=korap:group, operation=operation:sequence, operands=[" +
879// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
880// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=baum, match=match:eq}}" +
881// "]}" +
882// "]}";
883// ppt = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=der][base=hund]|[orth=der][base=baum]");
884// map = ppt.getRequestMap().get("query").toString();
885// assertEquals(disj5.replaceAll(" ", ""), map.replaceAll(" ", ""));
886//
887// // [orth=der]([base=katze]|[base=hund]|[base=baum])
888// String disj6 =
889// "{@type=korap:group, operation=operation:sequence, operands=[" +
890// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
891// "{@type=korap:group, operation=operation:or, operands=[" +
892// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=katze, match=match:eq}}," +
893// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=hund, match=match:eq}}," +
894// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=baum, match=match:eq}}" +
895// "]}" +
896// "]}";
897// ppt = new PoliqarpPlusTree("[orth=der]([base=katze]|[base=hund]|[base=baum])");
898// map = ppt.getRequestMap().get("query").toString();
899// assertEquals(disj6.replaceAll(" ", ""), map.replaceAll(" ", ""));
900// }
901//
902// @Test
903// public void testTokenElemSequence() throws QueryException {
904// // [base=Mann]<vp>
905// String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" +
906// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " +
907// "{@type=korap:span, key=vp}" +
908// "]}";
909// assertTrue(equalsQueryContent(seq1, "[base=Mann]<vp>"));
910//
911// // <vp>[base=Mann]
912// String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" +
913// "{@type=korap:span, key=vp}, "+
914// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}} " +
915// "]}";
916// assertTrue(equalsQueryContent(seq2, "<vp>[base=Mann]"));
917//
918// // <vp>[base=Mann]<pp>
919// String seq3 = "{@type=korap:group, operation=operation:sequence, operands=[" +
920// "{@type=korap:span, key=vp}, "+
921// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " +
922// "{@type=korap:span, key=pp} "+
923// "]}";
924// assertTrue(equalsQueryContent(seq3, "<vp>[base=Mann]<pp>"));
925// }
926//
927// @Test
928// public void testElemSequence() throws QueryException {
929// // <np><vp>
930// String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" +
931// "{@type=korap:span, key=np}," +
932// "{@type=korap:span, key=vp}" +
933// "]}";
934// assertTrue(equalsQueryContent(seq1, "<np><vp>"));
935//
936// // <np><vp><pp>
937// String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" +
938// "{@type=korap:span, key=np}," +
939// "{@type=korap:span, key=vp}," +
940// "{@type=korap:span, key=pp}" +
941// "]}";
942// assertTrue(equalsQueryContent(seq2, "<np><vp><pp>"));
943// }
944//
945// @Test
946// public void testClasses() throws QueryException {
947// String query;
948// // {[base=Mann]}
949// String cls1 = "{@type=korap:group, operation=operation:class, class=0, classOut=0, operands=[" +
950// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
951// "]}";
952// ppt = new PoliqarpPlusTree("{[base=Mann]}");
953// map = ppt.getRequestMap().get("query").toString();
954// assertEquals(cls1.replaceAll(" ", ""), map.replaceAll(" ", ""));
955//
956// // {[base=Mann][orth=Frau]}
957// query = "{[base=Mann][orth=Frau]}";
958// String cls2 = "{@type=korap:group, operation=operation:class, class=0, classOut=0, operands=[" +
959// "{@type=korap:group, operation=operation:sequence, operands=[" +
960// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," +
961// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}" +
962// "]}" +
963// "]}";
964// ppt = new PoliqarpPlusTree(query);
965// map = ppt.getRequestMap().get("query").toString();
966// assertEquals(cls2.replaceAll(" ", ""), map.replaceAll(" ", ""));
967//
968// // [p=NN]{[base=Mann][orth=Frau]}
969// String cls3 = "{@type=korap:group, operation=operation:sequence, operands=[" +
970// "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}," +
971// "{@type=korap:group, operation=operation:class, class=0, classOut=0, operands=[" +
972// "{@type=korap:group, operation=operation:sequence, operands=[" +
973// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," +
974// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}" +
975// "]}" +
976// "]}" +
977// "]}";
978// ppt = new PoliqarpPlusTree("[p=NN]{[base=Mann][orth=Frau]}");
979// map = ppt.getRequestMap().get("query").toString();
980// assertEquals(cls3.replaceAll(" ", ""), map.replaceAll(" ", ""));
981//
982// // {[base=Mann][orth=Frau]}[p=NN]
983// String cls4 = "{@type=korap:group, operation=operation:sequence, operands=[" +
984// "{@type=korap:group, operation=operation:class, class=0, classOut=0, operands=[" +
985// "{@type=korap:group, operation=operation:sequence, operands=[" +
986// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," +
987// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}" +
988// "]}" +
989// "]}," +
990// "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}" +
991// "]}";
992// ppt = new PoliqarpPlusTree("{[base=Mann][orth=Frau]}[p=NN]");
993// map = ppt.getRequestMap().get("query").toString();
994// assertEquals(cls4.replaceAll(" ", ""), map.replaceAll(" ", ""));
995//
996// // {2:{1:[tt/p=ADJA]}[mate/p=NN]}"
997// String cls5 = "{@type=korap:group, operation=operation:class, class=2, classOut=2, operands=[" +
998// "{@type=korap:group, operation=operation:sequence, operands=[" +
999// "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
1000// "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=p, key=ADJA, match=match:eq}}" +
1001// "]}," +
1002// "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=p, key=NN, match=match:eq}}" +
1003// "]}" +
1004// "]}";
1005// ppt = new PoliqarpPlusTree("{2: {1:[tt/p=ADJA]}[mate/p=NN]}");
1006// map = ppt.getRequestMap().get("query").toString();
1007// assertEquals(cls5.replaceAll(" ", ""), map.replaceAll(" ", ""));
1008// }
1009//
1010// @Test
1011// public void testPositions() throws QueryException {
1012// // contains(<s>,<np>)
1013// String pos1 = "{@type=korap:group, operation=operation:position, frames=[frames:contains], operands=[" +
1014// "{@type=korap:span, key=s}," +
1015// "{@type=korap:span, key=np}" +
1016// "], frame=frame:contains}";
1017// assertTrue(equalsQueryContent(pos1, "contains(<s>,<np>)"));
1018//
1019// // contains(<s>,[base=Mann])
1020// String pos2 = "{@type=korap:group, operation=operation:position, frames=[frames:contains], operands=[" +
1021// "{@type=korap:span, key=s}," +
1022// "{@type=korap:token, wrap= {@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
1023// "], frame=frame:contains}";
1024// assertTrue(equalsQueryContent(pos2, "contains(<s>,[base=Mann])"));
1025//
1026// // contains(<s>,[orth=der][orth=Mann])
1027// String pos3 = "{@type=korap:group, operation=operation:position, frames=[frames:contains], operands=[" +
1028// "{@type=korap:span, key=s}," +
1029// "{@type=korap:group, operation=operation:sequence, operands=[" +
1030// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
1031// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" +
1032// "]}" +
1033// "], frame=frame:contains}";
1034// ppt = new PoliqarpPlusTree("contains(<s>,[orth=der][orth=Mann])");
1035// map = ppt.getRequestMap().get("query").toString();
1036// assertEquals(pos3.replaceAll(" ", ""), map.replaceAll(" ", ""));
1037//
1038// // [base=Auto]contains(<s>,[base=Mann])
1039// String pos4 =
1040// "{@type=korap:group, operation=operation:sequence, operands=[" +
1041// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Auto, match=match:eq}}," +
1042// "{@type=korap:group, operation=operation:position, frames=[frames:contains], operands=[" +
1043// "{@type=korap:span, key=s}," +
1044// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
1045// "], frame=frame:contains}" +
1046// "]}";
1047// ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[base=Mann])");
1048// map = ppt.getRequestMap().get("query").toString();
1049// assertEquals(pos4.replaceAll(" ", ""), map.replaceAll(" ", ""));
1050//
1051// // contains(<s>,[pos=N]*)
1052// String pos5 =
1053// "{@type=korap:group, operation=operation:position, frames=[frames:contains], operands=[" +
1054// "{@type=korap:span, key=s}," +
1055// "{@type=korap:group, operation=operation:repetition, " +
1056// "operands=[{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}" +
1057// "], boundary={@type=korap:boundary, min=0}, min=0" +
1058// "}" +
1059// "], frame=frame:contains}";
1060// ppt = new PoliqarpPlusTree("contains(<s>,[pos=N]*)");
1061// map = ppt.getRequestMap().get("query").toString();
1062// assertEquals(pos5.replaceAll(" ", ""), map.replaceAll(" ", ""));
1063//
1064// // [base=Auto]contains(<s>,[pos=N]*)
1065// String pos6 =
1066// "{@type=korap:group, operation=operation:sequence, operands=[" +
1067// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Auto, match=match:eq}}," +
1068// "{@type=korap:group, operation=operation:position, frames=[frames:contains], operands=[" +
1069// "{@type=korap:span, key=s}," +
1070// "{@type=korap:group, operation=operation:repetition, " +
1071// "operands=[{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}" +
1072// "], boundary={@type=korap:boundary, min=0}, min=0" +
1073// "}" +
1074// "], frame=frame:contains}" +
1075// "]}";
1076// ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[pos=N]*)");
1077// map = ppt.getRequestMap().get("query").toString();
1078// assertEquals(pos6.replaceAll(" ", ""), map.replaceAll(" ", ""));
1079// }
1080//
1081// @Test
1082// public void testNestedPositions() throws QueryException {
1083// // contains(<s>,startswith(<np>,[orth=Der]))
1084// String npos1 =
1085// "{@type=korap:group, operation=operation:position, frames=[frames:contains], operands=[" +
1086// "{@type=korap:span, key=s}," +
1087// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1088// "{@type=korap:span, key=np}," +
1089// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}" +
1090// "], frame=frame:startswith}" +
1091// "], frame=frame:contains}";
1092// ppt = new PoliqarpPlusTree("contains(<s>, startswith(<np>,[orth=Der]))");
1093// map = ppt.getRequestMap().get("query").toString();
1094// assertEquals(npos1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1095// }
1096//
1097// @Test
1098// public void testFocusSplit() throws QueryException {
1099// // focus([orth=Der]{[orth=Mann]})
1100// String shr1 =
1101// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
1102// "{@type=korap:group, operation=operation:sequence, operands=[" +
1103// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}," +
1104// "{@type=korap:group, operation=operation:class, class=0, classOut=0, operands=[" +
1105// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" +
1106// "]}" +
1107// "]}" +
1108// "]}";
1109// ppt = new PoliqarpPlusTree("focus([orth=Der]{[orth=Mann]})");
1110// map = ppt.getRequestMap().get("query").toString();
1111// assertEquals(shr1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1112//
1113// // focus([orth=Der]{[orth=Mann][orth=geht]})
1114// String shr2 =
1115// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
1116// "{@type=korap:group, operation=operation:sequence, operands=[" +
1117// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}," +
1118// "{@type=korap:group, operation=operation:class, class=0, classOut=0, operands=[" +
1119// "{@type=korap:group, operation=operation:sequence, operands=[" +
1120// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}," +
1121// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=geht, match=match:eq}}" +
1122// "]}" +
1123// "]}" +
1124// "]}" +
1125// "]}";
1126// ppt = new PoliqarpPlusTree("focus([orth=Der]{[orth=Mann][orth=geht]})");
1127// map = ppt.getRequestMap().get("query").toString();
1128// assertEquals(shr2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1129//
1130// // focus(1:[orth=Der]{1:[orth=Mann][orth=geht]})
1131// String shr3 =
1132// "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
1133// "{@type=korap:group, operation=operation:sequence, operands=[" +
1134// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}," +
1135// "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
1136// "{@type=korap:group, operation=operation:sequence, operands=[" +
1137// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}," +
1138// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=geht, match=match:eq}}" +
1139// "]}" +
1140// "]}" +
1141// "]}" +
1142// "]}";
1143// ppt = new PoliqarpPlusTree("focus(1:[orth=Der]{1:[orth=Mann][orth=geht]})");
1144// map = ppt.getRequestMap().get("query").toString();
1145// assertEquals(shr3.replaceAll(" ", ""), map.replaceAll(" ", ""));
1146//
1147// // focus(1:startswith(<s>,{1:<np>}))
1148// String shr4 =
1149// "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
1150// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1151// "{@type=korap:span, key=s}," +
1152// "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
1153// "{@type=korap:span, key=np}" +
1154// "]}" +
1155// "], frame=frame:startswith}" +
1156// "]}";
1157// ppt = new PoliqarpPlusTree("focus(1:startswith(<s>,{1:<np>}))");
1158// map = ppt.getRequestMap().get("query").toString();
1159// assertEquals(shr4.replaceAll(" ", ""), map.replaceAll(" ", ""));
1160//
1161// // focus(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}}))
1162// String shr5 =
1163// "{@type=korap:reference, operation=operation:focus, classRef=[3], operands=[" +
1164// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1165// "{@type=korap:span, key=s}," +
1166// "{@type=korap:group, operation=operation:class, class=3, classOut=3, operands=[" +
1167// "{@type=korap:group, operation=operation:sequence, operands=[" +
1168// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
1169// "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
1170// "{@type=korap:group, operation=operation:sequence, operands=[" +
1171// "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=p, key=ADJA, match=match:eq}}," +
1172// "{@type=korap:group, operation=operation:class, class=2, classOut=2, operands=[" +
1173// "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=p, key=NN, match=match:eq}}" +
1174// "]}" +
1175// "]}" +
1176// "]}" +
1177// "]}" +
1178// "]}" +
1179// "], frame=frame:startswith}" +
1180// "]}";
1181// ppt = new PoliqarpPlusTree("focus(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
1182// map = ppt.getRequestMap().get("query").toString();
1183// assertEquals(shr5.replaceAll(" ", ""), map.replaceAll(" ", ""));
1184//
1185// // split(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}}))
1186// String shr6 =
1187// "{@type=korap:reference, operation=operation:split, classRef=[3], operands=[" +
1188// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1189// "{@type=korap:span, key=s}," +
1190// "{@type=korap:group, operation=operation:class, class=3, classOut=3, operands=[" +
1191// "{@type=korap:group, operation=operation:sequence, operands=[" +
1192// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
1193// "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
1194// "{@type=korap:group, operation=operation:sequence, operands=[" +
1195// "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=p, key=ADJA, match=match:eq}}," +
1196// "{@type=korap:group, operation=operation:class, class=2, classOut=2, operands=[" +
1197// "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=p, key=NN, match=match:eq}}" +
1198// "]}" +
1199// "]}" +
1200// "]}" +
1201// "]}" +
1202// "]}" +
1203// "], frame=frame:startswith}" +
1204// "]}";
1205// ppt = new PoliqarpPlusTree("split(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
1206// map = ppt.getRequestMap().get("query").toString();
1207// assertEquals(shr6.replaceAll(" ", ""), map.replaceAll(" ", ""));
1208//
1209// // split(2|3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}}))
1210// String shr7 =
1211// "{@type=korap:reference, operation=operation:split, classRef=[2, 3], classRefOp=classRefOp:intersection, operands=[" +
1212// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1213// "{@type=korap:span, key=s}," +
1214// "{@type=korap:group, operation=operation:class, class=3, classOut=3, operands=[" +
1215// "{@type=korap:group, operation=operation:sequence, operands=[" +
1216// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
1217// "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
1218// "{@type=korap:group, operation=operation:sequence, operands=[" +
1219// "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=p, key=ADJA, match=match:eq}}," +
1220// "{@type=korap:group, operation=operation:class, class=2, classOut=2, operands=[" +
1221// "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=p, key=NN, match=match:eq}}" +
1222// "]}" +
1223// "]}" +
1224// "]}" +
1225// "]}" +
1226// "]}" +
1227// "], frame=frame:startswith}" +
1228// "]}";
1229// ppt = new PoliqarpPlusTree("split(2|3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
1230// map = ppt.getRequestMap().get("query").toString();
1231// assertEquals(shr7.replaceAll(" ", ""), map.replaceAll(" ", ""));
1232//
1233//
1234// String shr8 =
1235// "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
1236// "{@type=korap:group, operation=operation:sequence, operands=[" +
1237// "{@type=korap:group, operation=operation:class, class=0, classOut=0, operands=[" +
1238// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}" +
1239// "]}," +
1240// "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
1241// "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=ADJA, match=match:eq}}" +
1242// "]}" +
1243// "]}" +
1244// "]}";
1245// ppt = new PoliqarpPlusTree("focus(1:{[base=der]}{1:[pos=ADJA]})");
1246// map = ppt.getRequestMap().get("query").toString();
1247// assertEquals(shr8.replaceAll(" ", ""), map.replaceAll(" ", ""));
1248//
1249// }
1250//
1251// @Test
1252// public void testSubspan() throws QueryException {
1253// query = "submatch(1,:<s>)";
1254// expected =
1255// "{@type=korap:reference, operation=operation:focus, operands=[" +
1256// "{@type=korap:span, key=s}" +
1257// "], spanRef=[1]" +
1258// "}";
1259// ppt = new PoliqarpPlusTree(query);
1260// map = ppt.getRequestMap().get("query").toString();
1261// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1262//
1263// query = "submatch(1,4:<s>)";
1264// expected =
1265// "{@type=korap:reference, operation=operation:focus, operands=[" +
1266// "{@type=korap:span, key=s}" +
1267// "], spanRef=[1,4]" +
1268// "}";
1269// ppt = new PoliqarpPlusTree(query);
1270// map = ppt.getRequestMap().get("query").toString();
1271// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1272//
1273// query = "submatch(1,4:contains(<s>,[base=Haus]))";
1274// expected =
1275// "{@type=korap:reference, operation=operation:focus, operands=[" +
1276// "{@type=korap:group, operation=operation:position, frames=[frames:contains], operands=[" +
1277// "{@type=korap:span, key=s}," +
1278// "{@type=korap:token, wrap= {@type=korap:term, layer=lemma, key=Haus, match=match:eq}}" +
1279// "], frame=frame:contains}" +
1280// "], spanRef=[1,4]" +
1281// "}";
1282// ppt = new PoliqarpPlusTree(query);
1283// map = ppt.getRequestMap().get("query").toString();
1284// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1285// }
1286//
1287// @Test
1288// public void testRelations() throws QueryException {
1289// query = "relatesTo(<s>,<np>)";
1290// expected =
1291// "{@type=korap:group, operation=operation:relation, operands=[" +
1292// "{@type=korap:span, key=s}," +
1293// "{@type=korap:span, key=np}" +
1294// "], relation={@type=korap:relation}" +
1295// "}";
1296// ppt = new PoliqarpPlusTree(query);
1297// map = ppt.getRequestMap().get("query").toString();
1298// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1299//
1300// query = "relatesTo([base=Baum],<np>)";
1301// expected =
1302// "{@type=korap:group, operation=operation:relation, operands=[" +
1303// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}," +
1304// "{@type=korap:span, key=np}" +
1305// "], relation={@type=korap:relation}" +
1306// "}";
1307// ppt = new PoliqarpPlusTree(query);
1308// map = ppt.getRequestMap().get("query").toString();
1309// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1310//
1311// query = "dominates(<np>,[base=Baum])";
1312// expected =
1313// "{@type=korap:group, operation=operation:relation, operands=[" +
1314// "{@type=korap:span, key=np}," +
1315// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" +
1316// "], relation={@type=korap:relation, layer=c}" +
1317// "}";
1318// ppt = new PoliqarpPlusTree(query);
1319// map = ppt.getRequestMap().get("query").toString();
1320// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1321//
1322// query = "dominates(cnx/c:<np>,[base=Baum])";
1323// expected =
1324// "{@type=korap:group, operation=operation:relation, operands=[" +
1325// "{@type=korap:span, key=np}," +
1326// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" +
1327// "], relation={@type=korap:relation, layer=c, foundry=cnx}" +
1328// "}";
1329// ppt = new PoliqarpPlusTree(query);
1330// map = ppt.getRequestMap().get("query").toString();
1331// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1332//
1333// query = "dominates(cnx/c*:<np>,[base=Baum])";
1334// expected =
1335// "{@type=korap:group, operation=operation:relation, operands=[" +
1336// "{@type=korap:span, key=np}," +
1337// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" +
1338// "], relation={@type=korap:relation, layer=c, foundry=cnx, boundary={@type=korap:boundary, min=0}}" +
1339// "}";
1340// ppt = new PoliqarpPlusTree(query);
1341// map = ppt.getRequestMap().get("query").toString();
1342// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1343//
1344// query = "dominates(cnx/c{1,5}:<np>,[base=Baum])";
1345// expected =
1346// "{@type=korap:group, operation=operation:relation, operands=[" +
1347// "{@type=korap:span, key=np}," +
1348// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" +
1349// "], relation={@type=korap:relation, layer=c, foundry=cnx, boundary={@type=korap:boundary, min=1, max=5}}" +
1350// "}";
1351// ppt = new PoliqarpPlusTree(query);
1352// map = ppt.getRequestMap().get("query").toString();
1353// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1354//
1355// query = "relatesTo(mate/d=HEAD:<np>,[base=Baum])";
1356// expected =
1357// "{@type=korap:group, operation=operation:relation, operands=[" +
1358// "{@type=korap:span, key=np}," +
1359// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" +
1360// "], relation={@type=korap:relation, foundry=mate, layer=d, key=HEAD}" +
1361// "}";
1362// ppt = new PoliqarpPlusTree(query);
1363// map = ppt.getRequestMap().get("query").toString();
1364// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1365//
1366// }
1367//
1368//
1369//
1370// @Test
1371// public void testFoundries() throws QueryException {
1372// // [tt/base=Mann]
1373// String layer1 = "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=lemma, key=Mann, match=match:eq}}";
1374// ppt = new PoliqarpPlusTree("[tt/base=Mann]");
1375// map = ppt.getRequestMap().get("query").toString();
1376// assertEquals(layer1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1377//
1378// }
1379//
1380// @Test
1381// public void testAlign() throws QueryException {
1382// // [orth=der]^[orth=Mann]
1383// query = "[orth=der]^[orth=Mann]";
1384// expected =
1385// "{@type=korap:group, operation=operation:sequence, operands=[" +
1386// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
1387// "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
1388// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" +
1389// "]}" +
1390// "]}";
1391// metaExpected =
1392// "{alignment=1025}";
1393// ppt = new PoliqarpPlusTree(query);
1394// map = ppt.getRequestMap().get("query").toString();
1395// metaMap = ppt.getRequestMap().get("meta").toString();
1396// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1397// assertEquals(metaExpected.replaceAll(" ", ""), metaMap.replaceAll(" ", ""));
1398//
1399// // [orth=der]^[orth=große][orth=Mann]
1400// query = "[orth=der]^[orth=große][orth=Mann]";
1401// String expected =
1402// "{@type=korap:group, operation=operation:sequence, operands=[" +
1403// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
1404// "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
1405// "{@type=korap:group, operation=operation:sequence, operands=[" +
1406// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=große, match=match:eq}}," +
1407// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" +
1408// "]}" +
1409// "]}" +
1410// "]}";
1411// metaExpected =
1412// "{alignment=1025}";
1413// ppt = new PoliqarpPlusTree(query);
1414// map = ppt.getRequestMap().get("query").toString();
1415// metaMap = ppt.getRequestMap().get("meta").toString();
1416// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1417// assertEquals(metaExpected.replaceAll(" ", ""), metaMap.replaceAll(" ", ""));
1418//
1419// query = "([base=a]^[base=b])|[base=c]";
1420// expected =
1421// "{@type=korap:group, operation=operation:or, operands=[" +
1422// "{@type=korap:group, operation=operation:sequence, operands=[" +
1423// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=a, match=match:eq}}," +
1424// "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
1425// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=b, match=match:eq}}" +
1426// "]}" +
1427// "]}," +
1428// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=c, match=match:eq}}" +
1429// "]}";
1430// metaExpected =
1431// "{alignment=1025}";
1432// ppt = new PoliqarpPlusTree(query);
1433// map = ppt.getRequestMap().get("query").toString();
1434// metaMap = ppt.getRequestMap().get("meta").toString();
1435// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1436// assertEquals(metaExpected.replaceAll(" ", ""), metaMap.replaceAll(" ", ""));
1437//
1438// query = "([base=a]^[base=b][base=c])|[base=d]";
1439// expected =
1440// "{@type=korap:group, operation=operation:or, operands=[" +
1441// "{@type=korap:group, operation=operation:sequence, operands=[" +
1442// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=a, match=match:eq}}," +
1443// "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
1444// "{@type=korap:group, operation=operation:sequence, operands=[" +
1445// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=b, match=match:eq}}," +
1446// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=c, match=match:eq}}" +
1447// "]}" +
1448// "]}" +
1449// "]}," +
1450// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=d, match=match:eq}}" +
1451// "]}";
1452// metaExpected =
1453// "{alignment=1025}";
1454// ppt = new PoliqarpPlusTree(query);
1455// map = ppt.getRequestMap().get("query").toString();
1456// metaMap = ppt.getRequestMap().get("meta").toString();
1457// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1458// assertEquals(metaExpected.replaceAll(" ", ""), metaMap.replaceAll(" ", ""));
1459//
1460// query = "([base=a]^[base=b]^[base=c])|[base=d]";
1461// expected =
1462// "{@type=korap:group, operation=operation:or, operands=[" +
1463// "{@type=korap:group, operation=operation:sequence, operands=[" +
1464// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=a, match=match:eq}}," +
1465// "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
1466// "{@type=korap:group, operation=operation:sequence, operands=[" +
1467// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=b, match=match:eq}}," +
1468// "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
1469// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=c, match=match:eq}}" +
1470// "]}" +
1471// "]}" +
1472// "]}" +
1473// "]}," +
1474// "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=d, match=match:eq}}" +
1475// "]}";
1476// metaExpected =
1477// "{alignment=[1025,1026]}";
1478// ppt = new PoliqarpPlusTree(query);
1479// map = ppt.getRequestMap().get("query").toString();
1480// metaMap = ppt.getRequestMap().get("meta").toString();
1481// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1482// assertEquals(metaExpected.replaceAll(" ", ""), metaMap.replaceAll(" ", ""));
1483//
1484//
1485// }
1486//
1487// @Test
1488// public void testSimpleQueries() throws QueryException {
1489// // Baum
1490// String simple1 =
1491// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}";
1492// ppt = new PoliqarpPlusTree("Baum");
1493// map = ppt.getRequestMap().get("query").toString();
1494// assertEquals(simple1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1495//
1496// // Baum/i
1497// String simple1b =
1498// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq, caseInsensitive=true}}";
1499// ppt = new PoliqarpPlusTree("Baum/i");
1500// map = ppt.getRequestMap().get("query").toString();
1501// assertEquals(simple1b.replaceAll(" ", ""), map.replaceAll(" ", ""));
1502//
1503// // Der Baum
1504// String simple2 =
1505// "{@type=korap:group, operation=operation:sequence, operands=[" +
1506// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " +
1507// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}" +
1508// "]}";
1509// ppt = new PoliqarpPlusTree("Der Baum");
1510// map = ppt.getRequestMap().get("query").toString();
1511// assertEquals(simple2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1512//
1513// // Der Baum/i
1514// String simple2b =
1515// "{@type=korap:group, operation=operation:sequence, operands=[" +
1516// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " +
1517// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq, caseInsensitive=true}}" +
1518// "]}";
1519// ppt = new PoliqarpPlusTree("Der Baum/i");
1520// map = ppt.getRequestMap().get("query").toString();
1521// assertEquals(simple2b.replaceAll(" ", ""), map.replaceAll(" ", ""));
1522//
1523// // Der große Baum
1524// String simple3 =
1525// "{@type=korap:group, operation=operation:sequence, operands=[" +
1526// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " +
1527// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=große, match=match:eq}}, " +
1528// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}" +
1529// "]}";
1530// ppt = new PoliqarpPlusTree("Der große Baum");
1531// map = ppt.getRequestMap().get("query").toString();
1532// assertEquals(simple3.replaceAll(" ", ""), map.replaceAll(" ", ""));
1533//
1534// // Baum | Stein
1535// String simple4 =
1536// "{@type=korap:group, operation=operation:or, operands=[" +
1537// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}, " +
1538// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Stein, match=match:eq}}" +
1539// "]}";
1540// ppt = new PoliqarpPlusTree("Baum | Stein");
1541// map = ppt.getRequestMap().get("query").toString();
1542// assertEquals(simple4.replaceAll(" ", ""), map.replaceAll(" ", ""));
1543//
1544// // Baum | Stein Haus
1545// String query = "(Baum | Stein) Haus";
1546// String simple5 =
1547// "{@type=korap:group, operation=operation:sequence, operands=[" +
1548// "{@type=korap:group, operation=operation:or, operands=[" +
1549// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}, " +
1550// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Stein, match=match:eq}}" +
1551// "]}," +
1552// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Haus, match=match:eq}} " +
1553// "]}";
1554// ppt = new PoliqarpPlusTree(query);
1555// map = ppt.getRequestMap().get("query").toString();
1556// assertEquals(simple5.replaceAll(" ", ""), map.replaceAll(" ", ""));
1557// }
1558}