blob: a4e31cf02e9ba949e653e9fe20d9e73556c76df1 [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;
13
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 Bingel2daf9862014-02-12 10:18:54 +0000213 "{@type=korap:group, operation=operation:sequence, inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000214 "distances=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000215 "{@type=korap:distance, key=w, min=1, max=4}" +
Joachim Bingel89cceac2014-01-08 15:51:08 +0000216 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000217 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000218 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
219 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
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 Bingel2daf9862014-02-12 10:18:54 +0000228 "{@type=korap:group, operation=operation:sequence, inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000229 "distances=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +0000230 "{@type=korap:distance, key=w, min=1, max=4}," +
231 "{@type=korap:distance, key=s, min=0, max=0}," +
232 "{@type=korap:distance, key=p, min=1, max=3}" +
Joachim Bingel89cceac2014-01-08 15:51:08 +0000233 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000234 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000235 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
236 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
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 Bingel2daf9862014-02-12 10:18:54 +0000245 "{@type=korap:group, operation=operation:sequence, inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000246 "distances=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +0000247 "{@type=korap:distance, key=w, min=1, max=4, exclude=true}," +
248 "{@type=korap:distance, key=s, min=0, max=0, exclude=true}," +
249 "{@type=korap:distance, key=p, min=1, max=3, exclude=true}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000250 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000251 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000252 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
253 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
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 Bingel87480d02014-01-17 14:07:46 +0000258 assertEquals(prox3.replaceAll(" ", ""), map.replaceAll(" ", ""));
259
260 query="Sonne /+w4 Mond";
261 String prox4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000262 "{@type=korap:group, operation=operation:sequence, inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000263 "distances=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000264 "{@type=korap:distance, key=w, min=0, max=4}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000265 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000266 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000267 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
268 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000269 "]" +
270 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000271 ct = new CosmasTree(query);
272 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000273 assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000274
275 query="Sonne /-w4 Mond";
276 String prox5 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000277 "{@type=korap:group, operation=operation:sequence, inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000278 "distances=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000279 "{@type=korap:distance, key=w, min=0, max=4}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000280 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000281 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000282 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
283 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000284 "]" +
285 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000286 ct = new CosmasTree(query);
287 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000288 assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", ""));
289 }
290
291 @Test
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000292 public void testOPPROXNested() throws QueryException {
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000293 query="Sonne /-w4 Mond /+w2 Sterne";
294 String prox6 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000295 "{@type=korap:group, operation=operation:sequence, inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000296 "distances=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000297 "{@type=korap:distance, key=w, min=0, max=4}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000298 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000299 "operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000300 "{@type=korap:group, operation=operation:sequence, inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000301 "distances=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000302 "{@type=korap:distance, key=w, min=0, max=2}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000303 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000304 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000305 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
306 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000307 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000308 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000309 "]" +
310 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000311 ct = new CosmasTree(query);
312 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000313 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000314 }
315
316 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000317 public void testOPIN() throws QueryException {
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000318 query="wegen #IN <s>";
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000319 String opin1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000320 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
321 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
322 "{@type=korap:span, key=s}," +
323 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000324 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +0000325 "]}" +
326 "]}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000327 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000328 ct = new CosmasTree(query);
329 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000330 assertEquals(opin1.replaceAll(" ", ""), map.replaceAll(" ", ""));
331
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000332 query="wegen #IN(L) <s>";
333 String opin2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000334 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
335 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
336 "{@type=korap:span, key=s}," +
337 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000338 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000339 "]}" +
340 "]}" +
341 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000342 ct = new CosmasTree(query);
343 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000344 assertEquals(opin2.replaceAll(" ", ""), map.replaceAll(" ", ""));
345
Joachim Bingel87480d02014-01-17 14:07:46 +0000346 query="wegen #IN(%, L) <s>";
347 String opin3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000348 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
349 "{@type=korap:group, operation=operation:position, frame=frame:startswith, exclude=true, operands=[" +
350 "{@type=korap:span, key=s}," +
351 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000352 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000353 "]}" +
354 "]}" +
355 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000356 ct = new CosmasTree(query);
357 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000358 assertEquals(opin3.replaceAll(" ", ""), map.replaceAll(" ", ""));
359
360 query="wegen #IN('FE,ALL,%,MIN') <s>";
361 String opin4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000362 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
363 "{@type=korap:group, operation=operation:position, frame=frame:matches, range=all, exclude=true, grouping=false, operands=[" +
364 "{@type=korap:span, key=s}," +
365 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000366 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000367 "]}" +
368 "]}" +
369 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000370 ct = new CosmasTree(query);
371 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000372 assertEquals(opin4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000373 }
374
375 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000376 public void testOPOV() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000377 query="wegen #OV <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000378 String opov1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000379 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
380 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
381 "{@type=korap:span, key=s}," +
382 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000383 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000384 "]}" +
385 "]}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000386 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000387 ct = new CosmasTree(query);
388 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000389 assertEquals(opov1.replaceAll(" ", ""), map.replaceAll(" ", ""));
390
391 query="wegen #OV(L) <s>";
392 String opov2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000393 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
394 "{@type=korap:group, operation=operation:position, frame=frame:overlaps-left, operands=[" +
395 "{@type=korap:span, key=s}," +
396 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000397 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000398 "]}" +
399 "]}" +
400 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000401 ct = new CosmasTree(query);
402 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000403 assertEquals(opov2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000404 }
405
406 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000407 public void testOPNOT() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000408 query="Sonne nicht Mond";
409 String opnot1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000410 "{@type=korap:group, operation=operation:sequence, distances=[" +
411 "{@type=korap:distance, key=t, min=0, max=0, exclude=true}" +
412 "], operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000413 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
414 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000415 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000416 ct = new CosmasTree(query);
417 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000418 assertEquals(opnot1.replaceAll(" ", ""), map.replaceAll(" ", ""));
419 }
420
421 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000422 public void testBEG_END() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000423 // BEG and END operators
424 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/links.html
425 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/rechts.html
426 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/thematische-bsp/bsp-satzlaenge.html
Joachim Bingel87480d02014-01-17 14:07:46 +0000427 query="#BEG(der /w3:5 Mann)";
428 String beg1 =
Joachim Bingelcd7b7252014-02-13 08:49:14 +0000429 "{@type=korap:group, operation=operation:submatch, spanRef=[0,1], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000430 "{@type=korap:group, operation=operation:sequence, inOrder=false, distances=[" +
431 "{@type=korap:distance, key=w, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000432 "]," +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000433 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000434 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
435 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000436 "]}" +
437 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000438 ct = new CosmasTree(query);
439 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000440 assertEquals(beg1.replaceAll(" ", ""), map.replaceAll(" ", ""));
441
442 query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group
443 String beg2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000444 "{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
445 "{@type=korap:distance, key=w, min=0, max=10}" +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000446 "], operands=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +0000447 "{@type=korap:group, operation=operation:submatch, spanRef=[0,1], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000448 "{@type=korap:group, operation=operation:sequence, inOrder=false, distances=[" +
449 "{@type=korap:distance, key=w, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000450 "]," +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000451 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000452 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
453 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000454 "]}" +
455 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000456 "{@type=korap:token, wrap={@type=korap:term, key=kommt, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000457 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000458 ct = new CosmasTree(query);
459 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000460 assertEquals(beg2.replaceAll(" ", ""), map.replaceAll(" ", ""));
461
462 query="#END(der /w3:5 Mann)";
463 String end1 =
Joachim Bingelcd7b7252014-02-13 08:49:14 +0000464 "{@type=korap:group, operation=operation:submatch, spanRef=[-1,1], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000465 "{@type=korap:group, operation=operation:sequence, inOrder=false, distances=[" +
466 "{@type=korap:distance, key=w, min=3, max=5}" +
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000467 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000468 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000469 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
470 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000471 "]}" +
472 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000473 ct = new CosmasTree(query);
474 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000475 assertEquals(end1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000476 }
Joachim Bingeld5161a12014-01-08 11:15:49 +0000477
478
479 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000480 public void testELEM() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000481 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/elem.html
Joachim Bingeleecc7652014-01-11 17:21:07 +0000482 query="#ELEM(S)";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000483 String elem1 = "{@type=korap:span, key=s}";
484 ct = new CosmasTree(query);
485 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +0000486 assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel402c6e12014-05-08 17:09:06 +0000487
488 query="#ELEM(W ANA=N)";
489 String elem2 =
490 "{@type=korap:span, key=w, attr=" +
491 "{@type=korap:termGroup, relation=relation:and, operands=[" +
492 "{@type=korap:term, layer=pos, key=N, match=match:eq}" +
493 "]}" +
494 "}";
495 ct = new CosmasTree(query);
496 map = ct.getRequestMap().get("query").toString();
497 assertEquals(elem2.replaceAll(" ", ""), map.replaceAll(" ", ""));
498
499 query="#ELEM(W ANA != 'N V')";
500 String elem3 =
501 "{@type=korap:span, key=w, attr=" +
502 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingelb674cca2014-05-09 14:00:58 +0000503 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
504 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000505 "]}" +
506 "}";
507 ct = new CosmasTree(query);
508 map = ct.getRequestMap().get("query").toString();
509 assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", ""));
510
Joachim Bingelb674cca2014-05-09 14:00:58 +0000511 query="#ELEM(W ANA != 'N A V' Genre = Sport)";
Joachim Bingel402c6e12014-05-08 17:09:06 +0000512 String elem4 =
513 "{@type=korap:span, key=w, attr=" +
514 "{@type=korap:termGroup, relation=relation:and, operands=[" +
515 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingelb674cca2014-05-09 14:00:58 +0000516 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
517 "{@type=korap:term, layer=pos, key=A, match=match:ne}," +
518 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
519 "]}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000520 "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" +
521 "]}" +
522 "}";
523 ct = new CosmasTree(query);
524 map = ct.getRequestMap().get("query").toString();
525 assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb674cca2014-05-09 14:00:58 +0000526
527 query="#ELEM(W ANA != 'N V' Genre != 'Sport Politik')";
528 String elem5 =
529 "{@type=korap:span, key=w, attr=" +
530 "{@type=korap:termGroup, relation=relation:and, operands=[" +
531 "{@type=korap:termGroup, relation=relation:and, operands=[" +
532 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
533 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
534 "]}," +
535 "{@type=korap:termGroup, relation=relation:and, operands=[" +
536 "{@type=korap:term, layer=Genre, key=Sport, match=match:ne}," +
537 "{@type=korap:term, layer=Genre, key=Politik, match=match:ne}" +
538 "]}" +
539 "]}" +
540 "}";
541 ct = new CosmasTree(query);
542 map = ct.getRequestMap().get("query").toString();
543 assertEquals(elem5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000544 }
545
546 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000547 public void testOPALL() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +0000548 query="#ALL(gehen /w1:10 voran)";
Joachim Bingele98d0882014-01-21 12:58:54 +0000549 String all1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000550 "{@type=korap:group, operation=operation:sequence, inOrder=false, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000551 "distances=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000552 "{@type=korap:distance, key=w, min=1, max=10}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000553 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000554 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000555 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
556 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000557 "]" +
558 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000559 ct = new CosmasTree(query);
560 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000561 assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000562 }
563
Joachim Bingel36233b52014-02-13 10:48:24 +0000564 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000565 public void testOPNHIT() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +0000566 query="#NHIT(gehen /w1:10 voran)";
567 String nhit1 =
Joachim Bingel36233b52014-02-13 10:48:24 +0000568 "{@type=korap:group, operation=operation:submatch, classRef=[1,2], classRefOp=classRefOp:intersection, operands=[" +
569 "{@type=korap:group, operation=operation:sequence, inOrder=false, " +
570 "distances=[" +
571 "{@type=korap:distance, key=w, min=1, max=10}" +
572 "], " +
573 "operands=[" +
574 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
575 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
576 "]}," +
577 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
578 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
579 "]}" +
580 "]" +
581 "}" +
582 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000583 ct = new CosmasTree(query);
584 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000585 assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000586 }
587
588 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000589 public void testOPBED() throws QueryException {
Joachim Bingeleecc7652014-01-11 17:21:07 +0000590 query = "#BED(der , sa)";
591 String bed1 =
Joachim Bingelcd7b7252014-02-13 08:49:14 +0000592 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands= [" +
593 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
594 "{@type=korap:span, key=s}," +
595 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
596 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
597 "]}" +
598 "]}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +0000599 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000600 ct = new CosmasTree(query);
601 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +0000602 assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", ""));
603
604 query = "#BED(der Mann , +pe)";
605 String bed2 =
Joachim Bingel36233b52014-02-13 10:48:24 +0000606 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands= [" +
607 "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
608 "{@type=korap:span, key=p}," +
609 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
610 "{@type=korap:group, operation=operation:sequence, operands=[" +
611 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
612 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
613 "]}" +
614 "]}" +
615 "]}" +
616 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000617 ct = new CosmasTree(query);
618 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +0000619 assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000620
621 query = "#BED(der Mann , sa,-pa)";
622 String bed3 =
Joachim Bingel36233b52014-02-13 10:48:24 +0000623 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
624 "{@type=korap:group, operation=operation:sequence, distances=[" +
625 "{@type=korap:distance, key=w, min=0, max=0}" +
626 "], operands=[" +
627 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
628 "{@type=korap:span, key=s}," +
629 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
630 "{@type=korap:group, operation=operation:sequence, operands=[" +
631 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
632 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
633 "]}" +
634 "]}" +
635 "]}," +
636 "{@type=korap:group, operation=operation:position, frame=frame:startswith, exclude=true, operands=[" +
637 "{@type=korap:span, key=p}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000638 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +0000639 "{@type=korap:group, operation=operation:sequence, operands=[" +
640 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
641 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
642 "]}" +
643 "]}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000644 "]}" +
645 "]}" +
646 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000647 ct = new CosmasTree(query);
648 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +0000649 assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000650 }
651
Joachim Bingel81812632014-02-18 08:55:22 +0000652 @Test
653 public void testColonSeparatedConditions() throws QueryException {
654
655 query = "Der:sa";
656 String col1 =
657 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
658 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
659 "{@type=korap:span, key=s}," +
660 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
661 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
662 "]}" +
663 "]}" +
664 "]}";
665 ct = new CosmasTree(query);
666 map = ct.getRequestMap().get("query").toString();
667 assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", ""));
668
669 query = "Mann:sa,-pa,+te)";
670 String col2 =
671 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
672 "{@type=korap:group, operation=operation:sequence, distances=[" +
673 "{@type=korap:distance, key=w, min=0, max=0}" +
674 "], operands=[" +
675 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
676 "{@type=korap:span, key=s}," +
677 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
678 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
679 "]}" +
680 "]}," +
681 "{@type=korap:group, operation=operation:position, frame=frame:startswith, exclude=true, operands=[" +
682 "{@type=korap:span, key=p}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000683 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +0000684 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
685 "]}" +
686 "]}," +
687 "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
688 "{@type=korap:span, key=t}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000689 "{@type=korap:group, operation=operation:class, class=3, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +0000690 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
691 "]}" +
692 "]}" +
693 "]}" +
694 "]}";
695 ct = new CosmasTree(query);
696 map = ct.getRequestMap().get("query").toString();
697 assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", ""));
698 }
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000699}
700