blob: d22257d1b9a2bdf4c0db15632aba3a5dac33b4f0 [file] [log] [blame]
Joachim Bingel019ba5c2014-04-28 14:59:04 +00001import static org.junit.Assert.*;
2
3import org.junit.Test;
4
5import de.ids_mannheim.korap.query.serialize.AqlTree;
Joachim Bingel019ba5c2014-04-28 14:59:04 +00006import de.ids_mannheim.korap.util.QueryException;
7
8public class AqlTreeTest {
9
10 AqlTree aqlt;
11 String map;
12 private String query;
13
14 private boolean equalsQueryContent(String res, String query) throws QueryException {
15 res = res.replaceAll(" ", "");
16 aqlt = new AqlTree(query);
17 String queryMap = aqlt.getRequestMap().get("query").toString().replaceAll(" ", "");
18 return res.equals(queryMap);
19 }
20
21 @Test
22 public void testContext() throws QueryException {
23 String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld";
24 aqlt = new AqlTree("Test");
25 assertEquals(contextString.replaceAll(" ", ""), aqlt.getRequestMap().get("@context").toString().replaceAll(" ", ""));
26 }
27
28 @Test
29 public void testSingleTokens() throws QueryException {
30 // "Mann"
31 query = "\"Mann\"";
Joachim Bingeleee549e2014-04-29 11:15:37 +000032 String token1 = "{@type=korap:token, wrap={@type=korap:term, key=Mann, match=match:eq}}";
Joachim Bingel019ba5c2014-04-28 14:59:04 +000033 assertTrue(equalsQueryContent(token1, query));
34
35 // [orth!=Frau]
36 query = "tok!=\"Frau\"";
Joachim Bingelca4944e2014-06-13 13:55:10 +000037 String token2 = "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:ne}}";
Joachim Bingel019ba5c2014-04-28 14:59:04 +000038 assertTrue(equalsQueryContent(token2, query));
39
40 // Mann
41 query = "Mann";
42 String token4 = "{@type=korap:span, layer=Mann}";
43 assertTrue(equalsQueryContent(token4, query));
44 }
45
46 @Test
47 public void testSpans() throws QueryException {
48 query = "node";
49 String span1 =
50 "{@type=korap:span}";
51 aqlt = new AqlTree(query);
52 map = aqlt.getRequestMap().get("query").toString();
53 assertEquals(span1.replaceAll(" ", ""), map.replaceAll(" ", ""));
54 }
55
56 @Test
57 public void testRegex() throws QueryException {
58 query = "/Mann/";
Joachim Bingeleee549e2014-04-29 11:15:37 +000059 String regex1 = "{@type=korap:token, wrap={@type=korap:term, type=type:regex, key=Mann, match=match:eq}}";
Joachim Bingel019ba5c2014-04-28 14:59:04 +000060 aqlt = new AqlTree(query);
61 map = aqlt.getRequestMap().get("query").toString();
62 assertEquals(regex1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingele49b4672014-07-16 08:06:56 +000063
64 query = "/.*?Mann.*?/";
65 String regex2 = "{@type=korap:token, wrap={@type=korap:term, type=type:regex, key=.*?Mann.*?, match=match:eq}}";
66 aqlt = new AqlTree(query);
67 map = aqlt.getRequestMap().get("query").toString();
68 assertEquals(regex2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel019ba5c2014-04-28 14:59:04 +000069 }
70
71 @Test
72 public void testLayers() throws QueryException {
73 query = "cnx/cat=\"NP\"";
Joachim Bingeleee549e2014-04-29 11:15:37 +000074 String layers1 = "{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq}";
Joachim Bingel019ba5c2014-04-28 14:59:04 +000075 aqlt = new AqlTree(query);
76 map = aqlt.getRequestMap().get("query").toString();
77 assertEquals(layers1.replaceAll(" ", ""), map.replaceAll(" ", ""));
78
79 query = "treetagger/pos=\"NN\"";
Joachim Bingeleee549e2014-04-29 11:15:37 +000080 String layers2 = "{@type=korap:token, wrap={@type=korap:term, foundry=treetagger, layer=pos, key=NN, match=match:eq}}";
Joachim Bingel019ba5c2014-04-28 14:59:04 +000081 aqlt = new AqlTree(query);
82 map = aqlt.getRequestMap().get("query").toString();
83 assertEquals(layers2.replaceAll(" ", ""), map.replaceAll(" ", ""));
84 }
85
86 @Test
Joachim Bingel75038792014-05-19 15:12:23 +000087 public void testDirectDeclarationRelations() throws QueryException {
88 query = "node > node";
89 String ddr1 =
90 "{@type=korap:group, operation=operation:relation, operands=[" +
91 "{@type=korap:span}," +
92 "{@type=korap:span}" +
Joachim Bingel62892412014-08-06 15:18:59 +000093 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
Joachim Bingel75038792014-05-19 15:12:23 +000094 "}";
95 aqlt = new AqlTree(query);
96 map = aqlt.getRequestMap().get("query").toString();
97 assertEquals(ddr1.replaceAll(" ", ""), map.replaceAll(" ", ""));
98
99 query = "node > cnx/cat=\"NP\"";
100 String ddr2 =
101 "{@type=korap:group, operation=operation:relation, operands=[" +
102 "{@type=korap:span}," +
103 "{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000104 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
Joachim Bingel75038792014-05-19 15:12:23 +0000105 "}";
106 aqlt = new AqlTree(query);
107 map = aqlt.getRequestMap().get("query").toString();
108 assertEquals(ddr2.replaceAll(" ", ""), map.replaceAll(" ", ""));
109
110 }
111
112 @Test
Joachim Bingelfc428812014-06-18 14:50:14 +0000113 public void testDefPredicationInversion() throws QueryException {
114 query = " #1 > #2 & cnx/cat=\"VP\" & cnx/cat=\"NP\"";
115 String dom1 =
116 "{@type=korap:group, operation=operation:relation, operands=[" +
117 "{@type=korap:span, foundry=cnx, layer=cat, key=VP, match=match:eq}," +
118 "{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000119 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
Joachim Bingelfc428812014-06-18 14:50:14 +0000120 "}";
121 aqlt = new AqlTree(query);
122 map = aqlt.getRequestMap().get("query").toString();
123 assertEquals(dom1.replaceAll(" ", ""), map.replaceAll(" ", ""));
124 }
125
126 @Test
Joachim Bingel019ba5c2014-04-28 14:59:04 +0000127 public void testSimpleDominance() throws QueryException {
128 query = "node & node & #2 > #1";
129 String dom1 =
Joachim Bingeld4ae5fd2014-04-29 15:00:16 +0000130 "{@type=korap:group, operation=operation:relation, operands=[" +
Joachim Bingel019ba5c2014-04-28 14:59:04 +0000131 "{@type=korap:span}," +
132 "{@type=korap:span}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000133 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
Joachim Bingeleee549e2014-04-29 11:15:37 +0000134 "}";
Joachim Bingel019ba5c2014-04-28 14:59:04 +0000135 aqlt = new AqlTree(query);
136 map = aqlt.getRequestMap().get("query").toString();
137 assertEquals(dom1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeleee549e2014-04-29 11:15:37 +0000138
139 query = "\"Mann\" & node & #2 > #1";
140 String dom2 =
Joachim Bingeld4ae5fd2014-04-29 15:00:16 +0000141 "{@type=korap:group, operation=operation:relation, operands=[" +
Joachim Bingeleee549e2014-04-29 11:15:37 +0000142 "{@type=korap:span}," +
143 "{@type=korap:token, wrap={@type=korap:term, key=Mann, match=match:eq}}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000144 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
Joachim Bingeleee549e2014-04-29 11:15:37 +0000145 "}";
146 aqlt = new AqlTree(query);
147 map = aqlt.getRequestMap().get("query").toString();
148 assertEquals(dom2.replaceAll(" ", ""), map.replaceAll(" ", ""));
149
Joachim Bingeld4ae5fd2014-04-29 15:00:16 +0000150 query = "\"Mann\" & node & #2 >[cat=\"NP\"] #1";
Joachim Bingeleee549e2014-04-29 11:15:37 +0000151 String dom3 =
Joachim Bingeld4ae5fd2014-04-29 15:00:16 +0000152 "{@type=korap:group, operation=operation:relation, operands=[" +
Joachim Bingeleee549e2014-04-29 11:15:37 +0000153 "{@type=korap:span}," +
154 "{@type=korap:token, wrap={@type=korap:term, key=Mann, match=match:eq}}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000155 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c, key=NP, match=match:eq}}" +
Joachim Bingeleee549e2014-04-29 11:15:37 +0000156 "}";
157 aqlt = new AqlTree(query);
158 map = aqlt.getRequestMap().get("query").toString();
159 assertEquals(dom3.replaceAll(" ", ""), map.replaceAll(" ", ""));
160
Joachim Bingeld4ae5fd2014-04-29 15:00:16 +0000161 query = "\"Mann\" & node & #2 >@l[cat=\"NP\"] #1";
Joachim Bingeleee549e2014-04-29 11:15:37 +0000162 String dom4 =
Joachim Bingeld4ae5fd2014-04-29 15:00:16 +0000163 "{@type=korap:group, operation=operation:relation, operands=[" +
Joachim Bingeleee549e2014-04-29 11:15:37 +0000164 "{@type=korap:span}," +
165 "{@type=korap:token, wrap={@type=korap:term, key=Mann, match=match:eq}}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000166 "], relation={@type=korap:relation, index=0, wrap={@type=korap:term, layer=c, key=NP, match=match:eq}}" +
Joachim Bingeleee549e2014-04-29 11:15:37 +0000167 "}";
168 aqlt = new AqlTree(query);
169 map = aqlt.getRequestMap().get("query").toString();
170 assertEquals(dom4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld4ae5fd2014-04-29 15:00:16 +0000171
172 query = "\"Mann\" & node & #2 >2,4 #1";
173 String dom5 =
174 "{@type=korap:group, operation=operation:relation, operands=[" +
175 "{@type=korap:span}," +
176 "{@type=korap:token, wrap={@type=korap:term, key=Mann, match=match:eq}}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000177 "], relation={@type=korap:relation, boundary={@type=korap:boundary, min=2, max=4}, wrap={@type=korap:term, layer=c}}" +
Joachim Bingeld4ae5fd2014-04-29 15:00:16 +0000178 "}";
179 aqlt = new AqlTree(query);
180 map = aqlt.getRequestMap().get("query").toString();
181 assertEquals(dom5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel019ba5c2014-04-28 14:59:04 +0000182 }
183
Joachim Bingel13421ef2014-05-07 16:22:58 +0000184 @Test
Joachim Bingelca4944e2014-06-13 13:55:10 +0000185 public void testMultipleDominance() throws QueryException {
Joachim Bingel949e3a82014-06-16 13:20:43 +0000186 query = "cat=\"CP\" & cat=\"VP\" & cat=\"NP\" & #1 > #2 > #3";
Joachim Bingelca4944e2014-06-13 13:55:10 +0000187 String dom1 =
188 "{@type=korap:group, operation=operation:relation, operands=[" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000189 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingelfc428812014-06-18 14:50:14 +0000190 "{@type=korap:group, operation=operation:relation, operands=[" +
191 "{@type=korap:span, layer=cat, key=CP, match=match:eq}," +
192 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
193 "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
194 "]}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000195 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000196 "]}," +
Joachim Bingel949e3a82014-06-16 13:20:43 +0000197 "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000198 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
Joachim Bingelca4944e2014-06-13 13:55:10 +0000199 "}";
200 aqlt = new AqlTree(query);
201 map = aqlt.getRequestMap().get("query").toString();
202 assertEquals(dom1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel949e3a82014-06-16 13:20:43 +0000203
204 query = "cat=\"CP\" & cat=\"VP\" & cat=\"NP\" & cat=\"DP\" & #1 > #2 > #3 > #4";
205 String dom2 =
206 "{@type=korap:group, operation=operation:relation, operands=[" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000207 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel949e3a82014-06-16 13:20:43 +0000208 "{@type=korap:group, operation=operation:relation, operands=[" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000209 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingelfc428812014-06-18 14:50:14 +0000210 "{@type=korap:group, operation=operation:relation, operands=[" +
211 "{@type=korap:span, layer=cat, key=CP, match=match:eq}," +
212 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
213 "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
214 "]}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000215 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000216 "]}," +
Joachim Bingelfc428812014-06-18 14:50:14 +0000217 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
218 "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
219 "]}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000220 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000221 "]}," +
Joachim Bingel949e3a82014-06-16 13:20:43 +0000222 "{@type=korap:span, layer=cat, key=DP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000223 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
Joachim Bingel949e3a82014-06-16 13:20:43 +0000224 "}";
225 aqlt = new AqlTree(query);
226 map = aqlt.getRequestMap().get("query").toString();
227 assertEquals(dom2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelca4944e2014-06-13 13:55:10 +0000228 }
229
230 @Test
Joachim Bingel13421ef2014-05-07 16:22:58 +0000231 public void testPointingRelations() throws QueryException {
Joachim Bingel62892412014-08-06 15:18:59 +0000232 query = "node & node & #2 ->coref[val=\"true\"] #1";
Joachim Bingel13421ef2014-05-07 16:22:58 +0000233 String dom1 =
234 "{@type=korap:group, operation=operation:relation, operands=[" +
235 "{@type=korap:span}," +
236 "{@type=korap:span}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000237 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=coref, key=true, match=match:eq}}" +
Joachim Bingel13421ef2014-05-07 16:22:58 +0000238 "}";
239 aqlt = new AqlTree(query);
240 map = aqlt.getRequestMap().get("query").toString();
241 assertEquals(dom1.replaceAll(" ", ""), map.replaceAll(" ", ""));
242
Joachim Bingel62892412014-08-06 15:18:59 +0000243 query = "node & node & #2 ->mate/coref[val=\"true\"] #1";
Joachim Bingel639df9c2014-05-12 15:27:00 +0000244 String dom2 =
245 "{@type=korap:group, operation=operation:relation, operands=[" +
246 "{@type=korap:span}," +
247 "{@type=korap:span}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000248 "], relation={@type=korap:relation, wrap={@type=korap:term, foundry=mate, layer=coref, key=true, match=match:eq}}" +
Joachim Bingel639df9c2014-05-12 15:27:00 +0000249 "}";
250 aqlt = new AqlTree(query);
251 map = aqlt.getRequestMap().get("query").toString();
252 assertEquals(dom2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel13421ef2014-05-07 16:22:58 +0000253 }
254
255 @Test
256 public void testSequence() throws QueryException {
257 query = "node & node & #1 . #2";
Joachim Bingelca4944e2014-06-13 13:55:10 +0000258 String seq1 =
Joachim Bingel13421ef2014-05-07 16:22:58 +0000259 "{@type=korap:group, operation=operation:sequence, " +
260 "operands=[" +
261 "{@type=korap:span}," +
262 "{@type=korap:span}" +
263 "], inOrder=true" +
264 "}";
265 aqlt = new AqlTree(query);
266 map = aqlt.getRequestMap().get("query").toString();
Joachim Bingelca4944e2014-06-13 13:55:10 +0000267 assertEquals(seq1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel13421ef2014-05-07 16:22:58 +0000268
269 query = "node & node & #1 .* #2";
Joachim Bingelca4944e2014-06-13 13:55:10 +0000270 String seq2 =
Joachim Bingel75038792014-05-19 15:12:23 +0000271 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel13421ef2014-05-07 16:22:58 +0000272 "{@type=korap:span}," +
273 "{@type=korap:span}" +
274 "], distances=[" +
Joachim Bingel687e4d42014-07-30 09:34:18 +0000275 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0}, min=0}" +
Joachim Bingel13421ef2014-05-07 16:22:58 +0000276 "], inOrder=true" +
277 "}";
278 aqlt = new AqlTree(query);
279 map = aqlt.getRequestMap().get("query").toString();
Joachim Bingelca4944e2014-06-13 13:55:10 +0000280 assertEquals(seq2.replaceAll(" ", ""), map.replaceAll(" ", ""));
281
282 query = "node & node & #1 .2,3 #2";
283 String seq3 =
284 "{@type=korap:group, operation=operation:sequence, operands=[" +
285 "{@type=korap:span}," +
286 "{@type=korap:span}" +
287 "], distances=[" +
Joachim Bingel55020e82014-07-28 14:22:51 +0000288 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=3}, min=2, max=3}" +
Joachim Bingelca4944e2014-06-13 13:55:10 +0000289 "], inOrder=true" +
290 "}";
291 aqlt = new AqlTree(query);
292 map = aqlt.getRequestMap().get("query").toString();
293 assertEquals(seq3.replaceAll(" ", ""), map.replaceAll(" ", ""));
294
295 }
296
297 @Test
298 public void testMultipleSequence() throws QueryException {
299 query = "tok=\"Sonne\" & tok=\"Mond\" & tok=\"Sterne\" & #1 .0,2 #2 .0,4 #3";
300 String seq4 =
301 "{@type=korap:group, operation=operation:sequence," +
Joachim Bingelfc428812014-06-18 14:50:14 +0000302 "operands=[" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000303 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingelca4944e2014-06-13 13:55:10 +0000304 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel949e3a82014-06-16 13:20:43 +0000305 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
Joachim Bingelfc428812014-06-18 14:50:14 +0000306 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
307 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
308 "]}" +
Joachim Bingel949e3a82014-06-16 13:20:43 +0000309 "], distances=[" +
Joachim Bingel55020e82014-07-28 14:22:51 +0000310 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
Joachim Bingelfc428812014-06-18 14:50:14 +0000311 "], inOrder=true}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000312 "]}," +
Joachim Bingelfc428812014-06-18 14:50:14 +0000313 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
314 "],distances=[" +
Joachim Bingel55020e82014-07-28 14:22:51 +0000315 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingelfc428812014-06-18 14:50:14 +0000316 "], inOrder=true" +
317 "}";
Joachim Bingelca4944e2014-06-13 13:55:10 +0000318 aqlt = new AqlTree(query);
319 map = aqlt.getRequestMap().get("query").toString();
320 assertEquals(seq4.replaceAll(" ", ""), map.replaceAll(" ", ""));
321
322 query = "node & node & node & #1 . #2 .1,3 #3";
323 String seq5 =
324 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000325 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingelfc428812014-06-18 14:50:14 +0000326 "{@type=korap:group, operation=operation:sequence, operands=[" +
327 "{@type=korap:span}," +
328 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
329 "{@type=korap:span}" +
330 "]} "+
331 "], inOrder=true}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000332 "]}," +
Joachim Bingel949e3a82014-06-16 13:20:43 +0000333 "{@type=korap:span}" +
334 "], distances=[" +
Joachim Bingel55020e82014-07-28 14:22:51 +0000335 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3}" +
Joachim Bingel949e3a82014-06-16 13:20:43 +0000336 "], inOrder=true" +
Joachim Bingelca4944e2014-06-13 13:55:10 +0000337 "}";
338 aqlt = new AqlTree(query);
339 map = aqlt.getRequestMap().get("query").toString();
340 assertEquals(seq5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000341
342 query = "tok=\"Sonne\" & tok=\"Mond\" & tok=\"Sterne\" & tok=\"Himmel\" & #1 .0,2 #2 .0,4 #3 . #4";
343 String seq6 =
344 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000345 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000346 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000347 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000348 "{@type=korap:group, operation=operation:sequence, operands=[" +
349 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
350 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
351 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
352 "]}" +
353 "], distances=[" +
Joachim Bingel55020e82014-07-28 14:22:51 +0000354 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000355 "], inOrder=true}" +
356 "]}," +
357 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
358 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
359 "]}" +
360 "],distances=[" +
Joachim Bingel55020e82014-07-28 14:22:51 +0000361 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000362 "], inOrder=true}" +
363 "]}," +
364 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Himmel, match=match:eq}}" +
365 "], inOrder=true}" ;
366 aqlt = new AqlTree(query);
367 map = aqlt.getRequestMap().get("query").toString();
368 assertEquals(seq6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel75038792014-05-19 15:12:23 +0000369 }
370
371 @Test
Joachim Bingel949e3a82014-06-16 13:20:43 +0000372 public void testMultipleMixedOperators() throws QueryException {
373 query = "tok=\"Sonne\" & tok=\"Mond\" & tok=\"Sterne\" & #1 > #2 .0,4 #3";
374 String seq4 =
Joachim Bingelfc428812014-06-18 14:50:14 +0000375 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000376 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingelfc428812014-06-18 14:50:14 +0000377 "{@type=korap:group, operation=operation:relation, operands=[" +
378 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
379 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
380 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
381 "]}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000382 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000383 "]}," +
Joachim Bingel949e3a82014-06-16 13:20:43 +0000384 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
385 "], distances=[" +
Joachim Bingel55020e82014-07-28 14:22:51 +0000386 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingel949e3a82014-06-16 13:20:43 +0000387 "], inOrder=true" +
388 "}";
389 aqlt = new AqlTree(query);
390 map = aqlt.getRequestMap().get("query").toString();
391 assertEquals(seq4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelfc428812014-06-18 14:50:14 +0000392
393 query = "tok=\"Sonne\" & tok=\"Mond\" & #1 > #2 .0,4 tok=\"Sterne\"";
394 String seq5 =
395 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000396 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingelfc428812014-06-18 14:50:14 +0000397 "{@type=korap:group, operation=operation:relation, operands=[" +
398 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
399 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
400 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
401 "]}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000402 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000403 "]}," +
Joachim Bingelfc428812014-06-18 14:50:14 +0000404 "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
405 "], distances=[" +
Joachim Bingel55020e82014-07-28 14:22:51 +0000406 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingelfc428812014-06-18 14:50:14 +0000407 "], inOrder=true" +
408 "}";
409 aqlt = new AqlTree(query);
410 map = aqlt.getRequestMap().get("query").toString();
411 assertEquals(seq5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000412
413 query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & #1 $ #2 > #3";
414 String cp2 =
415 "{@type=korap:group, operation=operation:relation, operands=[" +
416 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
417 "{@type=korap:group, operation=operation:relation, operands=[" +
418 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
419 "{@type=korap:group, operation=operation:relation, operands=[" +
420 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
421 "{@type=korap:span}" +
422 "]}," +
423 "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000424 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000425 "]}," +
426 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
427 "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
428 "]}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000429 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000430 "}" +
431 "]}," +
432 "{@type=korap:span, layer=cat, key=PP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000433 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000434 "}";
435 aqlt = new AqlTree(query);
436 map = aqlt.getRequestMap().get("query").toString();
437 assertEquals(cp2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel949e3a82014-06-16 13:20:43 +0000438 }
439
440 @Test
Joachim Bingel75038792014-05-19 15:12:23 +0000441 public void testPositions() throws QueryException {
442 query = "node & node & #2 _=_ #1";
443 String pos1 =
444 "{@type=korap:group, operation=operation:position, operands=[" +
445 "{@type=korap:span}," +
446 "{@type=korap:span}" +
447 "], frame=frame:matches" +
448 "}";
449 aqlt = new AqlTree(query);
450 map = aqlt.getRequestMap().get("query").toString();
451 assertEquals(pos1.replaceAll(" ", ""), map.replaceAll(" ", ""));
452
Joachim Bingelca4944e2014-06-13 13:55:10 +0000453 query = "node & node & #2 _i_ #1";
454 String pos2 =
455 "{@type=korap:group, operation=operation:position, operands=[" +
456 "{@type=korap:span}," +
457 "{@type=korap:span}" +
458 "], frame=frame:contains" +
459 "}";
460 aqlt = new AqlTree(query);
461 map = aqlt.getRequestMap().get("query").toString();
462 assertEquals(pos2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel75038792014-05-19 15:12:23 +0000463
Joachim Bingelca4944e2014-06-13 13:55:10 +0000464 query = "node & node & #2 _l_ #1";
465 String pos3 =
466 "{@type=korap:group, operation=operation:position, operands=[" +
467 "{@type=korap:span}," +
468 "{@type=korap:span}" +
469 "], inOrder=false, frame=frame:startswith" +
470 "}";
471 aqlt = new AqlTree(query);
472 map = aqlt.getRequestMap().get("query").toString();
473 assertEquals(pos3.replaceAll(" ", ""), map.replaceAll(" ", ""));
474
475 query = "node & \"Mann\" & #1 _r_ #2";
Joachim Bingel75038792014-05-19 15:12:23 +0000476 String pos4 =
Joachim Bingel75038792014-05-19 15:12:23 +0000477 "{@type=korap:group, operation=operation:position, operands=[" +
478 "{@type=korap:span}," +
Joachim Bingelca4944e2014-06-13 13:55:10 +0000479 "{@type=korap:token, wrap={@type=korap:term, key=Mann, match=match:eq}}" +
480 "], inOrder=false, frame=frame:endswith" +
481 "}";
Joachim Bingel75038792014-05-19 15:12:23 +0000482 aqlt = new AqlTree(query);
483 map = aqlt.getRequestMap().get("query").toString();
484 assertEquals(pos4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel13421ef2014-05-07 16:22:58 +0000485
Joachim Bingelca4944e2014-06-13 13:55:10 +0000486 query = "node & \"Mann\" & #2 _r_ #1";
487 String pos5 =
488 "{@type=korap:group, operation=operation:position, operands=[" +
489 "{@type=korap:token, wrap={@type=korap:term, key=Mann, match=match:eq}}," +
490 "{@type=korap:span}" +
491 "], inOrder=false, frame=frame:endswith" +
492 "}";
493 aqlt = new AqlTree(query);
494 map = aqlt.getRequestMap().get("query").toString();
495 assertEquals(pos5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel13421ef2014-05-07 16:22:58 +0000496 }
497
Joachim Bingelca4944e2014-06-13 13:55:10 +0000498 @Test
499 public void testMultiplePredications() throws QueryException {
Joachim Bingel9c3ddb92014-06-23 13:49:58 +0000500 // a noun before a verb before a preposition
Joachim Bingelfc428812014-06-18 14:50:14 +0000501 query = "pos=\"N\" & pos=\"V\" & pos=\"P\" & #1 . #2 & #2 . #3";
Joachim Bingelca4944e2014-06-13 13:55:10 +0000502 String mult1 =
Joachim Bingel9c3ddb92014-06-23 13:49:58 +0000503 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000504 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingelca4944e2014-06-13 13:55:10 +0000505 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel9c3ddb92014-06-23 13:49:58 +0000506 "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}," +
507 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
508 "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
509 "]}" +
510 "], inOrder=true}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000511 "]}," +
Joachim Bingel9c3ddb92014-06-23 13:49:58 +0000512 "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
513 "], inOrder=true}";
Joachim Bingelca4944e2014-06-13 13:55:10 +0000514 aqlt = new AqlTree(query);
515 map = aqlt.getRequestMap().get("query").toString();
516 assertEquals(mult1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel9c3ddb92014-06-23 13:49:58 +0000517
518 // a noun before a verb before a preposition
519 query = "pos=\"N\" & pos=\"V\" & #1 . #2 & #2 . pos=\"P\"";
520 String mult2 =
521 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000522 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingel9c3ddb92014-06-23 13:49:58 +0000523 "{@type=korap:group, operation=operation:sequence, operands=[" +
524 "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}," +
525 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
526 "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
527 "]}" +
528 "], inOrder=true}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000529 "]}," +
Joachim Bingel9c3ddb92014-06-23 13:49:58 +0000530 "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
531 "], inOrder=true}";
532 aqlt = new AqlTree(query);
533 map = aqlt.getRequestMap().get("query").toString();
534 assertEquals(mult2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000535
536 query = "pos=\"N\" & pos=\"V\" & pos=\"P\" & #1 > #2 & #1 > #3";
537 String mult3 =
538 "{@type=korap:group, operation=operation:relation, operands=[" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000539 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000540 "{@type=korap:group, operation=operation:relation, operands=[" +
541 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
542 "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}" +
543 "]}," +
544 "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000545 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000546 "]}," +
547 "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000548 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}";
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000549 aqlt = new AqlTree(query);
550 map = aqlt.getRequestMap().get("query").toString();
551 assertEquals(mult3.replaceAll(" ", ""), map.replaceAll(" ", ""));
552
553 query = "cat=\"NP\" & pos=\"V\" & pos=\"P\" & #1 > #2 & #1 > #3 & #2 . #3";
554 String mult4 =
555 "{@type=korap:group, operation=operation:sequence, operands=[" +
556 // reduce dominance relations "#1 > #2 & #1 > #3" to operand #2 in order to make it accessible for #2 . #3 (the last/outermost relation)
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000557 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000558 "{@type=korap:group, operation=operation:relation, operands=[" +
559 // dominance relation #1 > #2 is reduced to #1, for expressing #1 > #3
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000560 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000561 "{@type=korap:group, operation=operation:relation, operands=[" +
562 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
563 "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
564 "]}," +
565 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
566 "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
567 "]}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000568 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000569 "]}," +
570 // establish class 2 around P for later reference
571 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
572 "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
573 "]}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000574 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000575 "]}," +
576 // refer back to class 2 as second operand
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000577 "{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000578 "], inOrder=true}";
579 aqlt = new AqlTree(query);
580 map = aqlt.getRequestMap().get("query").toString();
581 assertEquals(mult4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelca4944e2014-06-13 13:55:10 +0000582 }
Joachim Bingeleee549e2014-04-29 11:15:37 +0000583
Joachim Bingelca4944e2014-06-13 13:55:10 +0000584 @Test
585 public void testUnaryRelations() throws QueryException {
586 query = "node & #1:tokenarity=2";
587 String unary1 =
588 "{@type=korap:span, attr={@type=korap:term, tokenarity={@type=korap:boundary,min=2,max=2}}}";
589 aqlt = new AqlTree(query);
590 map = aqlt.getRequestMap().get("query").toString();
591 assertEquals(unary1.replaceAll(" ", ""), map.replaceAll(" ", ""));
592
593 query = "cnx/cat=\"NP\" & #1:tokenarity=2";
594 String unary2 =
595 "{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq, attr={@type=korap:term, tokenarity={@type=korap:boundary,min=2,max=2}}}";
596 aqlt = new AqlTree(query);
597 map = aqlt.getRequestMap().get("query").toString();
598 assertEquals(unary2.replaceAll(" ", ""), map.replaceAll(" ", ""));
599
600 query = "cnx/cat=\"NP\" & #1:root";
601 String unary3 =
602 "{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq, attr={@type=korap:term, root=true}}";
603 aqlt = new AqlTree(query);
604 map = aqlt.getRequestMap().get("query").toString();
605 assertEquals(unary3.replaceAll(" ", ""), map.replaceAll(" ", ""));
606
607 query = "cnx/cat=\"NP\" & node & #1>#2 & #1:tokenarity=2";
608 String unary4 =
609 "{@type=korap:group, operation=operation:relation, operands=[" +
610 "{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq, attr={@type=korap:term, tokenarity={@type=korap:boundary,min=2,max=2}}}," +
611 "{@type=korap:span}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000612 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
Joachim Bingelca4944e2014-06-13 13:55:10 +0000613 "}";
614 aqlt = new AqlTree(query);
615 map = aqlt.getRequestMap().get("query").toString();
616 assertEquals(unary4.replaceAll(" ", ""), map.replaceAll(" ", ""));
617 }
618
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000619 @Test
620 public void testCommonParent() throws QueryException {
621 query = "cat=\"NP\" & cat=\"VP\" & #1 $ #2";
622 String cp1 =
623 "{@type=korap:group, operation=operation:relation, operands=[" +
624 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
625 "{@type=korap:group, operation=operation:relation, operands=[" +
626 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
627 "{@type=korap:span}" +
628 "]}," +
629 "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000630 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000631 "]}," +
632 "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000633 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000634 "";
635 aqlt = new AqlTree(query);
636 map = aqlt.getRequestMap().get("query").toString();
637 assertEquals(cp1.replaceAll(" ", ""), map.replaceAll(" ", ""));
638
639 query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & #1 $ #2 $ #3";
640 String cp2 =
641 "{@type=korap:group, operation=operation:relation, operands=[" +
642 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
643 "{@type=korap:group, operation=operation:relation, operands=[" +
644 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
645 "{@type=korap:group, operation=operation:relation, operands=[" +
646 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
647 "{@type=korap:span}" +
648 "]}," +
649 "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000650 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000651 "]}," +
652 "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000653 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000654 "}" +
655 "]}," +
656 "{@type=korap:span, layer=cat, key=PP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000657 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000658 "}";
659 aqlt = new AqlTree(query);
660 map = aqlt.getRequestMap().get("query").toString();
661 assertEquals(cp2.replaceAll(" ", ""), map.replaceAll(" ", ""));
662
663 query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & cat=\"CP\" & #1 $ #2 $ #3 $ #4";
664 String cp3 =
665 "{@type=korap:group, operation=operation:relation, operands=[" +
666 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
667 "{@type=korap:group, operation=operation:relation, operands=[" +
668 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
669 "{@type=korap:group, operation=operation:relation, operands=[" +
670 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
671 "{@type=korap:group, operation=operation:relation, operands=[" +
672 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
673 "{@type=korap:span}" +
674 "]}," +
675 "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000676 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000677 "]}," +
678 "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000679 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000680 "]}," +
681 "{@type=korap:span, layer=cat, key=PP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000682 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000683 "]}," +
684 "{@type=korap:span, layer=cat, key=CP, match=match:eq}" +
Joachim Bingel62892412014-08-06 15:18:59 +0000685 "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
Joachim Bingel1846c8c2014-07-08 14:13:31 +0000686 "}" +
687 "";
688 aqlt = new AqlTree(query);
689 map = aqlt.getRequestMap().get("query").toString();
690 assertEquals(cp3.replaceAll(" ", ""), map.replaceAll(" ", ""));
691 }
692
Joachim Bingelca4944e2014-06-13 13:55:10 +0000693}