blob: 2c6eeaf2fbbb9bcd65f581013569aab562557d94 [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;
Joachim Bingel16da4e12013-12-17 09:48:12 +00006import de.ids_mannheim.korap.util.QueryException;
Joachim Bingel53333e62013-12-09 19:25:52 +00007
8public class PoliqarpPlusTreeTest {
9
10 PoliqarpPlusTree ppt;
11 String map;
12
Joachim Bingel53333e62013-12-09 19:25:52 +000013
Joachim Bingel16da4e12013-12-17 09:48:12 +000014 private boolean equalsQueryContent(String res, String query) throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +000015 res = res.replaceAll(" ", "");
16 ppt = new PoliqarpPlusTree(query);
17 String queryMap = ppt.getRequestMap().get("query").toString().replaceAll(" ", "");
18 return res.equals(queryMap);
19 }
20
Joachim Bingel81812632014-02-18 08:55:22 +000021 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +000022 public void testContext() throws QueryException {
Joachim Bingel81812632014-02-18 08:55:22 +000023 String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld";
Joachim Bingel2daf9862014-02-12 10:18:54 +000024 ppt = new PoliqarpPlusTree("Test");
25 assertEquals(contextString.replaceAll(" ", ""), ppt.getRequestMap().get("@context").toString().replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +000026 }
27
28 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +000029 public void testSingleTokens() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +000030 // [base=Mann]
Joachim Bingelee3b21d2014-02-12 12:34:59 +000031 String token1 = "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}";
Joachim Bingel53333e62013-12-09 19:25:52 +000032 assertTrue(equalsQueryContent(token1, "[base=Mann]"));
33
34 // [orth!=Frau]
Joachim Bingelee3b21d2014-02-12 12:34:59 +000035 String token2 = "{@type=korap:token, wrap={@type=korap:term, key=Frau, layer=orth, match=match:ne}}";
Joachim Bingel53333e62013-12-09 19:25:52 +000036 assertTrue(equalsQueryContent(token2, "[orth!=Frau]"));
37
38 // [!p=NN]
Joachim Bingelee3b21d2014-02-12 12:34:59 +000039 String token3 = "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, match=match:ne}}";
Joachim Bingel53333e62013-12-09 19:25:52 +000040 assertTrue(equalsQueryContent(token3, "[!p=NN]"));
41
42 // [!p!=NN]
Joachim Bingelee3b21d2014-02-12 12:34:59 +000043 String token4 = "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, match=match:eq}}";
Joachim Bingel53333e62013-12-09 19:25:52 +000044 assertTrue(equalsQueryContent(token4, "[!p!=NN]"));
45 }
46
47 @Test
Joachim Bingel41e112e2014-02-12 10:46:18 +000048 public void testRegex() throws QueryException {
49 String query = "[orth=\"M(a|ä)nn(er)?\"]";
Joachim Bingelbc537b62014-02-12 12:47:45 +000050 String re1 = "{@type=korap:token, wrap={@type=korap:term, type=type:regex, key=M(a|ä)nn(er)?, layer=orth, match=match:eq}}";
Joachim Bingel41e112e2014-02-12 10:46:18 +000051 ppt = new PoliqarpPlusTree(query);
52 map = ppt.getRequestMap().get("query").toString();
53 assertEquals(re1.replaceAll(" ", ""), map.replaceAll(" ", ""));
54 }
55
56 @Test
Joachim Bingel0207d5e2014-02-12 14:18:41 +000057 public void testCaseSensitivityFlag() throws QueryException {
58 String query="[orth=deutscher/i]";
59 String cs1 =
60 "{@type=korap:token, wrap={@type=korap:term, key=deutscher, layer=orth, match=match:eq, caseInsensitive=true}}";
61 ppt = new PoliqarpPlusTree(query);
62 map = ppt.getRequestMap().get("query").toString();
63 assertEquals(cs1.replaceAll(" ", ""), map.replaceAll(" ", ""));
64
65 query="[orth=deutscher/i][orth=Bundestag]";
66 String cs2 =
67 "{@type=korap:group, operation=operation:sequence, operands=[" +
68 "{@type=korap:token, wrap={@type=korap:term, key=deutscher, layer=orth, match=match:eq, caseInsensitive=true}}," +
69 "{@type=korap:token, wrap={@type=korap:term, key=Bundestag, layer=orth, match=match:eq}}" +
70 "]}";
71 ppt = new PoliqarpPlusTree(query);
72 map = ppt.getRequestMap().get("query").toString();
73 assertEquals(cs2.replaceAll(" ", ""), map.replaceAll(" ", ""));
74 }
75
76 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +000077 public void testElements() throws QueryException {
Joachim Bingelfc1fb352014-02-26 14:40:27 +000078 String query;
Joachim Bingel53333e62013-12-09 19:25:52 +000079 // <s>
Joachim Bingel2daf9862014-02-12 10:18:54 +000080 String elem1 = "{@type=korap:span, key=s}";
Joachim Bingel53333e62013-12-09 19:25:52 +000081 assertTrue(equalsQueryContent(elem1, "<s>"));
82
83 // <vp>
Joachim Bingel2daf9862014-02-12 10:18:54 +000084 String elem2 = "{@type=korap:span, key=vp}";
Joachim Bingel53333e62013-12-09 19:25:52 +000085 assertTrue(equalsQueryContent(elem2, "<vp>"));
Joachim Bingelfc1fb352014-02-26 14:40:27 +000086
87 // <cnx/c=vp>
88 query = "<c=vp>";
89 String span3 = "{@type=korap:span, layer=c, key=vp}";
90 ppt = new PoliqarpPlusTree(query);
91 map = ppt.getRequestMap().get("query").toString();
92 assertEquals(span3.replaceAll(" ", ""), map.replaceAll(" ", ""));
93
94 // <cnx/c=vp>
95 query = "<cnx/c=vp>";
96 String span4 = "{@type=korap:span, foundry=cnx, layer=c, key=vp}";
97 ppt = new PoliqarpPlusTree(query);
98 map = ppt.getRequestMap().get("query").toString();
99 assertEquals(span4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000100 }
Joachim Bingel87480d02014-01-17 14:07:46 +0000101
102 @Test
103 public void testEmptyTokens() throws QueryException {
104 // [base=der][][base=Mann]
105 String et1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000106 "{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
Joachim Bingelb8a44a12014-04-17 09:35:30 +0000107 "{@type=korap:distance, key=w, min=2, max=2}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000108 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000109 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000110 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
111 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000112 "]}";
113 ppt = new PoliqarpPlusTree("[base=der][][base=Mann]");
114 map = ppt.getRequestMap().get("query").toString();
115 assertEquals(et1.replaceAll(" ", ""), map.replaceAll(" ", ""));
116
117 // [base=der][][][base=Mann]
118 String et2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000119 "{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
Joachim Bingelb8a44a12014-04-17 09:35:30 +0000120 "{@type=korap:distance, key=w, min=3, max=3}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000121 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000122 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000123 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
124 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000125 "]}";
Joachim Bingelffd65e32014-01-22 14:22:57 +0000126 ppt = new PoliqarpPlusTree("[base=der][][][base=Mann]");
Joachim Bingel87480d02014-01-17 14:07:46 +0000127 map = ppt.getRequestMap().get("query").toString();
128 assertEquals(et2.replaceAll(" ", ""), map.replaceAll(" ", ""));
129
130 // [base=der][][]?[base=Mann]
131 String et3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000132 "{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
Joachim Bingelb8a44a12014-04-17 09:35:30 +0000133 "{@type=korap:distance, key=w, min=2, max=3}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000134 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000135 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000136 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
137 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000138 "]}";
139 ppt = new PoliqarpPlusTree("[base=der][][]?[base=Mann]");
140 map = ppt.getRequestMap().get("query").toString();
141 assertEquals(et3.replaceAll(" ", ""), map.replaceAll(" ", ""));
142
Joachim Bingel87480d02014-01-17 14:07:46 +0000143
144 // startswith(<s>, [][base=Mann]
Joachim Bingelffd65e32014-01-22 14:22:57 +0000145 String et4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000146 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
147 "{@type=korap:span, key=s}," +
148 "{@type=korap:group, operation=operation:sequence, offset-min=1, offset-max=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000149 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000150 "]}" +
151 "]}";
Joachim Bingelffd65e32014-01-22 14:22:57 +0000152 ppt = new PoliqarpPlusTree("startswith(<s>, [][base=Mann])");
153 map = ppt.getRequestMap().get("query").toString();
154 assertEquals(et4.replaceAll(" ", ""), map.replaceAll(" ", ""));
155
Joachim Bingel11d5b152014-02-11 21:33:47 +0000156 // [base=der][]{2,5}[base=Mann][]?[][base=Frau] nested distances=
Joachim Bingelffd65e32014-01-22 14:22:57 +0000157 String et5 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000158 "{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
Joachim Bingelb8a44a12014-04-17 09:35:30 +0000159 "{@type=korap:distance, key=w, min=3, max=6}" +
Joachim Bingelffd65e32014-01-22 14:22:57 +0000160 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000161 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000162 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000163 "{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
Joachim Bingelb8a44a12014-04-17 09:35:30 +0000164 "{@type=korap:distance, key=w, min=2, max=3}" +
Joachim Bingelffd65e32014-01-22 14:22:57 +0000165 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000166 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000167 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}," +
168 "{@type=korap:token, wrap={@type=korap:term, key=Frau, layer=lemma, match=match:eq}}" +
Joachim Bingelffd65e32014-01-22 14:22:57 +0000169 "]}" +
170 "]}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000171 ppt = new PoliqarpPlusTree("[base=der][]{2,5}[base=Mann][]?[][base=Frau]");
Joachim Bingel87480d02014-01-17 14:07:46 +0000172 map = ppt.getRequestMap().get("query").toString();
173 assertEquals(et5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000174
Joachim Bingelc15720f2014-05-07 14:37:23 +0000175 // [base=der][]*[base=Mann]
176 String et6 =
177 "{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
178 "{@type=korap:distance, key=w, min=1, max=100}" +
179 "], " +
180 "operands=[" +
181 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
182 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
183 "]}";
184 ppt = new PoliqarpPlusTree("[base=der][]*[base=Mann]");
185 map = ppt.getRequestMap().get("query").toString();
186 assertEquals(et6.replaceAll(" ", ""), map.replaceAll(" ", ""));
187
188 // [base=der][]*[base=Mann]
189 String et7 =
190 "{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
191 "{@type=korap:distance, key=w, min=2, max=100}" +
192 "], " +
193 "operands=[" +
194 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
195 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
196 "]}";
197 ppt = new PoliqarpPlusTree("[base=der][]+[base=Mann]");
198 map = ppt.getRequestMap().get("query").toString();
199 assertEquals(et7.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000200 }
Joachim Bingel53333e62013-12-09 19:25:52 +0000201
202 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000203 public void testCoordinatedFields() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000204 // [base=Mann&(cas=N|cas=A)]
205 String cof1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000206 "{@type=korap:token, wrap=" +
Joachim Bingel2980bda2014-04-04 12:09:46 +0000207 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000208 "{@type=korap:term, key=Mann, layer=lemma, match=match:eq}," +
Joachim Bingel2980bda2014-04-04 12:09:46 +0000209 "{@type=korap:termGroup, relation=relation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000210 "{@type=korap:term, key=N, layer=cas, match=match:eq}," +
211 "{@type=korap:term, key=A, layer=cas, match=match:eq}" +
212 "]}" +
213 "]}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000214 "}";
215 ppt = new PoliqarpPlusTree("[base=Mann&(cas=N|cas=A)]");
216 map = ppt.getRequestMap().get("query").toString();
217 assertEquals(cof1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Nils Diewald7d486c22013-12-13 16:32:18 +0000218
219
220 assertEquals(
221 new PoliqarpPlusTree(" [ base=Mann & ( cas=N | cas=A)] ").getRequestMap().get("query").toString(),
222 new PoliqarpPlusTree("[base=Mann &(cas=N|cas=A)]").getRequestMap().get("query").toString()
223 );
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000224
225 // [base=Mann&cas=N&gen=m]
226 String cof2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000227 "{@type=korap:token, wrap=" +
Joachim Bingel2980bda2014-04-04 12:09:46 +0000228 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000229 "{@type=korap:term, key=Mann, layer=lemma, match=match:eq}," +
230 "{@type=korap:term, key=N, layer=cas, match=match:eq}," +
231 "{@type=korap:term, key=m, layer=gen, match=match:eq}" +
232 "]}" +
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000233 "}";
234 ppt = new PoliqarpPlusTree("[base=Mann&cas=N&gen=m]");
235 map = ppt.getRequestMap().get("query").toString();
236 assertEquals(cof2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000237 }
238
239 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000240 public void testOccurrence() throws QueryException {
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000241 // [base=foo]*
Joachim Bingel2daf9862014-02-12 10:18:54 +0000242 String occ1 = "{@type=korap:group, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000243 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000244 "], operation=operation:repetition, min=0, max=100}";
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000245 ppt = new PoliqarpPlusTree("[base=foo]*");
246 map = ppt.getRequestMap().get("query").toString();
247 assertEquals(occ1.replaceAll(" ", ""), map.replaceAll(" ", ""));
248
249 // [base=foo]*[base=bar]
250 String occ2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000251 "{@type=korap:group, operation=operation:sequence, operands=[" +
252 "{@type=korap:group, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000253 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000254 "], operation=operation:repetition, min=0, max=100 }," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000255 "{@type=korap:token, wrap={@type=korap:term, key=bar, layer=lemma, match=match:eq}}" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000256 "]}";
257 ppt = new PoliqarpPlusTree("[base=foo]*[base=bar]");
258 map = ppt.getRequestMap().get("query").toString();
259 assertEquals(occ2.replaceAll(" ", ""), map.replaceAll(" ", ""));
260
261 // [base=bar][base=foo]*
262 String occ3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000263 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000264 "{@type=korap:token, wrap={@type=korap:term, key=bar, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000265 "{@type=korap:group, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000266 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000267 "], operation=operation:repetition, min=0, max=100 }" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000268 "]}";
269 ppt = new PoliqarpPlusTree("[base=bar][base=foo]*");
270 map = ppt.getRequestMap().get("query").toString();
271 assertEquals(occ3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb4da7022013-12-09 23:17:24 +0000272
273 // ([base=bar][base=foo])*
274 String occ4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000275 "{@type=korap:group, operands=[" +
276 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000277 "{@type=korap:token, wrap={@type=korap:term, key=bar, layer=lemma, match=match:eq}}," +
278 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000279 "]}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000280 "], operation=operation:repetition, min=0, max=100 }" ;
Joachim Bingelb4da7022013-12-09 23:17:24 +0000281 ppt = new PoliqarpPlusTree("([base=bar][base=foo])*");
282 map = ppt.getRequestMap().get("query").toString();
283 assertEquals(occ4.replaceAll(" ", ""), map.replaceAll(" ", ""));
284
285 // <s>([base=bar][base=foo])*
286 String occ5 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000287 "{@type=korap:group, operation=operation:sequence, operands=[" +
288 "{@type=korap:span, key=s}," +
289 "{@type=korap:group, operands=[" +
290 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000291 "{@type=korap:token, wrap={@type=korap:term, key=bar, layer=lemma, match=match:eq}}," +
292 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000293 "]}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000294 "], operation=operation:repetition, min=0, max=100 }" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000295 "]}" ;
296 ppt = new PoliqarpPlusTree("<s>([base=bar][base=foo])*");
297 map = ppt.getRequestMap().get("query").toString();
298 assertEquals(occ5.replaceAll(" ", ""), map.replaceAll(" ", ""));
299
300 // <s><np>([base=bar][base=foo])*
Joachim Bingelb4da7022013-12-09 23:17:24 +0000301 String occ6 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000302 "{@type=korap:group, operation=operation:sequence, operands=[" +
303 "{@type=korap:span, key=s}," +
304 "{@type=korap:span, key=np}," +
305 "{@type=korap:group, operands=[" +
306 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000307 "{@type=korap:token, wrap={@type=korap:term, key=bar, layer=lemma, match=match:eq}}," +
308 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000309 "]}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000310 "], operation=operation:repetition, min=0, max=100 }" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000311 "]}" ;
312 ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*");
313 map = ppt.getRequestMap().get("query").toString();
314 assertEquals(occ6.replaceAll(" ", ""), map.replaceAll(" ", ""));
315
316 // <s><np>([base=bar][base=foo])*[p=NN]
317 // comment: embedded sequence shouldn't really be here, but does not really hurt, either. (?)
318 // really hard to get this behaviour out of the PQPlus grammar...
319 String occ7 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000320 "{@type=korap:group, operation=operation:sequence, operands=[" +
321 "{@type=korap:span, key=s}," +
322 "{@type=korap:span, key=np}," +
323 "{@type=korap:group, operands=[" +
324 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000325 "{@type=korap:token, wrap={@type=korap:term, key=bar, layer=lemma, match=match:eq}}," +
326 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000327 "]}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000328 "], operation=operation:repetition, min=0, max=100 }," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000329 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000330 "]}" ;
331 ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*[p=NN]");
332 map = ppt.getRequestMap().get("query").toString();
333 assertEquals(occ7.replaceAll(" ", ""), map.replaceAll(" ", ""));
334
335 // ([base=bar][base=foo])*[p=NN]
Joachim Bingelb4da7022013-12-09 23:17:24 +0000336 String occ8 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000337 "{@type=korap:group, operation=operation:sequence, operands=[" +
338 "{@type=korap:group, operands=[" +
339 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000340 "{@type=korap:token, wrap={@type=korap:term, key=bar, layer=lemma, match=match:eq}}," +
341 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000342 "]}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000343 "], operation=operation:repetition, min=0, max=100 }," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000344 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000345 "]}" ;
346 ppt = new PoliqarpPlusTree("([base=bar][base=foo])*[p=NN]");
347 map = ppt.getRequestMap().get("query").toString();
348 assertEquals(occ8.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000349
350 // [base=foo]+
Joachim Bingel2daf9862014-02-12 10:18:54 +0000351 String occ9 = "{@type=korap:group, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000352 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000353 "], operation=operation:repetition, min=1, max=100}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000354 ppt = new PoliqarpPlusTree("[base=foo]+");
355 map = ppt.getRequestMap().get("query").toString();
356 assertEquals(occ9.replaceAll(" ", ""), map.replaceAll(" ", ""));
357
358 // [base=foo]?
Joachim Bingel2daf9862014-02-12 10:18:54 +0000359 String occ10 = "{@type=korap:group, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000360 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000361 "], operation=operation:repetition, min=0, max=1}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000362 ppt = new PoliqarpPlusTree("[base=foo]?");
363 map = ppt.getRequestMap().get("query").toString();
364 assertEquals(occ10.replaceAll(" ", ""), map.replaceAll(" ", ""));
365
366 // [base=foo]{2,5}
Joachim Bingel2daf9862014-02-12 10:18:54 +0000367 String occ11 = "{@type=korap:group, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000368 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000369 "], operation=operation:repetition, min=2, max=5}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000370 ppt = new PoliqarpPlusTree("[base=foo]{2,5}");
371 map = ppt.getRequestMap().get("query").toString();
372 assertEquals(occ11.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel2980bda2014-04-04 12:09:46 +0000373
374 // [base=foo]{2}
375 String occ12 = "{@type=korap:group, operands=[" +
376 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
377 "], operation=operation:repetition, min=2, max=2}";
378 ppt = new PoliqarpPlusTree("[base=foo]{2}");
379 map = ppt.getRequestMap().get("query").toString();
380 assertEquals(occ12.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000381 }
382
383 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000384 public void testTokenSequence() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000385 // [base=Mann][orth=Frau]
Joachim Bingel2daf9862014-02-12 10:18:54 +0000386 String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000387 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}, " +
388 "{@type=korap:token, wrap={@type=korap:term, key=Frau, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000389 "]}";
390 assertTrue(equalsQueryContent(seq1, "[base=Mann][orth=Frau]"));
391
392 // [base=Mann][orth=Frau][p=NN]
Joachim Bingel2daf9862014-02-12 10:18:54 +0000393 String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000394 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}, " +
395 "{@type=korap:token, wrap={@type=korap:term, key=Frau, layer=orth, match=match:eq}}, " +
396 "{@type=korap:token, wrap={@type=korap:term, key=NN,layer=p, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000397 "]}";
398 assertTrue(equalsQueryContent(seq2, "[base=Mann][orth=Frau][p=NN]"));
399 }
400
401 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000402 public void testDisjSegments() throws QueryException {
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000403 // ([base=der]|[base=das])[base=Schild]
404 String disj1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000405 "{@type=korap:group, operation=operation:sequence, operands=[" +
406 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000407 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
408 "{@type=korap:token, wrap={@type=korap:term, key=das, layer=lemma, match=match:eq}}" +
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000409 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000410 "{@type=korap:token, wrap={@type=korap:term, key=Schild, layer=lemma, match=match:eq}}" +
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000411 "]}";
412 ppt = new PoliqarpPlusTree("([base=der]|[base=das])[base=Schild]");
413 map = ppt.getRequestMap().get("query").toString();
414 assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", ""));
415
416 // [base=Schild]([base=der]|[base=das])
417 String disj2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000418 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000419 "{@type=korap:token, wrap={@type=korap:term, key=Schild, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000420 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000421 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
422 "{@type=korap:token, wrap={@type=korap:term, key=das, layer=lemma, match=match:eq}}" +
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000423 "]}" +
424 "]}";
425 ppt = new PoliqarpPlusTree("[base=Schild]([base=der]|[base=das])");
426 map = ppt.getRequestMap().get("query").toString();
427 assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", ""));
428 }
429
430 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000431 public void testTokenElemSequence() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000432 // [base=Mann]<vp>
Joachim Bingel2daf9862014-02-12 10:18:54 +0000433 String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000434 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}, " +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000435 "{@type=korap:span, key=vp}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000436 "]}";
437 assertTrue(equalsQueryContent(seq1, "[base=Mann]<vp>"));
438
439 // <vp>[base=Mann]
Joachim Bingel2daf9862014-02-12 10:18:54 +0000440 String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" +
441 "{@type=korap:span, key=vp}, "+
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000442 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}} " +
Joachim Bingel53333e62013-12-09 19:25:52 +0000443 "]}";
444 assertTrue(equalsQueryContent(seq2, "<vp>[base=Mann]"));
445
446 // <vp>[base=Mann]<pp>
Joachim Bingel2daf9862014-02-12 10:18:54 +0000447 String seq3 = "{@type=korap:group, operation=operation:sequence, operands=[" +
448 "{@type=korap:span, key=vp}, "+
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000449 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}, " +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000450 "{@type=korap:span, key=pp} "+
Joachim Bingel53333e62013-12-09 19:25:52 +0000451 "]}";
452 assertTrue(equalsQueryContent(seq3, "<vp>[base=Mann]<pp>"));
453 }
454
455 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000456 public void testElemSequence() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000457 // <np><vp>
Joachim Bingel2daf9862014-02-12 10:18:54 +0000458 String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" +
459 "{@type=korap:span, key=np}," +
460 "{@type=korap:span, key=vp}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000461 "]}";
462 assertTrue(equalsQueryContent(seq1, "<np><vp>"));
463
464 // <np><vp><pp>
Joachim Bingel2daf9862014-02-12 10:18:54 +0000465 String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" +
466 "{@type=korap:span, key=np}," +
467 "{@type=korap:span, key=vp}," +
468 "{@type=korap:span, key=pp}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000469 "]}";
470 assertTrue(equalsQueryContent(seq2, "<np><vp><pp>"));
471 }
472
473 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000474 public void testClasses() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000475 // {[base=Mann]}
Joachim Bingel2daf9862014-02-12 10:18:54 +0000476 String cls1 = "{@type=korap:group, operation=operation:class, class=0, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000477 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000478 "]}";
Joachim Bingel8c640e42014-02-07 16:20:47 +0000479 ppt = new PoliqarpPlusTree("{[base=Mann]}");
480 map = ppt.getRequestMap().get("query").toString();
481 assertEquals(cls1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000482
483 // {[base=Mann][orth=Frau]}
Joachim Bingel2daf9862014-02-12 10:18:54 +0000484 String cls2 = "{@type=korap:group, operation=operation:class, class=0, operands=[" +
485 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000486 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}," +
487 "{@type=korap:token, wrap={@type=korap:term, key=Frau, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000488 "]}" +
489 "]}";
490 assertTrue(equalsQueryContent(cls2, "{[base=Mann][orth=Frau]}"));
491
492 // [p=NN]{[base=Mann][orth=Frau]}
Joachim Bingel2daf9862014-02-12 10:18:54 +0000493 String cls3 = "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000494 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000495 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
496 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000497 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}," +
498 "{@type=korap:token, wrap={@type=korap:term, key=Frau, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000499 "]}" +
500 "]}" +
501 "]}";
502 assertTrue(equalsQueryContent(cls3, "[p=NN]{[base=Mann][orth=Frau]}"));
503
504 // {[base=Mann][orth=Frau]}[p=NN]
Joachim Bingel2daf9862014-02-12 10:18:54 +0000505 String cls4 = "{@type=korap:group, operation=operation:sequence, operands=[" +
506 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
507 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000508 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}," +
509 "{@type=korap:token, wrap={@type=korap:term, key=Frau, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000510 "]}" +
511 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000512 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000513 "]}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000514 ppt = new PoliqarpPlusTree("{[base=Mann][orth=Frau]}[p=NN]");
515 map = ppt.getRequestMap().get("query").toString();
516 assertEquals(cls4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000517
518 // {2:{1:[tt/p=ADJA]}[mate/p=NN]}"
Joachim Bingel2daf9862014-02-12 10:18:54 +0000519 String cls5 = "{@type=korap:group, operation=operation:class, class=2, operands=[" +
520 "{@type=korap:group, operation=operation:sequence, operands=[" +
521 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000522 "{@type=korap:token, wrap={@type=korap:term, key=ADJA, layer=p, foundry=tt, match=match:eq}}" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000523 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000524 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, foundry=mate, match=match:eq}}" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000525 "]}" +
526 "]}";
527 ppt = new PoliqarpPlusTree("{2: {1:[tt/p=ADJA]}[mate/p=NN]}");
528 map = ppt.getRequestMap().get("query").toString();
529 assertEquals(cls5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000530 }
531
532 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000533 public void testPositions() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000534 // contains(<s>,<np>)
Joachim Bingel2daf9862014-02-12 10:18:54 +0000535 String pos1 = "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
536 "{@type=korap:span, key=s}," +
537 "{@type=korap:span, key=np}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000538 "]}";
539 assertTrue(equalsQueryContent(pos1, "contains(<s>,<np>)"));
540
541 // contains(<s>,[base=Mann])
Joachim Bingel2daf9862014-02-12 10:18:54 +0000542 String pos2 = "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
543 "{@type=korap:span, key=s}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000544 "{@type=korap:token, wrap= {@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000545 "]}";
546 assertTrue(equalsQueryContent(pos2, "contains(<s>,[base=Mann])"));
547
548 // contains(<s>,[orth=der][orth=Mann])
Joachim Bingel2daf9862014-02-12 10:18:54 +0000549 String pos3 = "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
550 "{@type=korap:span, key=s}," +
551 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000552 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
553 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000554 "]}" +
555 "]}";
556 ppt = new PoliqarpPlusTree("contains(<s>,[orth=der][orth=Mann])");
557 map = ppt.getRequestMap().get("query").toString();
558 assertEquals(pos3.replaceAll(" ", ""), map.replaceAll(" ", ""));
559
560 // [base=Auto]contains(<s>,[base=Mann])
561 String pos4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000562 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000563 "{@type=korap:token, wrap={@type=korap:term, key=Auto, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000564 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
565 "{@type=korap:span, key=s}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000566 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000567 "]}" +
568 "]}";
569 ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[base=Mann])");
570 map = ppt.getRequestMap().get("query").toString();
571 assertEquals(pos4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelef7059b2014-04-22 13:44:19 +0000572
573 // contains(<s>,[pos=N]*)
574 String pos5 =
575 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
576 "{@type=korap:span, key=s}," +
577 "{@type=korap:group, " +
578 "operands=[{@type=korap:token, wrap={@type=korap:term, key=N, layer=pos, match=match:eq}}" +
579 "], operation=operation:repetition, min=0, max=100" +
580 "}" +
581 "]}";
582 ppt = new PoliqarpPlusTree("contains(<s>,[pos=N]*)");
583 map = ppt.getRequestMap().get("query").toString();
584 assertEquals(pos5.replaceAll(" ", ""), map.replaceAll(" ", ""));
585
586 // [base=Auto]contains(<s>,[pos=N]*)
587 String pos6 =
588 "{@type=korap:group, operation=operation:sequence, operands=[" +
589 "{@type=korap:token, wrap={@type=korap:term, key=Auto, layer=lemma, match=match:eq}}," +
590 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
591 "{@type=korap:span, key=s}," +
592 "{@type=korap:group, " +
593 "operands=[{@type=korap:token, wrap={@type=korap:term, key=N, layer=pos, match=match:eq}}" +
594 "], operation=operation:repetition, min=0, max=100" +
595 "}" +
596 "]}" +
597 "]}";
598 ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[pos=N]*)");
599 map = ppt.getRequestMap().get("query").toString();
600 assertEquals(pos6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000601 }
602
603 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000604 public void testNestedPositions() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000605 // contains(<s>,startswith(<np>,[orth=Der]))
606 String npos1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000607 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
608 "{@type=korap:span, key=s}," +
609 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
610 "{@type=korap:span, key=np}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000611 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000612 "]}" +
613 "]}";
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000614 ppt = new PoliqarpPlusTree("contains(<s>, startswith(<np>,[orth=Der]))");
Joachim Bingel53333e62013-12-09 19:25:52 +0000615 map = ppt.getRequestMap().get("query").toString();
616 assertEquals(npos1.replaceAll(" ", ""), map.replaceAll(" ", ""));
617 }
618
619 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000620 public void testShrinkSplit() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000621 // shrink([orth=Der]{[orth=Mann]})
622 String shr1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000623 "{@type=korap:group, operation=operation:submatch, classRef=[0], operands=[" +
624 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000625 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000626 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000627 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000628 "]}" +
629 "]}" +
630 "]}";
631 ppt = new PoliqarpPlusTree("shrink([orth=Der]{[orth=Mann]})");
632 map = ppt.getRequestMap().get("query").toString();
633 assertEquals(shr1.replaceAll(" ", ""), map.replaceAll(" ", ""));
634
635 // shrink([orth=Der]{[orth=Mann][orth=geht]})
636 String shr2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000637 "{@type=korap:group, operation=operation:submatch, classRef=[0], operands=[" +
638 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000639 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000640 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
641 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000642 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
643 "{@type=korap:token, wrap={@type=korap:term, key=geht, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000644 "]}" +
645 "]}" +
646 "]}" +
647 "]}";
648 ppt = new PoliqarpPlusTree("shrink([orth=Der]{[orth=Mann][orth=geht]})");
649 map = ppt.getRequestMap().get("query").toString();
650 assertEquals(shr2.replaceAll(" ", ""), map.replaceAll(" ", ""));
651
652 // shrink(1:[orth=Der]{1:[orth=Mann][orth=geht]})
653 String shr3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000654 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
655 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000656 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000657 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
658 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000659 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
660 "{@type=korap:token, wrap={@type=korap:term, key=geht, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000661 "]}" +
662 "]}" +
663 "]}" +
664 "]}";
665 ppt = new PoliqarpPlusTree("shrink(1:[orth=Der]{1:[orth=Mann][orth=geht]})");
666 map = ppt.getRequestMap().get("query").toString();
667 assertEquals(shr3.replaceAll(" ", ""), map.replaceAll(" ", ""));
668
669 // shrink(1:startswith(<s>,{1:<np>}))
670 String shr4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000671 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
672 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
673 "{@type=korap:span, key=s}," +
674 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
675 "{@type=korap:span, key=np}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000676 "]}" +
677 "]}" +
678 "]}";
Joachim Bingeladefa622013-12-13 10:51:48 +0000679 ppt = new PoliqarpPlusTree("shrink(1:startswith(<s>,{1:<np>}))");
Joachim Bingel53333e62013-12-09 19:25:52 +0000680 map = ppt.getRequestMap().get("query").toString();
681 assertEquals(shr4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000682
683 // shrink(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}}))
684 String shr5 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000685 "{@type=korap:group, operation=operation:submatch, classRef=[3], operands=[" +
686 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
687 "{@type=korap:span, key=s}," +
688 "{@type=korap:group, operation=operation:class, class=3, operands=[" +
689 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000690 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000691 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
692 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000693 "{@type=korap:token, wrap={@type=korap:term, key=ADJA, layer=p, foundry=mate, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000694 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000695 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, foundry=tt, match=match:eq}}" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000696 "]}" +
697 "]}" +
698 "]}" +
699 "]}" +
700 "]}" +
701 "]}" +
702 "]}";
Joachim Bingeladefa622013-12-13 10:51:48 +0000703 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 +0000704 map = ppt.getRequestMap().get("query").toString();
705 assertEquals(shr5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000706
707 // split(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}}))
708 String shr6 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000709 "{@type=korap:group, operation=operation:split, classRef=[3], operands=[" +
710 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
711 "{@type=korap:span, key=s}," +
712 "{@type=korap:group, operation=operation:class, class=3, operands=[" +
713 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000714 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000715 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
716 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000717 "{@type=korap:token, wrap={@type=korap:term, key=ADJA, layer=p, foundry=mate, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000718 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000719 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, foundry=tt, match=match:eq}}" +
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000720 "]}" +
721 "]}" +
722 "]}" +
723 "]}" +
724 "]}" +
725 "]}" +
726 "]}";
727 ppt = new PoliqarpPlusTree("split(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
728 map = ppt.getRequestMap().get("query").toString();
729 assertEquals(shr6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel8c640e42014-02-07 16:20:47 +0000730
731 // split(2|3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}}))
732 String shr7 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000733 "{@type=korap:group, operation=operation:split, classRef=[2, 3], classRefOp=classRefOp:intersection, operands=[" +
734 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
735 "{@type=korap:span, key=s}," +
736 "{@type=korap:group, operation=operation:class, class=3, operands=[" +
737 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000738 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000739 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
740 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000741 "{@type=korap:token, wrap={@type=korap:term, key=ADJA, layer=p, foundry=mate, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000742 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000743 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, foundry=tt, match=match:eq}}" +
Joachim Bingel8c640e42014-02-07 16:20:47 +0000744 "]}" +
745 "]}" +
746 "]}" +
747 "]}" +
748 "]}" +
749 "]}" +
750 "]}";
751 ppt = new PoliqarpPlusTree("split(2|3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
752 map = ppt.getRequestMap().get("query").toString();
753 assertEquals(shr7.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000754 }
755
Joachim Bingel03882702013-12-31 19:53:05 +0000756
Joachim Bingel53333e62013-12-09 19:25:52 +0000757 @Test
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000758 public void testFoundries() throws QueryException {
759 // [tt/base=Mann]
Joachim Bingelac13a472014-02-14 21:18:52 +0000760 String layer1 = "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, foundry=tt, match=match:eq}}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000761 ppt = new PoliqarpPlusTree("[tt/base=Mann]");
762 map = ppt.getRequestMap().get("query").toString();
763 assertEquals(layer1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000764
765 }
Joachim Bingel16da4e12013-12-17 09:48:12 +0000766
767 @Test
Joachim Bingel8c640e42014-02-07 16:20:47 +0000768 public void testAlign() throws QueryException {
Joachim Bingel16da4e12013-12-17 09:48:12 +0000769 // [orth=der]^[orth=Mann]
770 String align1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000771 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000772 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000773 "{@type=korap:group, alignment=left, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000774 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel03882702013-12-31 19:53:05 +0000775 "]}" +
Joachim Bingel16da4e12013-12-17 09:48:12 +0000776 "]}";
777 ppt = new PoliqarpPlusTree("[orth=der]^[orth=Mann]");
778 map = ppt.getRequestMap().get("query").toString();
779 assertEquals(align1.replaceAll(" ", ""), map.replaceAll(" ", ""));
780
Joachim Bingel84e33df2014-01-31 14:02:46 +0000781 // [orth=der]^[orth=große][orth=Mann]
782 String query = "[orth=der]^[orth=große][orth=Mann]";
783 String align1b =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000784 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000785 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000786 "{@type=korap:group, alignment=left, operands=[" +
787 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000788 "{@type=korap:token, wrap={@type=korap:term, key=große, layer=orth, match=match:eq}}," +
789 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel84e33df2014-01-31 14:02:46 +0000790 "]}" +
791 "]}" +
792 "]}";
793 ppt = new PoliqarpPlusTree(query);
794 map = ppt.getRequestMap().get("query").toString();
795 assertEquals(align1b.replaceAll(" ", ""), map.replaceAll(" ", ""));
796
Joachim Bingel16da4e12013-12-17 09:48:12 +0000797 // "([base=a]^[base=b])|[base=c]",
798 String align2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000799 "{@type=korap:group, operation=operation:or, operands=[" +
800 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000801 "{@type=korap:token, wrap={@type=korap:term, key=a, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000802 "{@type=korap:group, alignment=left, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000803 "{@type=korap:token, wrap={@type=korap:term, key=b, layer=lemma, match=match:eq}}" +
Joachim Bingel03882702013-12-31 19:53:05 +0000804 "]}" +
Joachim Bingel16da4e12013-12-17 09:48:12 +0000805 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000806 "{@type=korap:token, wrap={@type=korap:term, key=c, layer=lemma, match=match:eq}}" +
Joachim Bingel16da4e12013-12-17 09:48:12 +0000807 "]}";
808 ppt = new PoliqarpPlusTree("([base=a]^[base=b])|[base=c]");
809 map = ppt.getRequestMap().get("query").toString();
810 assertEquals(align2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingela67e6a32014-01-02 18:35:24 +0000811
812 // "([base=a]^[base=b][base=c])|[base=d]",
813 String align3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000814 "{@type=korap:group, operation=operation:or, operands=[" +
815 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000816 "{@type=korap:token, wrap={@type=korap:term, key=a, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000817 "{@type=korap:group, alignment=left, operands=[" +
818 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000819 "{@type=korap:token, wrap={@type=korap:term, key=b, layer=lemma, match=match:eq}}," +
820 "{@type=korap:token, wrap={@type=korap:term, key=c, layer=lemma, match=match:eq}}" +
Joachim Bingel84e33df2014-01-31 14:02:46 +0000821 "]}" +
822 "]}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +0000823 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000824 "{@type=korap:token, wrap={@type=korap:term, key=d, layer=lemma, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +0000825 "]}";
826 ppt = new PoliqarpPlusTree("([base=a]^[base=b][base=c])|[base=d]");
827 map = ppt.getRequestMap().get("query").toString();
828 assertEquals(align3.replaceAll(" ", ""), map.replaceAll(" ", ""));
829
830 // "([base=a]^[base=b]^[base=c])|[base=d]",
831 String align4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000832 "{@type=korap:group, operation=operation:or, operands=[" +
833 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000834 "{@type=korap:token, wrap={@type=korap:term, key=a, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000835 "{@type=korap:group, alignment=left, operands=[" +
836 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000837 "{@type=korap:token, wrap={@type=korap:term, key=b, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000838 "{@type=korap:group, alignment=left, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000839 "{@type=korap:token, wrap={@type=korap:term, key=c, layer=lemma, match=match:eq}}" +
Joachim Bingel84e33df2014-01-31 14:02:46 +0000840 "]}" +
841 "]}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +0000842 "]}" +
843 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000844 "{@type=korap:token, wrap={@type=korap:term, key=d, layer=lemma, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +0000845 "]}";
846 ppt = new PoliqarpPlusTree("([base=a]^[base=b]^[base=c])|[base=d]");
847 map = ppt.getRequestMap().get("query").toString();
848 assertEquals(align4.replaceAll(" ", ""), map.replaceAll(" ", ""));
849
850
Joachim Bingel16da4e12013-12-17 09:48:12 +0000851 }
852
853 @Test
Joachim Bingel8c640e42014-02-07 16:20:47 +0000854 public void testSimpleQueries() throws QueryException {
Joachim Bingela67e6a32014-01-02 18:35:24 +0000855 // Baum
856 String simple1 =
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000857 "{@type=korap:token, wrap={@type=korap:term, key=Baum, layer=orth, match=match:eq}}";
Joachim Bingela67e6a32014-01-02 18:35:24 +0000858 ppt = new PoliqarpPlusTree("Baum");
859 map = ppt.getRequestMap().get("query").toString();
860 assertEquals(simple1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel16da4e12013-12-17 09:48:12 +0000861
Joachim Bingela67e6a32014-01-02 18:35:24 +0000862 // Der Baum
863 String simple2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000864 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000865 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}, " +
866 "{@type=korap:token, wrap={@type=korap:term, key=Baum, layer=orth, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +0000867 "]}";
868 ppt = new PoliqarpPlusTree("Der Baum");
869 map = ppt.getRequestMap().get("query").toString();
870 assertEquals(simple2.replaceAll(" ", ""), map.replaceAll(" ", ""));
871
872 // Der große Baum
873 String simple3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000874 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000875 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}, " +
876 "{@type=korap:token, wrap={@type=korap:term, key=große, layer=orth, match=match:eq}}, " +
877 "{@type=korap:token, wrap={@type=korap:term, key=Baum, layer=orth, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +0000878 "]}";
879 ppt = new PoliqarpPlusTree("Der große Baum");
880 map = ppt.getRequestMap().get("query").toString();
881 assertEquals(simple3.replaceAll(" ", ""), map.replaceAll(" ", ""));
882
883 // Baum | Stein
884 String simple4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000885 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000886 "{@type=korap:token, wrap={@type=korap:term, key=Baum, layer=orth, match=match:eq}}, " +
887 "{@type=korap:token, wrap={@type=korap:term, key=Stein, layer=orth, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +0000888 "]}";
889 ppt = new PoliqarpPlusTree("Baum | Stein");
890 map = ppt.getRequestMap().get("query").toString();
891 assertEquals(simple4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel84e33df2014-01-31 14:02:46 +0000892
893 // Baum | Stein Haus
894 String query = "(Baum | Stein) Haus";
895 String simple5 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000896 "{@type=korap:group, operation=operation:sequence, operands=[" +
897 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000898 "{@type=korap:token, wrap={@type=korap:term, key=Baum, layer=orth, match=match:eq}}, " +
899 "{@type=korap:token, wrap={@type=korap:term, key=Stein, layer=orth, match=match:eq}}" +
Joachim Bingel84e33df2014-01-31 14:02:46 +0000900 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000901 "{@type=korap:token, wrap={@type=korap:term, key=Haus, layer=orth, match=match:eq}} " +
Joachim Bingel84e33df2014-01-31 14:02:46 +0000902 "]}";
903 ppt = new PoliqarpPlusTree(query);
904 map = ppt.getRequestMap().get("query").toString();
905 assertEquals(simple5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel16da4e12013-12-17 09:48:12 +0000906 }
Joachim Bingel53333e62013-12-09 19:25:52 +0000907}
908