blob: ef5ed713ab15a083c8ff4566d7ac9a8dd44f308e [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 Bingel097c1eb2014-07-11 14:57:25 +0000213 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000214 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000215 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
216 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000217 "], inOrder=true, " +
218 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000219 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
Joachim Bingel89cceac2014-01-08 15:51:08 +0000220 "]" +
221 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000222 ct = new CosmasTree(query);
223 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000224 assertEquals(prox1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel89cceac2014-01-08 15:51:08 +0000225
226 query="Sonne /+w1:4,s0,p1:3 Mond";
227 String prox2 =
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000228 "{@type=korap:group, operation=operation:sequence, " +
229 "operands=[" +
230 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
231 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
232 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000233 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000234 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}," +
235 "{@type=korap:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}," +
236 "{@type=korap:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3}" +
Joachim Bingel89cceac2014-01-08 15:51:08 +0000237 "]" +
238 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000239 ct = new CosmasTree(query);
240 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000241 assertEquals(prox2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000242
243 query="Sonne %+w1:4,s0,p1:3 Mond";
244 String prox3 =
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000245 "{@type=korap:group, operation=operation:sequence, " +
246 "operands=[" +
247 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
248 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
249 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000250 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000251 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4, exclude=true}," +
252 "{@type=korap:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0, exclude=true}," +
253 "{@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 +0000254 "]" +
255 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000256 ct = new CosmasTree(query);
257 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +0000258// assertEquals(prox3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000259
260 query="Sonne /+w4 Mond";
261 String prox4 =
Joachim Bingel37a803f2014-07-28 14:21:44 +0000262 "{@type=korap:group, operation=operation:or, operands=[" +
263 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000264 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
265 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000266 "]}," +
267 "{@type=korap:group, operation=operation:sequence, " +
268 "operands=[" +
269 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
270 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
271 "], inOrder=true, " +
272 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000273 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000274 "]" +
275 "}" +
276 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000277 ct = new CosmasTree(query);
278 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000279 assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000280
281 query="Sonne /-w4 Mond";
282 String prox5 =
Joachim Bingel37a803f2014-07-28 14:21:44 +0000283 "{@type=korap:group, operation=operation:or, operands=[" +
284 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000285 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
286 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000287 "]}," +
288 "{@type=korap:group, operation=operation:sequence, " +
289 "operands=[" +
290 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
291 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
292 "], inOrder=true, " +
293 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000294 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000295 "]" +
296 "}" +
297 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000298 ct = new CosmasTree(query);
299 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000300 assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000301
302 query="Sonne /w4 Mond";
303 String prox6 =
Joachim Bingel37a803f2014-07-28 14:21:44 +0000304 "{@type=korap:group, operation=operation:or, operands=[" +
305 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
306 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
307 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
308 "]}," +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000309 "{@type=korap:group, operation=operation:sequence, " +
310 "operands=[" +
311 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
312 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
313 "], inOrder=false, " +
314 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000315 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000316 "]" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000317 "}" +
318 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000319 ct = new CosmasTree(query);
320 map = ct.getRequestMap().get("query").toString();
321 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000322 }
323
324 @Test
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000325 public void testOPPROXNested() throws QueryException {
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000326 query="Sonne /-w4 Mond /+w2 Sterne";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000327
328 String mondsterne =
329 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
330 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" ;
331 String mondsterneSeq =
332 "{@type=korap:group, operation=operation:sequence, operands=[" +
333 mondsterne +
334 "], inOrder=true, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000335 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000336 "]}" ;
337 String mondsterneOv =
338 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
339 mondsterne +
340 "]}";
341 String mondsterneAll =
342 "{@type=korap:group, operation=operation:or, operands=[" +
343 mondsterneOv + "," + mondsterneSeq +
344 "]}";
345
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000346 String prox6 =
Joachim Bingel37a803f2014-07-28 14:21:44 +0000347 "{@type=korap:group, operation=operation:or, operands=[" +
348 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
349 mondsterneAll + "," +
350 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
351 "]}," +
352 "{@type=korap:group, operation=operation:sequence, " +
353 "operands=[" +
354 mondsterneAll + "," +
355 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
356 "], inOrder=true, " +
357 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000358 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000359 "]" +
360 "}" +
361 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000362 ct = new CosmasTree(query);
363 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000364 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000365 }
366
367 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000368 public void testOPIN() throws QueryException {
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000369 query="wegen #IN <s>";
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000370 String opin1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000371 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000372 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
373 "{@type=korap:span, key=s}," +
374 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000375 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +0000376 "]}" +
377 "]}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000378 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000379 ct = new CosmasTree(query);
380 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000381 assertEquals(opin1.replaceAll(" ", ""), map.replaceAll(" ", ""));
382
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000383 query="wegen #IN(L) <s>"; //wrap an *excluded* matches-position around a startwith-position constraint in order to
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000384 String opin2 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000385 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000386 "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" +
387 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
388 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
389 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
390 "{@type=korap:span, key=s}" +
391 "]}," +
392 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
393 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
394 "]}" +
395 "]}" +
396 "]}," +
397 "{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
398 "], exclude=true}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000399 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000400 ct = new CosmasTree(query);
401 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000402 assertEquals(opin2.replaceAll(" ", ""), map.replaceAll(" ", ""));
403
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000404
405 query="wegen #IN(F) <s>";
406 String opin3=
407 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
408 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
409 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
410 "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
411 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
412 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
413 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
414 "{@type=korap:span, key=s}" +
415 "]}," +
416 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
417 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
418 "]}" +
419 "]}" +
420 "]}," +
421 "{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
422 "]}" +
423 "]}," +
424 "{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
425 "]}" +
426 "]}" +
427 "";
428 ct = new CosmasTree(query);
429 map = ct.getRequestMap().get("query").toString();
430 assertEquals(opin3.replaceAll(" ", ""), map.replaceAll(" ", ""));
431
432 query="wegen #IN(FI) <s>";
433 String opin4=
434 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
435 "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" +
436 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
437 "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
438 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
439 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
440 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
441 "{@type=korap:span, key=s}" +
442 "]}," +
443 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
444 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
445 "]}" +
446 "]}" +
447 "]}," +
448 "{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
449 "]}" +
450 "]}," +
451 "{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
452 "], exclude=true}" +
453 "]}" +
454 "";
455 ct = new CosmasTree(query);
456 map = ct.getRequestMap().get("query").toString();
457 assertEquals(opin4.replaceAll(" ", ""), map.replaceAll(" ", ""));
458
459 query="wegen #IN(FE) <s>";
460 String opin5=
461 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
462 "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" +
463 "{@type=korap:span, key=s}," +
464 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
465 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
466 "]}" +
467 "]}" +
468 "]}" +
469 "";
470 ct = new CosmasTree(query);
471 map = ct.getRequestMap().get("query").toString();
472 assertEquals(opin5.replaceAll(" ", ""), map.replaceAll(" ", ""));
473
Joachim Bingel87480d02014-01-17 14:07:46 +0000474 query="wegen #IN(%, L) <s>";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000475 String opin6 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000476 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
477 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000478 "{@type=korap:span, key=s}," +
479 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000480 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000481 "]}" +
Joachim Bingel0de1b412014-07-02 14:51:48 +0000482 "], exclude=true}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000483 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000484 ct = new CosmasTree(query);
485 map = ct.getRequestMap().get("query").toString();
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000486 assertEquals(opin6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000487
488 query="wegen #IN('FE,ALL,%,MIN') <s>";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000489 String opin7 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000490 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
491 "{@type=korap:group, operation=operation:position, frame=frame:matches, 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 Bingel87480d02014-01-17 14:07:46 +0000495 "]}" +
Joachim Bingel0de1b412014-07-02 14:51:48 +0000496 "], range=all, exclude=true, grouping=false}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000497 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000498 ct = new CosmasTree(query);
499 map = ct.getRequestMap().get("query").toString();
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000500 assertEquals(opin7.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000501 }
502
503 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000504 public void testOPOV() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000505 query="wegen #OV <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000506 String opov1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000507 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000508 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
509 "{@type=korap:span, key=s}," +
510 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000511 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000512 "]}" +
513 "]}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000514 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000515 ct = new CosmasTree(query);
516 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000517 assertEquals(opov1.replaceAll(" ", ""), map.replaceAll(" ", ""));
518
519 query="wegen #OV(L) <s>";
520 String opov2 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000521 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000522 "{@type=korap:group, operation=operation:position, frame=frame:overlapsLeft, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000523 "{@type=korap:span, key=s}," +
524 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000525 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000526 "]}" +
527 "]}" +
528 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000529 ct = new CosmasTree(query);
530 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000531 assertEquals(opov2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000532
533 query="wegen #OV(F) <s>";
534 String opov3=
535 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
536 "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
537 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
538 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
539 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
540 "{@type=korap:span, key=s}" +
541 "]}," +
542 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
543 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
544 "]}" +
545 "]}" +
546 "]}," +
547 "{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
548 "]}" +
549 "]}" +
550 "";
551 ct = new CosmasTree(query);
552 map = ct.getRequestMap().get("query").toString();
553 assertEquals(opov3.replaceAll(" ", ""), map.replaceAll(" ", ""));
554
555 query="wegen #OV(FI) <s>";
556 String opov4=
557 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
558 "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" +
559 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
560 "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
561 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
562 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
563 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
564 "{@type=korap:span, key=s}" +
565 "]}," +
566 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
567 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
568 "]}" +
569 "]}" +
570 "]}," +
571 "{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
572 "]}" +
573 "]}," +
574 "{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
575 "], exclude=true}" +
576 "]}" +
577 "";
578 ct = new CosmasTree(query);
579 map = ct.getRequestMap().get("query").toString();
580 assertEquals(opov4.replaceAll(" ", ""), map.replaceAll(" ", ""));
581
582 query="wegen #OV(FE) <s>";
583 String opov5=
584 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
585 "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" +
586 "{@type=korap:span, key=s}," +
587 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
588 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
589 "]}" +
590 "]}" +
591 "]}" +
592 "";
593 ct = new CosmasTree(query);
594 map = ct.getRequestMap().get("query").toString();
595 assertEquals(opov5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000596 }
597
598 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000599 public void testOPNOT() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000600 query="Sonne nicht Mond";
601 String opnot1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000602 "{@type=korap:group, operation=operation:sequence, distances=[" +
603 "{@type=korap:distance, key=t, min=0, max=0, exclude=true}" +
604 "], operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000605 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
606 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000607 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000608 ct = new CosmasTree(query);
609 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000610 assertEquals(opnot1.replaceAll(" ", ""), map.replaceAll(" ", ""));
611 }
612
613 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000614 public void testBEG_END() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000615 // BEG and END operators
616 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/links.html
617 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/rechts.html
618 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/thematische-bsp/bsp-satzlaenge.html
Joachim Bingel87480d02014-01-17 14:07:46 +0000619 query="#BEG(der /w3:5 Mann)";
620 String beg1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000621 "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000622 "{@type=korap:group, operation=operation:sequence," +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000623 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000624 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
625 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000626 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000627 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000628 "]}" +
629 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000630 ct = new CosmasTree(query);
631 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000632 assertEquals(beg1.replaceAll(" ", ""), map.replaceAll(" ", ""));
633
Joachim Bingel37a803f2014-07-28 14:21:44 +0000634
635 String dermannSeq = "{@type=korap:group, operation=operation:sequence," +
636 "operands = [" +
637 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
638 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
639 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000640 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000641 "]}";
642 String begDermannSeq = "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
643 dermannSeq +
644 "]}";
645 String kommt = "{@type=korap:token, wrap={@type=korap:term, key=kommt, layer=orth, match=match:eq}}";
646
Joachim Bingel87480d02014-01-17 14:07:46 +0000647 query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group
648 String beg2 =
Joachim Bingel37a803f2014-07-28 14:21:44 +0000649 "{@type=korap:group, operation=operation:or, operands=[" +
650 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
651 begDermannSeq + "," +
652 kommt +
653 "]}," +
654 "{@type=korap:group, operation=operation:sequence, operands=[" +
655 begDermannSeq + "," +
656 kommt +
657 "], inOrder=true, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000658 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000659 "]}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000660 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000661 ct = new CosmasTree(query);
662 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000663 assertEquals(beg2.replaceAll(" ", ""), map.replaceAll(" ", ""));
664
Joachim Bingel37a803f2014-07-28 14:21:44 +0000665 query="kommt /+w10 #BEG(der /w3:5 Mann)";
666 String beg3 =
667 "{@type=korap:group, operation=operation:or, operands=[" +
668 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
669 kommt + "," +
670 begDermannSeq +
671 "]}," +
672 "{@type=korap:group, operation=operation:sequence, operands=[" +
673 kommt + "," +
674 begDermannSeq +
675 "], inOrder=true, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000676 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000677 "]}" +
678 "]}";
679 ct = new CosmasTree(query);
680 map = ct.getRequestMap().get("query").toString();
681 assertEquals(beg3.replaceAll(" ", ""), map.replaceAll(" ", ""));
682
Joachim Bingel87480d02014-01-17 14:07:46 +0000683 query="#END(der /w3:5 Mann)";
684 String end1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000685 "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000686 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000687 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000688 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
689 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000690 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000691 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000692 "]}" +
693 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000694 ct = new CosmasTree(query);
695 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000696 assertEquals(end1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000697 }
Joachim Bingeld5161a12014-01-08 11:15:49 +0000698
Joachim Bingel03dfd952014-07-30 08:08:53 +0000699 /*
700 * YET UNCLEAR HOW TO SERIALIZE SPAN DISTANCES. BEING DISCUSSED.
701 *
Joachim Bingel37a803f2014-07-28 14:21:44 +0000702 @Test
703 public void testSentenceDistance() throws QueryException {
Joachim Bingel03dfd952014-07-30 08:08:53 +0000704 query="Sonne /s0 Mond"; // contains(focus(1:contains({1:<s>},Sonne)),Mond)
Joachim Bingel37a803f2014-07-28 14:21:44 +0000705 expected =
706 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000707 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000708 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000709 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000710 "{@type=korap:span, key=s}" +
711 "]}," +
712 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
713 "]}" +
714 "]}," +
715 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
716 "]}";
717 ct = new CosmasTree(query);
718 map = ct.getRequestMap().get("query").toString();
719 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
720
Joachim Bingel03dfd952014-07-30 08:08:53 +0000721 query="Sonne /s0,w5 Mond";
722 expected =
723 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
724 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
725 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
726 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
727 "{@type=korap:span, key=s}" +
728 "]}," +
729 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
730 "]}" +
731 "]}," +
732 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
733 "]}";
734// ct = new CosmasTree(query);
735// map = ct.getRequestMap().get("query").toString();
736// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
737
Joachim Bingel37a803f2014-07-28 14:21:44 +0000738 query="Sonne /s2:2 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond)
739 expected =
740 "{@type=korap:group, operation=operation:sequence, operands=[" +
741 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
742 "{@type=korap:span, key=s}," +
743 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
744 "]}," +
745 "{@type=korap:span, key=s}," +
746 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
747 "{@type=korap:span, key=s}," +
748 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000749 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000750 "]}";
751 ct = new CosmasTree(query);
752 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +0000753// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel37a803f2014-07-28 14:21:44 +0000754
Joachim Bingel03dfd952014-07-30 08:08:53 +0000755 query="Sonne /s2:3 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond)
756 expected =
757 "{@type=korap:group, operation=operation:sequence, operands=[" +
758 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
759 "{@type=korap:span, key=s}," +
760 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
761 "]}," +
762 "{@type=korap:group, operation=operation:repetition, operands=[" +
763 "{@type=korap:span, key=s}" +
764 "], boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}," +
765 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
766 "{@type=korap:span, key=s}," +
767 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
768 "]}" +
769 "]}";
770 ct = new CosmasTree(query);
771 map = ct.getRequestMap().get("query").toString();
772// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
773
774 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 +0000775 expected =
776 "{@type=korap:group, operation=operation:or, operands=[" +
777 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000778 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000779 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000780 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000781 "{@type=korap:span, key=s}" +
782 "]}," +
783 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
784 "]}" +
785 "]}," +
786 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
787 "]}," +
788 "{@type=korap:group, operation=operation:sequence, operands=[" +
789 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
790 "{@type=korap:span, key=s}," +
791 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
792 "]}," +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000793 "{@type=korap:group, operation=operation:repetition, operands=[" +
794 "{@type=korap:span, key=s}" +
795 "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}," +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000796 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
797 "{@type=korap:span, key=s}," +
798 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000799 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000800 "]}" +
801 "]}";
802 ct = new CosmasTree(query);
803 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +0000804// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel37a803f2014-07-28 14:21:44 +0000805 }
Joachim Bingel03dfd952014-07-30 08:08:53 +0000806 */
Joachim Bingel37a803f2014-07-28 14:21:44 +0000807
Joachim Bingeld5161a12014-01-08 11:15:49 +0000808
809 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000810 public void testELEM() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000811 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/elem.html
Joachim Bingeleecc7652014-01-11 17:21:07 +0000812 query="#ELEM(S)";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000813 String elem1 = "{@type=korap:span, key=s}";
814 ct = new CosmasTree(query);
815 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +0000816 assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel402c6e12014-05-08 17:09:06 +0000817
818 query="#ELEM(W ANA=N)";
819 String elem2 =
820 "{@type=korap:span, key=w, attr=" +
821 "{@type=korap:termGroup, relation=relation:and, operands=[" +
822 "{@type=korap:term, layer=pos, key=N, match=match:eq}" +
823 "]}" +
824 "}";
825 ct = new CosmasTree(query);
826 map = ct.getRequestMap().get("query").toString();
827 assertEquals(elem2.replaceAll(" ", ""), map.replaceAll(" ", ""));
828
829 query="#ELEM(W ANA != 'N V')";
830 String elem3 =
831 "{@type=korap:span, key=w, attr=" +
832 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingelb674cca2014-05-09 14:00:58 +0000833 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
834 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000835 "]}" +
836 "}";
837 ct = new CosmasTree(query);
838 map = ct.getRequestMap().get("query").toString();
839 assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", ""));
840
Joachim Bingelb674cca2014-05-09 14:00:58 +0000841 query="#ELEM(W ANA != 'N A V' Genre = Sport)";
Joachim Bingel402c6e12014-05-08 17:09:06 +0000842 String elem4 =
843 "{@type=korap:span, key=w, attr=" +
844 "{@type=korap:termGroup, relation=relation:and, operands=[" +
845 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingelb674cca2014-05-09 14:00:58 +0000846 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
847 "{@type=korap:term, layer=pos, key=A, match=match:ne}," +
848 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
849 "]}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000850 "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" +
851 "]}" +
852 "}";
853 ct = new CosmasTree(query);
854 map = ct.getRequestMap().get("query").toString();
855 assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb674cca2014-05-09 14:00:58 +0000856
857 query="#ELEM(W ANA != 'N V' Genre != 'Sport Politik')";
858 String elem5 =
859 "{@type=korap:span, key=w, attr=" +
860 "{@type=korap:termGroup, relation=relation:and, operands=[" +
861 "{@type=korap:termGroup, relation=relation:and, operands=[" +
862 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
863 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
864 "]}," +
865 "{@type=korap:termGroup, relation=relation:and, operands=[" +
866 "{@type=korap:term, layer=Genre, key=Sport, match=match:ne}," +
867 "{@type=korap:term, layer=Genre, key=Politik, match=match:ne}" +
868 "]}" +
869 "]}" +
870 "}";
871 ct = new CosmasTree(query);
872 map = ct.getRequestMap().get("query").toString();
873 assertEquals(elem5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000874 }
875
876 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000877 public void testOPALL() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +0000878 query="#ALL(gehen /w1:10 voran)";
Joachim Bingele98d0882014-01-21 12:58:54 +0000879 String all1 =
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000880 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000881 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000882 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
883 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000884 "], inOrder=false, " +
885 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000886 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000887 "]" +
888 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000889 ct = new CosmasTree(query);
890 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000891 assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000892 }
893
Joachim Bingel36233b52014-02-13 10:48:24 +0000894 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000895 public void testOPNHIT() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +0000896 query="#NHIT(gehen /w1:10 voran)";
897 String nhit1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000898 "{@type=korap:reference, operation=operation:focus, classRef=[1,2], classRefOp=classRefOp:intersection, operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000899 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel36233b52014-02-13 10:48:24 +0000900 "operands=[" +
901 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
902 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
903 "]}," +
904 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
905 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
906 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000907 "], inOrder=false, " +
908 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000909 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
Joachim Bingel36233b52014-02-13 10:48:24 +0000910 "]" +
911 "}" +
912 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000913 ct = new CosmasTree(query);
914 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000915 assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000916 }
917
918 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000919 public void testOPBED() throws QueryException {
Joachim Bingeleecc7652014-01-11 17:21:07 +0000920 query = "#BED(der , sa)";
921 String bed1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000922 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands= [" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +0000923 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
924 "{@type=korap:span, key=s}," +
925 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
926 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
927 "]}" +
928 "]}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +0000929 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000930 ct = new CosmasTree(query);
931 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +0000932 assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", ""));
933
934 query = "#BED(der Mann , +pe)";
935 String bed2 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000936 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands= [" +
Joachim Bingel36233b52014-02-13 10:48:24 +0000937 "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
938 "{@type=korap:span, key=p}," +
939 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
940 "{@type=korap:group, operation=operation:sequence, operands=[" +
941 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
942 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
943 "]}" +
944 "]}" +
945 "]}" +
946 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000947 ct = new CosmasTree(query);
948 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +0000949 assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000950
951 query = "#BED(der Mann , sa,-pa)";
952 String bed3 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000953 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000954 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +0000955 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
956 "{@type=korap:span, key=s}," +
957 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
958 "{@type=korap:group, operation=operation:sequence, operands=[" +
959 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
960 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
961 "]}" +
962 "]}" +
963 "]}," +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000964 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +0000965 "{@type=korap:span, key=p}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000966 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +0000967 "{@type=korap:group, operation=operation:sequence, operands=[" +
968 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
969 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
970 "]}" +
971 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000972 "], exclude=true}" +
973 "], distances=[" +
974 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000975 "]}" +
976 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000977 ct = new CosmasTree(query);
978 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +0000979 assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000980 }
981
Joachim Bingel81812632014-02-18 08:55:22 +0000982 @Test
983 public void testColonSeparatedConditions() throws QueryException {
984
985 query = "Der:sa";
986 String col1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000987 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +0000988 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
989 "{@type=korap:span, key=s}," +
990 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
991 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
992 "]}" +
993 "]}" +
994 "]}";
995 ct = new CosmasTree(query);
996 map = ct.getRequestMap().get("query").toString();
997 assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", ""));
998
999 query = "Mann:sa,-pa,+te)";
1000 String col2 =
Joachim Bingel0de1b412014-07-02 14:51:48 +00001001 "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001002 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001003 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
1004 "{@type=korap:span, key=s}," +
1005 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
1006 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1007 "]}" +
1008 "]}," +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001009 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001010 "{@type=korap:span, key=p}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001011 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001012 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1013 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001014 "], exclude=true}," +
Joachim Bingel81812632014-02-18 08:55:22 +00001015 "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
1016 "{@type=korap:span, key=t}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001017 "{@type=korap:group, operation=operation:class, class=3, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001018 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1019 "]}" +
1020 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001021 "], distances=[" +
1022 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}" +
Joachim Bingel81812632014-02-18 08:55:22 +00001023 "]}" +
1024 "]}";
1025 ct = new CosmasTree(query);
1026 map = ct.getRequestMap().get("query").toString();
1027 assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1028 }
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00001029}
1030