blob: 980de399175592208d5d0f0a70c54066e16f9a92 [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 Bingel9a202ab2014-10-07 12:35:17 +000048 public void testWildcardToken() throws QueryException {
49 query="*der";
50 String wc1 =
51 "{@type=korap:token, wrap={@type=korap:term, type=type:wildcard, key=*der, layer=orth, match=match:eq}}";
52 ct = new CosmasTree(query);
53 map = ct.getRequestMap().get("query").toString();
54 assertEquals(wc1.replaceAll(" ", ""), map.replaceAll(" ", ""));
55 }
56
57 @Test
Joachim Bingel8c640e42014-02-07 16:20:47 +000058 public void testCaseSensitivityFlag() throws QueryException {
Joachim Bingel0207d5e2014-02-12 14:18:41 +000059 query="$deutscher";
60 String cs1 =
61 "{@type=korap:token, wrap={@type=korap:term, caseInsensitive=true, key=deutscher, layer=orth, match=match:eq}}";
62 ct = new CosmasTree(query);
63 map = ct.getRequestMap().get("query").toString();
64 assertEquals(cs1.replaceAll(" ", ""), map.replaceAll(" ", ""));
65
66 query="$deutscher Bundestag";
67 String cs2 =
68 "{@type=korap:group, operation=operation:sequence, operands=[" +
69 "{@type=korap:token, wrap={@type=korap:term, caseInsensitive=true, key=deutscher, layer=orth, match=match:eq}}," +
70 "{@type=korap:token, wrap={@type=korap:term, key=Bundestag, layer=orth, match=match:eq}}" +
71 "]}";
72 ct = new CosmasTree(query);
73 map = ct.getRequestMap().get("query").toString();
74 assertEquals(cs2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel8c640e42014-02-07 16:20:47 +000075 }
76
77 @Test
Joachim Bingelffd65e32014-01-22 14:22:57 +000078 public void testMORPH() throws QueryException {
79 query="#MORPH(V)";
80 String morph1 =
Joachim Bingel0207d5e2014-02-12 14:18:41 +000081 "{@type=korap:token, wrap={@type=korap:term, key=V, layer=pos, match=match:eq}}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000082 ct = new CosmasTree(query);
83 map = ct.getRequestMap().get("query").toString();
Joachim Bingelffd65e32014-01-22 14:22:57 +000084 assertEquals(morph1.replaceAll(" ", ""), map.replaceAll(" ", ""));
85 }
86
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000087 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +000088 public void testSequence() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000089 query="der Mann";
90 String seq1 =
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}}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000094 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000095 ct = new CosmasTree(query);
96 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000097 assertEquals(seq1.replaceAll(" ", ""), map.replaceAll(" ", ""));
98
Joachim Bingeld5161a12014-01-08 11:15:49 +000099 query="der Mann schläft";
100 String seq2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000101 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000102 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
103 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
104 "{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000105 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000106 ct = new CosmasTree(query);
107 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000108 assertEquals(seq2.replaceAll(" ", ""), map.replaceAll(" ", ""));
109
110 query="der Mann schläft lang";
111 String seq3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000112 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000113 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
114 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
115 "{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}," +
116 "{@type=korap:token, wrap={@type=korap:term, key=lang, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000117 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000118 ct = new CosmasTree(query);
119 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000120 assertEquals(seq3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000121 }
122
123 @Test
124 public void testOPOR() throws QueryException {
125 query="Sonne oder Mond";
126 String disj1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000127 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000128 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
129 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000130 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000131 ct = new CosmasTree(query);
132 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000133 assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", ""));
134
Joachim Bingeld5161a12014-01-08 11:15:49 +0000135 query="(Sonne scheint) oder Mond";
136 String disj2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000137 "{@type=korap:group, operation=operation:or, operands=[" +
138 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000139 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
140 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000141 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000142 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000143 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000144 ct = new CosmasTree(query);
145 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000146 assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", ""));
147
148 query="(Sonne scheint) oder (Mond scheint)";
149 String disj3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000150 "{@type=korap:group, operation=operation:or, operands=[" +
151 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000152 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
153 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000154 "]}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000155 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000156 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
157 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000158 "]}" +
159 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000160 ct = new CosmasTree(query);
161 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000162 assertEquals(disj3.replaceAll(" ", ""), map.replaceAll(" ", ""));
163
164 }
165
166 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000167 public void testOPORAND() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000168 query="(Sonne oder Mond) und scheint";
169 String orand1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000170 "{@type=korap:group, operation=operation:sequence, distances=[" +
171 "{@type=korap:distance, key=t, min=0, max=0}" +
172 "], operands=[" +
173 "{@type=korap:group, operation=operation:or, operands=[" +
174 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
175 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
176 "]}," +
177 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000178 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000179 ct = new CosmasTree(query);
180 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000181 assertEquals(orand1.replaceAll(" ", ""), map.replaceAll(" ", ""));
182
183 query="scheint und (Sonne oder Mond)";
184 String orand2 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000185 "{@type=korap:group, operation=operation:sequence, distances=[" +
186 "{@type=korap:distance, key=t, min=0, max=0}" +
187 "], operands=[" +
188 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," +
189 "{@type=korap:group, operation=operation:or, operands=[" +
190 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
191 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000192 "]}" +
193 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000194 ct = new CosmasTree(query);
195 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000196 assertEquals(orand2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel92f9c9c2014-06-25 15:01:17 +0000197
198 query="Regen und scheint und (Sonne oder Mond)";
199 String orand3 =
200 "{@type=korap:group, operation=operation:sequence, distances=[" +
201 "{@type=korap:distance, key=t, min=0, max=0}" +
202 "], operands=[" +
203 "{@type=korap:token, wrap={@type=korap:term, key=Regen, layer=orth, match=match:eq}}," +
204 "{@type=korap:group, operation=operation:sequence, distances=[" +
205 "{@type=korap:distance, key=t, min=0, max=0}" +
206 "], operands=[" +
207 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," +
208 "{@type=korap:group, operation=operation:or, operands=[" +
209 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
210 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
211 "]}" +
212 "]}" +
213 "]}";
214 ct = new CosmasTree(query);
215 map = ct.getRequestMap().get("query").toString();
216 assertEquals(orand3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000217 }
218
219 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000220 public void testOPPROX() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000221 query="Sonne /+w1:4 Mond";
222 String prox1 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000223 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000224 "{@type=korap:group, operation=operation:sequence, " +
225 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000226 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000227 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
228 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000229 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000230 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
231 "]}" +
232 "], inOrder=true, " +
233 "distances=[" +
234 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
235 "]" +
236 "}" +
237 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000238 ct = new CosmasTree(query);
239 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000240 assertEquals(prox1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel89cceac2014-01-08 15:51:08 +0000241
242 query="Sonne /+w1:4,s0,p1:3 Mond";
243 String prox2 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000244 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000245 "{@type=korap:group, operation=operation:sequence, " +
246 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000247 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000248 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
249 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000250 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000251 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
252 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000253 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000254 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000255 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}," +
256 "{@type=korap:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}," +
257 "{@type=korap:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3}" +
Joachim Bingel89cceac2014-01-08 15:51:08 +0000258 "]" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000259 "}" +
260 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000261 ct = new CosmasTree(query);
262 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000263 assertEquals(prox2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000264
265 query="Sonne %+w1:4,s0,p1:3 Mond";
266 String prox3 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000267 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000268 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000269 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000270 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000271 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
272 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000273 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000274 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
275 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000276 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000277 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000278 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4, exclude=true}," +
279 "{@type=korap:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0, exclude=true}," +
280 "{@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 +0000281 "]" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000282 "}" +
283 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000284 ct = new CosmasTree(query);
285 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +0000286// assertEquals(prox3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000287
288 query="Sonne /+w4 Mond";
289 String prox4 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000290 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000291 "{@type=korap:group, operation=operation:sequence, " +
292 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000293 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000294 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
295 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000296 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000297 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
298 "]}" +
299 "], inOrder=true, " +
300 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000301 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000302 "]" +
303 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000304 "]}";
305// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000306// "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], 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// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000313// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000314// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000315// "{@type=korap:group, operation=operation:sequence, " +
316// "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000317// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000318// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
319// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000320// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000321// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
322// "]}" +
323// "], inOrder=true, " +
324// "distances=[" +
325// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
326// "]" +
327// "}" +
328// "]}" +
329// "]}";
330
331
Joachim Bingel2daf9862014-02-12 10:18:54 +0000332 ct = new CosmasTree(query);
333 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000334 assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000335
336 query="Sonne /-w4 Mond";
337 String prox5 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000338 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000339 "{@type=korap:group, operation=operation:sequence, " +
340 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000341 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000342 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
343 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000344 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000345 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
346 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000347 "], inOrder=true, " +
348 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000349 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000350 "]" +
351 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000352 "]}";
353// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000354// "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], 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// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000361// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000362// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000363// "{@type=korap:group, operation=operation:sequence, " +
364// "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000365// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000366// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
367// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000368// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000369// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
370// "]}" +
371// "], inOrder=true, " +
372// "distances=[" +
373// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
374// "]" +
375// "}" +
376// "]}" +
377// "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000378 ct = new CosmasTree(query);
379 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000380 assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000381
382 query="Sonne /w4 Mond";
383 String prox6 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000384 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000385 "{@type=korap:group, operation=operation:sequence, " +
386 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000387 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000388 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
389 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000390 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000391 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
392 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000393 "], inOrder=false, " +
394 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000395 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000396 "]" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000397 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000398 "]}";
399// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000400// "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], 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// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000407// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000408// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000409// "{@type=korap:group, operation=operation:sequence, " +
410// "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000411// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000412// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
413// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000414// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000415// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
416// "]}" +
417// "], inOrder=false, " +
418// "distances=[" +
419// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
420// "]" +
421// "}" +
422// "]}" +
423// "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000424 ct = new CosmasTree(query);
425 map = ct.getRequestMap().get("query").toString();
426 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000427 }
428
429 @Test
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000430 public void testOPPROXNested() throws QueryException {
Joachim Bingel09737972014-09-22 09:43:06 +0000431 query="Sonne /+w1:4 Mond /-w1:7 Sterne";
432 expected =
Joachim Bingelbd386362014-10-02 12:03:18 +0000433 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000434 "{@type=korap:group, operation=operation:sequence, " +
435 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000436 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000437 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
438 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000439 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
440 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000441 "{@type=korap:group, operation=operation:sequence, " +
442 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000443 "{@type=korap:group, operation=operation:class, class=1026, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000444 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000445 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000446 "{@type=korap:group, operation=operation:class, class=1026, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000447 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000448 "]}" +
449 "], inOrder=true, " +
450 "distances=[" +
451 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=7}, min=1, max=7}" +
452 "]" +
453 "}" +
454 "]}" +
455 "]}" +
456 "], inOrder=true, " +
457 "distances=[" +
458 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
459 "]" +
460 "}" +
461 "]}" +
462 "" ;
463 ct = new CosmasTree(query);
464 map = ct.getRequestMap().get("query").toString();
465 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
466
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000467 query="Sonne /-w4 Mond /+w2 Sterne";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000468
Joachim Bingelceb79062014-09-22 11:50:37 +0000469// String mondsterne =
470// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
471// "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" ;
Joachim Bingelfbc88792014-09-17 11:11:52 +0000472
473 String mondsterneClasses =
Joachim Bingelbd386362014-10-02 12:03:18 +0000474 "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000475 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
476 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000477 "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000478 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
479 "]}";
Joachim Bingelceb79062014-09-22 11:50:37 +0000480// String mondsterneSeq =
481// "{@type=korap:group, operation=operation:sequence, operands=[" +
482// mondsterne +
483// "], inOrder=true, distances=[" +
484// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
485// "]}" ;
Joachim Bingelfbc88792014-09-17 11:11:52 +0000486 String mondsterneClassesSeq =
Joachim Bingelbd386362014-10-02 12:03:18 +0000487 "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000488 "{@type=korap:group, operation=operation:sequence, operands=[" +
489 mondsterneClasses +
490 "], inOrder=true, distances=[" +
491 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
492 "]}" +
493 "]}" ;
Joachim Bingelceb79062014-09-22 11:50:37 +0000494// String mondsterneOv =
Joachim Bingel93e6c702014-09-30 15:19:23 +0000495// "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelceb79062014-09-22 11:50:37 +0000496// mondsterne +
497// "]}";
Joachim Bingelfbc88792014-09-17 11:11:52 +0000498 String mondsterneClassesOv =
Joachim Bingel93e6c702014-09-30 15:19:23 +0000499 "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000500 mondsterneClasses +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000501 "], frame=frame:overlaps}";
Joachim Bingelceb79062014-09-22 11:50:37 +0000502// String mondsterneAll =
503// "{@type=korap:group, operation=operation:or, operands=[" +
504// mondsterneOv + "," + mondsterneClassesSeq +
505// "]}";
Joachim Bingelfbc88792014-09-17 11:11:52 +0000506 String mondsterneAllClasses =
507 "{@type=korap:group, operation=operation:or, operands=[" +
508 mondsterneClassesOv + "," + mondsterneClassesSeq +
509 "]}";
510
511
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000512 String prox6 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000513 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000514 "{@type=korap:group, operation=operation:sequence, " +
515 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000516 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
517 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000518 "{@type=korap:group, operation=operation:sequence, " +
519 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000520 "{@type=korap:group, operation=operation:class, class=1026, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000521 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
522 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000523 "{@type=korap:group, operation=operation:class, class=1026, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000524 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
525 "]}" +
526 "], inOrder=true, " +
527 "distances=[" +
528 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
529 "]" +
530 "}" +
531 "]}" +
532 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000533 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000534 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
535 "]}" +
536 "], inOrder=true, " +
537 "distances=[" +
538 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
539 "]" +
540 "}" +
541 "]}" +
542 "" ;
543// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000544// "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], 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// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000551// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000552// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000553// "{@type=korap:group, operation=operation:sequence, " +
554// "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000555// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000556// mondsterneAllClasses +
557// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000558// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000559// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
560// "]}" +
561// "], inOrder=true, " +
562// "distances=[" +
563// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
564// "]" +
565// "}" +
566// "]}" +
567// "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000568 ct = new CosmasTree(query);
569 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000570 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000571 }
572
573 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000574 public void testOPIN() throws QueryException {
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000575 query="wegen #IN <s>";
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000576 String opin1 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000577 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000578 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000579 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000580 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000581 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +0000582 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000583 "], frames=[], sharedClasses=[sharedClasses:includes], frame=frame:contains}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000584 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000585 ct = new CosmasTree(query);
586 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000587 assertEquals(opin1.replaceAll(" ", ""), map.replaceAll(" ", ""));
588
Joachim Bingel09737972014-09-22 09:43:06 +0000589 query="wegen #IN(L) <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000590 String opin2 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000591 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000592 "{@type=korap:group, operation=operation:position, operands=[" +
593 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000594 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000595 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
596 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000597 "], frames=[frame:startswith], sharedClasses=[sharedClasses:includes], frame=frame:startswith}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000598 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000599 ct = new CosmasTree(query);
600 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000601 assertEquals(opin2.replaceAll(" ", ""), map.replaceAll(" ", ""));
602
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000603
604 query="wegen #IN(F) <s>";
605 String opin3=
Joachim Bingelbd386362014-10-02 12:03:18 +0000606 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000607 "{@type=korap:group, operation=operation:position, operands=[" +
608 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000609 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000610 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
611 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000612 "], frames=[frame:matches], sharedClasses=[sharedClasses:includes], frame=frame:matches}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000613 "]}" +
614 "";
615 ct = new CosmasTree(query);
616 map = ct.getRequestMap().get("query").toString();
617 assertEquals(opin3.replaceAll(" ", ""), map.replaceAll(" ", ""));
618
619 query="wegen #IN(FI) <s>";
620 String opin4=
Joachim Bingelbd386362014-10-02 12:03:18 +0000621 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000622 "{@type=korap:group, operation=operation:position, operands=[" +
623 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000624 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000625 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
626 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000627 "], frames=[frame:matches], sharedClasses=[sharedClasses:unequals,sharedClasses:includes], frame=frame:matches-noident}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000628 "]}" +
629 "";
630 ct = new CosmasTree(query);
631 map = ct.getRequestMap().get("query").toString();
632 assertEquals(opin4.replaceAll(" ", ""), map.replaceAll(" ", ""));
633
634 query="wegen #IN(FE) <s>";
635 String opin5=
Joachim Bingelbd386362014-10-02 12:03:18 +0000636 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000637 "{@type=korap:group, operation=operation:position, operands=[" +
638 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000639 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000640 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000641 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000642 "], frames=[frame:matches], sharedClasses=[sharedClasses:equals], frame=frame:matches}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000643 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000644 "";
645 ct = new CosmasTree(query);
646 map = ct.getRequestMap().get("query").toString();
647 assertEquals(opin5.replaceAll(" ", ""), map.replaceAll(" ", ""));
648
Joachim Bingel87480d02014-01-17 14:07:46 +0000649 query="wegen #IN(%, L) <s>";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000650 String opin6 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000651 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000652 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000653 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000654 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000655 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000656 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000657 "], frames=[frame:startswith], sharedClasses=[sharedClasses:includes], frame=frame:startswith, exclude=true}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000658 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000659 ct = new CosmasTree(query);
660 map = ct.getRequestMap().get("query").toString();
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000661 assertEquals(opin6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000662
663 query="wegen #IN('FE,ALL,%,MIN') <s>";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000664 String opin7 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000665 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000666 "{@type=korap:group, operation=operation:position, operands=[" +
667 "{@type=korap:reference, operation=operation:focus, reset=true, operands=[" +
668 "{@type=korap:span, key=s}" +
669 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000670 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000671 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000672 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000673 "], frames=[frame:matches], sharedClasses=[sharedClasses:equals], frame=frame:matches, exclude=true, grouping=false}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000674 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000675 ct = new CosmasTree(query);
676 map = ct.getRequestMap().get("query").toString();
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000677 assertEquals(opin7.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000678 }
679
680 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000681 public void testOPOV() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000682 query="wegen #OV <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000683 String opov1 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000684 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000685 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000686 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000687 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000688 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000689 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000690 "], frames=[], sharedClasses=[sharedClasses:intersects], frame=frame:overlaps}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000691 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000692 ct = new CosmasTree(query);
693 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000694 assertEquals(opov1.replaceAll(" ", ""), map.replaceAll(" ", ""));
695
696 query="wegen #OV(L) <s>";
697 String opov2 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000698 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000699 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000700 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000701 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000702 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000703 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000704 "], frames=[frame:startswith,frame:overlapsLeft], sharedClasses=[sharedClasses:intersects], frame=frame:overlapsLeft}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000705 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000706 ct = new CosmasTree(query);
707 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000708 assertEquals(opov2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000709
710 query="wegen #OV(F) <s>";
711 String opov3=
Joachim Bingelbd386362014-10-02 12:03:18 +0000712 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000713 "{@type=korap:group, operation=operation:position, operands=[" +
714 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000715 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000716 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
717 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000718 "], frames=[frame:matches], sharedClasses=[sharedClasses:intersects], frame=frame:matches}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000719 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000720 ct = new CosmasTree(query);
721 map = ct.getRequestMap().get("query").toString();
722 assertEquals(opov3.replaceAll(" ", ""), map.replaceAll(" ", ""));
723
724 query="wegen #OV(FI) <s>";
725 String opov4=
Joachim Bingelbd386362014-10-02 12:03:18 +0000726 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000727 "{@type=korap:group, operation=operation:position, operands=[" +
728 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000729 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000730 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
731 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000732 "], frames=[frame:matches], sharedClasses=[sharedClasses:unequals], frame=frame:matches-noident}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000733 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000734 ct = new CosmasTree(query);
735 map = ct.getRequestMap().get("query").toString();
736 assertEquals(opov4.replaceAll(" ", ""), map.replaceAll(" ", ""));
737
738 query="wegen #OV(FE) <s>";
739 String opov5=
Joachim Bingelbd386362014-10-02 12:03:18 +0000740 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000741 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000742 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000743 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000744 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
745 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000746 "], frames=[frame:matches], sharedClasses=[sharedClasses:equals], frame=frame:matches}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000747 "]}" +
748 "";
749 ct = new CosmasTree(query);
750 map = ct.getRequestMap().get("query").toString();
751 assertEquals(opov5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000752 }
753
754 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000755 public void testOPNOT() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000756 query="Sonne nicht Mond";
757 String opnot1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000758 "{@type=korap:group, operation=operation:sequence, distances=[" +
759 "{@type=korap:distance, key=t, min=0, max=0, exclude=true}" +
760 "], operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000761 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
762 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000763 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000764 ct = new CosmasTree(query);
765 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000766 assertEquals(opnot1.replaceAll(" ", ""), map.replaceAll(" ", ""));
767 }
768
769 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000770 public void testBEG_END() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000771 // BEG and END operators
772 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/links.html
773 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/rechts.html
774 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/thematische-bsp/bsp-satzlaenge.html
Joachim Bingel87480d02014-01-17 14:07:46 +0000775 query="#BEG(der /w3:5 Mann)";
776 String beg1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000777 "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000778 "{@type=korap:group, operation=operation:sequence," +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000779 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000780 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
781 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000782 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000783 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000784 "]}" +
785 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000786 ct = new CosmasTree(query);
787 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000788 assertEquals(beg1.replaceAll(" ", ""), map.replaceAll(" ", ""));
789
Joachim Bingel37a803f2014-07-28 14:21:44 +0000790
Joachim Bingelfbc88792014-09-17 11:11:52 +0000791// String dermannSeq = "{@type=korap:group, operation=operation:sequence," +
792// "operands = [" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000793// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000794// "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
795// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000796// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000797// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
798// "]}" +
799//
800// "], inOrder=false, distances=[" +
801// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
802// "]}";
803//
804// String begDermannSeq =
Joachim Bingelbd386362014-10-02 12:03:18 +0000805//// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000806// "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
807// dermannSeq +
808// "]}" +
809//// "]}" +
810// "";
811
Joachim Bingel37a803f2014-07-28 14:21:44 +0000812 String kommt = "{@type=korap:token, wrap={@type=korap:term, key=kommt, layer=orth, match=match:eq}}";
813
Joachim Bingel87480d02014-01-17 14:07:46 +0000814 query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group
815 String beg2 =
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000816// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000817// "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000818// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000819// beg1 +
820// "]}" + "," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000821// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000822// kommt +
823// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000824// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000825// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000826// "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000827// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000828// beg1 +
829// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000830// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000831// kommt +
832// "]}" +
833// "], inOrder=true, distances=[" +
834// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
835// "]}" +
836// "]}" +
837// "]}";
838//
Joachim Bingelbd386362014-10-02 12:03:18 +0000839 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000840 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000841 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000842 beg1 +
843 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000844 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000845 kommt +
846 "]}" +
847 "], inOrder=true, distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000848 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=10}, min=0, max=10}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000849 "]}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000850 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000851 ct = new CosmasTree(query);
852 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000853 assertEquals(beg2.replaceAll(" ", ""), map.replaceAll(" ", ""));
854
Joachim Bingel37a803f2014-07-28 14:21:44 +0000855 query="kommt /+w10 #BEG(der /w3:5 Mann)";
856 String beg3 =
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000857// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000858// "{@type=korap:group, operation=operation:position, frames=[frame:], sharedClasses=[sharedClasses:intersects], 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//// "," +
862// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000863// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000864// beg1+
865// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000866// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000867// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000868// "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000869// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000870// kommt +
871// "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000872// "{@type=korap:group, operation=operation:class, class=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000873// beg1+
874// "]}" +
875// "], inOrder=true, distances=[" +
876// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
877// "]}" +
878// "]}" +
879// "]}";
880
Joachim Bingelbd386362014-10-02 12:03:18 +0000881 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000882 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000883 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000884 kommt +
885 "]}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000886 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000887 beg1+
888 "]}" +
889 "], inOrder=true, distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000890 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=10}, min=0, max=10}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000891 "]}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000892 "]}";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000893 ct = new CosmasTree(query);
894 map = ct.getRequestMap().get("query").toString();
895 assertEquals(beg3.replaceAll(" ", ""), map.replaceAll(" ", ""));
896
Joachim Bingel87480d02014-01-17 14:07:46 +0000897 query="#END(der /w3:5 Mann)";
898 String end1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000899 "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000900 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000901 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000902 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
903 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000904 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000905 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000906 "]}" +
907 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000908 ct = new CosmasTree(query);
909 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000910 assertEquals(end1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000911 }
Joachim Bingeld5161a12014-01-08 11:15:49 +0000912
Joachim Bingel03dfd952014-07-30 08:08:53 +0000913 /*
914 * YET UNCLEAR HOW TO SERIALIZE SPAN DISTANCES. BEING DISCUSSED.
915 *
Joachim Bingel37a803f2014-07-28 14:21:44 +0000916 @Test
917 public void testSentenceDistance() throws QueryException {
Joachim Bingel03dfd952014-07-30 08:08:53 +0000918 query="Sonne /s0 Mond"; // contains(focus(1:contains({1:<s>},Sonne)),Mond)
Joachim Bingel37a803f2014-07-28 14:21:44 +0000919 expected =
Joachim Bingel93e6c702014-09-30 15:19:23 +0000920 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000921 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000922 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000923 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000924 "{@type=korap:span, key=s}" +
925 "]}," +
926 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
927 "]}" +
928 "]}," +
929 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
930 "]}";
931 ct = new CosmasTree(query);
932 map = ct.getRequestMap().get("query").toString();
933 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
934
Joachim Bingel03dfd952014-07-30 08:08:53 +0000935 query="Sonne /s0,w5 Mond";
936 expected =
Joachim Bingel93e6c702014-09-30 15:19:23 +0000937 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000938 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000939 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000940 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000941 "{@type=korap:span, key=s}" +
942 "]}," +
943 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
944 "]}" +
945 "]}," +
946 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
947 "]}";
948// ct = new CosmasTree(query);
949// map = ct.getRequestMap().get("query").toString();
950// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
951
Joachim Bingel37a803f2014-07-28 14:21:44 +0000952 query="Sonne /s2:2 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond)
953 expected =
954 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000955 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000956 "{@type=korap:span, key=s}," +
957 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
958 "]}," +
959 "{@type=korap:span, key=s}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000960 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000961 "{@type=korap:span, key=s}," +
962 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000963 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000964 "]}";
965 ct = new CosmasTree(query);
966 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +0000967// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel37a803f2014-07-28 14:21:44 +0000968
Joachim Bingel03dfd952014-07-30 08:08:53 +0000969 query="Sonne /s2:3 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond)
970 expected =
971 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000972 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000973 "{@type=korap:span, key=s}," +
974 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
975 "]}," +
976 "{@type=korap:group, operation=operation:repetition, operands=[" +
977 "{@type=korap:span, key=s}" +
978 "], boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000979 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000980 "{@type=korap:span, key=s}," +
981 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
982 "]}" +
983 "]}";
984 ct = new CosmasTree(query);
985 map = ct.getRequestMap().get("query").toString();
986// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
987
988 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 +0000989 expected =
990 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000991 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000992 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000993 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000994 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000995 "{@type=korap:span, key=s}" +
996 "]}," +
997 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
998 "]}" +
999 "]}," +
1000 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
1001 "]}," +
1002 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001003 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001004 "{@type=korap:span, key=s}," +
1005 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1006 "]}," +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001007 "{@type=korap:group, operation=operation:repetition, operands=[" +
1008 "{@type=korap:span, key=s}" +
1009 "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001010 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001011 "{@type=korap:span, key=s}," +
1012 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001013 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001014 "]}" +
1015 "]}";
1016 ct = new CosmasTree(query);
1017 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +00001018// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel37a803f2014-07-28 14:21:44 +00001019 }
Joachim Bingel03dfd952014-07-30 08:08:53 +00001020 */
Joachim Bingel37a803f2014-07-28 14:21:44 +00001021
Joachim Bingeld5161a12014-01-08 11:15:49 +00001022
1023 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001024 public void testELEM() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +00001025 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/elem.html
Joachim Bingeleecc7652014-01-11 17:21:07 +00001026 query="#ELEM(S)";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001027 String elem1 = "{@type=korap:span, key=s}";
1028 ct = new CosmasTree(query);
1029 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +00001030 assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel402c6e12014-05-08 17:09:06 +00001031
1032 query="#ELEM(W ANA=N)";
1033 String elem2 =
1034 "{@type=korap:span, key=w, attr=" +
1035 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1036 "{@type=korap:term, layer=pos, key=N, match=match:eq}" +
1037 "]}" +
1038 "}";
1039 ct = new CosmasTree(query);
1040 map = ct.getRequestMap().get("query").toString();
1041 assertEquals(elem2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1042
1043 query="#ELEM(W ANA != 'N V')";
1044 String elem3 =
1045 "{@type=korap:span, key=w, attr=" +
1046 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingelb674cca2014-05-09 14:00:58 +00001047 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
1048 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001049 "]}" +
1050 "}";
1051 ct = new CosmasTree(query);
1052 map = ct.getRequestMap().get("query").toString();
1053 assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", ""));
1054
Joachim Bingelb674cca2014-05-09 14:00:58 +00001055 query="#ELEM(W ANA != 'N A V' Genre = Sport)";
Joachim Bingel402c6e12014-05-08 17:09:06 +00001056 String elem4 =
1057 "{@type=korap:span, key=w, attr=" +
1058 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1059 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingelb674cca2014-05-09 14:00:58 +00001060 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
1061 "{@type=korap:term, layer=pos, key=A, match=match:ne}," +
1062 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
1063 "]}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001064 "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" +
1065 "]}" +
1066 "}";
1067 ct = new CosmasTree(query);
1068 map = ct.getRequestMap().get("query").toString();
1069 assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb674cca2014-05-09 14:00:58 +00001070
1071 query="#ELEM(W ANA != 'N V' Genre != 'Sport Politik')";
1072 String elem5 =
1073 "{@type=korap:span, key=w, attr=" +
1074 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1075 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1076 "{@type=korap:term, layer=pos, key=N, match=match:ne}," +
1077 "{@type=korap:term, layer=pos, key=V, match=match:ne}" +
1078 "]}," +
1079 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1080 "{@type=korap:term, layer=Genre, key=Sport, match=match:ne}," +
1081 "{@type=korap:term, layer=Genre, key=Politik, match=match:ne}" +
1082 "]}" +
1083 "]}" +
1084 "}";
1085 ct = new CosmasTree(query);
1086 map = ct.getRequestMap().get("query").toString();
1087 assertEquals(elem5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001088 }
1089
1090 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001091 public void testOPALL() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +00001092 query="#ALL(gehen /w1:10 voran)";
Joachim Bingele98d0882014-01-21 12:58:54 +00001093 String all1 =
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001094 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +00001095 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +00001096 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
1097 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001098 "], inOrder=false, " +
1099 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001100 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001101 "]" +
1102 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001103 ct = new CosmasTree(query);
1104 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +00001105 assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001106 }
1107
Joachim Bingel36233b52014-02-13 10:48:24 +00001108 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001109 public void testOPNHIT() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +00001110 query="#NHIT(gehen /w1:10 voran)";
Joachim Bingelbd386362014-10-02 12:03:18 +00001111// String nhit1 =
1112// "{@type=korap:reference, operation=operation:focus, classRef=[1025], classRefOp=classRefOp:inversion, operands=[" +
1113// "{@type=korap:group, operation=operation:sequence, " +
1114// "operands=[" +
1115// "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
1116// "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1117// "]}," +
1118// "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
1119// "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1120// "]}" +
1121// "], inOrder=false, " +
1122// "distances=[" +
1123// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1124// "]" +
1125// "}" +
1126// "]}";
1127
Joachim Bingel89cceac2014-01-08 15:51:08 +00001128 String nhit1 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001129 "{@type=korap:reference, operation=operation:focus, classRef=1025, operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001130 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel36233b52014-02-13 10:48:24 +00001131 "operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001132 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1133 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
1134 "{@type=korap:group, operation=operation:repetition, operands=[" +
1135 "{@type=korap:token}" +
1136 "], boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}}" +
1137 "]}," +
1138 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001139 "], inOrder=false, " +
1140 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001141 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001142 "]" +
1143 "}" +
1144 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001145 ct = new CosmasTree(query);
1146 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +00001147 assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001148 }
1149
1150 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001151 public void testOPBED() throws QueryException {
Joachim Bingeleecc7652014-01-11 17:21:07 +00001152 query = "#BED(der , sa)";
1153 String bed1 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001154 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands= [" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001155 "{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +00001156 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001157 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +00001158 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
1159 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001160 "], frame=frame:startswith}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +00001161 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001162 ct = new CosmasTree(query);
1163 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +00001164 assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1165
1166 query = "#BED(der Mann , +pe)";
1167 String bed2 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001168 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands= [" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001169 "{@type=korap:group, operation=operation:position, frames=[frame:endswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001170 "{@type=korap:span, key=p}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001171 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001172 "{@type=korap:group, operation=operation:sequence, operands=[" +
1173 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1174 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1175 "]}" +
1176 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001177 "], frame=frame:endswith}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001178 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001179 ct = new CosmasTree(query);
1180 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +00001181 assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001182
1183 query = "#BED(der Mann , sa,-pa)";
1184 String bed3 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001185 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
1186 "{@type=korap:group, operation=operation:position, frames=[frame:matches], sharedClasses=[sharedClasses:equals], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001187 "{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001188 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001189 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001190 "{@type=korap:group, operation=operation:sequence, operands=[" +
1191 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1192 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1193 "]}" +
1194 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001195 "], frame=frame:startswith}," +
1196 "{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001197 "{@type=korap:span, key=p}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001198 "{@type=korap:group, operation=operation:class, class=1026, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001199 "{@type=korap:group, operation=operation:sequence, operands=[" +
1200 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1201 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1202 "]}" +
1203 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001204 "], frame=frame:startswith, exclude=true}" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001205 "], frame=frame:matches}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001206 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001207 ct = new CosmasTree(query);
1208 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +00001209 assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001210 }
1211
Joachim Bingel81812632014-02-18 08:55:22 +00001212 @Test
1213 public void testColonSeparatedConditions() throws QueryException {
1214
1215 query = "Der:sa";
1216 String col1 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001217 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001218 "{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001219 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001220 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001221 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
1222 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001223 "], frame=frame:startswith}" +
Joachim Bingel81812632014-02-18 08:55:22 +00001224 "]}";
1225 ct = new CosmasTree(query);
1226 map = ct.getRequestMap().get("query").toString();
1227 assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1228
1229 query = "Mann:sa,-pa,+te)";
1230 String col2 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001231 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
1232 "{@type=korap:group, operation=operation:position, frames=[frame:matches], sharedClasses=[sharedClasses:equals], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001233 "{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001234 "{@type=korap:span, key=s}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001235 "{@type=korap:group, operation=operation:class, class=1025, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001236 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1237 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001238 "], frame=frame:startswith}," +
1239 "{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001240 "{@type=korap:span, key=p}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001241 "{@type=korap:group, operation=operation:class, class=1026, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001242 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1243 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001244 "], frame=frame:startswith, exclude=true}," +
1245 "{@type=korap:group, operation=operation:position, frames=[frame:endswith], sharedClasses=[sharedClasses:includes], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001246 "{@type=korap:span, key=t}," +
Joachim Bingelbd386362014-10-02 12:03:18 +00001247 "{@type=korap:group, operation=operation:class, class=1027, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001248 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingelaaabb722014-09-24 14:29:10 +00001249 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001250 "], frame=frame:endswith}" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001251 "], frame=frame:matches}" +
Joachim Bingel81812632014-02-18 08:55:22 +00001252 "]}";
1253 ct = new CosmasTree(query);
1254 map = ct.getRequestMap().get("query").toString();
1255 assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1256 }
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00001257}
1258