blob: c35a4f50d43c9a584d1d553248c038865ba825fe [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 Bingel81812632014-02-18 08:55:22 +000017 String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/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 Bingel8c640e42014-02-07 16:20:47 +000048 public void testCaseSensitivityFlag() throws QueryException {
Joachim Bingel0207d5e2014-02-12 14:18:41 +000049 query="$deutscher";
50 String cs1 =
51 "{@type=korap:token, wrap={@type=korap:term, caseInsensitive=true, key=deutscher, layer=orth, match=match:eq}}";
52 ct = new CosmasTree(query);
53 map = ct.getRequestMap().get("query").toString();
54 assertEquals(cs1.replaceAll(" ", ""), map.replaceAll(" ", ""));
55
56 query="$deutscher Bundestag";
57 String cs2 =
58 "{@type=korap:group, operation=operation:sequence, operands=[" +
59 "{@type=korap:token, wrap={@type=korap:term, caseInsensitive=true, key=deutscher, layer=orth, match=match:eq}}," +
60 "{@type=korap:token, wrap={@type=korap:term, key=Bundestag, layer=orth, match=match:eq}}" +
61 "]}";
62 ct = new CosmasTree(query);
63 map = ct.getRequestMap().get("query").toString();
64 assertEquals(cs2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel8c640e42014-02-07 16:20:47 +000065 }
66
67 @Test
Joachim Bingelffd65e32014-01-22 14:22:57 +000068 public void testMORPH() throws QueryException {
69 query="#MORPH(V)";
70 String morph1 =
Joachim Bingel0207d5e2014-02-12 14:18:41 +000071 "{@type=korap:token, wrap={@type=korap:term, key=V, layer=pos, match=match:eq}}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000072 ct = new CosmasTree(query);
73 map = ct.getRequestMap().get("query").toString();
Joachim Bingelffd65e32014-01-22 14:22:57 +000074 assertEquals(morph1.replaceAll(" ", ""), map.replaceAll(" ", ""));
75 }
76
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000077 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +000078 public void testSequence() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000079 query="der Mann";
80 String seq1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +000081 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +000082 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
83 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000084 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000085 ct = new CosmasTree(query);
86 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000087 assertEquals(seq1.replaceAll(" ", ""), map.replaceAll(" ", ""));
88
Joachim Bingeld5161a12014-01-08 11:15:49 +000089 query="der Mann schläft";
90 String seq2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +000091 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +000092 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
93 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
94 "{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +000095 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000096 ct = new CosmasTree(query);
97 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +000098 assertEquals(seq2.replaceAll(" ", ""), map.replaceAll(" ", ""));
99
100 query="der Mann schläft lang";
101 String seq3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000102 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000103 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
104 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
105 "{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}," +
106 "{@type=korap:token, wrap={@type=korap:term, key=lang, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000107 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000108 ct = new CosmasTree(query);
109 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000110 assertEquals(seq3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000111 }
112
113 @Test
114 public void testOPOR() throws QueryException {
115 query="Sonne oder Mond";
116 String disj1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000117 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000118 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
119 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000120 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000121 ct = new CosmasTree(query);
122 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000123 assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", ""));
124
Joachim Bingeld5161a12014-01-08 11:15:49 +0000125 query="(Sonne scheint) oder Mond";
126 String disj2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000127 "{@type=korap:group, operation=operation:or, operands=[" +
128 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000129 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
130 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000131 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000132 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000133 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000134 ct = new CosmasTree(query);
135 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000136 assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", ""));
137
138 query="(Sonne scheint) oder (Mond scheint)";
139 String disj3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000140 "{@type=korap:group, operation=operation:or, operands=[" +
141 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000142 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
143 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000144 "]}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000145 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000146 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
147 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000148 "]}" +
149 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000150 ct = new CosmasTree(query);
151 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000152 assertEquals(disj3.replaceAll(" ", ""), map.replaceAll(" ", ""));
153
154 }
155
156 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000157 public void testOPORAND() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000158 query="(Sonne oder Mond) und scheint";
159 String orand1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000160 "{@type=korap:group, operation=operation:sequence, distances=[" +
161 "{@type=korap:distance, key=t, min=0, max=0}" +
162 "], operands=[" +
163 "{@type=korap:group, operation=operation:or, operands=[" +
164 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
165 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
166 "]}," +
167 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000168 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000169 ct = new CosmasTree(query);
170 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000171 assertEquals(orand1.replaceAll(" ", ""), map.replaceAll(" ", ""));
172
173 query="scheint und (Sonne oder Mond)";
174 String orand2 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000175 "{@type=korap:group, operation=operation:sequence, distances=[" +
176 "{@type=korap:distance, key=t, min=0, max=0}" +
177 "], operands=[" +
178 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," +
179 "{@type=korap:group, operation=operation:or, operands=[" +
180 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
181 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000182 "]}" +
183 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000184 ct = new CosmasTree(query);
185 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000186 assertEquals(orand2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel92f9c9c2014-06-25 15:01:17 +0000187
188 query="Regen und scheint und (Sonne oder Mond)";
189 String orand3 =
190 "{@type=korap:group, operation=operation:sequence, distances=[" +
191 "{@type=korap:distance, key=t, min=0, max=0}" +
192 "], operands=[" +
193 "{@type=korap:token, wrap={@type=korap:term, key=Regen, layer=orth, match=match:eq}}," +
194 "{@type=korap:group, operation=operation:sequence, distances=[" +
195 "{@type=korap:distance, key=t, min=0, max=0}" +
196 "], operands=[" +
197 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," +
198 "{@type=korap:group, operation=operation:or, operands=[" +
199 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
200 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
201 "]}" +
202 "]}" +
203 "]}";
204 ct = new CosmasTree(query);
205 map = ct.getRequestMap().get("query").toString();
206 assertEquals(orand3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000207 }
208
209 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000210 public void testOPPROX() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000211 query="Sonne /+w1:4 Mond";
212 String prox1 =
Joachim Bingelfbc88792014-09-17 11:11:52 +0000213 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
214 "{@type=korap:group, operation=operation:sequence, " +
215 "operands=[" +
216 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
217 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
218 "]}," +
219 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
220 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
221 "]}" +
222 "], inOrder=true, " +
223 "distances=[" +
224 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
225 "]" +
226 "}" +
227 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000228 ct = new CosmasTree(query);
229 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000230 assertEquals(prox1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel89cceac2014-01-08 15:51:08 +0000231
232 query="Sonne /+w1:4,s0,p1:3 Mond";
233 String prox2 =
Joachim Bingelfbc88792014-09-17 11:11:52 +0000234 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000235 "{@type=korap:group, operation=operation:sequence, " +
236 "operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000237 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
238 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
239 "]}," +
240 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
241 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
242 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000243 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000244 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000245 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}," +
246 "{@type=korap:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}," +
247 "{@type=korap:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3}" +
Joachim Bingel89cceac2014-01-08 15:51:08 +0000248 "]" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000249 "}" +
250 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000251 ct = new CosmasTree(query);
252 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000253 assertEquals(prox2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000254
255 query="Sonne %+w1:4,s0,p1:3 Mond";
256 String prox3 =
Joachim Bingelfbc88792014-09-17 11:11:52 +0000257 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
258 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000259 "operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000260 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
261 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
262 "]}," +
263 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
264 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
265 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000266 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000267 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000268 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4, exclude=true}," +
269 "{@type=korap:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0, exclude=true}," +
270 "{@type=korap:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3, exclude=true}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000271 "]" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000272 "}" +
273 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000274 ct = new CosmasTree(query);
275 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +0000276// assertEquals(prox3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000277
278 query="Sonne /+w4 Mond";
279 String prox4 =
Joachim Bingel37a803f2014-07-28 14:21:44 +0000280 "{@type=korap:group, operation=operation:or, operands=[" +
281 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000282 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
283 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
284 "]}," +
285 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000286 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000287 "]}" +
288 "]}," +
289 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
290 "{@type=korap:group, operation=operation:sequence, " +
291 "operands=[" +
292 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
293 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
294 "]}," +
295 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
296 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
297 "]}" +
298 "], inOrder=true, " +
299 "distances=[" +
300 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
301 "]" +
302 "}" +
303 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000304 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000305 ct = new CosmasTree(query);
306 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000307 assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000308
309 query="Sonne /-w4 Mond";
310 String prox5 =
Joachim Bingel37a803f2014-07-28 14:21:44 +0000311 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000312 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
313 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
314 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000315 "]}," +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000316 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
317 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
318 "]}" +
319 "]}," +
320 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000321 "{@type=korap:group, operation=operation:sequence, " +
322 "operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000323 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
324 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
325 "]}," +
326 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
327 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
328 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000329 "], inOrder=true, " +
330 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000331 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000332 "]" +
333 "}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000334 "]}" +
335 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000336 ct = new CosmasTree(query);
337 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000338 assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000339
340 query="Sonne /w4 Mond";
341 String prox6 =
Joachim Bingel37a803f2014-07-28 14:21:44 +0000342 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000343 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
344 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
345 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000346 "]}," +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000347 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
348 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
349 "]}" +
350 "]}," +
351 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000352 "{@type=korap:group, operation=operation:sequence, " +
353 "operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000354 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
355 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
356 "]}," +
357 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
358 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
359 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000360 "], inOrder=false, " +
361 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000362 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000363 "]" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000364 "}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000365 "]}" +
366 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000367 ct = new CosmasTree(query);
368 map = ct.getRequestMap().get("query").toString();
369 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000370 }
371
372 @Test
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000373 public void testOPPROXNested() throws QueryException {
Joachim Bingel09737972014-09-22 09:43:06 +0000374 query="Sonne /+w1:4 Mond /-w1:7 Sterne";
375 expected =
376 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
377 "{@type=korap:group, operation=operation:sequence, " +
378 "operands=[" +
379 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
380 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
381 "]}," +
382 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
383 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
384 "{@type=korap:group, operation=operation:sequence, " +
385 "operands=[" +
386 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
387 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
388 "]}," +
389 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
390 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
391 "]}" +
392 "], inOrder=true, " +
393 "distances=[" +
394 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=7}, min=1, max=7}" +
395 "]" +
396 "}" +
397 "]}" +
398 "]}" +
399 "], inOrder=true, " +
400 "distances=[" +
401 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
402 "]" +
403 "}" +
404 "]}" +
405 "" ;
406 ct = new CosmasTree(query);
407 map = ct.getRequestMap().get("query").toString();
408 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
409
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000410 query="Sonne /-w4 Mond /+w2 Sterne";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000411
412 String mondsterne =
413 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
414 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" ;
Joachim Bingelfbc88792014-09-17 11:11:52 +0000415
416 String mondsterneClasses =
417 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
418 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
419 "]}," +
420 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
421 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
422 "]}";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000423 String mondsterneSeq =
424 "{@type=korap:group, operation=operation:sequence, operands=[" +
425 mondsterne +
426 "], inOrder=true, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000427 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000428 "]}" ;
Joachim Bingelfbc88792014-09-17 11:11:52 +0000429 String mondsterneClassesSeq =
430 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
431 "{@type=korap:group, operation=operation:sequence, operands=[" +
432 mondsterneClasses +
433 "], inOrder=true, distances=[" +
434 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
435 "]}" +
436 "]}" ;
Joachim Bingel37a803f2014-07-28 14:21:44 +0000437 String mondsterneOv =
438 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
439 mondsterne +
440 "]}";
Joachim Bingelfbc88792014-09-17 11:11:52 +0000441 String mondsterneClassesOv =
442 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
443 mondsterneClasses +
444 "]}";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000445 String mondsterneAll =
446 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000447 mondsterneOv + "," + mondsterneClassesSeq +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000448 "]}";
Joachim Bingelfbc88792014-09-17 11:11:52 +0000449 String mondsterneAllClasses =
450 "{@type=korap:group, operation=operation:or, operands=[" +
451 mondsterneClassesOv + "," + mondsterneClassesSeq +
452 "]}";
453
454
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000455 String prox6 =
Joachim Bingel37a803f2014-07-28 14:21:44 +0000456 "{@type=korap:group, operation=operation:or, operands=[" +
457 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000458 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
459 mondsterneAllClasses +
460 "]}," +
461 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000462 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000463 "]}" +
464 "]}," +
465 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
466 "{@type=korap:group, operation=operation:sequence, " +
467 "operands=[" +
468 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
469 mondsterneAllClasses +
470 "]}," +
471 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
472 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
473 "]}" +
474 "], inOrder=true, " +
475 "distances=[" +
476 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
477 "]" +
478 "}" +
479 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000480 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000481 ct = new CosmasTree(query);
482 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000483 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000484 }
485
486 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000487 public void testOPIN() throws QueryException {
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000488 query="wegen #IN <s>";
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000489 String opin1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000490 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000491 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000492 "{@type=korap:span, key=s}," +
493 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000494 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +0000495 "]}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000496 "], frames=[], sharedClasses=[includes]}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000497 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000498 ct = new CosmasTree(query);
499 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000500 assertEquals(opin1.replaceAll(" ", ""), map.replaceAll(" ", ""));
501
Joachim Bingel09737972014-09-22 09:43:06 +0000502 query="wegen #IN(L) <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000503 String opin2 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000504 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000505 "{@type=korap:group, operation=operation:position, operands=[" +
506 "{@type=korap:span, key=s}," +
507 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
508 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
509 "]}" +
510 "], frames=[startswith], sharedClasses=[includes]}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000511 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000512 ct = new CosmasTree(query);
513 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000514 assertEquals(opin2.replaceAll(" ", ""), map.replaceAll(" ", ""));
515
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000516
517 query="wegen #IN(F) <s>";
518 String opin3=
519 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000520 "{@type=korap:group, operation=operation:position, operands=[" +
521 "{@type=korap:span, key=s}," +
522 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
523 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
524 "]}" +
525 "], frames=[matches], sharedClasses=[includes]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000526 "]}" +
527 "";
528 ct = new CosmasTree(query);
529 map = ct.getRequestMap().get("query").toString();
530 assertEquals(opin3.replaceAll(" ", ""), map.replaceAll(" ", ""));
531
532 query="wegen #IN(FI) <s>";
533 String opin4=
534 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000535 "{@type=korap:group, operation=operation:position, operands=[" +
536 "{@type=korap:span, key=s}," +
537 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
538 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
539 "]}" +
540 "], frames=[matches], sharedClasses=[unequals,includes]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000541 "]}" +
542 "";
543 ct = new CosmasTree(query);
544 map = ct.getRequestMap().get("query").toString();
545 assertEquals(opin4.replaceAll(" ", ""), map.replaceAll(" ", ""));
546
547 query="wegen #IN(FE) <s>";
548 String opin5=
Joachim Bingel09737972014-09-22 09:43:06 +0000549 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
550 "{@type=korap:group, operation=operation:position, operands=[" +
551 "{@type=korap:span, key=s}," +
552 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
553 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000554 "]}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000555 "], frames=[matches], sharedClasses=[equals]}" +
556 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000557 "";
558 ct = new CosmasTree(query);
559 map = ct.getRequestMap().get("query").toString();
560 assertEquals(opin5.replaceAll(" ", ""), map.replaceAll(" ", ""));
561
Joachim Bingel87480d02014-01-17 14:07:46 +0000562 query="wegen #IN(%, L) <s>";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000563 String opin6 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000564 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000565 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000566 "{@type=korap:span, key=s}," +
567 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000568 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000569 "]}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000570 "], frames=[startswith], sharedClasses=[includes], exclude=true}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000571 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000572 ct = new CosmasTree(query);
573 map = ct.getRequestMap().get("query").toString();
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000574 assertEquals(opin6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000575
576 query="wegen #IN('FE,ALL,%,MIN') <s>";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000577 String opin7 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000578 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000579 "{@type=korap:group, operation=operation:position, operands=[" +
580 "{@type=korap:reference, operation=operation:focus, reset=true, operands=[" +
581 "{@type=korap:span, key=s}" +
582 "]}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000583 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000584 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000585 "]}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000586 "], frames=[matches], sharedClasses=[equals], exclude=true, grouping=false}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000587 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000588 ct = new CosmasTree(query);
589 map = ct.getRequestMap().get("query").toString();
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000590 assertEquals(opin7.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000591 }
592
593 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000594 public void testOPOV() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000595 query="wegen #OV <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000596 String opov1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000597 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000598 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000599 "{@type=korap:span, key=s}," +
600 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000601 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000602 "]}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000603 "], frames=[], sharedClasses=[intersects]}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000604 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000605 ct = new CosmasTree(query);
606 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000607 assertEquals(opov1.replaceAll(" ", ""), map.replaceAll(" ", ""));
608
609 query="wegen #OV(L) <s>";
610 String opov2 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000611 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000612 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000613 "{@type=korap:span, key=s}," +
614 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000615 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000616 "]}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000617 "], frames=[startswith,overlapsLeft], sharedClasses=[intersects]}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000618 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000619 ct = new CosmasTree(query);
620 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000621 assertEquals(opov2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000622
623 query="wegen #OV(F) <s>";
624 String opov3=
625 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000626 "{@type=korap:group, operation=operation:position, operands=[" +
627 "{@type=korap:span, key=s}," +
628 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
629 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
630 "]}" +
631 "], frames=[matches], sharedClasses=[intersects]}" +
632 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000633 ct = new CosmasTree(query);
634 map = ct.getRequestMap().get("query").toString();
635 assertEquals(opov3.replaceAll(" ", ""), map.replaceAll(" ", ""));
636
637 query="wegen #OV(FI) <s>";
638 String opov4=
639 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000640 "{@type=korap:group, operation=operation:position, operands=[" +
641 "{@type=korap:span, key=s}," +
642 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
643 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
644 "]}" +
645 "], frames=[matches], sharedClasses=[unequals]}" +
646 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000647 ct = new CosmasTree(query);
648 map = ct.getRequestMap().get("query").toString();
649 assertEquals(opov4.replaceAll(" ", ""), map.replaceAll(" ", ""));
650
651 query="wegen #OV(FE) <s>";
652 String opov5=
653 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000654 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000655 "{@type=korap:span, key=s}," +
656 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
657 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
658 "]}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000659 "], frames=[matches], sharedClasses=[equals]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000660 "]}" +
661 "";
662 ct = new CosmasTree(query);
663 map = ct.getRequestMap().get("query").toString();
664 assertEquals(opov5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000665 }
666
667 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000668 public void testOPNOT() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000669 query="Sonne nicht Mond";
670 String opnot1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000671 "{@type=korap:group, operation=operation:sequence, distances=[" +
672 "{@type=korap:distance, key=t, min=0, max=0, exclude=true}" +
673 "], operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000674 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
675 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000676 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000677 ct = new CosmasTree(query);
678 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000679 assertEquals(opnot1.replaceAll(" ", ""), map.replaceAll(" ", ""));
680 }
681
682 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000683 public void testBEG_END() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000684 // BEG and END operators
685 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/links.html
686 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/rechts.html
687 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/thematische-bsp/bsp-satzlaenge.html
Joachim Bingel87480d02014-01-17 14:07:46 +0000688 query="#BEG(der /w3:5 Mann)";
689 String beg1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000690 "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000691 "{@type=korap:group, operation=operation:sequence," +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000692 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000693 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
694 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000695 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000696 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000697 "]}" +
698 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000699 ct = new CosmasTree(query);
700 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000701 assertEquals(beg1.replaceAll(" ", ""), map.replaceAll(" ", ""));
702
Joachim Bingel37a803f2014-07-28 14:21:44 +0000703
Joachim Bingelfbc88792014-09-17 11:11:52 +0000704// String dermannSeq = "{@type=korap:group, operation=operation:sequence," +
705// "operands = [" +
706// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
707// "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
708// "]}," +
709// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
710// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
711// "]}" +
712//
713// "], inOrder=false, distances=[" +
714// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
715// "]}";
716//
717// String begDermannSeq =
718//// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
719// "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
720// dermannSeq +
721// "]}" +
722//// "]}" +
723// "";
724
Joachim Bingel37a803f2014-07-28 14:21:44 +0000725 String kommt = "{@type=korap:token, wrap={@type=korap:term, key=kommt, layer=orth, match=match:eq}}";
726
Joachim Bingel87480d02014-01-17 14:07:46 +0000727 query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group
728 String beg2 =
Joachim Bingelfbc88792014-09-17 11:11:52 +0000729 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000730 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000731 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
732 beg1 +
733 "]}" + "," +
734 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
735 kommt +
736 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000737 "]}," +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000738 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
739 "{@type=korap:group, operation=operation:sequence, operands=[" +
740 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
741 beg1 +
742 "]}," +
743 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
744 kommt +
745 "]}" +
746 "], inOrder=true, distances=[" +
747 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
748 "]}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000749 "]}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000750 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000751 ct = new CosmasTree(query);
752 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000753 assertEquals(beg2.replaceAll(" ", ""), map.replaceAll(" ", ""));
754
Joachim Bingel37a803f2014-07-28 14:21:44 +0000755 query="kommt /+w10 #BEG(der /w3:5 Mann)";
756 String beg3 =
757 "{@type=korap:group, operation=operation:or, operands=[" +
758 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000759 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
760 kommt +
761// "," +
762 "]}," +
763 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
764 beg1+
765 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000766 "]}," +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000767 "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
768 "{@type=korap:group, operation=operation:sequence, operands=[" +
769 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
770 kommt +
771 "]}," +
772 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
773 beg1+
774 "]}" +
775 "], inOrder=true, distances=[" +
776 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
777 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000778 "]}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000779 "]}";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000780 ct = new CosmasTree(query);
781 map = ct.getRequestMap().get("query").toString();
782 assertEquals(beg3.replaceAll(" ", ""), map.replaceAll(" ", ""));
783
Joachim Bingel87480d02014-01-17 14:07:46 +0000784 query="#END(der /w3:5 Mann)";
785 String end1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000786 "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000787 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000788 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000789 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
790 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000791 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000792 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000793 "]}" +
794 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000795 ct = new CosmasTree(query);
796 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000797 assertEquals(end1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000798 }
Joachim Bingeld5161a12014-01-08 11:15:49 +0000799
Joachim Bingel03dfd952014-07-30 08:08:53 +0000800 /*
801 * YET UNCLEAR HOW TO SERIALIZE SPAN DISTANCES. BEING DISCUSSED.
802 *
Joachim Bingel37a803f2014-07-28 14:21:44 +0000803 @Test
804 public void testSentenceDistance() throws QueryException {
Joachim Bingel03dfd952014-07-30 08:08:53 +0000805 query="Sonne /s0 Mond"; // contains(focus(1:contains({1:<s>},Sonne)),Mond)
Joachim Bingel37a803f2014-07-28 14:21:44 +0000806 expected =
807 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000808 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000809 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000810 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000811 "{@type=korap:span, key=s}" +
812 "]}," +
813 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
814 "]}" +
815 "]}," +
816 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
817 "]}";
818 ct = new CosmasTree(query);
819 map = ct.getRequestMap().get("query").toString();
820 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
821
Joachim Bingel03dfd952014-07-30 08:08:53 +0000822 query="Sonne /s0,w5 Mond";
823 expected =
824 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
825 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
826 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
827 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
828 "{@type=korap:span, key=s}" +
829 "]}," +
830 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
831 "]}" +
832 "]}," +
833 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
834 "]}";
835// ct = new CosmasTree(query);
836// map = ct.getRequestMap().get("query").toString();
837// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
838
Joachim Bingel37a803f2014-07-28 14:21:44 +0000839 query="Sonne /s2:2 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond)
840 expected =
841 "{@type=korap:group, operation=operation:sequence, operands=[" +
842 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
843 "{@type=korap:span, key=s}," +
844 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
845 "]}," +
846 "{@type=korap:span, key=s}," +
847 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
848 "{@type=korap:span, key=s}," +
849 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000850 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000851 "]}";
852 ct = new CosmasTree(query);
853 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +0000854// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel37a803f2014-07-28 14:21:44 +0000855
Joachim Bingel03dfd952014-07-30 08:08:53 +0000856 query="Sonne /s2:3 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond)
857 expected =
858 "{@type=korap:group, operation=operation:sequence, operands=[" +
859 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
860 "{@type=korap:span, key=s}," +
861 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
862 "]}," +
863 "{@type=korap:group, operation=operation:repetition, operands=[" +
864 "{@type=korap:span, key=s}" +
865 "], boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}," +
866 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
867 "{@type=korap:span, key=s}," +
868 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
869 "]}" +
870 "]}";
871 ct = new CosmasTree(query);
872 map = ct.getRequestMap().get("query").toString();
873// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
874
875 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 +0000876 expected =
877 "{@type=korap:group, operation=operation:or, operands=[" +
878 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000879 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000880 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000881 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000882 "{@type=korap:span, key=s}" +
883 "]}," +
884 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
885 "]}" +
886 "]}," +
887 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
888 "]}," +
889 "{@type=korap:group, operation=operation:sequence, operands=[" +
890 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
891 "{@type=korap:span, key=s}," +
892 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
893 "]}," +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000894 "{@type=korap:group, operation=operation:repetition, operands=[" +
895 "{@type=korap:span, key=s}" +
896 "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}," +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000897 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
898 "{@type=korap:span, key=s}," +
899 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000900 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000901 "]}" +
902 "]}";
903 ct = new CosmasTree(query);
904 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +0000905// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel37a803f2014-07-28 14:21:44 +0000906 }
Joachim Bingel03dfd952014-07-30 08:08:53 +0000907 */
Joachim Bingel37a803f2014-07-28 14:21:44 +0000908
Joachim Bingeld5161a12014-01-08 11:15:49 +0000909
910 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000911 public void testELEM() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000912 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/elem.html
Joachim Bingeleecc7652014-01-11 17:21:07 +0000913 query="#ELEM(S)";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000914 String elem1 = "{@type=korap:span, key=s}";
915 ct = new CosmasTree(query);
916 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +0000917 assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel402c6e12014-05-08 17:09:06 +0000918
919 query="#ELEM(W ANA=N)";
920 String elem2 =
921 "{@type=korap:span, key=w, attr=" +
922 "{@type=korap:termGroup, relation=relation:and, operands=[" +
923 "{@type=korap:term, layer=pos, key=N, match=match:eq}" +
924 "]}" +
925 "}";
926 ct = new CosmasTree(query);
927 map = ct.getRequestMap().get("query").toString();
928 assertEquals(elem2.replaceAll(" ", ""), map.replaceAll(" ", ""));
929
930 query="#ELEM(W ANA != 'N V')";
931 String elem3 =
932 "{@type=korap:span, key=w, attr=" +
933 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingelb674cca2014-05-09 14:00:58 +0000934 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
935 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000936 "]}" +
937 "}";
938 ct = new CosmasTree(query);
939 map = ct.getRequestMap().get("query").toString();
940 assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", ""));
941
Joachim Bingelb674cca2014-05-09 14:00:58 +0000942 query="#ELEM(W ANA != 'N A V' Genre = Sport)";
Joachim Bingel402c6e12014-05-08 17:09:06 +0000943 String elem4 =
944 "{@type=korap:span, key=w, attr=" +
945 "{@type=korap:termGroup, relation=relation:and, operands=[" +
946 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingelb674cca2014-05-09 14:00:58 +0000947 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
948 "{@type=korap:term, layer=pos, key=A, match=match:ne}," +
949 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
950 "]}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000951 "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" +
952 "]}" +
953 "}";
954 ct = new CosmasTree(query);
955 map = ct.getRequestMap().get("query").toString();
956 assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb674cca2014-05-09 14:00:58 +0000957
958 query="#ELEM(W ANA != 'N V' Genre != 'Sport Politik')";
959 String elem5 =
960 "{@type=korap:span, key=w, attr=" +
961 "{@type=korap:termGroup, relation=relation:and, operands=[" +
962 "{@type=korap:termGroup, relation=relation:and, operands=[" +
963 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
964 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
965 "]}," +
966 "{@type=korap:termGroup, relation=relation:and, operands=[" +
967 "{@type=korap:term, layer=Genre, key=Sport, match=match:ne}," +
968 "{@type=korap:term, layer=Genre, key=Politik, match=match:ne}" +
969 "]}" +
970 "]}" +
971 "}";
972 ct = new CosmasTree(query);
973 map = ct.getRequestMap().get("query").toString();
974 assertEquals(elem5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000975 }
976
977 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000978 public void testOPALL() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +0000979 query="#ALL(gehen /w1:10 voran)";
Joachim Bingele98d0882014-01-21 12:58:54 +0000980 String all1 =
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000981 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000982 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000983 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
984 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000985 "], inOrder=false, " +
986 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000987 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000988 "]" +
989 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000990 ct = new CosmasTree(query);
991 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000992 assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000993 }
994
Joachim Bingel36233b52014-02-13 10:48:24 +0000995 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000996 public void testOPNHIT() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +0000997 query="#NHIT(gehen /w1:10 voran)";
998 String nhit1 =
Joachim Bingel09737972014-09-22 09:43:06 +0000999 "{@type=korap:reference, operation=operation:focus, classRef=[1], classRefOp=classRefOp:inversion, operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001000 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel36233b52014-02-13 10:48:24 +00001001 "operands=[" +
1002 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
1003 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1004 "]}," +
Joachim Bingel09737972014-09-22 09:43:06 +00001005 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001006 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1007 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001008 "], inOrder=false, " +
1009 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001010 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001011 "]" +
1012 "}" +
1013 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001014 ct = new CosmasTree(query);
1015 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +00001016 assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001017 }
1018
1019 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001020 public void testOPBED() throws QueryException {
Joachim Bingeleecc7652014-01-11 17:21:07 +00001021 query = "#BED(der , sa)";
1022 String bed1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +00001023 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands= [" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +00001024 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
1025 "{@type=korap:span, key=s}," +
1026 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
1027 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
1028 "]}" +
1029 "]}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +00001030 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001031 ct = new CosmasTree(query);
1032 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +00001033 assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1034
1035 query = "#BED(der Mann , +pe)";
1036 String bed2 =
Joachim Bingel0de1b412014-07-02 14:51:48 +00001037 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands= [" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001038 "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
1039 "{@type=korap:span, key=p}," +
1040 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
1041 "{@type=korap:group, operation=operation:sequence, operands=[" +
1042 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1043 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1044 "]}" +
1045 "]}" +
1046 "]}" +
1047 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001048 ct = new CosmasTree(query);
1049 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +00001050 assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001051
1052 query = "#BED(der Mann , sa,-pa)";
1053 String bed3 =
Joachim Bingel0de1b412014-07-02 14:51:48 +00001054 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001055 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001056 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
1057 "{@type=korap:span, key=s}," +
1058 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
1059 "{@type=korap:group, operation=operation:sequence, operands=[" +
1060 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1061 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1062 "]}" +
1063 "]}" +
1064 "]}," +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001065 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001066 "{@type=korap:span, key=p}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001067 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001068 "{@type=korap:group, operation=operation:sequence, operands=[" +
1069 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1070 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1071 "]}" +
1072 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001073 "], exclude=true}" +
1074 "], distances=[" +
1075 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001076 "]}" +
1077 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001078 ct = new CosmasTree(query);
1079 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +00001080 assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001081 }
1082
Joachim Bingel81812632014-02-18 08:55:22 +00001083 @Test
1084 public void testColonSeparatedConditions() throws QueryException {
1085
1086 query = "Der:sa";
1087 String col1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +00001088 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001089 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
1090 "{@type=korap:span, key=s}," +
1091 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
1092 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
1093 "]}" +
1094 "]}" +
1095 "]}";
1096 ct = new CosmasTree(query);
1097 map = ct.getRequestMap().get("query").toString();
1098 assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1099
1100 query = "Mann:sa,-pa,+te)";
1101 String col2 =
Joachim Bingel0de1b412014-07-02 14:51:48 +00001102 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001103 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001104 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
1105 "{@type=korap:span, key=s}," +
1106 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
1107 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1108 "]}" +
1109 "]}," +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001110 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001111 "{@type=korap:span, key=p}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001112 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001113 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1114 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001115 "], exclude=true}," +
Joachim Bingel81812632014-02-18 08:55:22 +00001116 "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
1117 "{@type=korap:span, key=t}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001118 "{@type=korap:group, operation=operation:class, class=3, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001119 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1120 "]}" +
1121 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001122 "], distances=[" +
1123 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}" +
Joachim Bingel81812632014-02-18 08:55:22 +00001124 "]}" +
1125 "]}";
1126 ct = new CosmasTree(query);
1127 map = ct.getRequestMap().get("query").toString();
1128 assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1129 }
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00001130}
1131