blob: 777b75ac75c65350339f329ee0fb3284df5c02c3 [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(" ", ""));
31
32 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 Bingelb5f7bf02014-01-07 16:36:54 +0000187 }
188
189 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000190 public void testOPPROX() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000191 query="Sonne /+w1:4 Mond";
192 String prox1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000193 "{@type=korap:group, operation=operation:sequence, inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000194 "distances=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000195 "{@type=korap:distance, key=w, min=1, max=4}" +
Joachim Bingel89cceac2014-01-08 15:51:08 +0000196 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000197 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000198 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
199 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel89cceac2014-01-08 15:51:08 +0000200 "]" +
201 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000202 ct = new CosmasTree(query);
203 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000204 assertEquals(prox1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel89cceac2014-01-08 15:51:08 +0000205
206 query="Sonne /+w1:4,s0,p1:3 Mond";
207 String prox2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000208 "{@type=korap:group, operation=operation:sequence, inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000209 "distances=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +0000210 "{@type=korap:distance, key=w, min=1, max=4}," +
211 "{@type=korap:distance, key=s, min=0, max=0}," +
212 "{@type=korap:distance, key=p, min=1, max=3}" +
Joachim Bingel89cceac2014-01-08 15:51:08 +0000213 "], " +
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 Bingel89cceac2014-01-08 15:51:08 +0000217 "]" +
218 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000219 ct = new CosmasTree(query);
220 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000221 assertEquals(prox2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000222
223 query="Sonne %+w1:4,s0,p1:3 Mond";
224 String prox3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000225 "{@type=korap:group, operation=operation:sequence, inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000226 "distances=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +0000227 "{@type=korap:distance, key=w, min=1, max=4, exclude=true}," +
228 "{@type=korap:distance, key=s, min=0, max=0, exclude=true}," +
229 "{@type=korap:distance, key=p, min=1, max=3, exclude=true}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000230 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000231 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000232 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
233 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000234 "]" +
235 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000236 ct = new CosmasTree(query);
237 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000238 assertEquals(prox3.replaceAll(" ", ""), map.replaceAll(" ", ""));
239
240 query="Sonne /+w4 Mond";
241 String prox4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000242 "{@type=korap:group, operation=operation:sequence, inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000243 "distances=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000244 "{@type=korap:distance, key=w, min=0, max=4}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000245 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000246 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000247 "{@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}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000249 "]" +
250 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000251 ct = new CosmasTree(query);
252 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000253 assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000254
255 query="Sonne /-w4 Mond";
256 String prox5 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000257 "{@type=korap:group, operation=operation:sequence, inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000258 "distances=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000259 "{@type=korap:distance, key=w, min=0, max=4}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000260 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000261 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000262 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
263 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000264 "]" +
265 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000266 ct = new CosmasTree(query);
267 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000268 assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", ""));
269 }
270
271 @Test
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000272 public void testOPPROXNested() throws QueryException {
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000273 query="Sonne /-w4 Mond /+w2 Sterne";
274 String prox6 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000275 "{@type=korap:group, operation=operation:sequence, inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000276 "distances=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000277 "{@type=korap:distance, key=w, min=0, max=4}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000278 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000279 "operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000280 "{@type=korap:group, operation=operation:sequence, inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000281 "distances=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000282 "{@type=korap:distance, key=w, min=0, max=2}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000283 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000284 "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=Sterne, layer=orth, match=match:eq}}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000287 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000288 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000289 "]" +
290 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000291 ct = new CosmasTree(query);
292 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000293 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000294 }
295
296 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000297 public void testOPIN() throws QueryException {
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000298 query="wegen #IN <s>";
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000299 String opin1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000300 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
301 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
302 "{@type=korap:span, key=s}," +
303 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000304 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +0000305 "]}" +
306 "]}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000307 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000308 ct = new CosmasTree(query);
309 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000310 assertEquals(opin1.replaceAll(" ", ""), map.replaceAll(" ", ""));
311
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000312 query="wegen #IN(L) <s>";
313 String opin2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000314 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
315 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
316 "{@type=korap:span, key=s}," +
317 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000318 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000319 "]}" +
320 "]}" +
321 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000322 ct = new CosmasTree(query);
323 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000324 assertEquals(opin2.replaceAll(" ", ""), map.replaceAll(" ", ""));
325
Joachim Bingel87480d02014-01-17 14:07:46 +0000326 query="wegen #IN(%, L) <s>";
327 String opin3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000328 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
329 "{@type=korap:group, operation=operation:position, frame=frame:startswith, exclude=true, operands=[" +
330 "{@type=korap:span, key=s}," +
331 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000332 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000333 "]}" +
334 "]}" +
335 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000336 ct = new CosmasTree(query);
337 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000338 assertEquals(opin3.replaceAll(" ", ""), map.replaceAll(" ", ""));
339
340 query="wegen #IN('FE,ALL,%,MIN') <s>";
341 String opin4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000342 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
343 "{@type=korap:group, operation=operation:position, frame=frame:matches, range=all, exclude=true, grouping=false, operands=[" +
344 "{@type=korap:span, key=s}," +
345 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000346 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000347 "]}" +
348 "]}" +
349 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000350 ct = new CosmasTree(query);
351 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000352 assertEquals(opin4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000353 }
354
355 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000356 public void testOPOV() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000357 query="wegen #OV <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000358 String opov1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000359 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
360 "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
361 "{@type=korap:span, key=s}," +
362 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000363 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000364 "]}" +
365 "]}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000366 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000367 ct = new CosmasTree(query);
368 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000369 assertEquals(opov1.replaceAll(" ", ""), map.replaceAll(" ", ""));
370
371 query="wegen #OV(L) <s>";
372 String opov2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000373 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
374 "{@type=korap:group, operation=operation:position, frame=frame:overlaps-left, operands=[" +
375 "{@type=korap:span, key=s}," +
376 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000377 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000378 "]}" +
379 "]}" +
380 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000381 ct = new CosmasTree(query);
382 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000383 assertEquals(opov2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000384 }
385
386 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000387 public void testOPNOT() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000388 query="Sonne nicht Mond";
389 String opnot1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000390 "{@type=korap:group, operation=operation:sequence, distances=[" +
391 "{@type=korap:distance, key=t, min=0, max=0, exclude=true}" +
392 "], operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000393 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
394 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000395 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000396 ct = new CosmasTree(query);
397 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000398 assertEquals(opnot1.replaceAll(" ", ""), map.replaceAll(" ", ""));
399 }
400
401 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000402 public void testBEG_END() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000403 // BEG and END operators
404 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/links.html
405 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/rechts.html
406 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/thematische-bsp/bsp-satzlaenge.html
Joachim Bingel87480d02014-01-17 14:07:46 +0000407 query="#BEG(der /w3:5 Mann)";
408 String beg1 =
Joachim Bingelcd7b7252014-02-13 08:49:14 +0000409 "{@type=korap:group, operation=operation:submatch, spanRef=[0,1], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000410 "{@type=korap:group, operation=operation:sequence, inOrder=false, distances=[" +
411 "{@type=korap:distance, key=w, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000412 "]," +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000413 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000414 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
415 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000416 "]}" +
417 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000418 ct = new CosmasTree(query);
419 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000420 assertEquals(beg1.replaceAll(" ", ""), map.replaceAll(" ", ""));
421
422 query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group
423 String beg2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000424 "{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
425 "{@type=korap:distance, key=w, min=0, max=10}" +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000426 "], operands=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +0000427 "{@type=korap:group, operation=operation:submatch, spanRef=[0,1], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000428 "{@type=korap:group, operation=operation:sequence, inOrder=false, distances=[" +
429 "{@type=korap:distance, key=w, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000430 "]," +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000431 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000432 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
433 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000434 "]}" +
435 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000436 "{@type=korap:token, wrap={@type=korap:term, key=kommt, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000437 "]}";
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(beg2.replaceAll(" ", ""), map.replaceAll(" ", ""));
441
442 query="#END(der /w3:5 Mann)";
443 String end1 =
Joachim Bingelcd7b7252014-02-13 08:49:14 +0000444 "{@type=korap:group, operation=operation:submatch, spanRef=[-1,1], operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000445 "{@type=korap:group, operation=operation:sequence, inOrder=false, distances=[" +
446 "{@type=korap:distance, key=w, min=3, max=5}" +
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000447 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000448 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000449 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
450 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000451 "]}" +
452 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000453 ct = new CosmasTree(query);
454 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000455 assertEquals(end1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000456 }
Joachim Bingeld5161a12014-01-08 11:15:49 +0000457
458
459 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000460 public void testELEM() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000461 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/elem.html
Joachim Bingeleecc7652014-01-11 17:21:07 +0000462 query="#ELEM(S)";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000463 String elem1 = "{@type=korap:span, key=s}";
464 ct = new CosmasTree(query);
465 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +0000466 assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel402c6e12014-05-08 17:09:06 +0000467
468 query="#ELEM(W ANA=N)";
469 String elem2 =
470 "{@type=korap:span, key=w, attr=" +
471 "{@type=korap:termGroup, relation=relation:and, operands=[" +
472 "{@type=korap:term, layer=pos, key=N, match=match:eq}" +
473 "]}" +
474 "}";
475 ct = new CosmasTree(query);
476 map = ct.getRequestMap().get("query").toString();
477 assertEquals(elem2.replaceAll(" ", ""), map.replaceAll(" ", ""));
478
479 query="#ELEM(W ANA != 'N V')";
480 String elem3 =
481 "{@type=korap:span, key=w, attr=" +
482 "{@type=korap:termGroup, relation=relation:and, operands=[" +
483 "{@type=korap:term, layer=pos, key=N, match=match:eq}," +
484 "{@type=korap:term, layer=pos, key=V, match=match:eq}" +
485 "]}" +
486 "}";
487 ct = new CosmasTree(query);
488 map = ct.getRequestMap().get("query").toString();
489 assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", ""));
490
491 query="#ELEM(W ANA != 'N V' Genre = Sport)";
492 String elem4 =
493 "{@type=korap:span, key=w, attr=" +
494 "{@type=korap:termGroup, relation=relation:and, operands=[" +
495 "{@type=korap:termGroup, relation=relation:and, operands=[" +
496 "{@type=korap:term, layer=pos, key=N, match=match:eq}," +
497 "{@type=korap:term, layer=pos, key=V, match=match:eq}" +
498 "]}" +
499 "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" +
500 "]}" +
501 "}";
502 ct = new CosmasTree(query);
503 map = ct.getRequestMap().get("query").toString();
504 assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000505 }
506
507 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000508 public void testOPALL() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +0000509 query="#ALL(gehen /w1:10 voran)";
Joachim Bingele98d0882014-01-21 12:58:54 +0000510 String all1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000511 "{@type=korap:group, operation=operation:sequence, inOrder=false, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000512 "distances=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000513 "{@type=korap:distance, key=w, min=1, max=10}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000514 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000515 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000516 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
517 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000518 "]" +
519 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000520 ct = new CosmasTree(query);
521 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000522 assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000523 }
524
Joachim Bingel36233b52014-02-13 10:48:24 +0000525 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000526 public void testOPNHIT() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +0000527 query="#NHIT(gehen /w1:10 voran)";
528 String nhit1 =
Joachim Bingel36233b52014-02-13 10:48:24 +0000529 "{@type=korap:group, operation=operation:submatch, classRef=[1,2], classRefOp=classRefOp:intersection, operands=[" +
530 "{@type=korap:group, operation=operation:sequence, inOrder=false, " +
531 "distances=[" +
532 "{@type=korap:distance, key=w, min=1, max=10}" +
533 "], " +
534 "operands=[" +
535 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
536 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
537 "]}," +
538 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
539 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
540 "]}" +
541 "]" +
542 "}" +
543 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000544 ct = new CosmasTree(query);
545 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000546 assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000547 }
548
549 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000550 public void testOPBED() throws QueryException {
Joachim Bingeleecc7652014-01-11 17:21:07 +0000551 query = "#BED(der , sa)";
552 String bed1 =
Joachim Bingelcd7b7252014-02-13 08:49:14 +0000553 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands= [" +
554 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
555 "{@type=korap:span, key=s}," +
556 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
557 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
558 "]}" +
559 "]}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +0000560 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000561 ct = new CosmasTree(query);
562 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +0000563 assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", ""));
564
565 query = "#BED(der Mann , +pe)";
566 String bed2 =
Joachim Bingel36233b52014-02-13 10:48:24 +0000567 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands= [" +
568 "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
569 "{@type=korap:span, key=p}," +
570 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
571 "{@type=korap:group, operation=operation:sequence, operands=[" +
572 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
573 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
574 "]}" +
575 "]}" +
576 "]}" +
577 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000578 ct = new CosmasTree(query);
579 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +0000580 assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000581
582 query = "#BED(der Mann , sa,-pa)";
583 String bed3 =
Joachim Bingel36233b52014-02-13 10:48:24 +0000584 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
585 "{@type=korap:group, operation=operation:sequence, distances=[" +
586 "{@type=korap:distance, key=w, min=0, max=0}" +
587 "], operands=[" +
588 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
589 "{@type=korap:span, key=s}," +
590 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
591 "{@type=korap:group, operation=operation:sequence, operands=[" +
592 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
593 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
594 "]}" +
595 "]}" +
596 "]}," +
597 "{@type=korap:group, operation=operation:position, frame=frame:startswith, exclude=true, operands=[" +
598 "{@type=korap:span, key=p}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000599 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +0000600 "{@type=korap:group, operation=operation:sequence, operands=[" +
601 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
602 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
603 "]}" +
604 "]}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000605 "]}" +
606 "]}" +
607 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000608 ct = new CosmasTree(query);
609 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +0000610 assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000611 }
612
Joachim Bingel81812632014-02-18 08:55:22 +0000613 @Test
614 public void testColonSeparatedConditions() throws QueryException {
615
616 query = "Der:sa";
617 String col1 =
618 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
619 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
620 "{@type=korap:span, key=s}," +
621 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
622 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
623 "]}" +
624 "]}" +
625 "]}";
626 ct = new CosmasTree(query);
627 map = ct.getRequestMap().get("query").toString();
628 assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", ""));
629
630 query = "Mann:sa,-pa,+te)";
631 String col2 =
632 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
633 "{@type=korap:group, operation=operation:sequence, distances=[" +
634 "{@type=korap:distance, key=w, min=0, max=0}" +
635 "], operands=[" +
636 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
637 "{@type=korap:span, key=s}," +
638 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
639 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
640 "]}" +
641 "]}," +
642 "{@type=korap:group, operation=operation:position, frame=frame:startswith, exclude=true, operands=[" +
643 "{@type=korap:span, key=p}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000644 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +0000645 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
646 "]}" +
647 "]}," +
648 "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
649 "{@type=korap:span, key=t}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000650 "{@type=korap:group, operation=operation:class, class=3, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +0000651 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
652 "]}" +
653 "]}" +
654 "]}" +
655 "]}";
656 ct = new CosmasTree(query);
657 map = ct.getRequestMap().get("query").toString();
658 assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", ""));
659 }
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000660}
661