blob: 53145d896ffb512fa27e4e8de393fb1da68ac07c [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;
Joachim Bingel14239d82014-07-22 09:55:04 +000012 String expected;
13 String query;
Joachim Bingel53333e62013-12-09 19:25:52 +000014
Joachim Bingel16da4e12013-12-17 09:48:12 +000015 private boolean equalsQueryContent(String res, String query) throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +000016 res = res.replaceAll(" ", "");
17 ppt = new PoliqarpPlusTree(query);
18 String queryMap = ppt.getRequestMap().get("query").toString().replaceAll(" ", "");
19 return res.equals(queryMap);
20 }
21
Joachim Bingel81812632014-02-18 08:55:22 +000022 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +000023 public void testContext() throws QueryException {
Joachim Bingel81812632014-02-18 08:55:22 +000024 String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld";
Joachim Bingel2daf9862014-02-12 10:18:54 +000025 ppt = new PoliqarpPlusTree("Test");
26 assertEquals(contextString.replaceAll(" ", ""), ppt.getRequestMap().get("@context").toString().replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +000027 }
28
29 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +000030 public void testSingleTokens() throws QueryException {
Joachim Bingel0900a892014-06-30 16:26:21 +000031 String query;
Joachim Bingel53333e62013-12-09 19:25:52 +000032 // [base=Mann]
Joachim Bingel0900a892014-06-30 16:26:21 +000033 String token1 = "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}";
Joachim Bingel53333e62013-12-09 19:25:52 +000034 assertTrue(equalsQueryContent(token1, "[base=Mann]"));
35
36 // [orth!=Frau]
Joachim Bingel0900a892014-06-30 16:26:21 +000037 String token2 = "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:ne}}";
Joachim Bingel53333e62013-12-09 19:25:52 +000038 assertTrue(equalsQueryContent(token2, "[orth!=Frau]"));
39
40 // [!p=NN]
Joachim Bingel0900a892014-06-30 16:26:21 +000041 query = "[!p=NN]";
42 String token3 = "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:ne}}";
43 ppt = new PoliqarpPlusTree(query);
44 map = ppt.getRequestMap().get("query").toString();
45 assertEquals(token3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +000046
47 // [!p!=NN]
Joachim Bingel0900a892014-06-30 16:26:21 +000048 query = "[!p!=NN]";
49 String token4 = "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}";
50 ppt = new PoliqarpPlusTree(query);
51 map = ppt.getRequestMap().get("query").toString();
52 assertEquals(token4.replaceAll(" ", ""), map.replaceAll(" ", ""));
53
Joachim Bingeld1a3e712014-07-16 08:02:05 +000054 query = "[base=schland/x]";
Joachim Bingela83f8cc2014-08-05 14:12:59 +000055 String token5 = "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=.*?schland.*?, match=match:eq, type=type:regex}}";
Joachim Bingeld1a3e712014-07-16 08:02:05 +000056 ppt = new PoliqarpPlusTree(query);
57 map = ppt.getRequestMap().get("query").toString();
58 assertEquals(token5.replaceAll(" ", ""), map.replaceAll(" ", ""));
59 }
60
61 @Test
62 public void testValue() throws QueryException {
63 String query;
64
65 query = "[mate/m=temp:pres]";
66 String value1 = "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=m, key=temp, value=pres, match=match:eq}}";
67 ppt = new PoliqarpPlusTree(query);
68 map = ppt.getRequestMap().get("query").toString();
69 assertEquals(value1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +000070 }
71
72 @Test
Joachim Bingel41e112e2014-02-12 10:46:18 +000073 public void testRegex() throws QueryException {
74 String query = "[orth=\"M(a|ä)nn(er)?\"]";
Joachim Bingel0900a892014-06-30 16:26:21 +000075 String re1 = "{@type=korap:token, wrap={@type=korap:term, layer=orth, type=type:regex, key=M(a|ä)nn(er)?, match=match:eq}}";
Joachim Bingel41e112e2014-02-12 10:46:18 +000076 ppt = new PoliqarpPlusTree(query);
77 map = ppt.getRequestMap().get("query").toString();
78 assertEquals(re1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel0900a892014-06-30 16:26:21 +000079
80 query = "[orth=\"M(a|ä)nn(er)?\"/x]";
81 String re2 = "{@type=korap:token, wrap={@type=korap:term, layer=orth, type=type:regex, key=.*?M(a|ä)nn(er)?.*?, match=match:eq}}";
82 ppt = new PoliqarpPlusTree(query);
83 map = ppt.getRequestMap().get("query").toString();
84 assertEquals(re2.replaceAll(" ", ""), map.replaceAll(" ", ""));
85
86 query = "\"M(a|ä)nn(er)?\"/x";
87 String re3 = "{@type=korap:token, wrap={@type=korap:term, type=type:regex, layer=orth, key=.*?M(a|ä)nn(er)?.*?, match=match:eq}}";
88 ppt = new PoliqarpPlusTree(query);
89 map = ppt.getRequestMap().get("query").toString();
90 assertEquals(re3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld1a3e712014-07-16 08:02:05 +000091
92 query = "schland/x";
Joachim Bingela83f8cc2014-08-05 14:12:59 +000093 String re4 = "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=.*?schland.*?, match=match:eq, type=type:regex}}";
Joachim Bingeld1a3e712014-07-16 08:02:05 +000094 ppt = new PoliqarpPlusTree(query);
95 map = ppt.getRequestMap().get("query").toString();
96 assertEquals(re4.replaceAll(" ", ""), map.replaceAll(" ", ""));
97
98 query = "\".*?Mann.*?\"";
99 String re5 = "{@type=korap:token, wrap={@type=korap:term, type=type:regex, layer=orth, key=.*?Mann.*?, match=match:eq}}";
100 ppt = new PoliqarpPlusTree(query);
101 map = ppt.getRequestMap().get("query").toString();
102 assertEquals(re5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingela83f8cc2014-08-05 14:12:59 +0000103
104 query = "z.B./x";
105 String re6 = "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=.*?z\\.B\\..*?, match=match:eq, type=type:regex}}";
106 ppt = new PoliqarpPlusTree(query);
107 map = ppt.getRequestMap().get("query").toString();
108 assertEquals(re6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel41e112e2014-02-12 10:46:18 +0000109 }
110
111 @Test
Joachim Bingel0207d5e2014-02-12 14:18:41 +0000112 public void testCaseSensitivityFlag() throws QueryException {
113 String query="[orth=deutscher/i]";
114 String cs1 =
Joachim Bingel0900a892014-06-30 16:26:21 +0000115 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=deutscher, match=match:eq, caseInsensitive=true}}";
Joachim Bingel0207d5e2014-02-12 14:18:41 +0000116 ppt = new PoliqarpPlusTree(query);
117 map = ppt.getRequestMap().get("query").toString();
118 assertEquals(cs1.replaceAll(" ", ""), map.replaceAll(" ", ""));
119
120 query="[orth=deutscher/i][orth=Bundestag]";
121 String cs2 =
122 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000123 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=deutscher, match=match:eq, caseInsensitive=true}}," +
124 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Bundestag, match=match:eq}}" +
Joachim Bingel0207d5e2014-02-12 14:18:41 +0000125 "]}";
126 ppt = new PoliqarpPlusTree(query);
127 map = ppt.getRequestMap().get("query").toString();
128 assertEquals(cs2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeladd0fb12014-06-24 08:54:14 +0000129
130 query="deutscher/i";
131 String cs3 =
Joachim Bingel0900a892014-06-30 16:26:21 +0000132 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=deutscher, match=match:eq, caseInsensitive=true}}";
Joachim Bingeladd0fb12014-06-24 08:54:14 +0000133 ppt = new PoliqarpPlusTree(query);
134 map = ppt.getRequestMap().get("query").toString();
135 assertEquals(cs3.replaceAll(" ", ""), map.replaceAll(" ", ""));
136
137 query="deutscher/i Bundestag";
138 String cs4 =
139 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000140 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=deutscher, match=match:eq, caseInsensitive=true}}," +
141 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Bundestag, match=match:eq}}" +
Joachim Bingeladd0fb12014-06-24 08:54:14 +0000142 "]}";
143 ppt = new PoliqarpPlusTree(query);
144 map = ppt.getRequestMap().get("query").toString();
145 assertEquals(cs4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelf8dfcf82014-06-25 09:57:44 +0000146
147 query="deutscher Bundestag/i";
148 String cs5 =
149 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000150 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=deutscher, match=match:eq}}," +
151 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Bundestag, match=match:eq, caseInsensitive=true}}" +
Joachim Bingelf8dfcf82014-06-25 09:57:44 +0000152 "]}";
153 ppt = new PoliqarpPlusTree(query);
154 map = ppt.getRequestMap().get("query").toString();
155 assertEquals(cs5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel0207d5e2014-02-12 14:18:41 +0000156 }
157
158 @Test
Joachim Bingel3a41a442014-07-22 12:16:16 +0000159 public void testSpans() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000160 // <s>
Joachim Bingel2daf9862014-02-12 10:18:54 +0000161 String elem1 = "{@type=korap:span, key=s}";
Joachim Bingel53333e62013-12-09 19:25:52 +0000162 assertTrue(equalsQueryContent(elem1, "<s>"));
163
164 // <vp>
Joachim Bingel2daf9862014-02-12 10:18:54 +0000165 String elem2 = "{@type=korap:span, key=vp}";
Joachim Bingel53333e62013-12-09 19:25:52 +0000166 assertTrue(equalsQueryContent(elem2, "<vp>"));
Joachim Bingelfc1fb352014-02-26 14:40:27 +0000167
168 // <cnx/c=vp>
169 query = "<c=vp>";
170 String span3 = "{@type=korap:span, layer=c, key=vp}";
171 ppt = new PoliqarpPlusTree(query);
172 map = ppt.getRequestMap().get("query").toString();
173 assertEquals(span3.replaceAll(" ", ""), map.replaceAll(" ", ""));
174
175 // <cnx/c=vp>
176 query = "<cnx/c=vp>";
177 String span4 = "{@type=korap:span, foundry=cnx, layer=c, key=vp}";
178 ppt = new PoliqarpPlusTree(query);
179 map = ppt.getRequestMap().get("query").toString();
180 assertEquals(span4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3a41a442014-07-22 12:16:16 +0000181
182 // span negation
183 query = "<cnx/c!=vp>";
184 expected = "{@type=korap:span, foundry=cnx, layer=c, key=vp, match=match:ne}";
185 ppt = new PoliqarpPlusTree(query);
186 map = ppt.getRequestMap().get("query").toString();
187 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
188
189 // span negation
190 query = "<cnx/c!=vp>";
191 expected = "{@type=korap:span, foundry=cnx, layer=c, key=vp, match=match:ne}";
192 ppt = new PoliqarpPlusTree(query);
193 map = ppt.getRequestMap().get("query").toString();
194 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
195
196 query = "<cnx/c=vp class!=header>";
197 expected = "{@type=korap:span, foundry=cnx, layer=c, key=vp, attr={@type=korap:term, key=class, value=header, match=match:ne}}";
198 ppt = new PoliqarpPlusTree(query);
199 map = ppt.getRequestMap().get("query").toString();
200 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
201
202 query = "<cnx/c=vp !(class=header&id=7)>";
203 expected =
204 "{@type=korap:span, foundry=cnx, layer=c, key=vp, attr=" +
205 "{@type=korap:termGroup, relation=relation:and, operands=[" +
206 "{@type=korap:term, key=class, value=header, match=match:ne}," +
207 "{@type=korap:term, key=id, value=7, match=match:ne}" +
208 "]}" +
209 "}";
210 ppt = new PoliqarpPlusTree(query);
211 map = ppt.getRequestMap().get("query").toString();
212 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
213
214 query = "<cnx/c!=vp (class=header&id=7)>";
215 expected =
216 "{@type=korap:span, foundry=cnx, layer=c, key=vp, match=match:ne, attr=" +
217 "{@type=korap:termGroup, relation=relation:and, operands=[" +
218 "{@type=korap:term, key=class, value=header, match=match:eq}," +
219 "{@type=korap:term, key=id, value=7, match=match:eq}" +
220 "]}" +
221 "}";
222 ppt = new PoliqarpPlusTree(query);
223 map = ppt.getRequestMap().get("query").toString();
224 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
225
226 query = "<cnx/c=vp !!class=header>";
227 expected = "{@type=korap:span, foundry=cnx, layer=c, key=vp, attr={@type=korap:term, key=class, value=header, match=match:eq}}";
228 ppt = new PoliqarpPlusTree(query);
229 map = ppt.getRequestMap().get("query").toString();
230 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingela0ef08f2014-07-24 08:27:57 +0000231
232 query = "<cnx/c!=vp (foundry/class=header&id=7)>";
233 expected =
234 "{@type=korap:span, foundry=cnx, layer=c, key=vp, match=match:ne, attr=" +
235 "{@type=korap:termGroup, relation=relation:and, operands=[" +
236 "{@type=korap:term, foundry=foundry, key=class, value=header, match=match:eq}," +
237 "{@type=korap:term, key=id, value=7, match=match:eq}" +
238 "]}" +
239 "}";
240 ppt = new PoliqarpPlusTree(query);
241 map = ppt.getRequestMap().get("query").toString();
242 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000243 }
Joachim Bingel87480d02014-01-17 14:07:46 +0000244
245 @Test
Joachim Bingel14239d82014-07-22 09:55:04 +0000246 public void testDistances() throws QueryException {
Joachim Bingel87480d02014-01-17 14:07:46 +0000247 // [base=der][][base=Mann]
248 String et1 =
Joachim Bingel0900a892014-06-30 16:26:21 +0000249 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000250 "operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000251 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
252 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
253 "], inOrder=true, distances=[" +
Joachim Bingel5a146cd2014-07-24 14:44:57 +0000254 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000255 "]}";
256 ppt = new PoliqarpPlusTree("[base=der][][base=Mann]");
257 map = ppt.getRequestMap().get("query").toString();
258 assertEquals(et1.replaceAll(" ", ""), map.replaceAll(" ", ""));
259
260 // [base=der][][][base=Mann]
261 String et2 =
Joachim Bingel0900a892014-06-30 16:26:21 +0000262 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000263 "operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000264 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
265 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
266 "], inOrder=true, distances=[" +
Joachim Bingel5a146cd2014-07-24 14:44:57 +0000267 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=3}, min=3, max=3}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000268 "]}";
Joachim Bingelffd65e32014-01-22 14:22:57 +0000269 ppt = new PoliqarpPlusTree("[base=der][][][base=Mann]");
Joachim Bingel87480d02014-01-17 14:07:46 +0000270 map = ppt.getRequestMap().get("query").toString();
271 assertEquals(et2.replaceAll(" ", ""), map.replaceAll(" ", ""));
272
273 // [base=der][][]?[base=Mann]
274 String et3 =
Joachim Bingel0900a892014-06-30 16:26:21 +0000275 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000276 "operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000277 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
278 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
279 "], inOrder=true, distances=[" +
Joachim Bingel5a146cd2014-07-24 14:44:57 +0000280 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=3}, min=2, max=3}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000281 "]}";
282 ppt = new PoliqarpPlusTree("[base=der][][]?[base=Mann]");
283 map = ppt.getRequestMap().get("query").toString();
284 assertEquals(et3.replaceAll(" ", ""), map.replaceAll(" ", ""));
285
Joachim Bingel87480d02014-01-17 14:07:46 +0000286
Joachim Bingel14239d82014-07-22 09:55:04 +0000287
Joachim Bingelffd65e32014-01-22 14:22:57 +0000288
Joachim Bingel11d5b152014-02-11 21:33:47 +0000289 // [base=der][]{2,5}[base=Mann][]?[][base=Frau] nested distances=
Joachim Bingelffd65e32014-01-22 14:22:57 +0000290 String et5 =
Joachim Bingel0900a892014-06-30 16:26:21 +0000291 "{@type=korap:group, operation=operation:sequence," +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000292 "operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000293 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
294 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000295 "operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000296 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," +
297 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Frau, match=match:eq}}" +
298 "], inOrder=true, distances=[" +
Joachim Bingel5a146cd2014-07-24 14:44:57 +0000299 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=3}, min=2, max=3}" +
Joachim Bingelffd65e32014-01-22 14:22:57 +0000300 "]}" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000301 "], inOrder=true, distances=[" +
Joachim Bingel5a146cd2014-07-24 14:44:57 +0000302 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=6}, min=3, max=6}" +
Joachim Bingelffd65e32014-01-22 14:22:57 +0000303 "]}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000304 ppt = new PoliqarpPlusTree("[base=der][]{2,5}[base=Mann][]?[][base=Frau]");
Joachim Bingel87480d02014-01-17 14:07:46 +0000305 map = ppt.getRequestMap().get("query").toString();
306 assertEquals(et5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000307
Joachim Bingelc15720f2014-05-07 14:37:23 +0000308 // [base=der][]*[base=Mann]
309 String et6 =
Joachim Bingel0900a892014-06-30 16:26:21 +0000310 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingelc15720f2014-05-07 14:37:23 +0000311 "operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000312 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
313 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
314 "], inOrder=true, distances=[" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000315 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1}, min=1}" +
Joachim Bingelc15720f2014-05-07 14:37:23 +0000316 "]}";
317 ppt = new PoliqarpPlusTree("[base=der][]*[base=Mann]");
318 map = ppt.getRequestMap().get("query").toString();
319 assertEquals(et6.replaceAll(" ", ""), map.replaceAll(" ", ""));
320
Joachim Bingel0900a892014-06-30 16:26:21 +0000321 // [base=der][]+[base=Mann]
Joachim Bingelc15720f2014-05-07 14:37:23 +0000322 String et7 =
Joachim Bingel0900a892014-06-30 16:26:21 +0000323 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingelc15720f2014-05-07 14:37:23 +0000324 "operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000325 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
326 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
327 "], inOrder=true, distances=[" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000328 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2}, min=2}" +
Joachim Bingelc15720f2014-05-07 14:37:23 +0000329 "]}";
330 ppt = new PoliqarpPlusTree("[base=der][]+[base=Mann]");
331 map = ppt.getRequestMap().get("query").toString();
332 assertEquals(et7.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel14239d82014-07-22 09:55:04 +0000333
334 // [base=der][]+[base=Mann]
335 String et8 =
336 "{@type=korap:group, operation=operation:sequence, " +
337 "operands=[" +
338 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
339 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
340 "], inOrder=true, distances=[" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000341 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=103}, min=2, max=103}" +
Joachim Bingel14239d82014-07-22 09:55:04 +0000342 "]}";
343 ppt = new PoliqarpPlusTree("[base=der][]{1,102}[base=Mann]");
344 map = ppt.getRequestMap().get("query").toString();
345 assertEquals(et8.replaceAll(" ", ""), map.replaceAll(" ", ""));
346
347 // [base=geht][base=der][]*[base=Mann]
348 String et9 =
349 "{@type=korap:group, operation=operation:sequence, operands=[" +
350 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=geht, match=match:eq}}," +
351 "{@type=korap:group, operation=operation:sequence, " +
352 "operands=[" +
353 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
354 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
355 "], inOrder=true, distances=[" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000356 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1}, min=1}" +
Joachim Bingel14239d82014-07-22 09:55:04 +0000357 "]}" +
358 "]}";
359 ppt = new PoliqarpPlusTree("[base=geht][base=der][]*[base=Mann]");
360 map = ppt.getRequestMap().get("query").toString();
361 assertEquals(et9.replaceAll(" ", ""), map.replaceAll(" ", ""));
362
363 query = "[base=geht][base=der][]*[base=Mann][base=da]";
364 expected =
365 "{@type=korap:group, operation=operation:sequence, operands=[" +
366 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=geht, match=match:eq}}," +
367 "{@type=korap:group, operation=operation:sequence, " +
368 "operands=[" +
369 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
370 "{@type=korap:group, operation=operation:sequence, operands=[" +
371 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," +
372 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=da, match=match:eq}}" +
373 "]}" +
374 "], inOrder=true, distances=[" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000375 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1}, min=1}" +
Joachim Bingel14239d82014-07-22 09:55:04 +0000376 "]}" +
377 "]}";
378 ppt = new PoliqarpPlusTree(query);
379 map = ppt.getRequestMap().get("query").toString();
380 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
381
382 query = "[base=geht][base=der][]*contains(<s>,<np>)";
383 expected =
384 "{@type=korap:group, operation=operation:sequence, operands=[" +
385 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=geht, match=match:eq}}," +
386 "{@type=korap:group, operation=operation:sequence, " +
387 "operands=[" +
388 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
Joachim Bingel6b52d762014-09-30 15:29:11 +0000389 "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel14239d82014-07-22 09:55:04 +0000390 "{@type=korap:span, key=s}," +
391 "{@type=korap:span, key=np}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +0000392 "], frame=frame:contains}" +
Joachim Bingel14239d82014-07-22 09:55:04 +0000393 "], inOrder=true, distances=[" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000394 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1}, min=1}" +
Joachim Bingel14239d82014-07-22 09:55:04 +0000395 "]}" +
396 "]}";
397 ppt = new PoliqarpPlusTree(query);
398 map = ppt.getRequestMap().get("query").toString();
399 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000400 }
Joachim Bingel53333e62013-12-09 19:25:52 +0000401
402 @Test
Joachim Bingelbd386362014-10-02 12:03:18 +0000403 public void testDistancesWithClass() throws QueryException {
404 query = "[base=der]{1:[]}[base=Mann]";
405 expected =
406 "{@type=korap:group, operation=operation:sequence, operands=[" +
407 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
408 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
409 "{@type=korap:token}" +
410 "]}," +
411 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
412 "]}";
413 ppt = new PoliqarpPlusTree(query);
414 map = ppt.getRequestMap().get("query").toString();
415 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
416
417 query = "{1:[]}[base=der][base=Mann]";
418 expected =
419 "{@type=korap:group, operation=operation:sequence, operands=[" +
420 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
421 "{@type=korap:token}" +
422 "]}," +
423 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
424 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
425 "]}";
426 ppt = new PoliqarpPlusTree(query);
427 map = ppt.getRequestMap().get("query").toString();
428 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
429 }
430
431 @Test
Joachim Bingel14239d82014-07-22 09:55:04 +0000432 public void testLeadingTrailingEmptyTokens() throws QueryException {
433 // startswith(<s>, [][base=Mann]
434 String et1 =
Joachim Bingel6b52d762014-09-30 15:29:11 +0000435 "{@type=korap:group, operation=operation:position, frames=[frame:startswith],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel14239d82014-07-22 09:55:04 +0000436 "{@type=korap:span, key=s}," +
437 "{@type=korap:group, operation=operation:sequence, operands=[" +
438 "{@type=korap:token}," +
439 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
440 "]}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +0000441 "], frame=frame:startswith}";
Joachim Bingel14239d82014-07-22 09:55:04 +0000442 ppt = new PoliqarpPlusTree("startswith(<s>, [][base=Mann])");
443 map = ppt.getRequestMap().get("query").toString();
444 assertEquals(et1.replaceAll(" ", ""), map.replaceAll(" ", ""));
445
446 query = "[][base=Mann]";
447 expected =
448 "{@type=korap:group, operation=operation:sequence, operands=[" +
449 "{@type=korap:token}," +
450 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
451 "]}";
452 ppt = new PoliqarpPlusTree(query);
453 map = ppt.getRequestMap().get("query").toString();
454 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
455
456 query = "[][][base=Mann]";
457 expected =
458 "{@type=korap:group, operation=operation:sequence, operands=[" +
459 "{@type=korap:group, operation=operation:repetition, operands=[" +
460 "{@type=korap:token}" +
Joachim Bingel61631562014-07-24 14:26:02 +0000461 "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}," +
Joachim Bingel14239d82014-07-22 09:55:04 +0000462 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
463 "]}";
464 ppt = new PoliqarpPlusTree(query);
465 map = ppt.getRequestMap().get("query").toString();
466 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
467
468 query = "[][]*[base=Mann]";
469 expected =
470 "{@type=korap:group, operation=operation:sequence, operands=[" +
471 "{@type=korap:group, operation=operation:repetition, operands=[" +
472 "{@type=korap:token}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000473 "], boundary={@type=korap:boundary, min=1}, min=1}," +
Joachim Bingel14239d82014-07-22 09:55:04 +0000474 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
475 "]}";
476 ppt = new PoliqarpPlusTree(query);
477 map = ppt.getRequestMap().get("query").toString();
478 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
479
480 query = "[][]*[base=Mann][][]";
481 expected =
482 "{@type=korap:group, operation=operation:sequence, operands=[" +
483 "{@type=korap:group, operation=operation:repetition, operands=[" +
484 "{@type=korap:token}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000485 "], boundary={@type=korap:boundary, min=1}, min=1}," +
Joachim Bingel14239d82014-07-22 09:55:04 +0000486 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," +
487 "{@type=korap:group, operation=operation:repetition, operands=[" +
488 "{@type=korap:token}" +
Joachim Bingel61631562014-07-24 14:26:02 +0000489 "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}" +
Joachim Bingel14239d82014-07-22 09:55:04 +0000490 "]}";
491 ppt = new PoliqarpPlusTree(query);
492 map = ppt.getRequestMap().get("query").toString();
493 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
494
495 query = "[][]*contains(<s>, <np>)[][]";
496 expected =
497 "{@type=korap:group, operation=operation:sequence, operands=[" +
498 "{@type=korap:group, operation=operation:repetition, operands=[" +
499 "{@type=korap:token}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000500 "], boundary={@type=korap:boundary, min=1}, min=1}," +
Joachim Bingel6b52d762014-09-30 15:29:11 +0000501 "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel14239d82014-07-22 09:55:04 +0000502 "{@type=korap:span, key=s}," +
503 "{@type=korap:span, key=np}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +0000504 "], frame=frame:contains}," +
Joachim Bingel14239d82014-07-22 09:55:04 +0000505 "{@type=korap:group, operation=operation:repetition, operands=[" +
506 "{@type=korap:token}" +
Joachim Bingel61631562014-07-24 14:26:02 +0000507 "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}" +
Joachim Bingel14239d82014-07-22 09:55:04 +0000508 "]}";
509 ppt = new PoliqarpPlusTree(query);
510 map = ppt.getRequestMap().get("query").toString();
511 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
512 }
513
514 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000515 public void testCoordinatedFields() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000516 // [base=Mann&(cas=N|cas=A)]
517 String cof1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000518 "{@type=korap:token, wrap=" +
Joachim Bingel2980bda2014-04-04 12:09:46 +0000519 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000520 "{@type=korap:term, layer=lemma, key=Mann, match=match:eq}," +
Joachim Bingel2980bda2014-04-04 12:09:46 +0000521 "{@type=korap:termGroup, relation=relation:or, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000522 "{@type=korap:term, layer=cas, key=N, match=match:eq}," +
523 "{@type=korap:term, layer=cas, key=A, match=match:eq}" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000524 "]}" +
525 "]}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000526 "}";
527 ppt = new PoliqarpPlusTree("[base=Mann&(cas=N|cas=A)]");
528 map = ppt.getRequestMap().get("query").toString();
529 assertEquals(cof1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Nils Diewald7d486c22013-12-13 16:32:18 +0000530
531
532 assertEquals(
533 new PoliqarpPlusTree(" [ base=Mann & ( cas=N | cas=A)] ").getRequestMap().get("query").toString(),
534 new PoliqarpPlusTree("[base=Mann &(cas=N|cas=A)]").getRequestMap().get("query").toString()
535 );
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000536
537 // [base=Mann&cas=N&gen=m]
538 String cof2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000539 "{@type=korap:token, wrap=" +
Joachim Bingel2980bda2014-04-04 12:09:46 +0000540 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000541 "{@type=korap:term, layer=lemma, key=Mann, match=match:eq}," +
542 "{@type=korap:termGroup, relation=relation:and, operands=[" +
543 "{@type=korap:term, layer=cas, key=N, match=match:eq}," +
544 "{@type=korap:term, layer=gen, key=m, match=match:eq}" +
545 "]}" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000546 "]}" +
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000547 "}";
548 ppt = new PoliqarpPlusTree("[base=Mann&cas=N&gen=m]");
549 map = ppt.getRequestMap().get("query").toString();
550 assertEquals(cof2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000551 }
552
553 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000554 public void testOccurrence() throws QueryException {
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000555 // [base=foo]*
Joachim Bingel33bd45f2014-06-25 15:00:54 +0000556 String occ1 = "{@type=korap:group, operation=operation:repetition, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000557 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000558 "], boundary={@type=korap:boundary, min=0}, min=0}";
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000559 ppt = new PoliqarpPlusTree("[base=foo]*");
560 map = ppt.getRequestMap().get("query").toString();
561 assertEquals(occ1.replaceAll(" ", ""), map.replaceAll(" ", ""));
562
563 // [base=foo]*[base=bar]
564 String occ2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000565 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel33bd45f2014-06-25 15:00:54 +0000566 "{@type=korap:group, operation=operation:repetition, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000567 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000568 "], boundary={@type=korap:boundary, min=0}, min=0 }," +
Joachim Bingel0900a892014-06-30 16:26:21 +0000569 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000570 "]}";
571 ppt = new PoliqarpPlusTree("[base=foo]*[base=bar]");
572 map = ppt.getRequestMap().get("query").toString();
573 assertEquals(occ2.replaceAll(" ", ""), map.replaceAll(" ", ""));
574
575 // [base=bar][base=foo]*
576 String occ3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000577 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000578 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
Joachim Bingel33bd45f2014-06-25 15:00:54 +0000579 "{@type=korap:group, operation=operation:repetition, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000580 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000581 "], boundary={@type=korap:boundary, min=0}, min=0 }" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000582 "]}";
583 ppt = new PoliqarpPlusTree("[base=bar][base=foo]*");
584 map = ppt.getRequestMap().get("query").toString();
585 assertEquals(occ3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb4da7022013-12-09 23:17:24 +0000586
587 // ([base=bar][base=foo])*
588 String occ4 =
Joachim Bingel0900a892014-06-30 16:26:21 +0000589 "{@type=korap:group, operation=operation:repetition, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000590 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000591 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
592 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000593 "]}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000594 "], boundary={@type=korap:boundary, min=0}, min=0}" ;
Joachim Bingelb4da7022013-12-09 23:17:24 +0000595 ppt = new PoliqarpPlusTree("([base=bar][base=foo])*");
596 map = ppt.getRequestMap().get("query").toString();
597 assertEquals(occ4.replaceAll(" ", ""), map.replaceAll(" ", ""));
598
599 // <s>([base=bar][base=foo])*
600 String occ5 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000601 "{@type=korap:group, operation=operation:sequence, operands=[" +
602 "{@type=korap:span, key=s}," +
Joachim Bingel0900a892014-06-30 16:26:21 +0000603 "{@type=korap:group, operation=operation:repetition, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000604 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000605 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
606 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000607 "]}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000608 "], boundary={@type=korap:boundary, min=0}, min=0 }" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000609 "]}" ;
610 ppt = new PoliqarpPlusTree("<s>([base=bar][base=foo])*");
611 map = ppt.getRequestMap().get("query").toString();
612 assertEquals(occ5.replaceAll(" ", ""), map.replaceAll(" ", ""));
613
614 // <s><np>([base=bar][base=foo])*
Joachim Bingelb4da7022013-12-09 23:17:24 +0000615 String occ6 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000616 "{@type=korap:group, operation=operation:sequence, operands=[" +
617 "{@type=korap:span, key=s}," +
618 "{@type=korap:span, key=np}," +
Joachim Bingel0900a892014-06-30 16:26:21 +0000619 "{@type=korap:group, operation=operation:repetition, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000620 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000621 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
622 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000623 "]}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000624 "], boundary={@type=korap:boundary, min=0}, min=0 }" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000625 "]}" ;
626 ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*");
627 map = ppt.getRequestMap().get("query").toString();
628 assertEquals(occ6.replaceAll(" ", ""), map.replaceAll(" ", ""));
629
630 // <s><np>([base=bar][base=foo])*[p=NN]
631 // comment: embedded sequence shouldn't really be here, but does not really hurt, either. (?)
632 // really hard to get this behaviour out of the PQPlus grammar...
633 String occ7 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000634 "{@type=korap:group, operation=operation:sequence, operands=[" +
635 "{@type=korap:span, key=s}," +
636 "{@type=korap:span, key=np}," +
Joachim Bingel0900a892014-06-30 16:26:21 +0000637 "{@type=korap:group, operation=operation:repetition, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000638 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000639 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
640 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000641 "]}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000642 "], boundary={@type=korap:boundary, min=0}, min=0 }," +
Joachim Bingel0900a892014-06-30 16:26:21 +0000643 "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000644 "]}" ;
645 ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*[p=NN]");
646 map = ppt.getRequestMap().get("query").toString();
647 assertEquals(occ7.replaceAll(" ", ""), map.replaceAll(" ", ""));
648
649 // ([base=bar][base=foo])*[p=NN]
Joachim Bingelb4da7022013-12-09 23:17:24 +0000650 String occ8 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000651 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000652 "{@type=korap:group, operation=operation:repetition, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000653 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000654 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
655 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000656 "]}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000657 "], boundary={@type=korap:boundary, min=0}, min=0 }," +
Joachim Bingel0900a892014-06-30 16:26:21 +0000658 "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000659 "]}" ;
660 ppt = new PoliqarpPlusTree("([base=bar][base=foo])*[p=NN]");
661 map = ppt.getRequestMap().get("query").toString();
662 assertEquals(occ8.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000663
664 // [base=foo]+
Joachim Bingel33bd45f2014-06-25 15:00:54 +0000665 String occ9 = "{@type=korap:group, operation=operation:repetition, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000666 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000667 "], boundary={@type=korap:boundary, min=1}, min=1}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000668 ppt = new PoliqarpPlusTree("[base=foo]+");
669 map = ppt.getRequestMap().get("query").toString();
670 assertEquals(occ9.replaceAll(" ", ""), map.replaceAll(" ", ""));
671
672 // [base=foo]?
Joachim Bingel33bd45f2014-06-25 15:00:54 +0000673 String occ10 = "{@type=korap:group, operation=operation:repetition, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000674 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
Joachim Bingel61631562014-07-24 14:26:02 +0000675 "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000676 ppt = new PoliqarpPlusTree("[base=foo]?");
677 map = ppt.getRequestMap().get("query").toString();
678 assertEquals(occ10.replaceAll(" ", ""), map.replaceAll(" ", ""));
679
680 // [base=foo]{2,5}
Joachim Bingel33bd45f2014-06-25 15:00:54 +0000681 String occ11 = "{@type=korap:group, operation=operation:repetition, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000682 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
Joachim Bingel61631562014-07-24 14:26:02 +0000683 "], boundary={@type=korap:boundary, min=2, max=5}, min=2, max=5}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000684 ppt = new PoliqarpPlusTree("[base=foo]{2,5}");
685 map = ppt.getRequestMap().get("query").toString();
686 assertEquals(occ11.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel2980bda2014-04-04 12:09:46 +0000687
688 // [base=foo]{2}
Joachim Bingel33bd45f2014-06-25 15:00:54 +0000689 String occ12 = "{@type=korap:group, operation=operation:repetition, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000690 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
Joachim Bingel61631562014-07-24 14:26:02 +0000691 "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}";
Joachim Bingel2980bda2014-04-04 12:09:46 +0000692 ppt = new PoliqarpPlusTree("[base=foo]{2}");
693 map = ppt.getRequestMap().get("query").toString();
694 assertEquals(occ12.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb2aa1c72014-07-01 12:48:46 +0000695
696 // [base=foo]{2}
697 String occ13 = "{@type=korap:group, operation=operation:repetition, operands=[" +
698 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000699 "], boundary={@type=korap:boundary, min=2}, min=2}";
Joachim Bingelb2aa1c72014-07-01 12:48:46 +0000700 ppt = new PoliqarpPlusTree("[base=foo]{2,}");
701 map = ppt.getRequestMap().get("query").toString();
702 assertEquals(occ13.replaceAll(" ", ""), map.replaceAll(" ", ""));
703
704 // [base=foo]{2}
705 String occ14 = "{@type=korap:group, operation=operation:repetition, operands=[" +
706 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
Joachim Bingel61631562014-07-24 14:26:02 +0000707 "], boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}";
Joachim Bingelb2aa1c72014-07-01 12:48:46 +0000708 ppt = new PoliqarpPlusTree("[base=foo]{,2}");
709 map = ppt.getRequestMap().get("query").toString();
710 assertEquals(occ14.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000711 }
712
713 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000714 public void testTokenSequence() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000715 // [base=Mann][orth=Frau]
Joachim Bingel2daf9862014-02-12 10:18:54 +0000716 String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000717 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " +
718 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000719 "]}";
720 assertTrue(equalsQueryContent(seq1, "[base=Mann][orth=Frau]"));
721
722 // [base=Mann][orth=Frau][p=NN]
Joachim Bingel2daf9862014-02-12 10:18:54 +0000723 String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000724 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " +
725 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}, " +
726 "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000727 "]}";
728 assertTrue(equalsQueryContent(seq2, "[base=Mann][orth=Frau][p=NN]"));
729 }
730
731 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000732 public void testDisjSegments() throws QueryException {
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000733 // ([base=der]|[base=das])[base=Schild]
734 String disj1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000735 "{@type=korap:group, operation=operation:sequence, operands=[" +
736 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000737 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
738 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=das, match=match:eq}}" +
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000739 "]}," +
Joachim Bingel0900a892014-06-30 16:26:21 +0000740 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Schild, match=match:eq}}" +
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000741 "]}";
742 ppt = new PoliqarpPlusTree("([base=der]|[base=das])[base=Schild]");
743 map = ppt.getRequestMap().get("query").toString();
744 assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", ""));
745
746 // [base=Schild]([base=der]|[base=das])
747 String disj2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000748 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000749 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Schild, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000750 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000751 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
752 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=das, match=match:eq}}" +
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000753 "]}" +
754 "]}";
755 ppt = new PoliqarpPlusTree("[base=Schild]([base=der]|[base=das])");
756 map = ppt.getRequestMap().get("query").toString();
757 assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel76b498d2014-06-06 12:06:46 +0000758
759 // "([orth=der][base=katze])|([orth=eine][base=baum])"
760 String disj3 =
761 "{@type=korap:group, operation=operation:or, operands=[" +
762 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000763 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
764 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=katze, match=match:eq}}" +
Joachim Bingel76b498d2014-06-06 12:06:46 +0000765 "]}," +
766 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000767 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=eine, match=match:eq}}," +
768 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=baum, match=match:eq}}" +
Joachim Bingel76b498d2014-06-06 12:06:46 +0000769 "]}" +
770 "]}";
771 ppt = new PoliqarpPlusTree("([orth=der][base=katze])|([orth=eine][base=baum])");
772 map = ppt.getRequestMap().get("query").toString();
773 assertEquals(disj3.replaceAll(" ", ""), map.replaceAll(" ", ""));
774
775 // "[orth=der][base=katze]|[orth=eine][base=baum]"
776 String disj4 =
777 "{@type=korap:group, operation=operation:or, operands=[" +
778 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000779 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
780 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=katze, match=match:eq}}" +
Joachim Bingel76b498d2014-06-06 12:06:46 +0000781 "]}," +
782 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000783 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=eine, match=match:eq}}," +
784 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=baum, match=match:eq}}" +
Joachim Bingel76b498d2014-06-06 12:06:46 +0000785 "]}" +
786 "]}";
787 ppt = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=eine][base=baum]");
788 map = ppt.getRequestMap().get("query").toString();
789 assertEquals(disj4.replaceAll(" ", ""), map.replaceAll(" ", ""));
790
791 PoliqarpPlusTree ppt1 = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=eine][base=baum]");
792 PoliqarpPlusTree ppt2 = new PoliqarpPlusTree("([orth=der][base=katze])|([orth=eine][base=baum])");
793 assertEquals(ppt1.getRequestMap().toString(), ppt2.getRequestMap().toString());
794
795 // "[orth=der][base=katze]|[orth=der][base=hund]|[orth=der][base=baum]"
796 String disj5 =
797 "{@type=korap:group, operation=operation:or, operands=[" +
798 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000799 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
800 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=katze, match=match:eq}}" +
Joachim Bingel76b498d2014-06-06 12:06:46 +0000801 "]}," +
802 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000803 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
804 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=hund, match=match:eq}}" +
Joachim Bingel76b498d2014-06-06 12:06:46 +0000805 "]}," +
806 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000807 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
808 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=baum, match=match:eq}}" +
Joachim Bingel76b498d2014-06-06 12:06:46 +0000809 "]}" +
810 "]}";
811 ppt = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=der][base=hund]|[orth=der][base=baum]");
812 map = ppt.getRequestMap().get("query").toString();
813 assertEquals(disj5.replaceAll(" ", ""), map.replaceAll(" ", ""));
814
815 // [orth=der]([base=katze]|[base=hund]|[base=baum])
816 String disj6 =
817 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000818 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
Joachim Bingel76b498d2014-06-06 12:06:46 +0000819 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000820 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=katze, match=match:eq}}," +
821 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=hund, match=match:eq}}," +
822 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=baum, match=match:eq}}" +
Joachim Bingel76b498d2014-06-06 12:06:46 +0000823 "]}" +
824 "]}";
825 ppt = new PoliqarpPlusTree("[orth=der]([base=katze]|[base=hund]|[base=baum])");
826 map = ppt.getRequestMap().get("query").toString();
827 assertEquals(disj6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000828 }
829
830 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000831 public void testTokenElemSequence() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000832 // [base=Mann]<vp>
Joachim Bingel2daf9862014-02-12 10:18:54 +0000833 String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000834 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000835 "{@type=korap:span, key=vp}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000836 "]}";
837 assertTrue(equalsQueryContent(seq1, "[base=Mann]<vp>"));
838
839 // <vp>[base=Mann]
Joachim Bingel2daf9862014-02-12 10:18:54 +0000840 String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" +
841 "{@type=korap:span, key=vp}, "+
Joachim Bingel0900a892014-06-30 16:26:21 +0000842 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}} " +
Joachim Bingel53333e62013-12-09 19:25:52 +0000843 "]}";
844 assertTrue(equalsQueryContent(seq2, "<vp>[base=Mann]"));
845
846 // <vp>[base=Mann]<pp>
Joachim Bingel2daf9862014-02-12 10:18:54 +0000847 String seq3 = "{@type=korap:group, operation=operation:sequence, operands=[" +
848 "{@type=korap:span, key=vp}, "+
Joachim Bingel0900a892014-06-30 16:26:21 +0000849 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000850 "{@type=korap:span, key=pp} "+
Joachim Bingel53333e62013-12-09 19:25:52 +0000851 "]}";
852 assertTrue(equalsQueryContent(seq3, "<vp>[base=Mann]<pp>"));
853 }
854
855 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000856 public void testElemSequence() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000857 // <np><vp>
Joachim Bingel2daf9862014-02-12 10:18:54 +0000858 String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" +
859 "{@type=korap:span, key=np}," +
860 "{@type=korap:span, key=vp}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000861 "]}";
862 assertTrue(equalsQueryContent(seq1, "<np><vp>"));
863
864 // <np><vp><pp>
Joachim Bingel2daf9862014-02-12 10:18:54 +0000865 String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" +
866 "{@type=korap:span, key=np}," +
867 "{@type=korap:span, key=vp}," +
868 "{@type=korap:span, key=pp}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000869 "]}";
870 assertTrue(equalsQueryContent(seq2, "<np><vp><pp>"));
871 }
872
873 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000874 public void testClasses() throws QueryException {
Joachim Bingel0900a892014-06-30 16:26:21 +0000875 String query;
Joachim Bingel53333e62013-12-09 19:25:52 +0000876 // {[base=Mann]}
Joachim Bingel2daf9862014-02-12 10:18:54 +0000877 String cls1 = "{@type=korap:group, operation=operation:class, class=0, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000878 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000879 "]}";
Joachim Bingel8c640e42014-02-07 16:20:47 +0000880 ppt = new PoliqarpPlusTree("{[base=Mann]}");
881 map = ppt.getRequestMap().get("query").toString();
882 assertEquals(cls1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000883
884 // {[base=Mann][orth=Frau]}
Joachim Bingel0900a892014-06-30 16:26:21 +0000885 query = "{[base=Mann][orth=Frau]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000886 String cls2 = "{@type=korap:group, operation=operation:class, class=0, operands=[" +
887 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000888 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," +
889 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000890 "]}" +
891 "]}";
Joachim Bingel0900a892014-06-30 16:26:21 +0000892 ppt = new PoliqarpPlusTree(query);
893 map = ppt.getRequestMap().get("query").toString();
894 assertEquals(cls2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000895
896 // [p=NN]{[base=Mann][orth=Frau]}
Joachim Bingel2daf9862014-02-12 10:18:54 +0000897 String cls3 = "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000898 "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000899 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
900 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000901 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," +
902 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000903 "]}" +
904 "]}" +
905 "]}";
Joachim Bingel33bd45f2014-06-25 15:00:54 +0000906 ppt = new PoliqarpPlusTree("[p=NN]{[base=Mann][orth=Frau]}");
907 map = ppt.getRequestMap().get("query").toString();
908 assertEquals(cls3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000909
910 // {[base=Mann][orth=Frau]}[p=NN]
Joachim Bingel2daf9862014-02-12 10:18:54 +0000911 String cls4 = "{@type=korap:group, operation=operation:sequence, operands=[" +
912 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
913 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000914 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," +
915 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000916 "]}" +
917 "]}," +
Joachim Bingel0900a892014-06-30 16:26:21 +0000918 "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000919 "]}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000920 ppt = new PoliqarpPlusTree("{[base=Mann][orth=Frau]}[p=NN]");
921 map = ppt.getRequestMap().get("query").toString();
922 assertEquals(cls4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000923
924 // {2:{1:[tt/p=ADJA]}[mate/p=NN]}"
Joachim Bingel2daf9862014-02-12 10:18:54 +0000925 String cls5 = "{@type=korap:group, operation=operation:class, class=2, operands=[" +
926 "{@type=korap:group, operation=operation:sequence, operands=[" +
927 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000928 "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=p, key=ADJA, match=match:eq}}" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000929 "]}," +
Joachim Bingel0900a892014-06-30 16:26:21 +0000930 "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=p, key=NN, match=match:eq}}" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000931 "]}" +
932 "]}";
933 ppt = new PoliqarpPlusTree("{2: {1:[tt/p=ADJA]}[mate/p=NN]}");
934 map = ppt.getRequestMap().get("query").toString();
935 assertEquals(cls5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000936 }
937
938 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000939 public void testPositions() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000940 // contains(<s>,<np>)
Joachim Bingel6b52d762014-09-30 15:29:11 +0000941 String pos1 = "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000942 "{@type=korap:span, key=s}," +
943 "{@type=korap:span, key=np}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +0000944 "], frame=frame:contains}";
Joachim Bingel53333e62013-12-09 19:25:52 +0000945 assertTrue(equalsQueryContent(pos1, "contains(<s>,<np>)"));
946
947 // contains(<s>,[base=Mann])
Joachim Bingel6b52d762014-09-30 15:29:11 +0000948 String pos2 = "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000949 "{@type=korap:span, key=s}," +
Joachim Bingel0900a892014-06-30 16:26:21 +0000950 "{@type=korap:token, wrap= {@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +0000951 "], frame=frame:contains}";
Joachim Bingel53333e62013-12-09 19:25:52 +0000952 assertTrue(equalsQueryContent(pos2, "contains(<s>,[base=Mann])"));
953
954 // contains(<s>,[orth=der][orth=Mann])
Joachim Bingel6b52d762014-09-30 15:29:11 +0000955 String pos3 = "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000956 "{@type=korap:span, key=s}," +
957 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000958 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
959 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000960 "]}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +0000961 "], frame=frame:contains}";
Joachim Bingel53333e62013-12-09 19:25:52 +0000962 ppt = new PoliqarpPlusTree("contains(<s>,[orth=der][orth=Mann])");
963 map = ppt.getRequestMap().get("query").toString();
964 assertEquals(pos3.replaceAll(" ", ""), map.replaceAll(" ", ""));
965
966 // [base=Auto]contains(<s>,[base=Mann])
967 String pos4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000968 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000969 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Auto, match=match:eq}}," +
Joachim Bingel6b52d762014-09-30 15:29:11 +0000970 "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000971 "{@type=korap:span, key=s}," +
Joachim Bingel0900a892014-06-30 16:26:21 +0000972 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +0000973 "], frame=frame:contains}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000974 "]}";
975 ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[base=Mann])");
976 map = ppt.getRequestMap().get("query").toString();
977 assertEquals(pos4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelef7059b2014-04-22 13:44:19 +0000978
979 // contains(<s>,[pos=N]*)
980 String pos5 =
Joachim Bingel6b52d762014-09-30 15:29:11 +0000981 "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingelef7059b2014-04-22 13:44:19 +0000982 "{@type=korap:span, key=s}," +
Joachim Bingel33bd45f2014-06-25 15:00:54 +0000983 "{@type=korap:group, operation=operation:repetition, " +
Joachim Bingel0900a892014-06-30 16:26:21 +0000984 "operands=[{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000985 "], boundary={@type=korap:boundary, min=0}, min=0" +
Joachim Bingelef7059b2014-04-22 13:44:19 +0000986 "}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +0000987 "], frame=frame:contains}";
Joachim Bingelef7059b2014-04-22 13:44:19 +0000988 ppt = new PoliqarpPlusTree("contains(<s>,[pos=N]*)");
989 map = ppt.getRequestMap().get("query").toString();
990 assertEquals(pos5.replaceAll(" ", ""), map.replaceAll(" ", ""));
991
992 // [base=Auto]contains(<s>,[pos=N]*)
993 String pos6 =
994 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +0000995 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Auto, match=match:eq}}," +
Joachim Bingel6b52d762014-09-30 15:29:11 +0000996 "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingelef7059b2014-04-22 13:44:19 +0000997 "{@type=korap:span, key=s}," +
Joachim Bingel33bd45f2014-06-25 15:00:54 +0000998 "{@type=korap:group, operation=operation:repetition, " +
Joachim Bingel0900a892014-06-30 16:26:21 +0000999 "operands=[{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}" +
Joachim Bingel687e4d42014-07-30 09:34:18 +00001000 "], boundary={@type=korap:boundary, min=0}, min=0" +
Joachim Bingelef7059b2014-04-22 13:44:19 +00001001 "}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +00001002 "], frame=frame:contains}" +
Joachim Bingelef7059b2014-04-22 13:44:19 +00001003 "]}";
1004 ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[pos=N]*)");
1005 map = ppt.getRequestMap().get("query").toString();
1006 assertEquals(pos6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +00001007 }
1008
1009 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +00001010 public void testNestedPositions() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +00001011 // contains(<s>,startswith(<np>,[orth=Der]))
1012 String npos1 =
Joachim Bingel6b52d762014-09-30 15:29:11 +00001013 "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001014 "{@type=korap:span, key=s}," +
Joachim Bingel6b52d762014-09-30 15:29:11 +00001015 "{@type=korap:group, operation=operation:position, frames=[frame:startswith],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001016 "{@type=korap:span, key=np}," +
Joachim Bingel0900a892014-06-30 16:26:21 +00001017 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +00001018 "], frame=frame:startswith}" +
1019 "], frame=frame:contains}";
Joachim Bingelcd9ed332013-12-09 21:01:35 +00001020 ppt = new PoliqarpPlusTree("contains(<s>, startswith(<np>,[orth=Der]))");
Joachim Bingel53333e62013-12-09 19:25:52 +00001021 map = ppt.getRequestMap().get("query").toString();
1022 assertEquals(npos1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1023 }
1024
1025 @Test
Joachim Bingel23c31ad2014-08-11 09:44:46 +00001026 public void testFocusSplit() throws QueryException {
Joachim Bingel0900a892014-06-30 16:26:21 +00001027 // focus([orth=Der]{[orth=Mann]})
Joachim Bingel53333e62013-12-09 19:25:52 +00001028 String shr1 =
Joachim Bingeld1a3e712014-07-16 08:02:05 +00001029 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001030 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001031 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001032 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001033 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +00001034 "]}" +
1035 "]}" +
1036 "]}";
Joachim Bingelf8dfcf82014-06-25 09:57:44 +00001037 ppt = new PoliqarpPlusTree("focus([orth=Der]{[orth=Mann]})");
Joachim Bingel53333e62013-12-09 19:25:52 +00001038 map = ppt.getRequestMap().get("query").toString();
1039 assertEquals(shr1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1040
Joachim Bingel0900a892014-06-30 16:26:21 +00001041 // focus([orth=Der]{[orth=Mann][orth=geht]})
Joachim Bingel53333e62013-12-09 19:25:52 +00001042 String shr2 =
Joachim Bingeld1a3e712014-07-16 08:02:05 +00001043 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001044 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001045 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001046 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
1047 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001048 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}," +
1049 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=geht, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +00001050 "]}" +
1051 "]}" +
1052 "]}" +
1053 "]}";
Joachim Bingelf8dfcf82014-06-25 09:57:44 +00001054 ppt = new PoliqarpPlusTree("focus([orth=Der]{[orth=Mann][orth=geht]})");
Joachim Bingel53333e62013-12-09 19:25:52 +00001055 map = ppt.getRequestMap().get("query").toString();
1056 assertEquals(shr2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1057
Joachim Bingel0900a892014-06-30 16:26:21 +00001058 // focus(1:[orth=Der]{1:[orth=Mann][orth=geht]})
Joachim Bingel53333e62013-12-09 19:25:52 +00001059 String shr3 =
Joachim Bingeld1a3e712014-07-16 08:02:05 +00001060 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001061 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001062 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001063 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
1064 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001065 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}," +
1066 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=geht, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +00001067 "]}" +
1068 "]}" +
1069 "]}" +
1070 "]}";
Joachim Bingelf8dfcf82014-06-25 09:57:44 +00001071 ppt = new PoliqarpPlusTree("focus(1:[orth=Der]{1:[orth=Mann][orth=geht]})");
Joachim Bingel53333e62013-12-09 19:25:52 +00001072 map = ppt.getRequestMap().get("query").toString();
1073 assertEquals(shr3.replaceAll(" ", ""), map.replaceAll(" ", ""));
1074
Joachim Bingel0900a892014-06-30 16:26:21 +00001075 // focus(1:startswith(<s>,{1:<np>}))
Joachim Bingel53333e62013-12-09 19:25:52 +00001076 String shr4 =
Joachim Bingeld1a3e712014-07-16 08:02:05 +00001077 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel6b52d762014-09-30 15:29:11 +00001078 "{@type=korap:group, operation=operation:position, frames=[frame:startswith],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001079 "{@type=korap:span, key=s}," +
1080 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
1081 "{@type=korap:span, key=np}" +
Joachim Bingel53333e62013-12-09 19:25:52 +00001082 "]}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +00001083 "], frame=frame:startswith}" +
Joachim Bingel53333e62013-12-09 19:25:52 +00001084 "]}";
Joachim Bingelf8dfcf82014-06-25 09:57:44 +00001085 ppt = new PoliqarpPlusTree("focus(1:startswith(<s>,{1:<np>}))");
Joachim Bingel53333e62013-12-09 19:25:52 +00001086 map = ppt.getRequestMap().get("query").toString();
1087 assertEquals(shr4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelcd9ed332013-12-09 21:01:35 +00001088
Joachim Bingel0900a892014-06-30 16:26:21 +00001089 // focus(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}}))
Joachim Bingelcd9ed332013-12-09 21:01:35 +00001090 String shr5 =
Joachim Bingeld1a3e712014-07-16 08:02:05 +00001091 "{@type=korap:reference, operation=operation:focus, classRef=[3], operands=[" +
Joachim Bingel6b52d762014-09-30 15:29:11 +00001092 "{@type=korap:group, operation=operation:position, frames=[frame:startswith],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001093 "{@type=korap:span, key=s}," +
1094 "{@type=korap:group, operation=operation:class, class=3, operands=[" +
1095 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001096 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001097 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
1098 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001099 "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=p, key=ADJA, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001100 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001101 "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=p, key=NN, match=match:eq}}" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +00001102 "]}" +
1103 "]}" +
1104 "]}" +
1105 "]}" +
1106 "]}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +00001107 "], frame=frame:startswith}" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +00001108 "]}";
Joachim Bingelf8dfcf82014-06-25 09:57:44 +00001109 ppt = new PoliqarpPlusTree("focus(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
Joachim Bingelcd9ed332013-12-09 21:01:35 +00001110 map = ppt.getRequestMap().get("query").toString();
1111 assertEquals(shr5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelba9a0ab2014-01-29 10:12:25 +00001112
1113 // split(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}}))
1114 String shr6 =
Joachim Bingeld1a3e712014-07-16 08:02:05 +00001115 "{@type=korap:reference, operation=operation:split, classRef=[3], operands=[" +
Joachim Bingel6b52d762014-09-30 15:29:11 +00001116 "{@type=korap:group, operation=operation:position, frames=[frame:startswith],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001117 "{@type=korap:span, key=s}," +
1118 "{@type=korap:group, operation=operation:class, class=3, operands=[" +
1119 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001120 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001121 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
1122 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001123 "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=p, key=ADJA, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001124 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001125 "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=p, key=NN, match=match:eq}}" +
Joachim Bingelba9a0ab2014-01-29 10:12:25 +00001126 "]}" +
1127 "]}" +
1128 "]}" +
1129 "]}" +
1130 "]}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +00001131 "], frame=frame:startswith}" +
Joachim Bingelba9a0ab2014-01-29 10:12:25 +00001132 "]}";
1133 ppt = new PoliqarpPlusTree("split(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
1134 map = ppt.getRequestMap().get("query").toString();
1135 assertEquals(shr6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel8c640e42014-02-07 16:20:47 +00001136
1137 // split(2|3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}}))
1138 String shr7 =
Joachim Bingeld1a3e712014-07-16 08:02:05 +00001139 "{@type=korap:reference, operation=operation:split, classRef=[2, 3], classRefOp=classRefOp:intersection, operands=[" +
Joachim Bingel6b52d762014-09-30 15:29:11 +00001140 "{@type=korap:group, operation=operation:position, frames=[frame:startswith],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001141 "{@type=korap:span, key=s}," +
1142 "{@type=korap:group, operation=operation:class, class=3, operands=[" +
1143 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001144 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001145 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
1146 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001147 "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=p, key=ADJA, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001148 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001149 "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=p, key=NN, match=match:eq}}" +
Joachim Bingel8c640e42014-02-07 16:20:47 +00001150 "]}" +
1151 "]}" +
1152 "]}" +
1153 "]}" +
1154 "]}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +00001155 "], frame=frame:startswith}" +
Joachim Bingel8c640e42014-02-07 16:20:47 +00001156 "]}";
1157 ppt = new PoliqarpPlusTree("split(2|3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
1158 map = ppt.getRequestMap().get("query").toString();
1159 assertEquals(shr7.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel5146ebe2014-06-12 08:49:21 +00001160
1161
1162 String shr8 =
Joachim Bingeld1a3e712014-07-16 08:02:05 +00001163 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingeladd0fb12014-06-24 08:54:14 +00001164 "{@type=korap:group, operation=operation:sequence, operands=[" +
1165 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001166 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}" +
Joachim Bingeladd0fb12014-06-24 08:54:14 +00001167 "]}," +
1168 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001169 "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=ADJA, match=match:eq}}" +
Joachim Bingel5146ebe2014-06-12 08:49:21 +00001170 "]}" +
Joachim Bingeladd0fb12014-06-24 08:54:14 +00001171 "]}" +
1172 "]}";
Joachim Bingelf8dfcf82014-06-25 09:57:44 +00001173 ppt = new PoliqarpPlusTree("focus(1:{[base=der]}{1:[pos=ADJA]})");
Joachim Bingeladd0fb12014-06-24 08:54:14 +00001174 map = ppt.getRequestMap().get("query").toString();
1175 assertEquals(shr8.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel5146ebe2014-06-12 08:49:21 +00001176
Joachim Bingel53333e62013-12-09 19:25:52 +00001177 }
1178
Joachim Bingel23c31ad2014-08-11 09:44:46 +00001179 @Test
1180 public void testSubspan() throws QueryException {
Joachim Bingel9bbd4fc2014-08-11 14:56:48 +00001181 query = "submatch(1,:<s>)";
Joachim Bingel23c31ad2014-08-11 09:44:46 +00001182 expected =
1183 "{@type=korap:reference, operation=operation:focus, operands=[" +
1184 "{@type=korap:span, key=s}" +
1185 "], spanRef=[1]" +
1186 "}";
1187 ppt = new PoliqarpPlusTree(query);
1188 map = ppt.getRequestMap().get("query").toString();
1189 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1190
Joachim Bingel9bbd4fc2014-08-11 14:56:48 +00001191 query = "submatch(1,4:<s>)";
Joachim Bingel23c31ad2014-08-11 09:44:46 +00001192 expected =
1193 "{@type=korap:reference, operation=operation:focus, operands=[" +
1194 "{@type=korap:span, key=s}" +
1195 "], spanRef=[1,4]" +
1196 "}";
1197 ppt = new PoliqarpPlusTree(query);
1198 map = ppt.getRequestMap().get("query").toString();
1199 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1200
Joachim Bingel9bbd4fc2014-08-11 14:56:48 +00001201 query = "submatch(1,4:contains(<s>,[base=Haus]))";
Joachim Bingel23c31ad2014-08-11 09:44:46 +00001202 expected =
1203 "{@type=korap:reference, operation=operation:focus, operands=[" +
Joachim Bingel6b52d762014-09-30 15:29:11 +00001204 "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel23c31ad2014-08-11 09:44:46 +00001205 "{@type=korap:span, key=s}," +
1206 "{@type=korap:token, wrap= {@type=korap:term, layer=lemma, key=Haus, match=match:eq}}" +
Joachim Bingel6b52d762014-09-30 15:29:11 +00001207 "], frame=frame:contains}" +
Joachim Bingel23c31ad2014-08-11 09:44:46 +00001208 "], spanRef=[1,4]" +
1209 "}";
1210 ppt = new PoliqarpPlusTree(query);
1211 map = ppt.getRequestMap().get("query").toString();
1212 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1213 }
1214
1215 @Test
1216 public void testRelations() throws QueryException {
1217 query = "relatesTo(<s>,<np>)";
1218 expected =
1219 "{@type=korap:group, operation=operation:relation, operands=[" +
1220 "{@type=korap:span, key=s}," +
1221 "{@type=korap:span, key=np}" +
1222 "], relation={@type=korap:relation}" +
1223 "}";
1224 ppt = new PoliqarpPlusTree(query);
1225 map = ppt.getRequestMap().get("query").toString();
1226 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1227
1228 query = "relatesTo([base=Baum],<np>)";
1229 expected =
1230 "{@type=korap:group, operation=operation:relation, operands=[" +
1231 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}," +
1232 "{@type=korap:span, key=np}" +
1233 "], relation={@type=korap:relation}" +
1234 "}";
1235 ppt = new PoliqarpPlusTree(query);
1236 map = ppt.getRequestMap().get("query").toString();
1237 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1238
1239 query = "dominates(<np>,[base=Baum])";
1240 expected =
1241 "{@type=korap:group, operation=operation:relation, operands=[" +
1242 "{@type=korap:span, key=np}," +
1243 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" +
1244 "], relation={@type=korap:relation, layer=c}" +
1245 "}";
1246 ppt = new PoliqarpPlusTree(query);
1247 map = ppt.getRequestMap().get("query").toString();
1248 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1249
1250 query = "dominates(cnx/c:<np>,[base=Baum])";
1251 expected =
1252 "{@type=korap:group, operation=operation:relation, operands=[" +
1253 "{@type=korap:span, key=np}," +
1254 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" +
1255 "], relation={@type=korap:relation, layer=c, foundry=cnx}" +
1256 "}";
1257 ppt = new PoliqarpPlusTree(query);
1258 map = ppt.getRequestMap().get("query").toString();
1259 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1260
1261 query = "dominates(cnx/c*:<np>,[base=Baum])";
1262 expected =
1263 "{@type=korap:group, operation=operation:relation, operands=[" +
1264 "{@type=korap:span, key=np}," +
1265 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" +
1266 "], relation={@type=korap:relation, layer=c, foundry=cnx, boundary={@type=korap:boundary, min=0}}" +
1267 "}";
1268 ppt = new PoliqarpPlusTree(query);
1269 map = ppt.getRequestMap().get("query").toString();
1270 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1271
1272 query = "dominates(cnx/c{1,5}:<np>,[base=Baum])";
1273 expected =
1274 "{@type=korap:group, operation=operation:relation, operands=[" +
1275 "{@type=korap:span, key=np}," +
1276 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" +
1277 "], relation={@type=korap:relation, layer=c, foundry=cnx, boundary={@type=korap:boundary, min=1, max=5}}" +
1278 "}";
1279 ppt = new PoliqarpPlusTree(query);
1280 map = ppt.getRequestMap().get("query").toString();
1281 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1282
1283 query = "relatesTo(mate/d=HEAD:<np>,[base=Baum])";
1284 expected =
1285 "{@type=korap:group, operation=operation:relation, operands=[" +
1286 "{@type=korap:span, key=np}," +
1287 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" +
1288 "], relation={@type=korap:relation, foundry=mate, layer=d, key=HEAD}" +
1289 "}";
1290 ppt = new PoliqarpPlusTree(query);
1291 map = ppt.getRequestMap().get("query").toString();
1292 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1293
1294 }
1295
1296
Joachim Bingel03882702013-12-31 19:53:05 +00001297
Joachim Bingel53333e62013-12-09 19:25:52 +00001298 @Test
Joachim Bingelba9a0ab2014-01-29 10:12:25 +00001299 public void testFoundries() throws QueryException {
1300 // [tt/base=Mann]
Joachim Bingel0900a892014-06-30 16:26:21 +00001301 String layer1 = "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=lemma, key=Mann, match=match:eq}}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +00001302 ppt = new PoliqarpPlusTree("[tt/base=Mann]");
1303 map = ppt.getRequestMap().get("query").toString();
1304 assertEquals(layer1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +00001305
1306 }
Joachim Bingel16da4e12013-12-17 09:48:12 +00001307
1308 @Test
Joachim Bingel8c640e42014-02-07 16:20:47 +00001309 public void testAlign() throws QueryException {
Joachim Bingel16da4e12013-12-17 09:48:12 +00001310 // [orth=der]^[orth=Mann]
1311 String align1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +00001312 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001313 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
1314 "{@type=korap:group, operation=operation:alignment, operands=[" +
1315 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" +
1316 "], align=align:left}" +
Joachim Bingel16da4e12013-12-17 09:48:12 +00001317 "]}";
1318 ppt = new PoliqarpPlusTree("[orth=der]^[orth=Mann]");
1319 map = ppt.getRequestMap().get("query").toString();
1320 assertEquals(align1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1321
Joachim Bingel84e33df2014-01-31 14:02:46 +00001322 // [orth=der]^[orth=große][orth=Mann]
1323 String query = "[orth=der]^[orth=große][orth=Mann]";
1324 String align1b =
Joachim Bingel2daf9862014-02-12 10:18:54 +00001325 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001326 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," +
1327 "{@type=korap:group, operation=operation:alignment, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001328 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001329 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=große, match=match:eq}}," +
1330 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" +
Joachim Bingel84e33df2014-01-31 14:02:46 +00001331 "]}" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001332 "], align=align:left}" +
Joachim Bingel84e33df2014-01-31 14:02:46 +00001333 "]}";
1334 ppt = new PoliqarpPlusTree(query);
1335 map = ppt.getRequestMap().get("query").toString();
1336 assertEquals(align1b.replaceAll(" ", ""), map.replaceAll(" ", ""));
1337
Joachim Bingel16da4e12013-12-17 09:48:12 +00001338 // "([base=a]^[base=b])|[base=c]",
1339 String align2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +00001340 "{@type=korap:group, operation=operation:or, operands=[" +
1341 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001342 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=a, match=match:eq}}," +
1343 "{@type=korap:group, operation=operation:alignment, operands=[" +
1344 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=b, match=match:eq}}" +
1345 "], align=align:left}" +
Joachim Bingel16da4e12013-12-17 09:48:12 +00001346 "]}," +
Joachim Bingel0900a892014-06-30 16:26:21 +00001347 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=c, match=match:eq}}" +
Joachim Bingel16da4e12013-12-17 09:48:12 +00001348 "]}";
1349 ppt = new PoliqarpPlusTree("([base=a]^[base=b])|[base=c]");
1350 map = ppt.getRequestMap().get("query").toString();
1351 assertEquals(align2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingela67e6a32014-01-02 18:35:24 +00001352
1353 // "([base=a]^[base=b][base=c])|[base=d]",
1354 String align3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +00001355 "{@type=korap:group, operation=operation:or, operands=[" +
1356 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001357 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=a, match=match:eq}}," +
1358 "{@type=korap:group, operation=operation:alignment, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001359 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001360 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=b, match=match:eq}}," +
1361 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=c, match=match:eq}}" +
Joachim Bingel84e33df2014-01-31 14:02:46 +00001362 "]}" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001363 "], align=align:left}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +00001364 "]}," +
Joachim Bingel0900a892014-06-30 16:26:21 +00001365 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=d, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +00001366 "]}";
1367 ppt = new PoliqarpPlusTree("([base=a]^[base=b][base=c])|[base=d]");
1368 map = ppt.getRequestMap().get("query").toString();
1369 assertEquals(align3.replaceAll(" ", ""), map.replaceAll(" ", ""));
1370
1371 // "([base=a]^[base=b]^[base=c])|[base=d]",
1372 String align4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +00001373 "{@type=korap:group, operation=operation:or, operands=[" +
1374 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001375 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=a, match=match:eq}}," +
1376 "{@type=korap:group, operation=operation:alignment, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +00001377 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001378 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=b, match=match:eq}}," +
1379 "{@type=korap:group, operation=operation:alignment, operands=[" +
1380 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=c, match=match:eq}}" +
1381 "], align=align:left}" +
Joachim Bingel84e33df2014-01-31 14:02:46 +00001382 "]}" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001383 "], align=align:left}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +00001384 "]}," +
Joachim Bingel0900a892014-06-30 16:26:21 +00001385 "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=d, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +00001386 "]}";
1387 ppt = new PoliqarpPlusTree("([base=a]^[base=b]^[base=c])|[base=d]");
1388 map = ppt.getRequestMap().get("query").toString();
1389 assertEquals(align4.replaceAll(" ", ""), map.replaceAll(" ", ""));
1390
1391
Joachim Bingel16da4e12013-12-17 09:48:12 +00001392 }
1393
1394 @Test
Joachim Bingel8c640e42014-02-07 16:20:47 +00001395 public void testSimpleQueries() throws QueryException {
Joachim Bingela67e6a32014-01-02 18:35:24 +00001396 // Baum
1397 String simple1 =
Joachim Bingel0900a892014-06-30 16:26:21 +00001398 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}";
Joachim Bingela67e6a32014-01-02 18:35:24 +00001399 ppt = new PoliqarpPlusTree("Baum");
1400 map = ppt.getRequestMap().get("query").toString();
1401 assertEquals(simple1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel0900a892014-06-30 16:26:21 +00001402
1403 // Baum/i
1404 String simple1b =
1405 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq, caseInsensitive=true}}";
1406 ppt = new PoliqarpPlusTree("Baum/i");
1407 map = ppt.getRequestMap().get("query").toString();
1408 assertEquals(simple1b.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel16da4e12013-12-17 09:48:12 +00001409
Joachim Bingela67e6a32014-01-02 18:35:24 +00001410 // Der Baum
1411 String simple2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +00001412 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001413 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " +
1414 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +00001415 "]}";
1416 ppt = new PoliqarpPlusTree("Der Baum");
1417 map = ppt.getRequestMap().get("query").toString();
1418 assertEquals(simple2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1419
Joachim Bingel0900a892014-06-30 16:26:21 +00001420 // Der Baum/i
1421 String simple2b =
1422 "{@type=korap:group, operation=operation:sequence, operands=[" +
1423 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " +
1424 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq, caseInsensitive=true}}" +
1425 "]}";
1426 ppt = new PoliqarpPlusTree("Der Baum/i");
1427 map = ppt.getRequestMap().get("query").toString();
1428 assertEquals(simple2b.replaceAll(" ", ""), map.replaceAll(" ", ""));
1429
Joachim Bingela67e6a32014-01-02 18:35:24 +00001430 // Der große Baum
1431 String simple3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +00001432 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001433 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " +
1434 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=große, match=match:eq}}, " +
1435 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +00001436 "]}";
1437 ppt = new PoliqarpPlusTree("Der große Baum");
1438 map = ppt.getRequestMap().get("query").toString();
1439 assertEquals(simple3.replaceAll(" ", ""), map.replaceAll(" ", ""));
1440
1441 // Baum | Stein
1442 String simple4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +00001443 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001444 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}, " +
1445 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Stein, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +00001446 "]}";
1447 ppt = new PoliqarpPlusTree("Baum | Stein");
1448 map = ppt.getRequestMap().get("query").toString();
1449 assertEquals(simple4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel84e33df2014-01-31 14:02:46 +00001450
1451 // Baum | Stein Haus
1452 String query = "(Baum | Stein) Haus";
1453 String simple5 =
Joachim Bingel2daf9862014-02-12 10:18:54 +00001454 "{@type=korap:group, operation=operation:sequence, operands=[" +
1455 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel0900a892014-06-30 16:26:21 +00001456 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}, " +
1457 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Stein, match=match:eq}}" +
Joachim Bingel84e33df2014-01-31 14:02:46 +00001458 "]}," +
Joachim Bingel0900a892014-06-30 16:26:21 +00001459 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Haus, match=match:eq}} " +
Joachim Bingel84e33df2014-01-31 14:02:46 +00001460 "]}";
1461 ppt = new PoliqarpPlusTree(query);
1462 map = ppt.getRequestMap().get("query").toString();
1463 assertEquals(simple5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel16da4e12013-12-17 09:48:12 +00001464 }
Joachim Bingel53333e62013-12-09 19:25:52 +00001465}
1466