blob: a65d2b1b36800b9004c2228d917d7884af5881b5 [file] [log] [blame]
Joachim Bingel019ba5c2014-04-28 14:59:04 +00001import static org.junit.Assert.*;
2
Joachim Bingel66472b82014-12-04 16:00:05 +00003import java.io.IOException;
4import java.util.ArrayList;
5
Joachim Bingel019ba5c2014-04-28 14:59:04 +00006import org.junit.Test;
7
Joachim Bingel66472b82014-12-04 16:00:05 +00008import com.fasterxml.jackson.core.JsonProcessingException;
9import com.fasterxml.jackson.databind.JsonNode;
10import com.fasterxml.jackson.databind.ObjectMapper;
11
12import de.ids_mannheim.korap.query.serialize.QuerySerializer;
Joachim Bingel019ba5c2014-04-28 14:59:04 +000013import de.ids_mannheim.korap.util.QueryException;
14
Joachim Bingel66472b82014-12-04 16:00:05 +000015/**
16 * Tests for JSON-LD serialization of ANNIS QL queries.
17 * @author Joachim Bingel (bingel@ids-mannheim.de)
18 * @version 1.0
19 */
Joachim Bingel019ba5c2014-04-28 14:59:04 +000020public class AqlTreeTest {
21
Joachim Bingel66472b82014-12-04 16:00:05 +000022 String query;
23 ArrayList<JsonNode> operands;
Joachim Bingel019ba5c2014-04-28 14:59:04 +000024
Joachim Bingel66472b82014-12-04 16:00:05 +000025 QuerySerializer qs = new QuerySerializer();
26 ObjectMapper mapper = new ObjectMapper();
27 JsonNode res;
28
29 @Test
30 public void testContext() throws QueryException, JsonProcessingException, IOException {
31 String contextUrl = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld";
32 query = "foo";
33 qs.setQuery(query, "annis");
34 res = mapper.readTree(qs.toJSON());
35 assertEquals(contextUrl, res.get("@context").asText());
Joachim Bingel019ba5c2014-04-28 14:59:04 +000036 }
37
38 @Test
Joachim Bingel66472b82014-12-04 16:00:05 +000039 public void testSingleTokens() throws QueryException, JsonProcessingException, IOException {
Joachim Bingel019ba5c2014-04-28 14:59:04 +000040 query = "\"Mann\"";
Joachim Bingel66472b82014-12-04 16:00:05 +000041 qs.setQuery(query, "annis");
42 res = mapper.readTree(qs.toJSON());
43 assertEquals("korap:token", res.at("/query/@type").asText());
44 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
45 assertEquals("orth", res.at("/query/wrap/layer").asText());
46 assertEquals("Mann", res.at("/query/wrap/key").asText());
47 assertEquals("match:eq", res.at("/query/wrap/match").asText());
Joachim Bingel019ba5c2014-04-28 14:59:04 +000048
Joachim Bingel019ba5c2014-04-28 14:59:04 +000049 query = "tok!=\"Frau\"";
Joachim Bingel66472b82014-12-04 16:00:05 +000050 qs.setQuery(query, "annis");
51 res = mapper.readTree(qs.toJSON());
52 assertEquals("korap:token", res.at("/query/@type").asText());
53 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
54 assertEquals("orth", res.at("/query/wrap/layer").asText());
55 assertEquals("Frau", res.at("/query/wrap/key").asText());
56 assertEquals("match:ne", res.at("/query/wrap/match").asText());
Joachim Bingel019ba5c2014-04-28 14:59:04 +000057
Joachim Bingel66472b82014-12-04 16:00:05 +000058 query = "tok"; // special keyword for token
59 qs.setQuery(query, "annis");
60 res = mapper.readTree(qs.toJSON());
61 assertEquals("korap:token", res.at("/query/@type").asText());
Joachim Bingelc9c0cf92014-10-02 12:03:59 +000062
Joachim Bingel66472b82014-12-04 16:00:05 +000063 query = "Mann"; // no special keyword -> defaults to layer name
64 qs.setQuery(query, "annis");
65 res = mapper.readTree(qs.toJSON());
66 assertEquals("korap:span", res.at("/query/@type").asText());
67 assertEquals("Mann", res.at("/query/layer").asText());
Joachim Bingel019ba5c2014-04-28 14:59:04 +000068 }
69
70 @Test
Joachim Bingel66472b82014-12-04 16:00:05 +000071 public void testSpans() throws QueryException, JsonProcessingException, IOException {
72 query = "node"; // special keyword for general span
73 qs.setQuery(query, "annis");
74 res = mapper.readTree(qs.toJSON());
75 assertEquals("korap:span", res.at("/query/@type").asText());
76
77 query = "cat=\"np\""; // cat is special keyword for spans
78 qs.setQuery(query, "annis");
79 res = mapper.readTree(qs.toJSON());
80 assertEquals("korap:span", res.at("/query/@type").asText());
81 assertEquals("np", res.at("/query/key").asText());
82 assertEquals("c", res.at("/query/layer").asText());
83
84 query = "cat=\"NP\"";
85 qs.setQuery(query, "annis");
86 res = mapper.readTree(qs.toJSON());
87 assertEquals("korap:span", res.at("/query/@type").asText());
88 assertEquals("NP", res.at("/query/key").asText());
89 assertEquals("c", res.at("/query/layer").asText());
Joachim Bingel019ba5c2014-04-28 14:59:04 +000090 }
91
92 @Test
Joachim Bingel66472b82014-12-04 16:00:05 +000093 public void testRegex() throws QueryException, JsonProcessingException, IOException {
94 query = "/Mann/";
95 qs.setQuery(query, "annis");
96 res = mapper.readTree(qs.toJSON());
97 assertEquals("korap:token", res.at("/query/@type").asText());
98 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
99 assertEquals("type:regex", res.at("/query/wrap/type").asText());
100 assertEquals("orth", res.at("/query/wrap/layer").asText());
101 assertEquals("Mann", res.at("/query/wrap/key").asText());
102 assertEquals("match:eq", res.at("/query/wrap/match").asText());
Joachim Bingele49b4672014-07-16 08:06:56 +0000103
Joachim Bingel66472b82014-12-04 16:00:05 +0000104 query = "/.*?Mann.*?/";
105 qs.setQuery(query, "annis");
106 res = mapper.readTree(qs.toJSON());
107 assertEquals("type:regex", res.at("/query/wrap/type").asText());
108 assertEquals(".*?Mann.*?", res.at("/query/wrap/key").asText());
Joachim Bingel019ba5c2014-04-28 14:59:04 +0000109 }
Joachim Bingelaee38ae2014-06-25 09:32:56 +0000110
Joachim Bingelca4944e2014-06-13 13:55:10 +0000111 @Test
Joachim Bingel66472b82014-12-04 16:00:05 +0000112 public void testFoundriesLayers() throws QueryException, JsonProcessingException, IOException {
113 query = "c=\"np\"";
114 qs.setQuery(query, "annis");
115 res = mapper.readTree(qs.toJSON());
116 assertEquals("korap:span", res.at("/query/@type").asText());
117 assertEquals("np", res.at("/query/key").asText());
118 assertEquals("c", res.at("/query/layer").asText());
Joachim Bingelca4944e2014-06-13 13:55:10 +0000119
Joachim Bingel66472b82014-12-04 16:00:05 +0000120 query = "cnx/c=\"np\"";
121 qs.setQuery(query, "annis");
122 res = mapper.readTree(qs.toJSON());
123 assertEquals("korap:span", res.at("/query/@type").asText());
124 assertEquals("np", res.at("/query/key").asText());
125 assertEquals("c", res.at("/query/layer").asText());
126 assertEquals("cnx", res.at("/query/foundry").asText());
Joachim Bingelca4944e2014-06-13 13:55:10 +0000127
Joachim Bingel66472b82014-12-04 16:00:05 +0000128 query = "tt/pos=\"np\"";
129 qs.setQuery(query, "annis");
130 res = mapper.readTree(qs.toJSON());
131 assertEquals("korap:token", res.at("/query/@type").asText());
132 assertEquals("korap:term", res.at("/query/wrap/@type").asText());
133 assertEquals("np", res.at("/query/wrap/key").asText());
134 assertEquals("p", res.at("/query/wrap/layer").asText());
135 assertEquals("tt", res.at("/query/wrap/foundry").asText());
Joachim Bingele6d73b12014-09-30 15:34:59 +0000136 }
137
Joachim Bingel66472b82014-12-04 16:00:05 +0000138 @Test
139 public void testDirectDeclarationRelations() throws QueryException, JsonProcessingException, IOException {
140 query = "node > node";
141 qs.setQuery(query, "annis");
142 res = mapper.readTree(qs.toJSON());
143 assertEquals("korap:group", res.at("/query/@type").asText());
144 assertEquals("operation:relation", res.at("/query/operation").asText());
145 assertEquals("korap:span", res.at("/query/operands/0/@type").asText());
146 assertEquals("korap:span", res.at("/query/operands/1/@type").asText());
147 assertEquals("korap:relation", res.at("/query/relation/@type").asText());
148 assertEquals("korap:term", res.at("/query/relation/wrap/@type").asText());
149 assertEquals("c", res.at("/query/relation/wrap/layer").asText());
150
151 query = "node > cnx/c=\"np\"";
152 qs.setQuery(query, "annis");
153 res = mapper.readTree(qs.toJSON());
154 assertEquals("korap:group", res.at("/query/@type").asText());
155 assertEquals("operation:relation", res.at("/query/operation").asText());
156 assertEquals("korap:span", res.at("/query/operands/0/@type").asText());
157 assertEquals("korap:span", res.at("/query/operands/1/@type").asText());
158 assertEquals("np", res.at("/query/operands/1/key").asText());
159 assertEquals("c", res.at("/query/operands/1/layer").asText());
160 assertEquals("cnx", res.at("/query/operands/1/foundry").asText());
161 assertEquals("korap:relation", res.at("/query/relation/@type").asText());
162 assertEquals("korap:term", res.at("/query/relation/wrap/@type").asText());
163 assertEquals("c", res.at("/query/relation/wrap/layer").asText());
164
165 query = "cnx/c=\"np\" > node";
166 qs.setQuery(query, "annis");
167 res = mapper.readTree(qs.toJSON());
168 assertEquals(true, res.at("/query/operands/1/key").isMissingNode());
169 assertEquals("np", res.at("/query/operands/0/key").asText());
Joachim Bingelab1aff42014-12-16 16:38:00 +0000170
171 query = "cat=/NP/ & cat=/PP/ > #1";
172 qs.setQuery(query, "annis");
173 res = mapper.readTree(qs.toJSON());
174 assertEquals("korap:group", res.at("/query/@type").asText());
175 assertEquals("operation:relation", res.at("/query/operation").asText());
176 assertEquals("korap:span", res.at("/query/operands/0/@type").asText());
177 assertEquals("PP", res.at("/query/operands/0/key").asText());
178 assertEquals("korap:span", res.at("/query/operands/1/@type").asText());
179 assertEquals("NP", res.at("/query/operands/1/key").asText());
180 assertEquals(true, res.at("/query/operands/2").isMissingNode());
181 assertEquals("korap:relation", res.at("/query/relation/@type").asText());
182 assertEquals("korap:term", res.at("/query/relation/wrap/@type").asText());
183 assertEquals("c", res.at("/query/relation/wrap/layer").asText());
Joachim Bingel66472b82014-12-04 16:00:05 +0000184 }
185
186 @Test
187 public void testDefPredicationInversion() throws QueryException, JsonProcessingException, IOException {
188 query = "#1 > #2 & cnx/cat=\"vp\" & cnx/cat=\"np\"";
189 qs.setQuery(query, "annis");
190 res = mapper.readTree(qs.toJSON());
191 assertEquals("korap:group", res.at("/query/@type").asText());
192 assertEquals("operation:relation", res.at("/query/operation").asText());
193 assertEquals("korap:span", res.at("/query/operands/0/@type").asText());
194 assertEquals("korap:span", res.at("/query/operands/0/@type").asText());
195 assertEquals("vp", res.at("/query/operands/0/key").asText());
196 assertEquals("c", res.at("/query/operands/0/layer").asText());
197 assertEquals("cnx", res.at("/query/operands/0/foundry").asText());
198 assertEquals("korap:span", res.at("/query/operands/1/@type").asText());
199 assertEquals("np", res.at("/query/operands/1/key").asText());
200 assertEquals("c", res.at("/query/operands/1/layer").asText());
201 assertEquals("cnx", res.at("/query/operands/1/foundry").asText());
202 assertEquals("korap:relation", res.at("/query/relation/@type").asText());
203 assertEquals("korap:term", res.at("/query/relation/wrap/@type").asText());
204 assertEquals("c", res.at("/query/relation/wrap/layer").asText());
205 }
206
207 @Test
208 public void testSimpleDominance() throws QueryException, JsonProcessingException, IOException {
209 query = "node & node & #2 > #1";
210 qs.setQuery(query, "annis");
211 res = mapper.readTree(qs.toJSON());
212 assertEquals("korap:group", res.at("/query/@type").asText());
213 assertEquals("operation:relation", res.at("/query/operation").asText());
214 assertEquals("korap:span", res.at("/query/operands/0/@type").asText());
215 assertEquals("korap:span", res.at("/query/operands/1/@type").asText());
216 assertEquals("korap:relation", res.at("/query/relation/@type").asText());
217 assertEquals("korap:term", res.at("/query/relation/wrap/@type").asText());
218 assertEquals("c", res.at("/query/relation/wrap/layer").asText());
219
220 query = "\"Mann\" & node & #2 > #1";
221 qs.setQuery(query, "annis");
222 res = mapper.readTree(qs.toJSON());
223 assertEquals("korap:group", res.at("/query/@type").asText());
224 assertEquals("operation:relation", res.at("/query/operation").asText());
225 assertEquals("korap:span", res.at("/query/operands/0/@type").asText());
226 assertEquals("korap:token", res.at("/query/operands/1/@type").asText());
227 assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText());
228 assertEquals("korap:relation", res.at("/query/relation/@type").asText());
229 assertEquals("korap:term", res.at("/query/relation/wrap/@type").asText());
230 assertEquals("c", res.at("/query/relation/wrap/layer").asText());
231
232 query = "\"Mann\" & node & #2 >[func=\"SB\"] #1"; //coordinates the func=SB term and requires a "c"-layer term (consituency relation/dominance)
233 qs.setQuery(query, "annis");
234 res = mapper.readTree(qs.toJSON());
235 assertEquals("korap:relation", res.at("/query/relation/@type").asText());
236 assertEquals("korap:termGroup", res.at("/query/relation/wrap/@type").asText());
237 assertEquals("relation:and", res.at("/query/relation/wrap/relation").asText());
238 assertEquals("c", res.at("/query/relation/wrap/operands/1/layer").asText());
239 assertEquals("func", res.at("/query/relation/wrap/operands/0/layer").asText());
240 assertEquals("SB", res.at("/query/relation/wrap/operands/0/key").asText());
241
242 query = "cat=\"S\" & node & #1 >[func=\"SB\" func=\"MO\"] #2"; // quite meaningless (function is subject and modifier), but this is allowed by Annis, however its backend only regards the 1st option
243 qs.setQuery(query, "annis");
244 res = mapper.readTree(qs.toJSON());
245 assertEquals("korap:relation", res.at("/query/relation/@type").asText());
246 assertEquals("korap:termGroup", res.at("/query/relation/wrap/@type").asText());
247 assertEquals("relation:and", res.at("/query/relation/wrap/relation").asText());
248 assertEquals("func", res.at("/query/relation/wrap/operands/0/layer").asText());
249 assertEquals("SB", res.at("/query/relation/wrap/operands/0/key").asText());
250 assertEquals("func", res.at("/query/relation/wrap/operands/1/layer").asText());
251 assertEquals("MO" , res.at("/query/relation/wrap/operands/1/key").asText());
252 assertEquals("c", res.at("/query/relation/wrap/operands/2/layer").asText());
253
Joachim Bingel755ada92014-12-16 13:55:37 +0000254 query = "cat=\"S\" & cat=\"NP\" & #1 >@l #2"; // all sentences starting with NP -> wrap relation in startswith and retrieve 2nd operand with focus
Joachim Bingel66472b82014-12-04 16:00:05 +0000255 qs.setQuery(query, "annis");
256 res = mapper.readTree(qs.toJSON());
Joachim Bingel755ada92014-12-16 13:55:37 +0000257 assertEquals("operation:position", res.at("/query/operation").asText());
258 assertEquals("operation:relation", res.at("/query/operands/0/operation").asText());
259 assertEquals("frames:startswith", res.at("/query/frames/0").asText());
Joachim Bingel66472b82014-12-04 16:00:05 +0000260 assertEquals("korap:span", res.at("/query/operands/0/operands/0/@type").asText());
261 assertEquals("S", res.at("/query/operands/0/operands/0/key").asText());
262 assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText());
263 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
Joachim Bingel755ada92014-12-16 13:55:37 +0000264 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
Joachim Bingel66472b82014-12-04 16:00:05 +0000265 assertEquals("korap:span", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
266 assertEquals("NP", res.at("/query/operands/0/operands/1/operands/0/key").asText());
267 assertEquals("korap:reference", res.at("/query/operands/1/@type").asText());
268 assertEquals("operation:focus", res.at("/query/operands/1/operation").asText());
Joachim Bingel755ada92014-12-16 13:55:37 +0000269 assertEquals(129, res.at("/query/operands/1/classRef/0").asInt());
270
271 query = "cat=\"S\" & cat=\"NP\" & #1 >@r #2";
272 qs.setQuery(query, "annis");
273 res = mapper.readTree(qs.toJSON());
274 assertEquals("operation:position", res.at("/query/operation").asText());
275 assertEquals("operation:relation", res.at("/query/operands/0/operation").asText());
276 assertEquals("frames:endswith", res.at("/query/frames/0").asText());
277 assertEquals("korap:span", res.at("/query/operands/0/operands/0/@type").asText());
278 assertEquals("S", res.at("/query/operands/0/operands/0/key").asText());
279 assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText());
280 assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
281 assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
282 assertEquals("korap:span", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
283 assertEquals("NP", res.at("/query/operands/0/operands/1/operands/0/key").asText());
284 assertEquals("korap:reference", res.at("/query/operands/1/@type").asText());
285 assertEquals("operation:focus", res.at("/query/operands/1/operation").asText());
286 assertEquals(129, res.at("/query/operands/1/classRef/0").asInt());
Joachim Bingel66472b82014-12-04 16:00:05 +0000287 }
288
289 @Test
290 public void testIndirectDominance() throws QueryException, JsonProcessingException, IOException {
291 query = "node & node & #1 >2,4 #2";
292 qs.setQuery(query, "annis");
293 res = mapper.readTree(qs.toJSON());
294 assertEquals("korap:group", res.at("/query/@type").asText());
295 assertEquals("operation:relation", res.at("/query/operation").asText());
296 assertEquals("korap:span", res.at("/query/operands/0/@type").asText());
297 assertEquals("korap:span", res.at("/query/operands/1/@type").asText());
298 assertEquals("korap:relation", res.at("/query/relation/@type").asText());
299 assertEquals(2, res.at("/query/relation/boundary/min").asInt());
300 assertEquals(4, res.at("/query/relation/boundary/max").asInt());
301 assertEquals("korap:term", res.at("/query/relation/wrap/@type").asText());
302 assertEquals("c", res.at("/query/relation/wrap/layer").asText());
303
304 query = "node & node & #1 >* #2";
305 qs.setQuery(query, "annis");
306 res = mapper.readTree(qs.toJSON());
307 assertEquals(0, res.at("/query/relation/boundary/min").asInt());
308 assertEquals(true, res.at("/query/relation/boundary/max").isMissingNode());
309 }
310
Joachim Bingelab1aff42014-12-16 16:38:00 +0000311
312 @Test
313 public void testMultipleDominance() throws QueryException {
314
315 }
Joachim Bingel66472b82014-12-04 16:00:05 +0000316// query = "cat=\"CP\" & cat=\"VP\" & cat=\"NP\" & #1 > #2 > #3";
317// String dom1 =
318// "{@type=korap:group, operation=operation:relation, operands=[" +
319// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
320// "{@type=korap:group, operation=operation:relation, operands=[" +
321// "{@type=korap:span, layer=cat, key=CP, match=match:eq}," +
322// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
323// "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
324// "]}" +
325// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
326// "]}," +
327// "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
328// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
329// "}";
330// aqlt = new AqlTree(query);
331// map = aqlt.getRequestMap().get("query").toString();
332// assertEquals(dom1.replaceAll(" ", ""), map.replaceAll(" ", ""));
333//
334// query = "cat=\"CP\" & cat=\"VP\" & cat=\"NP\" & cat=\"DP\" & #1 > #2 > #3 > #4";
335// String dom2 =
336// "{@type=korap:group, operation=operation:relation, operands=[" +
337// "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
338// "{@type=korap:group, operation=operation:relation, operands=[" +
339// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
340// "{@type=korap:group, operation=operation:relation, operands=[" +
341// "{@type=korap:span, layer=cat, key=CP, match=match:eq}," +
342// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
343// "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
344// "]}" +
345// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
346// "]}," +
347// "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
348// "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
349// "]}" +
350// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
351// "]}," +
352// "{@type=korap:span, layer=cat, key=DP, match=match:eq}" +
353// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
354// "}";
355// aqlt = new AqlTree(query);
356// map = aqlt.getRequestMap().get("query").toString();
357// assertEquals(dom2.replaceAll(" ", ""), map.replaceAll(" ", ""));
358// }
359//
360// @Test
361// public void testPointingRelations() throws QueryException {
362// query = "node & node & #2 ->coref[val=\"true\"] #1";
363// String dom1 =
364// "{@type=korap:group, operation=operation:relation, operands=[" +
365// "{@type=korap:span}," +
366// "{@type=korap:span}" +
367// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=coref, key=true, match=match:eq}}" +
368// "}";
369// aqlt = new AqlTree(query);
370// map = aqlt.getRequestMap().get("query").toString();
371// assertEquals(dom1.replaceAll(" ", ""), map.replaceAll(" ", ""));
372//
373// query = "node & node & #2 ->mate/coref[val=\"true\"] #1";
374// String dom2 =
375// "{@type=korap:group, operation=operation:relation, operands=[" +
376// "{@type=korap:span}," +
377// "{@type=korap:span}" +
378// "], relation={@type=korap:relation, wrap={@type=korap:term, foundry=mate, layer=coref, key=true, match=match:eq}}" +
379// "}";
380// aqlt = new AqlTree(query);
381// map = aqlt.getRequestMap().get("query").toString();
382// assertEquals(dom2.replaceAll(" ", ""), map.replaceAll(" ", ""));
383// }
384//
385// @Test
386// public void testSequence() throws QueryException {
387// query = "node & node & #1 . #2";
388// String seq1 =
389// "{@type=korap:group, operation=operation:sequence, " +
390// "operands=[" +
391// "{@type=korap:span}," +
392// "{@type=korap:span}" +
393// "], inOrder=true" +
394// "}";
395// aqlt = new AqlTree(query);
396// map = aqlt.getRequestMap().get("query").toString();
397// assertEquals(seq1.replaceAll(" ", ""), map.replaceAll(" ", ""));
398//
399// query = "node & node & #1 .* #2";
400// String seq2 =
401// "{@type=korap:group, operation=operation:sequence, operands=[" +
402// "{@type=korap:span}," +
403// "{@type=korap:span}" +
404// "], distances=[" +
405// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0}, min=0}" +
406// "], inOrder=true" +
407// "}";
408// aqlt = new AqlTree(query);
409// map = aqlt.getRequestMap().get("query").toString();
410// assertEquals(seq2.replaceAll(" ", ""), map.replaceAll(" ", ""));
411//
412// query = "node & node & #1 .2,3 #2";
413// String seq3 =
414// "{@type=korap:group, operation=operation:sequence, operands=[" +
415// "{@type=korap:span}," +
416// "{@type=korap:span}" +
417// "], distances=[" +
418// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=3}, min=2, max=3}" +
419// "], inOrder=true" +
420// "}";
421// aqlt = new AqlTree(query);
422// map = aqlt.getRequestMap().get("query").toString();
423// assertEquals(seq3.replaceAll(" ", ""), map.replaceAll(" ", ""));
424//
425// }
426//
427// @Test
428// public void testMultipleSequence() throws QueryException {
429// query = "tok=\"Sonne\" & tok=\"Mond\" & tok=\"Sterne\" & #1 .0,2 #2 .0,4 #3";
430// String seq4 =
431// "{@type=korap:group, operation=operation:sequence," +
432// "operands=[" +
433// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
434// "{@type=korap:group, operation=operation:sequence, operands=[" +
435// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
436// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
437// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
438// "]}" +
439// "], distances=[" +
440// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
441// "], inOrder=true}" +
442// "]}," +
443// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
444// "],distances=[" +
445// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
446// "], inOrder=true" +
447// "}";
448// aqlt = new AqlTree(query);
449// map = aqlt.getRequestMap().get("query").toString();
450// assertEquals(seq4.replaceAll(" ", ""), map.replaceAll(" ", ""));
451//
452// query = "node & node & node & #1 . #2 .1,3 #3";
453// String seq5 =
454// "{@type=korap:group, operation=operation:sequence, operands=[" +
455// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
456// "{@type=korap:group, operation=operation:sequence, operands=[" +
457// "{@type=korap:span}," +
458// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
459// "{@type=korap:span}" +
460// "]} "+
461// "], inOrder=true}" +
462// "]}," +
463// "{@type=korap:span}" +
464// "], distances=[" +
465// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3}" +
466// "], inOrder=true" +
467// "}";
468// aqlt = new AqlTree(query);
469// map = aqlt.getRequestMap().get("query").toString();
470// assertEquals(seq5.replaceAll(" ", ""), map.replaceAll(" ", ""));
471//
472// query = "tok=\"Sonne\" & tok=\"Mond\" & tok=\"Sterne\" & tok=\"Himmel\" & #1 .0,2 #2 .0,4 #3 . #4";
473// String seq6 =
474// "{@type=korap:group, operation=operation:sequence, operands=[" +
475// "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
476// "{@type=korap:group, operation=operation:sequence, operands=[" +
477// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
478// "{@type=korap:group, operation=operation:sequence, operands=[" +
479// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
480// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
481// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
482// "]}" +
483// "], distances=[" +
484// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
485// "], inOrder=true}" +
486// "]}," +
487// "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
488// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
489// "]}" +
490// "],distances=[" +
491// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
492// "], inOrder=true}" +
493// "]}," +
494// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Himmel, match=match:eq}}" +
495// "], inOrder=true}" ;
496// aqlt = new AqlTree(query);
497// map = aqlt.getRequestMap().get("query").toString();
498// assertEquals(seq6.replaceAll(" ", ""), map.replaceAll(" ", ""));
499// }
500//
501// @Test
502// public void testMultipleMixedOperators() throws QueryException {
503// query = "tok=\"Sonne\" & tok=\"Mond\" & tok=\"Sterne\" & #1 > #2 .0,4 #3";
504// String seq4 =
505// "{@type=korap:group, operation=operation:sequence, operands=[" +
506// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
507// "{@type=korap:group, operation=operation:relation, operands=[" +
508// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
509// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
510// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
511// "]}" +
512// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
513// "]}," +
514// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
515// "], distances=[" +
516// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
517// "], inOrder=true" +
518// "}";
519// aqlt = new AqlTree(query);
520// map = aqlt.getRequestMap().get("query").toString();
521// assertEquals(seq4.replaceAll(" ", ""), map.replaceAll(" ", ""));
522//
523// query = "tok=\"Sonne\" & tok=\"Mond\" & #1 > #2 .0,4 tok=\"Sterne\"";
524// String seq5 =
525// "{@type=korap:group, operation=operation:sequence, operands=[" +
526// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
527// "{@type=korap:group, operation=operation:relation, operands=[" +
528// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
529// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
530// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
531// "]}" +
532// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
533// "]}," +
534// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
535// "], distances=[" +
536// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
537// "], inOrder=true" +
538// "}";
539// aqlt = new AqlTree(query);
540// map = aqlt.getRequestMap().get("query").toString();
541// assertEquals(seq5.replaceAll(" ", ""), map.replaceAll(" ", ""));
542//
543// query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & #1 $ #2 > #3";
544// String cp2 =
545// "{@type=korap:group, operation=operation:relation, operands=[" +
546// "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
547// "{@type=korap:group, operation=operation:relation, operands=[" +
548// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
549// "{@type=korap:group, operation=operation:relation, operands=[" +
550// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
551// "{@type=korap:span}" +
552// "]}," +
553// "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
554// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
555// "]}," +
556// "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
557// "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
558// "]}" +
559// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
560// "}" +
561// "]}," +
562// "{@type=korap:span, layer=cat, key=PP, match=match:eq}" +
563// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
564// "}";
565// aqlt = new AqlTree(query);
566// map = aqlt.getRequestMap().get("query").toString();
567// assertEquals(cp2.replaceAll(" ", ""), map.replaceAll(" ", ""));
568// }
569// /*
570// @Test
571// public void testMultipleOperatorsWithSameOperands() throws QueryException {
572//
573// query = "cat=\"NP\" > cat=\"VP\" & #1 _l_ #2";
574// String eq2 =
575// "{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
576// "{@type=korap:group, operation=operation:relation, operands=[" +
577// "{@type=korap:group, operation=operation:class, class=, classOut=129, operands=[" +
578// "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
579// "]}," +
580// "{@type=korap:group, operation=operation:class, class=, classOut=129, operands=[" +
581// "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
582// "]}" +
583// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}," +
584// "{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
585// "]" +
586// "}"; // ???
587// aqlt = new AqlTree(query);
588// map = aqlt.getRequestMap().get("query").toString();
589// assertEquals(eq2.replaceAll(" ", ""), map.replaceAll(" ", ""));
590// }
591// */
592// @Test
593// public void testPositions() throws QueryException {
594// query = "node & node & #2 _=_ #1";
595// String pos1 =
596// "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
597// "{@type=korap:span}," +
598// "{@type=korap:span}" +
599// "], frame=frame:matches}";
600// aqlt = new AqlTree(query);
601// map = aqlt.getRequestMap().get("query").toString();
602// assertEquals(pos1.replaceAll(" ", ""), map.replaceAll(" ", ""));
603//
604// query = "node & node & #2 _i_ #1";
605// String pos2 =
606// "{@type=korap:group, operation=operation:position, frames=[frames:contains], operands=[" +
607// "{@type=korap:span}," +
608// "{@type=korap:span}" +
609// "], frame=frame:contains" +
610// "}";
611// aqlt = new AqlTree(query);
612// map = aqlt.getRequestMap().get("query").toString();
613// assertEquals(pos2.replaceAll(" ", ""), map.replaceAll(" ", ""));
614//
615// query = "node & node & #2 _l_ #1";
616// String pos3 =
617// "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
618// "{@type=korap:span}," +
619// "{@type=korap:span}" +
620// "], frame=frame:startswith" +
621// "}";
622// aqlt = new AqlTree(query);
623// map = aqlt.getRequestMap().get("query").toString();
624// assertEquals(pos3.replaceAll(" ", ""), map.replaceAll(" ", ""));
625//
626// query = "node & \"Mann\" & #1 _r_ #2";
627// String pos4 =
628// "{@type=korap:group, operation=operation:position, frames=[frames:endswith], operands=[" +
629// "{@type=korap:span}," +
630// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" +
631// "], frame=frame:endswith" +
632// "}";
633// aqlt = new AqlTree(query);
634// map = aqlt.getRequestMap().get("query").toString();
635// assertEquals(pos4.replaceAll(" ", ""), map.replaceAll(" ", ""));
636//
637// query = "node & \"Mann\" & #2 _r_ #1";
638// String pos5 =
639// "{@type=korap:group, operation=operation:position, frames=[frames:endswith], operands=[" +
640// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}," +
641// "{@type=korap:span}" +
642// "], frame=frame:endswith" +
643// "}";
644// aqlt = new AqlTree(query);
645// map = aqlt.getRequestMap().get("query").toString();
646// assertEquals(pos5.replaceAll(" ", ""), map.replaceAll(" ", ""));
647// }
648//
649// @Test
650// public void testMultiplePredications() throws QueryException {
651// // a noun before a verb before a preposition
652// query = "pos=\"N\" & pos=\"V\" & pos=\"P\" & #1 . #2 & #2 . #3";
653// String mult1 =
654// "{@type=korap:group, operation=operation:sequence, operands=[" +
655// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
656// "{@type=korap:group, operation=operation:sequence, operands=[" +
657// "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}," +
658// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
659// "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
660// "]}" +
661// "], inOrder=true}" +
662// "]}," +
663// "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
664// "], inOrder=true}";
665// aqlt = new AqlTree(query);
666// map = aqlt.getRequestMap().get("query").toString();
667// assertEquals(mult1.replaceAll(" ", ""), map.replaceAll(" ", ""));
668//
669// // a noun before a verb before a preposition
670// query = "pos=\"N\" & pos=\"V\" & #1 . #2 & #2 . pos=\"P\"";
671// String mult2 =
672// "{@type=korap:group, operation=operation:sequence, operands=[" +
673// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
674// "{@type=korap:group, operation=operation:sequence, operands=[" +
675// "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}," +
676// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
677// "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
678// "]}" +
679// "], inOrder=true}" +
680// "]}," +
681// "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
682// "], inOrder=true}";
683// aqlt = new AqlTree(query);
684// map = aqlt.getRequestMap().get("query").toString();
685// assertEquals(mult2.replaceAll(" ", ""), map.replaceAll(" ", ""));
686//
687// query = "pos=\"N\" & pos=\"V\" & pos=\"P\" & #1 > #2 & #1 > #3";
688// String mult3 =
689// "{@type=korap:group, operation=operation:relation, operands=[" +
690// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
691// "{@type=korap:group, operation=operation:relation, operands=[" +
692// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
693// "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}" +
694// "]}," +
695// "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
696// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
697// "]}," +
698// "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
699// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}";
700// aqlt = new AqlTree(query);
701// map = aqlt.getRequestMap().get("query").toString();
702// assertEquals(mult3.replaceAll(" ", ""), map.replaceAll(" ", ""));
703//
704// query = "cat=\"NP\" & pos=\"V\" & pos=\"P\" & #1 > #2 & #1 > #3 & #2 . #3";
705// String mult4 =
706// "{@type=korap:group, operation=operation:sequence, operands=[" +
707// // reduce dominance relations "#1 > #2 & #1 > #3" to operand #2 in order to make it accessible for #2 . #3 (the last/outermost relation)
708// "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
709// "{@type=korap:group, operation=operation:relation, operands=[" +
710// // dominance relation #1 > #2 is reduced to #1, for expressing #1 > #3
711// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
712// "{@type=korap:group, operation=operation:relation, operands=[" +
713// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
714// "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
715// "]}," +
716// "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
717// "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
718// "]}" +
719// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
720// "]}," +
721// // establish class 2 around P for later reference
722// "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
723// "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
724// "]}" +
725// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
726// "]}," +
727// // refer back to class 2 as second operand
728// "{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
729// "], inOrder=true}";
730// aqlt = new AqlTree(query);
731// map = aqlt.getRequestMap().get("query").toString();
732// assertEquals(mult4.replaceAll(" ", ""), map.replaceAll(" ", ""));
733// }
734//
735// @Test
736// public void testUnaryRelations() throws QueryException {
737// query = "node & #1:tokenarity=2";
738// String unary1 =
739// "{@type=korap:span, attr={@type=korap:term, tokenarity={@type=korap:boundary,min=2,max=2}}}";
740// aqlt = new AqlTree(query);
741// map = aqlt.getRequestMap().get("query").toString();
742// assertEquals(unary1.replaceAll(" ", ""), map.replaceAll(" ", ""));
743//
744// query = "cnx/cat=\"NP\" & #1:tokenarity=2";
745// String unary2 =
746// "{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq, attr={@type=korap:term, tokenarity={@type=korap:boundary,min=2,max=2}}}";
747// aqlt = new AqlTree(query);
748// map = aqlt.getRequestMap().get("query").toString();
749// assertEquals(unary2.replaceAll(" ", ""), map.replaceAll(" ", ""));
750//
751// query = "cnx/cat=\"NP\" & #1:root";
752// String unary3 =
753// "{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq, attr={@type=korap:term, root=true}}";
754// aqlt = new AqlTree(query);
755// map = aqlt.getRequestMap().get("query").toString();
756// assertEquals(unary3.replaceAll(" ", ""), map.replaceAll(" ", ""));
757//
758// query = "cnx/cat=\"NP\" & node & #1>#2 & #1:tokenarity=2";
759// String unary4 =
760// "{@type=korap:group, operation=operation:relation, operands=[" +
761// "{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq, attr={@type=korap:term, tokenarity={@type=korap:boundary,min=2,max=2}}}," +
762// "{@type=korap:span}" +
763// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
764// "}";
765// aqlt = new AqlTree(query);
766// map = aqlt.getRequestMap().get("query").toString();
767// assertEquals(unary4.replaceAll(" ", ""), map.replaceAll(" ", ""));
768// }
769//
770// @Test
771// public void testCommonParent() throws QueryException {
772// query = "cat=\"NP\" & cat=\"VP\" & #1 $ #2";
773// String cp1 =
774// "{@type=korap:group, operation=operation:relation, operands=[" +
775// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
776// "{@type=korap:group, operation=operation:relation, operands=[" +
777// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
778// "{@type=korap:span}" +
779// "]}," +
780// "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
781// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
782// "]}," +
783// "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
784// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
785// "";
786// aqlt = new AqlTree(query);
787// map = aqlt.getRequestMap().get("query").toString();
788// assertEquals(cp1.replaceAll(" ", ""), map.replaceAll(" ", ""));
789//
790// query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & #1 $ #2 $ #3";
791// String cp2 =
792// "{@type=korap:group, operation=operation:relation, operands=[" +
793// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
794// "{@type=korap:group, operation=operation:relation, operands=[" +
795// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
796// "{@type=korap:group, operation=operation:relation, operands=[" +
797// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
798// "{@type=korap:span}" +
799// "]}," +
800// "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
801// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
802// "]}," +
803// "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
804// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
805// "}" +
806// "]}," +
807// "{@type=korap:span, layer=cat, key=PP, match=match:eq}" +
808// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
809// "}";
810// aqlt = new AqlTree(query);
811// map = aqlt.getRequestMap().get("query").toString();
812// assertEquals(cp2.replaceAll(" ", ""), map.replaceAll(" ", ""));
813//
814// query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & cat=\"CP\" & #1 $ #2 $ #3 $ #4";
815// String cp3 =
816// "{@type=korap:group, operation=operation:relation, operands=[" +
817// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
818// "{@type=korap:group, operation=operation:relation, operands=[" +
819// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
820// "{@type=korap:group, operation=operation:relation, operands=[" +
821// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
822// "{@type=korap:group, operation=operation:relation, operands=[" +
823// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
824// "{@type=korap:span}" +
825// "]}," +
826// "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
827// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
828// "]}," +
829// "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
830// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
831// "]}," +
832// "{@type=korap:span, layer=cat, key=PP, match=match:eq}" +
833// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
834// "]}," +
835// "{@type=korap:span, layer=cat, key=CP, match=match:eq}" +
836// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
837// "}" +
838// "";
839// aqlt = new AqlTree(query);
840// map = aqlt.getRequestMap().get("query").toString();
841// assertEquals(cp3.replaceAll(" ", ""), map.replaceAll(" ", ""));
842//
843// query = "cat=\"NP\" & cat=\"VP\" & #1 $* #2";
844// String cp4 =
845// "{@type=korap:group, operation=operation:relation, operands=[" +
846// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
847// "{@type=korap:group, operation=operation:relation, operands=[" +
848// "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
849// "{@type=korap:span}" +
850// "]}," +
851// "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
852// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c},boundary={@type=korap:boundary,min=1}}}" +
853// "]}," +
854// "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
855// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c},boundary={@type=korap:boundary,min=1}}}" +
856// "";
857// aqlt = new AqlTree(query);
858// map = aqlt.getRequestMap().get("query").toString();
859// assertEquals(cp4.replaceAll(" ", ""), map.replaceAll(" ", ""));
860// }
861
Joachim Bingele6d73b12014-09-30 15:34:59 +0000862 /*
863 @Test
864 public void testEqualNotequalValue() throws QueryException {
865 query = "cat=\"NP\" & cat=\"VP\" & #1 == #2";
866 String eq1 =
867 "{}"; // ???
868 aqlt = new AqlTree(query);
869 map = aqlt.getRequestMap().get("query").toString();
870 assertEquals(eq1.replaceAll(" ", ""), map.replaceAll(" ", ""));
871 }
872 */
873
Joachim Bingel66472b82014-12-04 16:00:05 +0000874}