blob: ecf0cfc4c041f9281b7d9f8fabed0fa8167c24d0 [file] [log] [blame]
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00001import static org.junit.Assert.*;
2
3import org.junit.Test;
4
5import de.ids_mannheim.korap.query.serialize.CosmasTree;
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00006import de.ids_mannheim.korap.util.QueryException;
7
8public class CosmasTreeTest {
9
Joachim Bingel2daf9862014-02-12 10:18:54 +000010 CosmasTree ct;
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000011 String map;
12 String query;
Joachim Bingel37a803f2014-07-28 14:21:44 +000013 String expected;
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000014
Joachim Bingel81812632014-02-18 08:55:22 +000015 @Test
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000016 public void testContext() throws QueryException {
Joachim Bingel9e6b9482014-10-15 12:02:49 +000017 String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld";
Joachim Bingel2daf9862014-02-12 10:18:54 +000018 ct = new CosmasTree("Test");
19 assertEquals(contextString.replaceAll(" ", ""), ct.getRequestMap().get("@context").toString().replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000020 }
21
22
23 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +000024 public void testSingleToken() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000025 query="der";
26 String single1 =
Joachim Bingelee3b21d2014-02-12 12:34:59 +000027 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000028 ct = new CosmasTree(query);
29 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000030 assertEquals(single1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Michael Hanlbaf1a5e2014-05-15 19:51:40 +000031
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000032 query="Mann";
33 String single2 =
Joachim Bingelee3b21d2014-02-12 12:34:59 +000034 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000035 ct = new CosmasTree(query);
36 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000037 assertEquals(single2.replaceAll(" ", ""), map.replaceAll(" ", ""));
38
39 query="&Mann";
40 String single3 =
Joachim Bingelee3b21d2014-02-12 12:34:59 +000041 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000042 ct = new CosmasTree(query);
43 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000044 assertEquals(single3.replaceAll(" ", ""), map.replaceAll(" ", ""));
45 }
46
Joachim Bingelba9a0ab2014-01-29 10:12:25 +000047 @Test
Joachim Bingel9a202ab2014-10-07 12:35:17 +000048 public void testWildcardToken() throws QueryException {
49 query="*der";
50 String wc1 =
51 "{@type=korap:token, wrap={@type=korap:term, type=type:wildcard, key=*der, layer=orth, match=match:eq}}";
52 ct = new CosmasTree(query);
53 map = ct.getRequestMap().get("query").toString();
54 assertEquals(wc1.replaceAll(" ", ""), map.replaceAll(" ", ""));
55 }
56
57 @Test
Joachim Bingel8c640e42014-02-07 16:20:47 +000058 public void testCaseSensitivityFlag() throws QueryException {
Joachim Bingel0207d5e2014-02-12 14:18:41 +000059 query="$deutscher";
60 String cs1 =
61 "{@type=korap:token, wrap={@type=korap:term, caseInsensitive=true, key=deutscher, layer=orth, match=match:eq}}";
62 ct = new CosmasTree(query);
63 map = ct.getRequestMap().get("query").toString();
64 assertEquals(cs1.replaceAll(" ", ""), map.replaceAll(" ", ""));
65
66 query="$deutscher Bundestag";
67 String cs2 =
68 "{@type=korap:group, operation=operation:sequence, operands=[" +
69 "{@type=korap:token, wrap={@type=korap:term, caseInsensitive=true, key=deutscher, layer=orth, match=match:eq}}," +
70 "{@type=korap:token, wrap={@type=korap:term, key=Bundestag, layer=orth, match=match:eq}}" +
71 "]}";
72 ct = new CosmasTree(query);
73 map = ct.getRequestMap().get("query").toString();
74 assertEquals(cs2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel8c640e42014-02-07 16:20:47 +000075 }
76
77 @Test
Joachim Bingelffd65e32014-01-22 14:22:57 +000078 public void testMORPH() throws QueryException {
Joachim Bingelb4ab2502014-11-06 10:07:26 +000079 query="MORPH(pos=V)";
Joachim Bingelffd65e32014-01-22 14:22:57 +000080 String morph1 =
Joachim Bingel0207d5e2014-02-12 14:18:41 +000081 "{@type=korap:token, wrap={@type=korap:term, key=V, layer=pos, match=match:eq}}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000082 ct = new CosmasTree(query);
83 map = ct.getRequestMap().get("query").toString();
Joachim Bingelffd65e32014-01-22 14:22:57 +000084 assertEquals(morph1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld73a1852014-12-01 11:06:23 +000085
86 query="MORPH(V)";
87 expected =
88 "{@type=korap:token, wrap={@type=korap:term, key=V, match=match:eq}}";
89 ct = new CosmasTree(query);
90 map = ct.getRequestMap().get("query").toString();
91 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelffd65e32014-01-22 14:22:57 +000092 }
93
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000094 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +000095 public void testSequence() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000096 query="der Mann";
97 String seq1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +000098 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +000099 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
100 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000101 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000102 ct = new CosmasTree(query);
103 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000104 assertEquals(seq1.replaceAll(" ", ""), map.replaceAll(" ", ""));
105
Joachim Bingeld5161a12014-01-08 11:15:49 +0000106 query="der Mann schläft";
107 String seq2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000108 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000109 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
110 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
111 "{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000112 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000113 ct = new CosmasTree(query);
114 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000115 assertEquals(seq2.replaceAll(" ", ""), map.replaceAll(" ", ""));
116
117 query="der Mann schläft lang";
118 String seq3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000119 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000120 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
121 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
122 "{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}," +
123 "{@type=korap:token, wrap={@type=korap:term, key=lang, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000124 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000125 ct = new CosmasTree(query);
126 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000127 assertEquals(seq3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel896067a2014-11-07 19:02:27 +0000128
129 query="der #ELEM(S)";
130 expected =
131 "{@type=korap:group, operation=operation:sequence, operands=[" +
132 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
133 "{@type=korap:span, key=s}" +
134 "]}";
135 ct = new CosmasTree(query);
136 map = ct.getRequestMap().get("query").toString();
137 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
138
139 query="der MORPH(mate/p=ADJA)";
140 expected =
141 "{@type=korap:group, operation=operation:sequence, operands=[" +
142 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
143 "{@type=korap:token, wrap={@type=korap:term, key=ADJA, foundry=mate, layer=p, match=match:eq}}" +
144 "]}";
145 ct = new CosmasTree(query);
146 map = ct.getRequestMap().get("query").toString();
147 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000148 }
149
150 @Test
151 public void testOPOR() throws QueryException {
152 query="Sonne oder Mond";
153 String disj1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000154 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000155 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
156 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000157 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000158 ct = new CosmasTree(query);
159 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000160 assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", ""));
161
Joachim Bingeld5161a12014-01-08 11:15:49 +0000162 query="(Sonne scheint) oder Mond";
163 String disj2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000164 "{@type=korap:group, operation=operation:or, operands=[" +
165 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000166 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
167 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000168 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000169 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000170 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000171 ct = new CosmasTree(query);
172 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000173 assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", ""));
174
175 query="(Sonne scheint) oder (Mond scheint)";
176 String disj3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000177 "{@type=korap:group, operation=operation:or, operands=[" +
178 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000179 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
180 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000181 "]}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000182 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000183 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
184 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000185 "]}" +
186 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000187 ct = new CosmasTree(query);
188 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000189 assertEquals(disj3.replaceAll(" ", ""), map.replaceAll(" ", ""));
190
191 }
192
193 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000194 public void testOPORAND() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000195 query="(Sonne oder Mond) und scheint";
196 String orand1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000197 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000198 "{@type=cosmas:distance, key=t, min=0, max=0}" +
Joachim Bingelb7a59792014-02-14 13:52:29 +0000199 "], operands=[" +
200 "{@type=korap:group, operation=operation:or, operands=[" +
201 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
202 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
203 "]}," +
204 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000205 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000206 ct = new CosmasTree(query);
207 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000208 assertEquals(orand1.replaceAll(" ", ""), map.replaceAll(" ", ""));
209
210 query="scheint und (Sonne oder Mond)";
211 String orand2 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000212 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000213 "{@type=cosmas:distance, key=t, min=0, max=0}" +
Joachim Bingelb7a59792014-02-14 13:52:29 +0000214 "], operands=[" +
215 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," +
216 "{@type=korap:group, operation=operation:or, operands=[" +
217 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
218 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000219 "]}" +
220 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000221 ct = new CosmasTree(query);
222 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000223 assertEquals(orand2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel92f9c9c2014-06-25 15:01:17 +0000224
225 query="Regen und scheint und (Sonne oder Mond)";
226 String orand3 =
227 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000228 "{@type=cosmas:distance, key=t, min=0, max=0}" +
Joachim Bingel92f9c9c2014-06-25 15:01:17 +0000229 "], operands=[" +
230 "{@type=korap:token, wrap={@type=korap:term, key=Regen, layer=orth, match=match:eq}}," +
231 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000232 "{@type=cosmas:distance, key=t, min=0, max=0}" +
Joachim Bingel92f9c9c2014-06-25 15:01:17 +0000233 "], operands=[" +
234 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," +
235 "{@type=korap:group, operation=operation:or, operands=[" +
236 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
237 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
238 "]}" +
239 "]}" +
240 "]}";
241 ct = new CosmasTree(query);
242 map = ct.getRequestMap().get("query").toString();
243 assertEquals(orand3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000244 }
245
246 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000247 public void testOPPROX() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000248 query="Sonne /+w1:4 Mond";
249 String prox1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000250 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000251 "{@type=korap:group, operation=operation:sequence, " +
252 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000253 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000254 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
255 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000256 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000257 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
258 "]}" +
259 "], inOrder=true, " +
260 "distances=[" +
261 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
262 "]" +
263 "}" +
264 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000265 ct = new CosmasTree(query);
266 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000267 assertEquals(prox1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel89cceac2014-01-08 15:51:08 +0000268
269 query="Sonne /+w1:4,s0,p1:3 Mond";
270 String prox2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000271 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000272 "{@type=korap:group, operation=operation:sequence, " +
273 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000274 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000275 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
276 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000277 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000278 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
279 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000280 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000281 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000282 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}," +
Joachim Bingel832800e2014-10-17 14:46:39 +0000283 "{@type=cosmas:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}," +
284 "{@type=cosmas:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3}" +
Joachim Bingel89cceac2014-01-08 15:51:08 +0000285 "]" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000286 "}" +
287 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000288 ct = new CosmasTree(query);
289 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000290 assertEquals(prox2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000291
292 query="Sonne %+w1:4,s0,p1:3 Mond";
293 String prox3 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000294 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000295 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000296 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000297 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000298 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
299 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000300 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000301 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
302 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000303 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000304 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000305 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4, exclude=true}," +
Joachim Bingel832800e2014-10-17 14:46:39 +0000306 "{@type=cosmas:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0, exclude=true}," +
307 "{@type=cosmas:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3, exclude=true}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000308 "]" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000309 "}" +
310 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000311 ct = new CosmasTree(query);
312 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +0000313// assertEquals(prox3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000314
315 query="Sonne /+w4 Mond";
316 String prox4 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000317 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000318 "{@type=korap:group, operation=operation:sequence, " +
319 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000320 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000321 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
322 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000323 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000324 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
325 "]}" +
326 "], inOrder=true, " +
327 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000328 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000329 "]" +
330 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000331 "]}";
332// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000333// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000334// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000335// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
336// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000337// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000338// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
339// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000340// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000341// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000342// "{@type=korap:group, operation=operation:sequence, " +
343// "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000344// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000345// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
346// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000347// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000348// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
349// "]}" +
350// "], inOrder=true, " +
351// "distances=[" +
352// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
353// "]" +
354// "}" +
355// "]}" +
356// "]}";
357
358
Joachim Bingel2daf9862014-02-12 10:18:54 +0000359 ct = new CosmasTree(query);
360 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000361 assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000362
363 query="Sonne /-w4 Mond";
364 String prox5 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000365 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000366 "{@type=korap:group, operation=operation:sequence, " +
367 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000368 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000369 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
370 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000371 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000372 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
373 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000374 "], inOrder=true, " +
375 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000376 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000377 "]" +
378 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000379 "]}";
380// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000381// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000382// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000383// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
384// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000385// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000386// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
387// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000388// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000389// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000390// "{@type=korap:group, operation=operation:sequence, " +
391// "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000392// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000393// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
394// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000395// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000396// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
397// "]}" +
398// "], inOrder=true, " +
399// "distances=[" +
400// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
401// "]" +
402// "}" +
403// "]}" +
404// "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000405 ct = new CosmasTree(query);
406 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000407 assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000408
409 query="Sonne /w4 Mond";
410 String prox6 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000411 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000412 "{@type=korap:group, operation=operation:sequence, " +
413 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000414 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000415 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
416 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000417 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000418 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
419 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000420 "], inOrder=false, " +
421 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000422 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000423 "]" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000424 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000425 "]}";
426// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000427// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000428// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000429// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
430// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000431// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000432// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
433// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000434// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000435// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000436// "{@type=korap:group, operation=operation:sequence, " +
437// "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000438// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000439// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
440// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000441// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000442// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
443// "]}" +
444// "], inOrder=false, " +
445// "distances=[" +
446// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
447// "]" +
448// "}" +
449// "]}" +
450// "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000451 ct = new CosmasTree(query);
452 map = ct.getRequestMap().get("query").toString();
453 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000454 }
455
456 @Test
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000457 public void testOPPROXNested() throws QueryException {
Joachim Bingel09737972014-09-22 09:43:06 +0000458 query="Sonne /+w1:4 Mond /-w1:7 Sterne";
459 expected =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000460 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000461 "{@type=korap:group, operation=operation:sequence, " +
462 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000463 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000464 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
465 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000466 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
467 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000468 "{@type=korap:group, operation=operation:sequence, " +
469 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000470 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000471 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000472 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000473 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000474 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000475 "]}" +
476 "], inOrder=true, " +
477 "distances=[" +
478 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=7}, min=1, max=7}" +
479 "]" +
480 "}" +
481 "]}" +
482 "]}" +
483 "], inOrder=true, " +
484 "distances=[" +
485 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
486 "]" +
487 "}" +
488 "]}" +
489 "" ;
490 ct = new CosmasTree(query);
491 map = ct.getRequestMap().get("query").toString();
492 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
493
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000494 query="Sonne /-w4 Mond /+w2 Sterne";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000495
Joachim Bingelceb79062014-09-22 11:50:37 +0000496// String mondsterne =
497// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
498// "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" ;
Joachim Bingelfbc88792014-09-17 11:11:52 +0000499
500 String mondsterneClasses =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000501 "{@type=korap:group, operation=operation:class, class=128 , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000502 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
503 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000504 "{@type=korap:group, operation=operation:class, class=128 , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000505 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
506 "]}";
Joachim Bingelceb79062014-09-22 11:50:37 +0000507// String mondsterneSeq =
508// "{@type=korap:group, operation=operation:sequence, operands=[" +
509// mondsterne +
510// "], inOrder=true, distances=[" +
511// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
512// "]}" ;
Joachim Bingelfbc88792014-09-17 11:11:52 +0000513 String mondsterneClassesSeq =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000514 "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000515 "{@type=korap:group, operation=operation:sequence, operands=[" +
516 mondsterneClasses +
517 "], inOrder=true, distances=[" +
518 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
519 "]}" +
520 "]}" ;
Joachim Bingelceb79062014-09-22 11:50:37 +0000521// String mondsterneOv =
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000522// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelceb79062014-09-22 11:50:37 +0000523// mondsterne +
524// "]}";
Joachim Bingelfbc88792014-09-17 11:11:52 +0000525 String mondsterneClassesOv =
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000526 "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000527 mondsterneClasses +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000528 "], frame=frame:overlaps}";
Joachim Bingelceb79062014-09-22 11:50:37 +0000529// String mondsterneAll =
530// "{@type=korap:group, operation=operation:or, operands=[" +
531// mondsterneOv + "," + mondsterneClassesSeq +
532// "]}";
Joachim Bingelfbc88792014-09-17 11:11:52 +0000533 String mondsterneAllClasses =
534 "{@type=korap:group, operation=operation:or, operands=[" +
535 mondsterneClassesOv + "," + mondsterneClassesSeq +
536 "]}";
537
538
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000539 String prox6 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000540 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000541 "{@type=korap:group, operation=operation:sequence, " +
542 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000543 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
544 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000545 "{@type=korap:group, operation=operation:sequence, " +
546 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000547 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000548 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
549 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000550 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000551 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
552 "]}" +
553 "], inOrder=true, " +
554 "distances=[" +
555 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
556 "]" +
557 "}" +
558 "]}" +
559 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000560 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000561 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
562 "]}" +
563 "], inOrder=true, " +
564 "distances=[" +
565 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
566 "]" +
567 "}" +
568 "]}" +
569 "" ;
570// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000571// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000572// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000573// mondsterneAllClasses +
574// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000575// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000576// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
577// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000578// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000579// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000580// "{@type=korap:group, operation=operation:sequence, " +
581// "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000582// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000583// mondsterneAllClasses +
584// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000585// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000586// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
587// "]}" +
588// "], inOrder=true, " +
589// "distances=[" +
590// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
591// "]" +
592// "}" +
593// "]}" +
594// "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000595 ct = new CosmasTree(query);
596 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000597 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000598 }
599
600 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000601 public void testOPIN() throws QueryException {
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000602 query="wegen #IN <s>";
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000603 String opin1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000604 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000605 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000606 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000607 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000608 "{@type=korap:span, key=s}" +
609 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000610 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000611 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
612 "]}" +
613 "], frames=[], frame=frame:contains}" +
614 "]}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000615 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000616 ct = new CosmasTree(query);
617 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000618 assertEquals(opin1.replaceAll(" ", ""), map.replaceAll(" ", ""));
619
Joachim Bingel09737972014-09-22 09:43:06 +0000620 query="wegen #IN(L) <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000621 String opin2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000622 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000623 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000624 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000625 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000626 "{@type=korap:span, key=s}" +
627 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000628 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000629 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
630 "]}" +
631 "], frames=[frames:startswith], frame=frame:startswith}" +
632 "]}" +
633 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000634 ct = new CosmasTree(query);
635 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000636 assertEquals(opin2.replaceAll(" ", ""), map.replaceAll(" ", ""));
637
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000638
639 query="wegen #IN(F) <s>";
640 String opin3=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000641 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000642 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000643 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000644 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000645 "{@type=korap:span, key=s}" +
646 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000647 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000648 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
649 "]}" +
650 "], frames=[frames:matches], frame=frame:matches}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000651 "]}" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000652 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000653 ct = new CosmasTree(query);
654 map = ct.getRequestMap().get("query").toString();
655 assertEquals(opin3.replaceAll(" ", ""), map.replaceAll(" ", ""));
656
657 query="wegen #IN(FI) <s>";
658 String opin4=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000659 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000660 "{@type=korap:group, operation=operation:class, classRefCheck=[classRefCheck:unequals,classRefCheck:includes], classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000661 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000662 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000663 "{@type=korap:span, key=s}" +
664 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000665 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000666 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
667 "]}" +
668 "], frames=[frames:matches], frame=frame:matches-noident}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000669 "]}" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000670 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000671 ct = new CosmasTree(query);
672 map = ct.getRequestMap().get("query").toString();
673 assertEquals(opin4.replaceAll(" ", ""), map.replaceAll(" ", ""));
674
675 query="wegen #IN(FE) <s>";
676 String opin5=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000677 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000678 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000679 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000680 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000681 "{@type=korap:span, key=s}" +
682 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000683 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000684 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
685 "]}" +
686 "], frames=[frames:matches], frame=frame:matches}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000687 "]}" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000688 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000689 ct = new CosmasTree(query);
690 map = ct.getRequestMap().get("query").toString();
691 assertEquals(opin5.replaceAll(" ", ""), map.replaceAll(" ", ""));
692
Joachim Bingel87480d02014-01-17 14:07:46 +0000693 query="wegen #IN(%, L) <s>";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000694 String opin6 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000695 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000696 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000697 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000698 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000699 "{@type=korap:span, key=s}" +
700 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000701 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000702 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
703 "]}" +
704 "], frames=[frames:startswith], frame=frame:startswith, exclude=true}" +
705 "]}" +
706 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000707 ct = new CosmasTree(query);
708 map = ct.getRequestMap().get("query").toString();
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000709 assertEquals(opin6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000710
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000711 query="wegen #IN(FE,ALL,%,MIN) <s>";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000712 String opin7 =
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000713 "{@type=korap:reference, operation=operation:focus, reset=true, operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000714 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000715 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000716 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000717 "{@type=korap:span, key=s}" +
718 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000719 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000720 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000721 "]}" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000722
723 "], frames=[frames:matches], frame=frame:matches, exclude=true, grouping=false}" +
724 "]}" +
725 "]}" +
726 "";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000727 ct = new CosmasTree(query);
728 map = ct.getRequestMap().get("query").toString();
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000729 assertEquals(opin7.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000730 }
731
732 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000733 public void testOPOV() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000734 query="wegen #OV <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000735 String opov1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000736 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000737 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000738 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000739 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000740 "{@type=korap:span, key=s}" +
741 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000742 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000743 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
744 "]}" +
745 "], frames=[], frame=frame:overlaps}" +
746 "]}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000747 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000748 ct = new CosmasTree(query);
749 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000750 assertEquals(opov1.replaceAll(" ", ""), map.replaceAll(" ", ""));
751
752 query="wegen #OV(L) <s>";
753 String opov2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000754 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000755 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000756 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000757 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000758 "{@type=korap:span, key=s}" +
759 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000760 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000761 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
762 "]}" +
763 "], frames=[frames:startswith,frames:overlapsLeft], frame=frame:overlapsLeft}" +
764 "]}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000765 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000766 ct = new CosmasTree(query);
767 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000768 assertEquals(opov2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000769
770 query="wegen #OV(F) <s>";
771 String opov3=
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000772
Joachim Bingel6b491c22014-10-21 08:35:18 +0000773 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000774 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000775 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000776 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000777 "{@type=korap:span, key=s}" +
778 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000779 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000780 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
781 "]}" +
782 "], frames=[frames:matches], frame=frame:matches}" +
783 "]}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000784 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000785 ct = new CosmasTree(query);
786 map = ct.getRequestMap().get("query").toString();
787 assertEquals(opov3.replaceAll(" ", ""), map.replaceAll(" ", ""));
788
789 query="wegen #OV(FI) <s>";
790 String opov4=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000791 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000792 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:unequals, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000793 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000794 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000795 "{@type=korap:span, key=s}" +
796 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000797 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000798 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
799 "]}" +
800 "], frames=[frames:matches], frame=frame:matches-noident}" +
801 "]}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000802 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000803 ct = new CosmasTree(query);
804 map = ct.getRequestMap().get("query").toString();
805 assertEquals(opov4.replaceAll(" ", ""), map.replaceAll(" ", ""));
806
807 query="wegen #OV(FE) <s>";
808 String opov5=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000809 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000810 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000811 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000812 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000813 "{@type=korap:span, key=s}" +
814 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000815 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000816 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
817 "]}" +
818 "], frames=[frames:matches], frame=frame:matches}" +
819 "]}" +
820 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000821 ct = new CosmasTree(query);
822 map = ct.getRequestMap().get("query").toString();
823 assertEquals(opov5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000824 }
825
826 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000827 public void testOPNOT() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000828 query="Sonne nicht Mond";
829 String opnot1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000830 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000831 "{@type=cosmas:distance, key=t, min=0, max=0, exclude=true}" +
Joachim Bingelb7a59792014-02-14 13:52:29 +0000832 "], operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000833 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
834 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000835 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000836 ct = new CosmasTree(query);
837 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000838 assertEquals(opnot1.replaceAll(" ", ""), map.replaceAll(" ", ""));
839 }
840
841 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000842 public void testBEG_END() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000843 // BEG and END operators
844 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/links.html
845 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/rechts.html
846 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/thematische-bsp/bsp-satzlaenge.html
Joachim Bingel87480d02014-01-17 14:07:46 +0000847 query="#BEG(der /w3:5 Mann)";
848 String beg1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000849 "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000850 "{@type=korap:group, operation=operation:sequence," +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000851 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000852 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
853 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000854 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000855 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000856 "]}" +
857 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000858 ct = new CosmasTree(query);
859 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000860 assertEquals(beg1.replaceAll(" ", ""), map.replaceAll(" ", ""));
861
Joachim Bingel37a803f2014-07-28 14:21:44 +0000862
Joachim Bingelfbc88792014-09-17 11:11:52 +0000863// String dermannSeq = "{@type=korap:group, operation=operation:sequence," +
864// "operands = [" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000865// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000866// "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
867// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000868// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000869// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
870// "]}" +
871//
872// "], inOrder=false, distances=[" +
873// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
874// "]}";
875//
876// String begDermannSeq =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000877//// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000878// "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
879// dermannSeq +
880// "]}" +
881//// "]}" +
882// "";
883
Joachim Bingel37a803f2014-07-28 14:21:44 +0000884 String kommt = "{@type=korap:token, wrap={@type=korap:term, key=kommt, layer=orth, match=match:eq}}";
885
Joachim Bingel87480d02014-01-17 14:07:46 +0000886 query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group
887 String beg2 =
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000888// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000889// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000890// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000891// beg1 +
892// "]}" + "," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000893// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000894// kommt +
895// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000896// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000897// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000898// "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000899// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000900// beg1 +
901// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000902// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000903// kommt +
904// "]}" +
905// "], inOrder=true, distances=[" +
906// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
907// "]}" +
908// "]}" +
909// "]}";
910//
Joachim Bingel6b491c22014-10-21 08:35:18 +0000911 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000912 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000913 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000914 beg1 +
915 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000916 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000917 kommt +
918 "]}" +
919 "], inOrder=true, distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000920 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=10}, min=0, max=10}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000921 "]}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000922 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000923 ct = new CosmasTree(query);
924 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000925 assertEquals(beg2.replaceAll(" ", ""), map.replaceAll(" ", ""));
926
Joachim Bingel37a803f2014-07-28 14:21:44 +0000927 query="kommt /+w10 #BEG(der /w3:5 Mann)";
928 String beg3 =
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000929// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000930// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000931// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000932// kommt +
933//// "," +
934// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000935// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000936// beg1+
937// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000938// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000939// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000940// "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000941// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000942// kommt +
943// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000944// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000945// beg1+
946// "]}" +
947// "], inOrder=true, distances=[" +
948// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
949// "]}" +
950// "]}" +
951// "]}";
952
Joachim Bingel6b491c22014-10-21 08:35:18 +0000953 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000954 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000955 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000956 kommt +
957 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000958 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000959 beg1+
960 "]}" +
961 "], inOrder=true, distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000962 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=10}, min=0, max=10}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000963 "]}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000964 "]}";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000965 ct = new CosmasTree(query);
966 map = ct.getRequestMap().get("query").toString();
967 assertEquals(beg3.replaceAll(" ", ""), map.replaceAll(" ", ""));
968
Joachim Bingel87480d02014-01-17 14:07:46 +0000969 query="#END(der /w3:5 Mann)";
970 String end1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000971 "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000972 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000973 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000974 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
975 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000976 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000977 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000978 "]}" +
979 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000980 ct = new CosmasTree(query);
981 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000982 assertEquals(end1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000983 }
Joachim Bingeld5161a12014-01-08 11:15:49 +0000984
Joachim Bingel03dfd952014-07-30 08:08:53 +0000985 /*
986 * YET UNCLEAR HOW TO SERIALIZE SPAN DISTANCES. BEING DISCUSSED.
987 *
Joachim Bingel37a803f2014-07-28 14:21:44 +0000988 @Test
989 public void testSentenceDistance() throws QueryException {
Joachim Bingel03dfd952014-07-30 08:08:53 +0000990 query="Sonne /s0 Mond"; // contains(focus(1:contains({1:<s>},Sonne)),Mond)
Joachim Bingel37a803f2014-07-28 14:21:44 +0000991 expected =
Joachim Bingel93e6c702014-09-30 15:19:23 +0000992 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000993 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000994 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000995 "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000996 "{@type=korap:span, key=s}" +
997 "]}," +
998 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
999 "]}" +
1000 "]}," +
1001 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
1002 "]}";
1003 ct = new CosmasTree(query);
1004 map = ct.getRequestMap().get("query").toString();
1005 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1006
Joachim Bingel03dfd952014-07-30 08:08:53 +00001007 query="Sonne /s0,w5 Mond";
1008 expected =
Joachim Bingel93e6c702014-09-30 15:19:23 +00001009 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001010 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001011 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001012 "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001013 "{@type=korap:span, key=s}" +
1014 "]}," +
1015 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1016 "]}" +
1017 "]}," +
1018 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
1019 "]}";
1020// ct = new CosmasTree(query);
1021// map = ct.getRequestMap().get("query").toString();
1022// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1023
Joachim Bingel37a803f2014-07-28 14:21:44 +00001024 query="Sonne /s2:2 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond)
1025 expected =
1026 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001027 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001028 "{@type=korap:span, key=s}," +
1029 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1030 "]}," +
1031 "{@type=korap:span, key=s}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001032 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001033 "{@type=korap:span, key=s}," +
1034 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001035 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001036 "]}";
1037 ct = new CosmasTree(query);
1038 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +00001039// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel37a803f2014-07-28 14:21:44 +00001040
Joachim Bingel03dfd952014-07-30 08:08:53 +00001041 query="Sonne /s2:3 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond)
1042 expected =
1043 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001044 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001045 "{@type=korap:span, key=s}," +
1046 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1047 "]}," +
1048 "{@type=korap:group, operation=operation:repetition, operands=[" +
1049 "{@type=korap:span, key=s}" +
1050 "], boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001051 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001052 "{@type=korap:span, key=s}," +
1053 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
1054 "]}" +
1055 "]}";
1056 ct = new CosmasTree(query);
1057 map = ct.getRequestMap().get("query").toString();
1058// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1059
1060 query="Sonne /s2 Mond"; // contains(focus(1:contains({1:<s>},Sonne)),Mond) | contains(<s>,Sonne)<s>?contains(<s>,Mond)
Joachim Bingel37a803f2014-07-28 14:21:44 +00001061 expected =
1062 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001063 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001064 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001065 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001066 "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001067 "{@type=korap:span, key=s}" +
1068 "]}," +
1069 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1070 "]}" +
1071 "]}," +
1072 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
1073 "]}," +
1074 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001075 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001076 "{@type=korap:span, key=s}," +
1077 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1078 "]}," +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001079 "{@type=korap:group, operation=operation:repetition, operands=[" +
1080 "{@type=korap:span, key=s}" +
1081 "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001082 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001083 "{@type=korap:span, key=s}," +
1084 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001085 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001086 "]}" +
1087 "]}";
1088 ct = new CosmasTree(query);
1089 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +00001090// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel37a803f2014-07-28 14:21:44 +00001091 }
Joachim Bingel03dfd952014-07-30 08:08:53 +00001092 */
Joachim Bingel37a803f2014-07-28 14:21:44 +00001093
Joachim Bingeld5161a12014-01-08 11:15:49 +00001094
1095 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001096 public void testELEM() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +00001097 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/elem.html
Joachim Bingeleecc7652014-01-11 17:21:07 +00001098 query="#ELEM(S)";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001099 String elem1 = "{@type=korap:span, key=s}";
1100 ct = new CosmasTree(query);
1101 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +00001102 assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel402c6e12014-05-08 17:09:06 +00001103
1104 query="#ELEM(W ANA=N)";
1105 String elem2 =
1106 "{@type=korap:span, key=w, attr=" +
1107 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001108 "{@type=korap:term, layer=p, key=N, match=match:eq}" +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001109 "]}" +
1110 "}";
1111 ct = new CosmasTree(query);
1112 map = ct.getRequestMap().get("query").toString();
1113 assertEquals(elem2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1114
1115 query="#ELEM(W ANA != 'N V')";
1116 String elem3 =
1117 "{@type=korap:span, key=w, attr=" +
1118 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001119 "{@type=korap:term, layer=p, key=N, match=match:ne}," +
1120 "{@type=korap:term, layer=p, key=V, match=match:ne}" +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001121 "]}" +
1122 "}";
1123 ct = new CosmasTree(query);
1124 map = ct.getRequestMap().get("query").toString();
1125 assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", ""));
1126
Joachim Bingelb674cca2014-05-09 14:00:58 +00001127 query="#ELEM(W ANA != 'N A V' Genre = Sport)";
Joachim Bingel402c6e12014-05-08 17:09:06 +00001128 String elem4 =
1129 "{@type=korap:span, key=w, attr=" +
1130 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1131 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001132 "{@type=korap:term, layer=p, key=N, match=match:ne}," +
1133 "{@type=korap:term, layer=p, key=A, match=match:ne}," +
1134 "{@type=korap:term, layer=p, key=V, match=match:ne}" +
Joachim Bingelb674cca2014-05-09 14:00:58 +00001135 "]}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001136 "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" +
1137 "]}" +
1138 "}";
1139 ct = new CosmasTree(query);
1140 map = ct.getRequestMap().get("query").toString();
1141 assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb674cca2014-05-09 14:00:58 +00001142
1143 query="#ELEM(W ANA != 'N V' Genre != 'Sport Politik')";
1144 String elem5 =
1145 "{@type=korap:span, key=w, attr=" +
1146 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1147 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001148 "{@type=korap:term, layer=p, key=N, match=match:ne}," +
1149 "{@type=korap:term, layer=p, key=V, match=match:ne}" +
Joachim Bingelb674cca2014-05-09 14:00:58 +00001150 "]}," +
1151 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1152 "{@type=korap:term, layer=Genre, key=Sport, match=match:ne}," +
1153 "{@type=korap:term, layer=Genre, key=Politik, match=match:ne}" +
1154 "]}" +
1155 "]}" +
1156 "}";
1157 ct = new CosmasTree(query);
1158 map = ct.getRequestMap().get("query").toString();
1159 assertEquals(elem5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001160 }
1161
1162 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001163 public void testOPALL() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +00001164 query="#ALL(gehen /w1:10 voran)";
Joachim Bingele98d0882014-01-21 12:58:54 +00001165 String all1 =
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001166 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +00001167 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +00001168 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
1169 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001170 "], inOrder=false, " +
1171 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001172 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001173 "]" +
1174 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001175 ct = new CosmasTree(query);
1176 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +00001177 assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001178
1179 query="#ALL(gehen /w1:10 (voran /w1:4 schnell))";
1180 String all2 =
1181 "{@type=korap:group, operation=operation:sequence, " +
1182 "operands=[" +
1183 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
1184 "{@type=korap:group, operation=operation:sequence, operands=[" +
1185 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}," +
1186 "{@type=korap:token, wrap={@type=korap:term, key=schnell, layer=orth, match=match:eq}}" +
1187 "], inOrder=false, " +
1188 "distances=[" +
1189 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
1190 "]" +
1191 "}" +
1192 "], inOrder=false, " +
1193 "distances=[" +
1194 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1195 "]" +
1196 "}";
1197 ct = new CosmasTree(query);
1198 map = ct.getRequestMap().get("query").toString();
1199 assertEquals(all2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001200 }
1201
Joachim Bingel36233b52014-02-13 10:48:24 +00001202 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001203 public void testOPNHIT() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +00001204 query="#NHIT(gehen /w1:10 voran)";
1205 String nhit1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001206 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
1207 "{@type=korap:group, operation=operation:class, classRefOp=classRefOp:inversion, classIn=[130,131], classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001208 "{@type=korap:group, operation=operation:sequence, " +
1209 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001210 "{@type=korap:group, operation=operation:class, class=130 , classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001211 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1212 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001213 "{@type=korap:group, operation=operation:class, class=131 , classOut=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001214 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1215 "]}" +
1216 "], inOrder=false, " +
1217 "distances=[" +
1218 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1219 "]" +
1220 "}" +
1221 "]}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001222 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001223 ct = new CosmasTree(query);
1224 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +00001225 assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel832800e2014-10-17 14:46:39 +00001226
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001227// query="#NHIT(gehen %w1:10 voran)";
1228// String nhit2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001229// "{@type=korap:reference, operation=operation:focus, classRef=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001230// "{@type=korap:group, operation=operation:sequence, " +
1231// "operands=[" +
1232// "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001233// "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001234// "{@type=korap:group, operation=operation:repetition, operands=[" +
1235// "{@type=korap:token}" +
1236// "], boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}}" +
1237// "]}," +
1238// "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1239// "], inOrder=false, " +
1240// "distances=[" +
1241// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1242// "]" +
1243// "}" +
1244// "]}";
1245// ct = new CosmasTree(query);
1246// map = ct.getRequestMap().get("query").toString();
1247// assertEquals(nhit2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1248
1249 query="#NHIT(gehen /+w1:10 voran /w1:10 Beispiel)";
1250 String nhit3 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001251 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
1252 "{@type=korap:group, operation=operation:class, classRefOp=classRefOp:inversion, classIn=[130,131], classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001253 "{@type=korap:group, operation=operation:sequence, " +
1254 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001255 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001256 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1257 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001258 "{@type=korap:group, operation=operation:class, class=131, classOut=131, operands=[" +
1259 "{@type=korap:reference, operation=operation:focus, classRef=[132], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001260 "{@type=korap:group, operation=operation:sequence, " +
1261 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001262 "{@type=korap:group, operation=operation:class, class=132, classOut=132, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001263 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1264 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001265 "{@type=korap:group, operation=operation:class, class=132, classOut=132, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001266 "{@type=korap:token, wrap={@type=korap:term, key=Beispiel, layer=orth, match=match:eq}}" +
1267 "]}" +
1268 "], inOrder=false, " +
1269 "distances=[" +
1270 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1271 "]" +
1272 "}" +
1273 "]}" +
1274 "]}" +
1275 "], inOrder=true, " +
1276 "distances=[" +
1277 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1278 "]" +
1279 "}" +
1280 "]}" +
1281 "]}";
1282 ct = new CosmasTree(query);
1283 map = ct.getRequestMap().get("query").toString();
1284 assertEquals(nhit3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001285 }
1286
1287 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001288 public void testOPBED() throws QueryException {
Joachim Bingeleecc7652014-01-11 17:21:07 +00001289 query = "#BED(der , sa)";
1290 String bed1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001291 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands= [" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001292 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +00001293 "{@type=korap:span, key=s}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001294 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +00001295 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
1296 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001297 "], frame=frame:startswith}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +00001298 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001299 ct = new CosmasTree(query);
1300 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +00001301 assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1302
1303 query = "#BED(der Mann , +pe)";
1304 String bed2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001305 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands= [" +
Joachim Bingel896067a2014-11-07 19:02:27 +00001306 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1307 "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
1308 "{@type=korap:span, key=p}" +
1309 "]}," +
1310 "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
1311 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
1312 "{@type=korap:group, operation=operation:sequence, operands=[" +
1313 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1314 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1315 "]}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001316 "]}" +
1317 "]}" +
Joachim Bingel896067a2014-11-07 19:02:27 +00001318 "], frame=frame:matches}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001319 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001320 ct = new CosmasTree(query);
1321 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +00001322 assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001323
1324 query = "#BED(der Mann , sa,-pa)";
1325 String bed3 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001326 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001327 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1328 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001329 "{@type=korap:span, key=s}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001330 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001331 "{@type=korap:group, operation=operation:sequence, operands=[" +
1332 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1333 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1334 "]}" +
1335 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001336 "], frame=frame:startswith}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001337 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001338 "{@type=korap:span, key=p}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001339 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001340 "{@type=korap:group, operation=operation:sequence, operands=[" +
1341 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1342 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1343 "]}" +
1344 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001345 "], frame=frame:startswith, exclude=true}" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001346 "], frame=frame:matches}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001347 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001348 ct = new CosmasTree(query);
1349 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +00001350 assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001351 }
1352
Joachim Bingel81812632014-02-18 08:55:22 +00001353 @Test
1354 public void testColonSeparatedConditions() throws QueryException {
1355
1356 query = "Der:sa";
1357 String col1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001358 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001359 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001360 "{@type=korap:span, key=s}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001361 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001362 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
1363 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001364 "], frame=frame:startswith}" +
Joachim Bingel81812632014-02-18 08:55:22 +00001365 "]}";
1366 ct = new CosmasTree(query);
1367 map = ct.getRequestMap().get("query").toString();
1368 assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1369
Joachim Bingelb4ab2502014-11-06 10:07:26 +00001370 query = "Mann:sa,-pa,+te";
Joachim Bingel81812632014-02-18 08:55:22 +00001371 String col2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001372 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001373 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1374 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001375 "{@type=korap:span, key=s}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001376 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001377 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1378 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001379 "], frame=frame:startswith}," +
Joachim Bingel896067a2014-11-07 19:02:27 +00001380 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
1381 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1382 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1383 "{@type=korap:span, key=p}," +
1384 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
1385 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1386 "]}" +
1387 "], frame=frame:startswith, exclude=true}," +
1388 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1389 "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
1390 "{@type=korap:span, key=t}" +
1391 "]}," +
1392 "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
1393 "{@type=korap:group, operation=operation:class, class=131, classOut=131, operands=[" +
1394 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1395 "]}" +
1396 "]}" +
1397 "], frame=frame:matches}" +
1398 "], frame=frame:matches}" +
1399 "]}" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001400 "], frame=frame:matches}" +
Joachim Bingel81812632014-02-18 08:55:22 +00001401 "]}";
1402 ct = new CosmasTree(query);
1403 map = ct.getRequestMap().get("query").toString();
1404 assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelf204a672014-11-07 19:40:23 +00001405
1406 query = "Mann:sa,-pa,+te,se";
1407 expected =
1408 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
1409 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1410 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1411 "{@type=korap:span, key=s}," +
1412 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
1413 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1414 "]}" +
1415 "], frame=frame:startswith}," +
1416 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
1417 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1418 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1419 "{@type=korap:span, key=p}," +
1420 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
1421 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1422 "]}" +
1423 "], frame=frame:startswith, exclude=true}," +
1424 "{@type=korap:reference, operation=operation:focus, classRef=[131], operands=[" +
1425 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1426 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1427 "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
1428 "{@type=korap:span, key=t}" +
1429 "]}," +
1430 "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
1431 "{@type=korap:group, operation=operation:class, class=131, classOut=131, operands=[" +
1432 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1433 "]}" +
1434 "]}" +
1435 "], frame=frame:matches}," +
1436 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1437 "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
1438 "{@type=korap:span, key=s}" +
1439 "]}," +
1440 "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
1441 "{@type=korap:group, operation=operation:class, class=132, classOut=132, operands=[" +
1442 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1443 "]}" +
1444 "]}" +
1445 "], frame=frame:matches}" +
1446 "], frame=frame:matches}" +
1447 "]}" +
1448 "], frame=frame:matches}" +
1449 "]}" +
1450 "], frame=frame:matches}" +
1451 "]}";
1452 ct = new CosmasTree(query);
1453 map = ct.getRequestMap().get("query").toString();
1454 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel81812632014-02-18 08:55:22 +00001455 }
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00001456}
1457