blob: f5f494ac64ca40c0c43fb5db1c116fa5a20e65cb [file] [log] [blame]
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00001import static org.junit.Assert.*;
2
3import org.junit.Test;
4
5import de.ids_mannheim.korap.query.serialize.CosmasTree;
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00006import de.ids_mannheim.korap.util.QueryException;
7
8public class CosmasTreeTest {
9
Joachim Bingel2daf9862014-02-12 10:18:54 +000010 CosmasTree ct;
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000011 String map;
12 String query;
Joachim Bingel37a803f2014-07-28 14:21:44 +000013 String expected;
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000014
Joachim Bingel81812632014-02-18 08:55:22 +000015 @Test
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000016 public void testContext() throws QueryException {
Joachim Bingel81812632014-02-18 08:55:22 +000017 String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld";
Joachim Bingel2daf9862014-02-12 10:18:54 +000018 ct = new CosmasTree("Test");
19 assertEquals(contextString.replaceAll(" ", ""), ct.getRequestMap().get("@context").toString().replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000020 }
21
22
23 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +000024 public void testSingleToken() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000025 query="der";
26 String single1 =
Joachim Bingelee3b21d2014-02-12 12:34:59 +000027 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000028 ct = new CosmasTree(query);
29 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000030 assertEquals(single1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Michael Hanlbaf1a5e2014-05-15 19:51:40 +000031
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000032 query="Mann";
33 String single2 =
Joachim Bingelee3b21d2014-02-12 12:34:59 +000034 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000035 ct = new CosmasTree(query);
36 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000037 assertEquals(single2.replaceAll(" ", ""), map.replaceAll(" ", ""));
38
39 query="&Mann";
40 String single3 =
Joachim Bingelee3b21d2014-02-12 12:34:59 +000041 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000042 ct = new CosmasTree(query);
43 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000044 assertEquals(single3.replaceAll(" ", ""), map.replaceAll(" ", ""));
45 }
46
Joachim Bingelba9a0ab2014-01-29 10:12:25 +000047 @Test
Joachim Bingel8c640e42014-02-07 16:20:47 +000048 public void testCaseSensitivityFlag() throws QueryException {
Joachim Bingel0207d5e2014-02-12 14:18:41 +000049 query="$deutscher";
50 String cs1 =
51 "{@type=korap:token, wrap={@type=korap:term, caseInsensitive=true, key=deutscher, layer=orth, match=match:eq}}";
52 ct = new CosmasTree(query);
53 map = ct.getRequestMap().get("query").toString();
54 assertEquals(cs1.replaceAll(" ", ""), map.replaceAll(" ", ""));
55
56 query="$deutscher Bundestag";
57 String cs2 =
58 "{@type=korap:group, operation=operation:sequence, operands=[" +
59 "{@type=korap:token, wrap={@type=korap:term, caseInsensitive=true, key=deutscher, layer=orth, match=match:eq}}," +
60 "{@type=korap:token, wrap={@type=korap:term, key=Bundestag, layer=orth, match=match:eq}}" +
61 "]}";
62 ct = new CosmasTree(query);
63 map = ct.getRequestMap().get("query").toString();
64 assertEquals(cs2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel8c640e42014-02-07 16:20:47 +000065 }
66
67 @Test
Joachim Bingelffd65e32014-01-22 14:22:57 +000068 public void testMORPH() throws QueryException {
69 query="#MORPH(V)";
70 String morph1 =
Joachim Bingel0207d5e2014-02-12 14:18:41 +000071 "{@type=korap:token, wrap={@type=korap:term, key=V, layer=pos, match=match:eq}}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000072 ct = new CosmasTree(query);
73 map = ct.getRequestMap().get("query").toString();
Joachim Bingelffd65e32014-01-22 14:22:57 +000074 assertEquals(morph1.replaceAll(" ", ""), map.replaceAll(" ", ""));
75 }
76
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000077 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +000078 public void testSequence() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000079 query="der Mann";
80 String seq1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +000081 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +000082 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
83 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000084 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000085 ct = new CosmasTree(query);
86 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000087 assertEquals(seq1.replaceAll(" ", ""), map.replaceAll(" ", ""));
88
Joachim Bingeld5161a12014-01-08 11:15:49 +000089 query="der Mann schläft";
90 String seq2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +000091 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +000092 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
93 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
94 "{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +000095 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000096 ct = new CosmasTree(query);
97 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +000098 assertEquals(seq2.replaceAll(" ", ""), map.replaceAll(" ", ""));
99
100 query="der Mann schläft lang";
101 String seq3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000102 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000103 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
104 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
105 "{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}," +
106 "{@type=korap:token, wrap={@type=korap:term, key=lang, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000107 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000108 ct = new CosmasTree(query);
109 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000110 assertEquals(seq3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000111 }
112
113 @Test
114 public void testOPOR() throws QueryException {
115 query="Sonne oder Mond";
116 String disj1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000117 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000118 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
119 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000120 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000121 ct = new CosmasTree(query);
122 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000123 assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", ""));
124
Joachim Bingeld5161a12014-01-08 11:15:49 +0000125 query="(Sonne scheint) oder Mond";
126 String disj2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000127 "{@type=korap:group, operation=operation:or, operands=[" +
128 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000129 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
130 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000131 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000132 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000133 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000134 ct = new CosmasTree(query);
135 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000136 assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", ""));
137
138 query="(Sonne scheint) oder (Mond scheint)";
139 String disj3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000140 "{@type=korap:group, operation=operation:or, operands=[" +
141 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000142 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
143 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000144 "]}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000145 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000146 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
147 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000148 "]}" +
149 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000150 ct = new CosmasTree(query);
151 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000152 assertEquals(disj3.replaceAll(" ", ""), map.replaceAll(" ", ""));
153
154 }
155
156 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000157 public void testOPORAND() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000158 query="(Sonne oder Mond) und scheint";
159 String orand1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000160 "{@type=korap:group, operation=operation:sequence, distances=[" +
161 "{@type=korap:distance, key=t, min=0, max=0}" +
162 "], operands=[" +
163 "{@type=korap:group, operation=operation:or, operands=[" +
164 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
165 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
166 "]}," +
167 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000168 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000169 ct = new CosmasTree(query);
170 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000171 assertEquals(orand1.replaceAll(" ", ""), map.replaceAll(" ", ""));
172
173 query="scheint und (Sonne oder Mond)";
174 String orand2 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000175 "{@type=korap:group, operation=operation:sequence, distances=[" +
176 "{@type=korap:distance, key=t, min=0, max=0}" +
177 "], operands=[" +
178 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," +
179 "{@type=korap:group, operation=operation:or, operands=[" +
180 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
181 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000182 "]}" +
183 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000184 ct = new CosmasTree(query);
185 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000186 assertEquals(orand2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel92f9c9c2014-06-25 15:01:17 +0000187
188 query="Regen und scheint und (Sonne oder Mond)";
189 String orand3 =
190 "{@type=korap:group, operation=operation:sequence, distances=[" +
191 "{@type=korap:distance, key=t, min=0, max=0}" +
192 "], operands=[" +
193 "{@type=korap:token, wrap={@type=korap:term, key=Regen, layer=orth, match=match:eq}}," +
194 "{@type=korap:group, operation=operation:sequence, distances=[" +
195 "{@type=korap:distance, key=t, min=0, max=0}" +
196 "], operands=[" +
197 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," +
198 "{@type=korap:group, operation=operation:or, operands=[" +
199 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
200 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
201 "]}" +
202 "]}" +
203 "]}";
204 ct = new CosmasTree(query);
205 map = ct.getRequestMap().get("query").toString();
206 assertEquals(orand3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000207 }
208
209 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000210 public void testOPPROX() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000211 query="Sonne /+w1:4 Mond";
212 String prox1 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000213 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000214 "{@type=korap:group, operation=operation:sequence, " +
215 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000216 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000217 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
218 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000219 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000220 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
221 "]}" +
222 "], inOrder=true, " +
223 "distances=[" +
224 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
225 "]" +
226 "}" +
227 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000228 ct = new CosmasTree(query);
229 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000230 assertEquals(prox1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel89cceac2014-01-08 15:51:08 +0000231
232 query="Sonne /+w1:4,s0,p1:3 Mond";
233 String prox2 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000234 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000235 "{@type=korap:group, operation=operation:sequence, " +
236 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000237 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000238 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
239 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000240 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000241 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
242 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000243 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000244 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000245 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}," +
246 "{@type=korap:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}," +
247 "{@type=korap:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3}" +
Joachim Bingel89cceac2014-01-08 15:51:08 +0000248 "]" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000249 "}" +
250 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000251 ct = new CosmasTree(query);
252 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000253 assertEquals(prox2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000254
255 query="Sonne %+w1:4,s0,p1:3 Mond";
256 String prox3 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000257 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000258 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000259 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000260 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000261 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
262 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000263 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000264 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
265 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000266 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000267 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000268 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4, exclude=true}," +
269 "{@type=korap:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0, exclude=true}," +
270 "{@type=korap:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3, exclude=true}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000271 "]" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000272 "}" +
273 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000274 ct = new CosmasTree(query);
275 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +0000276// assertEquals(prox3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000277
278 query="Sonne /+w4 Mond";
279 String prox4 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000280 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000281 "{@type=korap:group, operation=operation:sequence, " +
282 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000283 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000284 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
285 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000286 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000287 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
288 "]}" +
289 "], inOrder=true, " +
290 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000291 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000292 "]" +
293 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000294 "]}";
295// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000296// "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000297// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000298// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
299// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000300// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000301// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
302// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000303// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000304// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000305// "{@type=korap:group, operation=operation:sequence, " +
306// "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000307// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000308// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
309// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000310// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000311// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
312// "]}" +
313// "], inOrder=true, " +
314// "distances=[" +
315// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
316// "]" +
317// "}" +
318// "]}" +
319// "]}";
320
321
Joachim Bingel2daf9862014-02-12 10:18:54 +0000322 ct = new CosmasTree(query);
323 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000324 assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000325
326 query="Sonne /-w4 Mond";
327 String prox5 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000328 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000329 "{@type=korap:group, operation=operation:sequence, " +
330 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000331 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000332 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
333 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000334 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000335 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
336 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000337 "], inOrder=true, " +
338 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000339 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000340 "]" +
341 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000342 "]}";
343// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000344// "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000345// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000346// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
347// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000348// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000349// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
350// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000351// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000352// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000353// "{@type=korap:group, operation=operation:sequence, " +
354// "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000355// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000356// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
357// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000358// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000359// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
360// "]}" +
361// "], inOrder=true, " +
362// "distances=[" +
363// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
364// "]" +
365// "}" +
366// "]}" +
367// "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000368 ct = new CosmasTree(query);
369 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000370 assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000371
372 query="Sonne /w4 Mond";
373 String prox6 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000374 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000375 "{@type=korap:group, operation=operation:sequence, " +
376 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000377 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000378 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
379 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000380 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000381 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
382 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000383 "], inOrder=false, " +
384 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000385 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000386 "]" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000387 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000388 "]}";
389// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000390// "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000391// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000392// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
393// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000394// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000395// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
396// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000397// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000398// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000399// "{@type=korap:group, operation=operation:sequence, " +
400// "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000401// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000402// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
403// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000404// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000405// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
406// "]}" +
407// "], inOrder=false, " +
408// "distances=[" +
409// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
410// "]" +
411// "}" +
412// "]}" +
413// "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000414 ct = new CosmasTree(query);
415 map = ct.getRequestMap().get("query").toString();
416 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000417 }
418
419 @Test
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000420 public void testOPPROXNested() throws QueryException {
Joachim Bingel09737972014-09-22 09:43:06 +0000421 query="Sonne /+w1:4 Mond /-w1:7 Sterne";
422 expected =
Joachim Bingelbd386362014-10-02 12:03:18 +0000423 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000424 "{@type=korap:group, operation=operation:sequence, " +
425 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000426 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000427 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
428 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000429 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
430 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000431 "{@type=korap:group, operation=operation:sequence, " +
432 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000433 "{@type=korap:group, operation=operation:class, class=1026, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000434 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000435 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000436 "{@type=korap:group, operation=operation:class, class=1026, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000437 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000438 "]}" +
439 "], inOrder=true, " +
440 "distances=[" +
441 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=7}, min=1, max=7}" +
442 "]" +
443 "}" +
444 "]}" +
445 "]}" +
446 "], inOrder=true, " +
447 "distances=[" +
448 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
449 "]" +
450 "}" +
451 "]}" +
452 "" ;
453 ct = new CosmasTree(query);
454 map = ct.getRequestMap().get("query").toString();
455 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
456
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000457 query="Sonne /-w4 Mond /+w2 Sterne";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000458
Joachim Bingelceb79062014-09-22 11:50:37 +0000459// String mondsterne =
460// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
461// "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" ;
Joachim Bingelfbc88792014-09-17 11:11:52 +0000462
463 String mondsterneClasses =
Joachim Bingelbd386362014-10-02 12:03:18 +0000464 "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000465 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
466 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000467 "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000468 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
469 "]}";
Joachim Bingelceb79062014-09-22 11:50:37 +0000470// String mondsterneSeq =
471// "{@type=korap:group, operation=operation:sequence, operands=[" +
472// mondsterne +
473// "], inOrder=true, distances=[" +
474// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
475// "]}" ;
Joachim Bingelfbc88792014-09-17 11:11:52 +0000476 String mondsterneClassesSeq =
Joachim Bingelbd386362014-10-02 12:03:18 +0000477 "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000478 "{@type=korap:group, operation=operation:sequence, operands=[" +
479 mondsterneClasses +
480 "], inOrder=true, distances=[" +
481 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
482 "]}" +
483 "]}" ;
Joachim Bingelceb79062014-09-22 11:50:37 +0000484// String mondsterneOv =
Joachim Bingel93e6c702014-09-30 15:19:23 +0000485// "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelceb79062014-09-22 11:50:37 +0000486// mondsterne +
487// "]}";
Joachim Bingelfbc88792014-09-17 11:11:52 +0000488 String mondsterneClassesOv =
Joachim Bingel93e6c702014-09-30 15:19:23 +0000489 "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000490 mondsterneClasses +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000491 "], frame=frame:overlaps}";
Joachim Bingelceb79062014-09-22 11:50:37 +0000492// String mondsterneAll =
493// "{@type=korap:group, operation=operation:or, operands=[" +
494// mondsterneOv + "," + mondsterneClassesSeq +
495// "]}";
Joachim Bingelfbc88792014-09-17 11:11:52 +0000496 String mondsterneAllClasses =
497 "{@type=korap:group, operation=operation:or, operands=[" +
498 mondsterneClassesOv + "," + mondsterneClassesSeq +
499 "]}";
500
501
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000502 String prox6 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000503 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000504 "{@type=korap:group, operation=operation:sequence, " +
505 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000506 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
507 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000508 "{@type=korap:group, operation=operation:sequence, " +
509 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000510 "{@type=korap:group, operation=operation:class, class=1026, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000511 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
512 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000513 "{@type=korap:group, operation=operation:class, class=1026, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000514 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
515 "]}" +
516 "], inOrder=true, " +
517 "distances=[" +
518 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
519 "]" +
520 "}" +
521 "]}" +
522 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000523 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000524 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
525 "]}" +
526 "], inOrder=true, " +
527 "distances=[" +
528 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
529 "]" +
530 "}" +
531 "]}" +
532 "" ;
533// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000534// "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000535// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000536// mondsterneAllClasses +
537// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000538// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000539// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
540// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000541// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000542// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000543// "{@type=korap:group, operation=operation:sequence, " +
544// "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000545// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000546// mondsterneAllClasses +
547// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000548// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000549// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
550// "]}" +
551// "], inOrder=true, " +
552// "distances=[" +
553// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
554// "]" +
555// "}" +
556// "]}" +
557// "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000558 ct = new CosmasTree(query);
559 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000560 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000561 }
562
563 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000564 public void testOPIN() throws QueryException {
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000565 query="wegen #IN <s>";
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000566 String opin1 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000567 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000568 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000569 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000570 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000571 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +0000572 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000573 "], frames=[], sharedClasses=[sharedClasses:includes], frame=frame:contains}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000574 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000575 ct = new CosmasTree(query);
576 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000577 assertEquals(opin1.replaceAll(" ", ""), map.replaceAll(" ", ""));
578
Joachim Bingel09737972014-09-22 09:43:06 +0000579 query="wegen #IN(L) <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000580 String opin2 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000581 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000582 "{@type=korap:group, operation=operation:position, operands=[" +
583 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000584 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000585 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
586 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000587 "], frames=[frame:startswith], sharedClasses=[sharedClasses:includes], frame=frame:startswith}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000588 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000589 ct = new CosmasTree(query);
590 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000591 assertEquals(opin2.replaceAll(" ", ""), map.replaceAll(" ", ""));
592
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000593
594 query="wegen #IN(F) <s>";
595 String opin3=
Joachim Bingelbd386362014-10-02 12:03:18 +0000596 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000597 "{@type=korap:group, operation=operation:position, operands=[" +
598 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000599 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000600 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
601 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000602 "], frames=[frame:matches], sharedClasses=[sharedClasses:includes], frame=frame:matches}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000603 "]}" +
604 "";
605 ct = new CosmasTree(query);
606 map = ct.getRequestMap().get("query").toString();
607 assertEquals(opin3.replaceAll(" ", ""), map.replaceAll(" ", ""));
608
609 query="wegen #IN(FI) <s>";
610 String opin4=
Joachim Bingelbd386362014-10-02 12:03:18 +0000611 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000612 "{@type=korap:group, operation=operation:position, operands=[" +
613 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000614 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000615 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
616 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000617 "], frames=[frame:matches], sharedClasses=[sharedClasses:unequals,sharedClasses:includes], frame=frame:matches-noident}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000618 "]}" +
619 "";
620 ct = new CosmasTree(query);
621 map = ct.getRequestMap().get("query").toString();
622 assertEquals(opin4.replaceAll(" ", ""), map.replaceAll(" ", ""));
623
624 query="wegen #IN(FE) <s>";
625 String opin5=
Joachim Bingelbd386362014-10-02 12:03:18 +0000626 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000627 "{@type=korap:group, operation=operation:position, operands=[" +
628 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000629 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000630 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000631 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000632 "], frames=[frame:matches], sharedClasses=[sharedClasses:equals], frame=frame:matches}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000633 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000634 "";
635 ct = new CosmasTree(query);
636 map = ct.getRequestMap().get("query").toString();
637 assertEquals(opin5.replaceAll(" ", ""), map.replaceAll(" ", ""));
638
Joachim Bingel87480d02014-01-17 14:07:46 +0000639 query="wegen #IN(%, L) <s>";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000640 String opin6 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000641 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000642 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000643 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000644 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000645 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000646 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000647 "], frames=[frame:startswith], sharedClasses=[sharedClasses:includes], frame=frame:startswith, exclude=true}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000648 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000649 ct = new CosmasTree(query);
650 map = ct.getRequestMap().get("query").toString();
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000651 assertEquals(opin6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000652
653 query="wegen #IN('FE,ALL,%,MIN') <s>";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000654 String opin7 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000655 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000656 "{@type=korap:group, operation=operation:position, operands=[" +
657 "{@type=korap:reference, operation=operation:focus, reset=true, operands=[" +
658 "{@type=korap:span, key=s}" +
659 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000660 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000661 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000662 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000663 "], frames=[frame:matches], sharedClasses=[sharedClasses:equals], frame=frame:matches, exclude=true, grouping=false}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000664 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000665 ct = new CosmasTree(query);
666 map = ct.getRequestMap().get("query").toString();
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000667 assertEquals(opin7.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000668 }
669
670 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000671 public void testOPOV() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000672 query="wegen #OV <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000673 String opov1 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000674 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000675 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000676 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000677 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000678 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000679 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000680 "], frames=[], sharedClasses=[sharedClasses:intersects], frame=frame:overlaps}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000681 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000682 ct = new CosmasTree(query);
683 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000684 assertEquals(opov1.replaceAll(" ", ""), map.replaceAll(" ", ""));
685
686 query="wegen #OV(L) <s>";
687 String opov2 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000688 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000689 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000690 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000691 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000692 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000693 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000694 "], frames=[frame:startswith,frame:overlapsLeft], sharedClasses=[sharedClasses:intersects], frame=frame:overlapsLeft}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000695 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000696 ct = new CosmasTree(query);
697 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000698 assertEquals(opov2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000699
700 query="wegen #OV(F) <s>";
701 String opov3=
Joachim Bingelbd386362014-10-02 12:03:18 +0000702 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000703 "{@type=korap:group, operation=operation:position, operands=[" +
704 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000705 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000706 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
707 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000708 "], frames=[frame:matches], sharedClasses=[sharedClasses:intersects], frame=frame:matches}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000709 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000710 ct = new CosmasTree(query);
711 map = ct.getRequestMap().get("query").toString();
712 assertEquals(opov3.replaceAll(" ", ""), map.replaceAll(" ", ""));
713
714 query="wegen #OV(FI) <s>";
715 String opov4=
Joachim Bingelbd386362014-10-02 12:03:18 +0000716 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000717 "{@type=korap:group, operation=operation:position, operands=[" +
718 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000719 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000720 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
721 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000722 "], frames=[frame:matches], sharedClasses=[sharedClasses:unequals], frame=frame:matches-noident}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000723 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000724 ct = new CosmasTree(query);
725 map = ct.getRequestMap().get("query").toString();
726 assertEquals(opov4.replaceAll(" ", ""), map.replaceAll(" ", ""));
727
728 query="wegen #OV(FE) <s>";
729 String opov5=
Joachim Bingelbd386362014-10-02 12:03:18 +0000730 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000731 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000732 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000733 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000734 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
735 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000736 "], frames=[frame:matches], sharedClasses=[sharedClasses:equals], frame=frame:matches}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000737 "]}" +
738 "";
739 ct = new CosmasTree(query);
740 map = ct.getRequestMap().get("query").toString();
741 assertEquals(opov5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000742 }
743
744 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000745 public void testOPNOT() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000746 query="Sonne nicht Mond";
747 String opnot1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000748 "{@type=korap:group, operation=operation:sequence, distances=[" +
749 "{@type=korap:distance, key=t, min=0, max=0, exclude=true}" +
750 "], operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000751 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
752 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000753 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000754 ct = new CosmasTree(query);
755 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000756 assertEquals(opnot1.replaceAll(" ", ""), map.replaceAll(" ", ""));
757 }
758
759 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000760 public void testBEG_END() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000761 // BEG and END operators
762 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/links.html
763 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/rechts.html
764 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/thematische-bsp/bsp-satzlaenge.html
Joachim Bingel87480d02014-01-17 14:07:46 +0000765 query="#BEG(der /w3:5 Mann)";
766 String beg1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000767 "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000768 "{@type=korap:group, operation=operation:sequence," +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000769 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000770 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
771 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000772 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000773 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000774 "]}" +
775 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000776 ct = new CosmasTree(query);
777 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000778 assertEquals(beg1.replaceAll(" ", ""), map.replaceAll(" ", ""));
779
Joachim Bingel37a803f2014-07-28 14:21:44 +0000780
Joachim Bingelfbc88792014-09-17 11:11:52 +0000781// String dermannSeq = "{@type=korap:group, operation=operation:sequence," +
782// "operands = [" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000783// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000784// "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
785// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000786// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000787// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
788// "]}" +
789//
790// "], inOrder=false, distances=[" +
791// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
792// "]}";
793//
794// String begDermannSeq =
Joachim Bingelbd386362014-10-02 12:03:18 +0000795//// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000796// "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
797// dermannSeq +
798// "]}" +
799//// "]}" +
800// "";
801
Joachim Bingel37a803f2014-07-28 14:21:44 +0000802 String kommt = "{@type=korap:token, wrap={@type=korap:term, key=kommt, layer=orth, match=match:eq}}";
803
Joachim Bingel87480d02014-01-17 14:07:46 +0000804 query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group
805 String beg2 =
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000806// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000807// "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000808// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000809// beg1 +
810// "]}" + "," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000811// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000812// kommt +
813// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000814// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000815// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000816// "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000817// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000818// beg1 +
819// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000820// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000821// kommt +
822// "]}" +
823// "], inOrder=true, distances=[" +
824// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
825// "]}" +
826// "]}" +
827// "]}";
828//
Joachim Bingelbd386362014-10-02 12:03:18 +0000829 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000830 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000831 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000832 beg1 +
833 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000834 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000835 kommt +
836 "]}" +
837 "], inOrder=true, distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000838 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=10}, min=0, max=10}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000839 "]}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000840 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000841 ct = new CosmasTree(query);
842 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000843 assertEquals(beg2.replaceAll(" ", ""), map.replaceAll(" ", ""));
844
Joachim Bingel37a803f2014-07-28 14:21:44 +0000845 query="kommt /+w10 #BEG(der /w3:5 Mann)";
846 String beg3 =
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000847// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000848// "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000849// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000850// kommt +
851//// "," +
852// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000853// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000854// beg1+
855// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000856// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000857// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000858// "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000859// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000860// kommt +
861// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000862// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000863// beg1+
864// "]}" +
865// "], inOrder=true, distances=[" +
866// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
867// "]}" +
868// "]}" +
869// "]}";
870
Joachim Bingelbd386362014-10-02 12:03:18 +0000871 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000872 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000873 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000874 kommt +
875 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000876 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000877 beg1+
878 "]}" +
879 "], inOrder=true, distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000880 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=10}, min=0, max=10}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000881 "]}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000882 "]}";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000883 ct = new CosmasTree(query);
884 map = ct.getRequestMap().get("query").toString();
885 assertEquals(beg3.replaceAll(" ", ""), map.replaceAll(" ", ""));
886
Joachim Bingel87480d02014-01-17 14:07:46 +0000887 query="#END(der /w3:5 Mann)";
888 String end1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000889 "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000890 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000891 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000892 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
893 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000894 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000895 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000896 "]}" +
897 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000898 ct = new CosmasTree(query);
899 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000900 assertEquals(end1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000901 }
Joachim Bingeld5161a12014-01-08 11:15:49 +0000902
Joachim Bingel03dfd952014-07-30 08:08:53 +0000903 /*
904 * YET UNCLEAR HOW TO SERIALIZE SPAN DISTANCES. BEING DISCUSSED.
905 *
Joachim Bingel37a803f2014-07-28 14:21:44 +0000906 @Test
907 public void testSentenceDistance() throws QueryException {
Joachim Bingel03dfd952014-07-30 08:08:53 +0000908 query="Sonne /s0 Mond"; // contains(focus(1:contains({1:<s>},Sonne)),Mond)
Joachim Bingel37a803f2014-07-28 14:21:44 +0000909 expected =
Joachim Bingel93e6c702014-09-30 15:19:23 +0000910 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000911 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000912 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000913 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000914 "{@type=korap:span, key=s}" +
915 "]}," +
916 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
917 "]}" +
918 "]}," +
919 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
920 "]}";
921 ct = new CosmasTree(query);
922 map = ct.getRequestMap().get("query").toString();
923 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
924
Joachim Bingel03dfd952014-07-30 08:08:53 +0000925 query="Sonne /s0,w5 Mond";
926 expected =
Joachim Bingel93e6c702014-09-30 15:19:23 +0000927 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000928 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000929 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000930 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000931 "{@type=korap:span, key=s}" +
932 "]}," +
933 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
934 "]}" +
935 "]}," +
936 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
937 "]}";
938// ct = new CosmasTree(query);
939// map = ct.getRequestMap().get("query").toString();
940// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
941
Joachim Bingel37a803f2014-07-28 14:21:44 +0000942 query="Sonne /s2:2 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond)
943 expected =
944 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000945 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000946 "{@type=korap:span, key=s}," +
947 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
948 "]}," +
949 "{@type=korap:span, key=s}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000950 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000951 "{@type=korap:span, key=s}," +
952 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000953 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000954 "]}";
955 ct = new CosmasTree(query);
956 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +0000957// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel37a803f2014-07-28 14:21:44 +0000958
Joachim Bingel03dfd952014-07-30 08:08:53 +0000959 query="Sonne /s2:3 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond)
960 expected =
961 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000962 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000963 "{@type=korap:span, key=s}," +
964 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
965 "]}," +
966 "{@type=korap:group, operation=operation:repetition, operands=[" +
967 "{@type=korap:span, key=s}" +
968 "], boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000969 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000970 "{@type=korap:span, key=s}," +
971 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
972 "]}" +
973 "]}";
974 ct = new CosmasTree(query);
975 map = ct.getRequestMap().get("query").toString();
976// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
977
978 query="Sonne /s2 Mond"; // contains(focus(1:contains({1:<s>},Sonne)),Mond) | contains(<s>,Sonne)<s>?contains(<s>,Mond)
Joachim Bingel37a803f2014-07-28 14:21:44 +0000979 expected =
980 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000981 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000982 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000983 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000984 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000985 "{@type=korap:span, key=s}" +
986 "]}," +
987 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
988 "]}" +
989 "]}," +
990 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
991 "]}," +
992 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000993 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000994 "{@type=korap:span, key=s}," +
995 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
996 "]}," +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000997 "{@type=korap:group, operation=operation:repetition, operands=[" +
998 "{@type=korap:span, key=s}" +
999 "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001000 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001001 "{@type=korap:span, key=s}," +
1002 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001003 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001004 "]}" +
1005 "]}";
1006 ct = new CosmasTree(query);
1007 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +00001008// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel37a803f2014-07-28 14:21:44 +00001009 }
Joachim Bingel03dfd952014-07-30 08:08:53 +00001010 */
Joachim Bingel37a803f2014-07-28 14:21:44 +00001011
Joachim Bingeld5161a12014-01-08 11:15:49 +00001012
1013 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001014 public void testELEM() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +00001015 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/elem.html
Joachim Bingeleecc7652014-01-11 17:21:07 +00001016 query="#ELEM(S)";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001017 String elem1 = "{@type=korap:span, key=s}";
1018 ct = new CosmasTree(query);
1019 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +00001020 assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel402c6e12014-05-08 17:09:06 +00001021
1022 query="#ELEM(W ANA=N)";
1023 String elem2 =
1024 "{@type=korap:span, key=w, attr=" +
1025 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1026 "{@type=korap:term, layer=pos, key=N, match=match:eq}" +
1027 "]}" +
1028 "}";
1029 ct = new CosmasTree(query);
1030 map = ct.getRequestMap().get("query").toString();
1031 assertEquals(elem2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1032
1033 query="#ELEM(W ANA != 'N V')";
1034 String elem3 =
1035 "{@type=korap:span, key=w, attr=" +
1036 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingelb674cca2014-05-09 14:00:58 +00001037 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
1038 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001039 "]}" +
1040 "}";
1041 ct = new CosmasTree(query);
1042 map = ct.getRequestMap().get("query").toString();
1043 assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", ""));
1044
Joachim Bingelb674cca2014-05-09 14:00:58 +00001045 query="#ELEM(W ANA != 'N A V' Genre = Sport)";
Joachim Bingel402c6e12014-05-08 17:09:06 +00001046 String elem4 =
1047 "{@type=korap:span, key=w, attr=" +
1048 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1049 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingelb674cca2014-05-09 14:00:58 +00001050 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
1051 "{@type=korap:term, layer=pos, key=A, match=match:ne}," +
1052 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
1053 "]}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001054 "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" +
1055 "]}" +
1056 "}";
1057 ct = new CosmasTree(query);
1058 map = ct.getRequestMap().get("query").toString();
1059 assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb674cca2014-05-09 14:00:58 +00001060
1061 query="#ELEM(W ANA != 'N V' Genre != 'Sport Politik')";
1062 String elem5 =
1063 "{@type=korap:span, key=w, attr=" +
1064 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1065 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1066 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
1067 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
1068 "]}," +
1069 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1070 "{@type=korap:term, layer=Genre, key=Sport, match=match:ne}," +
1071 "{@type=korap:term, layer=Genre, key=Politik, match=match:ne}" +
1072 "]}" +
1073 "]}" +
1074 "}";
1075 ct = new CosmasTree(query);
1076 map = ct.getRequestMap().get("query").toString();
1077 assertEquals(elem5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001078 }
1079
1080 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001081 public void testOPALL() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +00001082 query="#ALL(gehen /w1:10 voran)";
Joachim Bingele98d0882014-01-21 12:58:54 +00001083 String all1 =
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001084 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +00001085 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +00001086 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
1087 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001088 "], inOrder=false, " +
1089 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001090 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001091 "]" +
1092 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001093 ct = new CosmasTree(query);
1094 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +00001095 assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001096 }
1097
Joachim Bingel36233b52014-02-13 10:48:24 +00001098 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001099 public void testOPNHIT() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +00001100 query="#NHIT(gehen /w1:10 voran)";
Joachim Bingelbd386362014-10-02 12:03:18 +00001101// String nhit1 =
1102// "{@type=korap:reference, operation=operation:focus, classRef=[1025], classRefOp=classRefOp:inversion, operands=[" +
1103// "{@type=korap:group, operation=operation:sequence, " +
1104// "operands=[" +
1105// "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
1106// "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1107// "]}," +
1108// "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
1109// "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1110// "]}" +
1111// "], inOrder=false, " +
1112// "distances=[" +
1113// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1114// "]" +
1115// "}" +
1116// "]}";
1117
Joachim Bingel89cceac2014-01-08 15:51:08 +00001118 String nhit1 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001119 "{@type=korap:reference, operation=operation:focus, classRef=1025, operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001120 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel36233b52014-02-13 10:48:24 +00001121 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001122 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1123 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
1124 "{@type=korap:group, operation=operation:repetition, operands=[" +
1125 "{@type=korap:token}" +
1126 "], boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}}" +
1127 "]}," +
1128 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001129 "], inOrder=false, " +
1130 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001131 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001132 "]" +
1133 "}" +
1134 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001135 ct = new CosmasTree(query);
1136 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +00001137 assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001138 }
1139
1140 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001141 public void testOPBED() throws QueryException {
Joachim Bingeleecc7652014-01-11 17:21:07 +00001142 query = "#BED(der , sa)";
1143 String bed1 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001144 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands= [" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001145 "{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +00001146 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001147 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +00001148 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
1149 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001150 "], frame=frame:startswith}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +00001151 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001152 ct = new CosmasTree(query);
1153 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +00001154 assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1155
1156 query = "#BED(der Mann , +pe)";
1157 String bed2 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001158 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands= [" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001159 "{@type=korap:group, operation=operation:position, frames=[frame:endswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001160 "{@type=korap:span, key=p}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001161 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001162 "{@type=korap:group, operation=operation:sequence, operands=[" +
1163 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1164 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1165 "]}" +
1166 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001167 "], frame=frame:endswith}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001168 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001169 ct = new CosmasTree(query);
1170 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +00001171 assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001172
1173 query = "#BED(der Mann , sa,-pa)";
1174 String bed3 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001175 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
1176 "{@type=korap:group, operation=operation:position, frames=[frame:matches], sharedClasses=[sharedClasses:equals], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001177 "{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001178 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001179 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001180 "{@type=korap:group, operation=operation:sequence, operands=[" +
1181 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1182 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1183 "]}" +
1184 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001185 "], frame=frame:startswith}," +
1186 "{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001187 "{@type=korap:span, key=p}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001188 "{@type=korap:group, operation=operation:class, class=1026, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001189 "{@type=korap:group, operation=operation:sequence, operands=[" +
1190 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1191 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1192 "]}" +
1193 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001194 "], frame=frame:startswith, exclude=true}" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001195 "], frame=frame:matches}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001196 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001197 ct = new CosmasTree(query);
1198 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +00001199 assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001200 }
1201
Joachim Bingel81812632014-02-18 08:55:22 +00001202 @Test
1203 public void testColonSeparatedConditions() throws QueryException {
1204
1205 query = "Der:sa";
1206 String col1 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001207 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001208 "{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001209 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001210 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001211 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
1212 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001213 "], frame=frame:startswith}" +
Joachim Bingel81812632014-02-18 08:55:22 +00001214 "]}";
1215 ct = new CosmasTree(query);
1216 map = ct.getRequestMap().get("query").toString();
1217 assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1218
1219 query = "Mann:sa,-pa,+te)";
1220 String col2 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001221 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
1222 "{@type=korap:group, operation=operation:position, frames=[frame:matches], sharedClasses=[sharedClasses:equals], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001223 "{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001224 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001225 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001226 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1227 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001228 "], frame=frame:startswith}," +
1229 "{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001230 "{@type=korap:span, key=p}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001231 "{@type=korap:group, operation=operation:class, class=1026, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001232 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1233 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001234 "], frame=frame:startswith, exclude=true}," +
1235 "{@type=korap:group, operation=operation:position, frames=[frame:endswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001236 "{@type=korap:span, key=t}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001237 "{@type=korap:group, operation=operation:class, class=1027, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001238 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingelaaabb722014-09-24 14:29:10 +00001239 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001240 "], frame=frame:endswith}" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001241 "], frame=frame:matches}" +
Joachim Bingel81812632014-02-18 08:55:22 +00001242 "]}";
1243 ct = new CosmasTree(query);
1244 map = ct.getRequestMap().get("query").toString();
1245 assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1246 }
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00001247}
1248