blob: 71aef54158dbff44448c24f591bf33240fd90a16 [file] [log] [blame]
Joachim Bingel53333e62013-12-09 19:25:52 +00001import static org.junit.Assert.*;
2
3import org.junit.Test;
4
5import de.ids_mannheim.korap.query.serialize.PoliqarpPlusTree;
6
7public class PoliqarpPlusTreeTest {
8
9 PoliqarpPlusTree ppt;
10 String map;
11
12 private boolean equalsContent(String str, Object map) {
13 str = str.replaceAll(" ", "");
14 String mapStr = map.toString().replaceAll(" ", "");
15 return str.equals(mapStr);
16 }
17
18 private boolean equalsQueryContent(String res, String query) {
19 res = res.replaceAll(" ", "");
20 ppt = new PoliqarpPlusTree(query);
21 String queryMap = ppt.getRequestMap().get("query").toString().replaceAll(" ", "");
22 return res.equals(queryMap);
23 }
24
25 @Test
26 public void testContext() {
27 String contextString = "{korap=http://korap.ids-mannheim.de/ns/query, @language=de, operands={@id=korap:operands, @container=@list}, relation={@id=korap:relation, @type=korap:relation#types}, class={@id=korap:class, @type=xsd:integer}, query=korap:query, filter=korap:filter, meta=korap:meta}";
28 ppt = new PoliqarpPlusTree("[base=test]");
29 assertTrue(equalsContent(contextString, ppt.getRequestMap().get("@context")));
30 }
31
32 @Test
33 public void testSingleTokens() {
34 // [base=Mann]
35 String token1 = "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}";
36 assertTrue(equalsQueryContent(token1, "[base=Mann]"));
37
38 // [orth!=Frau]
39 String token2 = "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation=!=}}";
40 assertTrue(equalsQueryContent(token2, "[orth!=Frau]"));
41
42 // [!p=NN]
43 String token3 = "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation=!=}}";
44 assertTrue(equalsQueryContent(token3, "[!p=NN]"));
45
46 // [!p!=NN]
47 String token4 = "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}";
48 assertTrue(equalsQueryContent(token4, "[!p!=NN]"));
49 }
50
51 @Test
52 public void testElements() {
53 // <s>
54 String elem1 = "{@type=korap:element, @value=s}";
55 assertTrue(equalsQueryContent(elem1, "<s>"));
56
57 // <vp>
58 String elem2 = "{@type=korap:element, @value=vp}";
59 assertTrue(equalsQueryContent(elem2, "<vp>"));
60 }
61
62 @Test
63 public void testCoordinatedFields() {
64 // [base=Mann&(cas=N|cas=A)]
65 String cof1 =
66 "{@type=korap:token, @value=" +
67 "{@type=korap:group, operands=[" +
68 "{@type=korap:term, @value=base:Mann, relation==}," +
69 "{@type=korap:group, operands=[" +
70 "{@type=korap:term, @value=cas:N, relation==}," +
71 "{@type=korap:term, @value=cas:A, relation==}" +
72 "], relation=or}" +
73 "], relation=and}" +
74 "}";
75 ppt = new PoliqarpPlusTree("[base=Mann&(cas=N|cas=A)]");
76 map = ppt.getRequestMap().get("query").toString();
77 assertEquals(cof1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Nils Diewald7d486c22013-12-13 16:32:18 +000078
79
80 assertEquals(
81 new PoliqarpPlusTree(" [ base=Mann & ( cas=N | cas=A)] ").getRequestMap().get("query").toString(),
82 new PoliqarpPlusTree("[base=Mann &(cas=N|cas=A)]").getRequestMap().get("query").toString()
83 );
Joachim Bingel53333e62013-12-09 19:25:52 +000084 }
85
86 @Test
87 public void testOccurrence() {
Joachim Bingelcd9ed332013-12-09 21:01:35 +000088 // [base=foo]*
89 String occ1 = "{@type=korap:group, operands=[" +
90 "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
91 "], relation=repetition, quantifier=* }";
92 ppt = new PoliqarpPlusTree("[base=foo]*");
93 map = ppt.getRequestMap().get("query").toString();
94 assertEquals(occ1.replaceAll(" ", ""), map.replaceAll(" ", ""));
95
96 // [base=foo]*[base=bar]
97 String occ2 =
98 "{@type=korap:sequence, operands=[" +
99 "{@type=korap:group, operands=[" +
100 "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
101 "], relation=repetition, quantifier=* }," +
102 "{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}" +
103 "]}";
104 ppt = new PoliqarpPlusTree("[base=foo]*[base=bar]");
105 map = ppt.getRequestMap().get("query").toString();
106 assertEquals(occ2.replaceAll(" ", ""), map.replaceAll(" ", ""));
107
108 // [base=bar][base=foo]*
109 String occ3 =
110 "{@type=korap:sequence, operands=[" +
111 "{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," +
112 "{@type=korap:group, operands=[" +
113 "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
114 "], relation=repetition, quantifier=* }" +
115 "]}";
116 ppt = new PoliqarpPlusTree("[base=bar][base=foo]*");
117 map = ppt.getRequestMap().get("query").toString();
118 assertEquals(occ3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb4da7022013-12-09 23:17:24 +0000119
120 // ([base=bar][base=foo])*
121 String occ4 =
122 "{@type=korap:group, operands=[" +
123 "{@type=korap:sequence, operands=[" +
124 "{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," +
125 "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
126 "]}" +
127 "], relation=repetition, quantifier=* }" ;
128 ppt = new PoliqarpPlusTree("([base=bar][base=foo])*");
129 map = ppt.getRequestMap().get("query").toString();
130 assertEquals(occ4.replaceAll(" ", ""), map.replaceAll(" ", ""));
131
132 // <s>([base=bar][base=foo])*
133 String occ5 =
134 "{@type=korap:sequence, operands=[" +
135 "{@type=korap:element, @value=s}," +
136 "{@type=korap:group, operands=[" +
137 "{@type=korap:sequence, operands=[" +
138 "{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," +
139 "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
140 "]}" +
141 "], relation=repetition, quantifier=* }" +
142 "]}" ;
143 ppt = new PoliqarpPlusTree("<s>([base=bar][base=foo])*");
144 map = ppt.getRequestMap().get("query").toString();
145 assertEquals(occ5.replaceAll(" ", ""), map.replaceAll(" ", ""));
146
147 // <s><np>([base=bar][base=foo])*
Joachim Bingelb4da7022013-12-09 23:17:24 +0000148 String occ6 =
149 "{@type=korap:sequence, operands=[" +
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000150 "{@type=korap:element, @value=s}," +
151 "{@type=korap:element, @value=np}," +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000152 "{@type=korap:group, operands=[" +
153 "{@type=korap:sequence, operands=[" +
154 "{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," +
155 "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
156 "]}" +
157 "], relation=repetition, quantifier=* }" +
158 "]}" ;
159 ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*");
160 map = ppt.getRequestMap().get("query").toString();
161 assertEquals(occ6.replaceAll(" ", ""), map.replaceAll(" ", ""));
162
163 // <s><np>([base=bar][base=foo])*[p=NN]
164 // comment: embedded sequence shouldn't really be here, but does not really hurt, either. (?)
165 // really hard to get this behaviour out of the PQPlus grammar...
166 String occ7 =
167 "{@type=korap:sequence, operands=[" +
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000168 "{@type=korap:element, @value=s}," +
169 "{@type=korap:element, @value=np}," +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000170 "{@type=korap:group, operands=[" +
171 "{@type=korap:sequence, operands=[" +
172 "{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," +
173 "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
174 "]}" +
175 "], relation=repetition, quantifier=* }," +
176 "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}" +
177 "]}" ;
178 ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*[p=NN]");
179 map = ppt.getRequestMap().get("query").toString();
180 assertEquals(occ7.replaceAll(" ", ""), map.replaceAll(" ", ""));
181
182 // ([base=bar][base=foo])*[p=NN]
Joachim Bingelb4da7022013-12-09 23:17:24 +0000183 String occ8 =
184 "{@type=korap:sequence, operands=[" +
185 "{@type=korap:group, operands=[" +
186 "{@type=korap:sequence, operands=[" +
187 "{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," +
188 "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
189 "]}" +
190 "], relation=repetition, quantifier=* }," +
191 "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}" +
192 "]}" ;
193 ppt = new PoliqarpPlusTree("([base=bar][base=foo])*[p=NN]");
194 map = ppt.getRequestMap().get("query").toString();
195 assertEquals(occ8.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000196 }
197
198 @Test
199 public void testTokenSequence() {
200 // [base=Mann][orth=Frau]
201 String seq1 = "{@type=korap:sequence, operands=[" +
202 "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}, " +
203 "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}" +
204 "]}";
205 assertTrue(equalsQueryContent(seq1, "[base=Mann][orth=Frau]"));
206
207 // [base=Mann][orth=Frau][p=NN]
208 String seq2 = "{@type=korap:sequence, operands=[" +
209 "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}, " +
210 "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}, " +
211 "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}" +
212 "]}";
213 assertTrue(equalsQueryContent(seq2, "[base=Mann][orth=Frau][p=NN]"));
214 }
215
216 @Test
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000217 public void testDisjSegments() {
218 // ([base=der]|[base=das])[base=Schild]
219 String disj1 =
220 "{@type=korap:sequence, operands=[" +
221 "{@type=korap:group, relation=or, operands=[" +
222 "{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," +
223 "{@type=korap:token, @value={@type=korap:term, @value=base:das, relation==}}" +
224 "]}," +
225 "{@type=korap:token, @value={@type=korap:term, @value=base:Schild, relation==}}" +
226 "]}";
227 ppt = new PoliqarpPlusTree("([base=der]|[base=das])[base=Schild]");
228 map = ppt.getRequestMap().get("query").toString();
229 assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", ""));
230
231 // [base=Schild]([base=der]|[base=das])
232 String disj2 =
233 "{@type=korap:sequence, operands=[" +
234 "{@type=korap:token, @value={@type=korap:term, @value=base:Schild, relation==}}," +
235 "{@type=korap:group, relation=or, operands=[" +
236 "{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," +
237 "{@type=korap:token, @value={@type=korap:term, @value=base:das, relation==}}" +
238 "]}" +
239 "]}";
240 ppt = new PoliqarpPlusTree("[base=Schild]([base=der]|[base=das])");
241 map = ppt.getRequestMap().get("query").toString();
242 assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", ""));
243 }
244
245 @Test
Joachim Bingel53333e62013-12-09 19:25:52 +0000246 public void testTokenElemSequence() {
247 // [base=Mann]<vp>
248 String seq1 = "{@type=korap:sequence, operands=[" +
249 "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}, " +
250 "{@type=korap:element, @value=vp}" +
251 "]}";
252 assertTrue(equalsQueryContent(seq1, "[base=Mann]<vp>"));
253
254 // <vp>[base=Mann]
255 String seq2 = "{@type=korap:sequence, operands=[" +
256 "{@type=korap:element, @value=vp}, "+
257 "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}} " +
258 "]}";
259 assertTrue(equalsQueryContent(seq2, "<vp>[base=Mann]"));
260
261 // <vp>[base=Mann]<pp>
262 String seq3 = "{@type=korap:sequence, operands=[" +
263 "{@type=korap:element, @value=vp}, "+
264 "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}, " +
265 "{@type=korap:element, @value=pp} "+
266 "]}";
267 assertTrue(equalsQueryContent(seq3, "<vp>[base=Mann]<pp>"));
268 }
269
270 @Test
271 public void testElemSequence() {
272 // <np><vp>
273 String seq1 = "{@type=korap:sequence, operands=[" +
274 "{@type=korap:element, @value=np}," +
275 "{@type=korap:element, @value=vp}" +
276 "]}";
277 assertTrue(equalsQueryContent(seq1, "<np><vp>"));
278
279 // <np><vp><pp>
280 String seq2 = "{@type=korap:sequence, operands=[" +
281 "{@type=korap:element, @value=np}," +
282 "{@type=korap:element, @value=vp}," +
283 "{@type=korap:element, @value=pp}" +
284 "]}";
285 assertTrue(equalsQueryContent(seq2, "<np><vp><pp>"));
286 }
287
288 @Test
289 public void testClasses() {
290 // {[base=Mann]}
291 String cls1 = "{@type=korap:group, class=0, operands=[" +
292 "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}" +
293 "]}";
294 assertTrue(equalsQueryContent(cls1, "{[base=Mann]}"));
295
296 // {[base=Mann][orth=Frau]}
297 String cls2 = "{@type=korap:group, class=0, operands=[" +
298 "{@type=korap:sequence, operands=[" +
299 "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}," +
300 "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}" +
301 "]}" +
302 "]}";
303 assertTrue(equalsQueryContent(cls2, "{[base=Mann][orth=Frau]}"));
304
305 // [p=NN]{[base=Mann][orth=Frau]}
306 String cls3 = "{@type=korap:sequence, operands=[" +
307 "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}," +
308 "{@type=korap:group, class=0, operands=[" +
309 "{@type=korap:sequence, operands=[" +
310 "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}," +
311 "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}" +
312 "]}" +
313 "]}" +
314 "]}";
315 assertTrue(equalsQueryContent(cls3, "[p=NN]{[base=Mann][orth=Frau]}"));
316
317 // {[base=Mann][orth=Frau]}[p=NN]
318 String cls4 = "{@type=korap:sequence, operands=[" +
319 "{@type=korap:group, class=0, operands=[" +
320 "{@type=korap:sequence, operands=[" +
321 "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}," +
322 "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}" +
323 "]}" +
324 "]}," +
325 "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}" +
326 "]}";
327 assertTrue(equalsQueryContent(cls4, "{[base=Mann][orth=Frau]}[p=NN]"));
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000328
329 // {2:{1:[tt/p=ADJA]}[mate/p=NN]}"
330 String cls5 = "{@type=korap:group, class=2, operands=[" +
331 "{@type=korap:sequence, operands=[" +
332 "{@type=korap:group, class=1, operands=[" +
333 "{@type=korap:token, @value={@type=korap:term, @value=tt/p:ADJA, relation==}}" +
334 "]}," +
335 "{@type=korap:token, @value={@type=korap:term, @value=mate/p:NN, relation==}}" +
336 "]}" +
337 "]}";
338 ppt = new PoliqarpPlusTree("{2: {1:[tt/p=ADJA]}[mate/p=NN]}");
339 map = ppt.getRequestMap().get("query").toString();
340 assertEquals(cls5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000341 }
342
343 @Test
344 public void testPositions() {
345 // contains(<s>,<np>)
346 String pos1 = "{@type=korap:group, relation=position, position=contains, operands=[" +
347 "{@type=korap:element, @value=s}," +
348 "{@type=korap:element, @value=np}" +
349 "]}";
350 assertTrue(equalsQueryContent(pos1, "contains(<s>,<np>)"));
351
352 // contains(<s>,[base=Mann])
353 String pos2 = "{@type=korap:group, relation=position, position=contains, operands=[" +
354 "{@type=korap:element, @value=s}," +
355 "{@type=korap:token, @value= {@type=korap:term, @value=base:Mann, relation==}}" +
356 "]}";
357 assertTrue(equalsQueryContent(pos2, "contains(<s>,[base=Mann])"));
358
359 // contains(<s>,[orth=der][orth=Mann])
360 String pos3 = "{@type=korap:group, relation=position, position=contains, operands=[" +
361 "{@type=korap:element, @value=s}," +
362 "{@type=korap:sequence, operands=[" +
363 "{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}," +
364 "{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" +
365 "]}" +
366 "]}";
367 ppt = new PoliqarpPlusTree("contains(<s>,[orth=der][orth=Mann])");
368 map = ppt.getRequestMap().get("query").toString();
369 assertEquals(pos3.replaceAll(" ", ""), map.replaceAll(" ", ""));
370
371 // [base=Auto]contains(<s>,[base=Mann])
372 String pos4 =
373 "{@type=korap:sequence, operands=[" +
374 "{@type=korap:token, @value={@type=korap:term, @value=base:Auto, relation==}}," +
375 "{@type=korap:group, relation=position, position=contains, operands=[" +
376 "{@type=korap:element, @value=s}," +
377 "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}" +
378 "]}" +
379 "]}";
380 ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[base=Mann])");
381 map = ppt.getRequestMap().get("query").toString();
382 assertEquals(pos4.replaceAll(" ", ""), map.replaceAll(" ", ""));
383 }
384
385 @Test
386 public void testNestedPositions() {
387 // contains(<s>,startswith(<np>,[orth=Der]))
388 String npos1 =
389 "{@type=korap:group, relation=position, position=contains, operands=[" +
390 "{@type=korap:element, @value=s}," +
391 "{@type=korap:group, relation=position, position=startswith, operands=[" +
392 "{@type=korap:element, @value=np}," +
393 "{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}" +
394 "]}" +
395 "]}";
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000396 ppt = new PoliqarpPlusTree("contains(<s>, startswith(<np>,[orth=Der]))");
Joachim Bingel53333e62013-12-09 19:25:52 +0000397 map = ppt.getRequestMap().get("query").toString();
398 assertEquals(npos1.replaceAll(" ", ""), map.replaceAll(" ", ""));
399 }
400
401 @Test
402 public void testShrinkSplit() {
403 // shrink([orth=Der]{[orth=Mann]})
404 String shr1 =
405 "{@type=korap:group, relation=shrink, shrink=0, operands=[" +
406 "{@type=korap:sequence, operands=[" +
407 "{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}," +
408 "{@type=korap:group, class=0, operands=[" +
409 "{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" +
410 "]}" +
411 "]}" +
412 "]}";
413 ppt = new PoliqarpPlusTree("shrink([orth=Der]{[orth=Mann]})");
414 map = ppt.getRequestMap().get("query").toString();
415 assertEquals(shr1.replaceAll(" ", ""), map.replaceAll(" ", ""));
416
417 // shrink([orth=Der]{[orth=Mann][orth=geht]})
418 String shr2 =
419 "{@type=korap:group, relation=shrink, shrink=0, operands=[" +
420 "{@type=korap:sequence, operands=[" +
421 "{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}," +
422 "{@type=korap:group, class=0, operands=[" +
423 "{@type=korap:sequence, operands=[" +
424 "{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}," +
425 "{@type=korap:token, @value={@type=korap:term, @value=orth:geht, relation==}}" +
426 "]}" +
427 "]}" +
428 "]}" +
429 "]}";
430 ppt = new PoliqarpPlusTree("shrink([orth=Der]{[orth=Mann][orth=geht]})");
431 map = ppt.getRequestMap().get("query").toString();
432 assertEquals(shr2.replaceAll(" ", ""), map.replaceAll(" ", ""));
433
434 // shrink(1:[orth=Der]{1:[orth=Mann][orth=geht]})
435 String shr3 =
436 "{@type=korap:group, relation=shrink, shrink=1, operands=[" +
437 "{@type=korap:sequence, operands=[" +
438 "{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}," +
439 "{@type=korap:group, class=1, operands=[" +
440 "{@type=korap:sequence, operands=[" +
441 "{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}," +
442 "{@type=korap:token, @value={@type=korap:term, @value=orth:geht, relation==}}" +
443 "]}" +
444 "]}" +
445 "]}" +
446 "]}";
447 ppt = new PoliqarpPlusTree("shrink(1:[orth=Der]{1:[orth=Mann][orth=geht]})");
448 map = ppt.getRequestMap().get("query").toString();
449 assertEquals(shr3.replaceAll(" ", ""), map.replaceAll(" ", ""));
450
451 // shrink(1:startswith(<s>,{1:<np>}))
452 String shr4 =
453 "{@type=korap:group, relation=shrink, shrink=1, operands=[" +
454 "{@type=korap:group, relation=position, position=startswith, operands=[" +
455 "{@type=korap:element, @value=s}," +
456 "{@type=korap:group, class=1, operands=[" +
457 "{@type=korap:element, @value=np}" +
458 "]}" +
459 "]}" +
460 "]}";
Joachim Bingeladefa622013-12-13 10:51:48 +0000461 ppt = new PoliqarpPlusTree("shrink(1:startswith(<s>,{1:<np>}))");
Joachim Bingel53333e62013-12-09 19:25:52 +0000462 map = ppt.getRequestMap().get("query").toString();
463 assertEquals(shr4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000464
465 // shrink(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}}))
466 String shr5 =
467 "{@type=korap:group, relation=shrink, shrink=3, operands=[" +
468 "{@type=korap:group, relation=position, position=startswith, operands=[" +
469 "{@type=korap:element, @value=s}," +
470 "{@type=korap:group, class=3, operands=[" +
471 "{@type=korap:sequence, operands=[" +
472 "{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," +
473 "{@type=korap:group, class=1, operands=[" +
474 "{@type=korap:sequence, operands=[" +
475 "{@type=korap:token, @value={@type=korap:term, @value=mate/p:ADJA, relation==}}," +
476 "{@type=korap:group, class=2, operands=[" +
477 "{@type=korap:token, @value={@type=korap:term, @value=tt/p:NN, relation==}}" +
478 "]}" +
479 "]}" +
480 "]}" +
481 "]}" +
482 "]}" +
483 "]}" +
484 "]}";
Joachim Bingeladefa622013-12-13 10:51:48 +0000485 ppt = new PoliqarpPlusTree("shrink(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000486 map = ppt.getRequestMap().get("query").toString();
487 assertEquals(shr5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000488 }
489
490 @Test
491 public void testLayers() {
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000492 // [base=Mann]
493 String layer1 = "{@type=korap:token, @value={@type=korap:term, @value=tt/base:Mann, relation==}}";
494 assertTrue(equalsQueryContent(layer1, "[tt/base=Mann]"));
Joachim Bingel53333e62013-12-09 19:25:52 +0000495
496 }
497}
498