blob: 55d2c8e311a440ce47675f5917244ebb8819fe10 [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 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=[" +
Joachim Bingelb674cca2014-05-09 14:00:58 +0000483 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
484 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000485 "]}" +
486 "}";
487 ct = new CosmasTree(query);
488 map = ct.getRequestMap().get("query").toString();
489 assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", ""));
490
Joachim Bingelb674cca2014-05-09 14:00:58 +0000491 query="#ELEM(W ANA != 'N A V' Genre = Sport)";
Joachim Bingel402c6e12014-05-08 17:09:06 +0000492 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=[" +
Joachim Bingelb674cca2014-05-09 14:00:58 +0000496 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
497 "{@type=korap:term, layer=pos, key=A, match=match:ne}," +
498 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
499 "]}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000500 "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" +
501 "]}" +
502 "}";
503 ct = new CosmasTree(query);
504 map = ct.getRequestMap().get("query").toString();
505 assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb674cca2014-05-09 14:00:58 +0000506
507 query="#ELEM(W ANA != 'N V' Genre != 'Sport Politik')";
508 String elem5 =
509 "{@type=korap:span, key=w, attr=" +
510 "{@type=korap:termGroup, relation=relation:and, operands=[" +
511 "{@type=korap:termGroup, relation=relation:and, operands=[" +
512 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
513 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
514 "]}," +
515 "{@type=korap:termGroup, relation=relation:and, operands=[" +
516 "{@type=korap:term, layer=Genre, key=Sport, match=match:ne}," +
517 "{@type=korap:term, layer=Genre, key=Politik, match=match:ne}" +
518 "]}" +
519 "]}" +
520 "}";
521 ct = new CosmasTree(query);
522 map = ct.getRequestMap().get("query").toString();
523 assertEquals(elem5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000524 }
525
526 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000527 public void testOPALL() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +0000528 query="#ALL(gehen /w1:10 voran)";
Joachim Bingele98d0882014-01-21 12:58:54 +0000529 String all1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000530 "{@type=korap:group, operation=operation:sequence, inOrder=false, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000531 "distances=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000532 "{@type=korap:distance, key=w, min=1, max=10}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000533 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000534 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000535 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
536 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000537 "]" +
538 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000539 ct = new CosmasTree(query);
540 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000541 assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000542 }
543
Joachim Bingel36233b52014-02-13 10:48:24 +0000544 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000545 public void testOPNHIT() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +0000546 query="#NHIT(gehen /w1:10 voran)";
547 String nhit1 =
Joachim Bingel36233b52014-02-13 10:48:24 +0000548 "{@type=korap:group, operation=operation:submatch, classRef=[1,2], classRefOp=classRefOp:intersection, operands=[" +
549 "{@type=korap:group, operation=operation:sequence, inOrder=false, " +
550 "distances=[" +
551 "{@type=korap:distance, key=w, min=1, max=10}" +
552 "], " +
553 "operands=[" +
554 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
555 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
556 "]}," +
557 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
558 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
559 "]}" +
560 "]" +
561 "}" +
562 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000563 ct = new CosmasTree(query);
564 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000565 assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000566 }
567
568 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000569 public void testOPBED() throws QueryException {
Joachim Bingeleecc7652014-01-11 17:21:07 +0000570 query = "#BED(der , sa)";
571 String bed1 =
Joachim Bingelcd7b7252014-02-13 08:49:14 +0000572 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands= [" +
573 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
574 "{@type=korap:span, key=s}," +
575 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
576 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
577 "]}" +
578 "]}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +0000579 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000580 ct = new CosmasTree(query);
581 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +0000582 assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", ""));
583
584 query = "#BED(der Mann , +pe)";
585 String bed2 =
Joachim Bingel36233b52014-02-13 10:48:24 +0000586 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands= [" +
587 "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
588 "{@type=korap:span, key=p}," +
589 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
590 "{@type=korap:group, operation=operation:sequence, operands=[" +
591 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
592 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
593 "]}" +
594 "]}" +
595 "]}" +
596 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000597 ct = new CosmasTree(query);
598 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +0000599 assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000600
601 query = "#BED(der Mann , sa,-pa)";
602 String bed3 =
Joachim Bingel36233b52014-02-13 10:48:24 +0000603 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
604 "{@type=korap:group, operation=operation:sequence, distances=[" +
605 "{@type=korap:distance, key=w, min=0, max=0}" +
606 "], operands=[" +
607 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
608 "{@type=korap:span, key=s}," +
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 "{@type=korap:group, operation=operation:position, frame=frame:startswith, exclude=true, operands=[" +
617 "{@type=korap:span, key=p}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000618 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +0000619 "{@type=korap:group, operation=operation:sequence, operands=[" +
620 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
621 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
622 "]}" +
623 "]}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000624 "]}" +
625 "]}" +
626 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000627 ct = new CosmasTree(query);
628 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +0000629 assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000630 }
631
Joachim Bingel81812632014-02-18 08:55:22 +0000632 @Test
633 public void testColonSeparatedConditions() throws QueryException {
634
635 query = "Der:sa";
636 String col1 =
637 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
638 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
639 "{@type=korap:span, key=s}," +
640 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
641 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
642 "]}" +
643 "]}" +
644 "]}";
645 ct = new CosmasTree(query);
646 map = ct.getRequestMap().get("query").toString();
647 assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", ""));
648
649 query = "Mann:sa,-pa,+te)";
650 String col2 =
651 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
652 "{@type=korap:group, operation=operation:sequence, distances=[" +
653 "{@type=korap:distance, key=w, min=0, max=0}" +
654 "], operands=[" +
655 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
656 "{@type=korap:span, key=s}," +
657 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
658 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
659 "]}" +
660 "]}," +
661 "{@type=korap:group, operation=operation:position, frame=frame:startswith, exclude=true, operands=[" +
662 "{@type=korap:span, key=p}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000663 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +0000664 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
665 "]}" +
666 "]}," +
667 "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
668 "{@type=korap:span, key=t}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +0000669 "{@type=korap:group, operation=operation:class, class=3, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +0000670 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
671 "]}" +
672 "]}" +
673 "]}" +
674 "]}";
675 ct = new CosmasTree(query);
676 map = ct.getRequestMap().get("query").toString();
677 assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", ""));
678 }
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000679}
680