blob: 107408601bc99ce3e8e471654eb566b8d24b1239 [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 Bingel9e6b9482014-10-15 12:02:49 +000017 String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/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 {
Joachim Bingelb4ab2502014-11-06 10:07:26 +000079 query="MORPH(pos=V)";
Joachim Bingelffd65e32014-01-22 14:22:57 +000080 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 Bingel896067a2014-11-07 19:02:27 +0000121
122 query="der #ELEM(S)";
123 expected =
124 "{@type=korap:group, operation=operation:sequence, operands=[" +
125 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
126 "{@type=korap:span, key=s}" +
127 "]}";
128 ct = new CosmasTree(query);
129 map = ct.getRequestMap().get("query").toString();
130 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
131
132 query="der MORPH(mate/p=ADJA)";
133 expected =
134 "{@type=korap:group, operation=operation:sequence, operands=[" +
135 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
136 "{@type=korap:token, wrap={@type=korap:term, key=ADJA, foundry=mate, layer=p, match=match:eq}}" +
137 "]}";
138 ct = new CosmasTree(query);
139 map = ct.getRequestMap().get("query").toString();
140 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000141 }
142
143 @Test
144 public void testOPOR() throws QueryException {
145 query="Sonne oder Mond";
146 String disj1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000147 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000148 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
149 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000150 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000151 ct = new CosmasTree(query);
152 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000153 assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", ""));
154
Joachim Bingeld5161a12014-01-08 11:15:49 +0000155 query="(Sonne scheint) oder Mond";
156 String disj2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000157 "{@type=korap:group, operation=operation:or, operands=[" +
158 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000159 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
160 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000161 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000162 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000163 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000164 ct = new CosmasTree(query);
165 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000166 assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", ""));
167
168 query="(Sonne scheint) oder (Mond scheint)";
169 String disj3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000170 "{@type=korap:group, operation=operation:or, operands=[" +
171 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000172 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
173 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000174 "]}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000175 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000176 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
177 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000178 "]}" +
179 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000180 ct = new CosmasTree(query);
181 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000182 assertEquals(disj3.replaceAll(" ", ""), map.replaceAll(" ", ""));
183
184 }
185
186 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000187 public void testOPORAND() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000188 query="(Sonne oder Mond) und scheint";
189 String orand1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000190 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000191 "{@type=cosmas:distance, key=t, min=0, max=0}" +
Joachim Bingelb7a59792014-02-14 13:52:29 +0000192 "], operands=[" +
193 "{@type=korap:group, operation=operation:or, operands=[" +
194 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
195 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
196 "]}," +
197 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000198 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000199 ct = new CosmasTree(query);
200 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000201 assertEquals(orand1.replaceAll(" ", ""), map.replaceAll(" ", ""));
202
203 query="scheint und (Sonne oder Mond)";
204 String orand2 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000205 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000206 "{@type=cosmas:distance, key=t, min=0, max=0}" +
Joachim Bingelb7a59792014-02-14 13:52:29 +0000207 "], operands=[" +
208 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," +
209 "{@type=korap:group, operation=operation:or, operands=[" +
210 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
211 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000212 "]}" +
213 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000214 ct = new CosmasTree(query);
215 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000216 assertEquals(orand2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel92f9c9c2014-06-25 15:01:17 +0000217
218 query="Regen und scheint und (Sonne oder Mond)";
219 String orand3 =
220 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000221 "{@type=cosmas:distance, key=t, min=0, max=0}" +
Joachim Bingel92f9c9c2014-06-25 15:01:17 +0000222 "], operands=[" +
223 "{@type=korap:token, wrap={@type=korap:term, key=Regen, layer=orth, match=match:eq}}," +
224 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000225 "{@type=cosmas:distance, key=t, min=0, max=0}" +
Joachim Bingel92f9c9c2014-06-25 15:01:17 +0000226 "], operands=[" +
227 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," +
228 "{@type=korap:group, operation=operation:or, operands=[" +
229 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
230 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
231 "]}" +
232 "]}" +
233 "]}";
234 ct = new CosmasTree(query);
235 map = ct.getRequestMap().get("query").toString();
236 assertEquals(orand3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000237 }
238
239 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000240 public void testOPPROX() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000241 query="Sonne /+w1:4 Mond";
242 String prox1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000243 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000244 "{@type=korap:group, operation=operation:sequence, " +
245 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000246 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000247 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
248 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000249 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000250 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
251 "]}" +
252 "], inOrder=true, " +
253 "distances=[" +
254 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
255 "]" +
256 "}" +
257 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000258 ct = new CosmasTree(query);
259 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000260 assertEquals(prox1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel89cceac2014-01-08 15:51:08 +0000261
262 query="Sonne /+w1:4,s0,p1:3 Mond";
263 String prox2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000264 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000265 "{@type=korap:group, operation=operation:sequence, " +
266 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000267 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000268 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
269 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000270 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000271 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
272 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000273 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000274 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000275 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}," +
Joachim Bingel832800e2014-10-17 14:46:39 +0000276 "{@type=cosmas:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}," +
277 "{@type=cosmas:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3}" +
Joachim Bingel89cceac2014-01-08 15:51:08 +0000278 "]" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000279 "}" +
280 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000281 ct = new CosmasTree(query);
282 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000283 assertEquals(prox2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000284
285 query="Sonne %+w1:4,s0,p1:3 Mond";
286 String prox3 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000287 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000288 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000289 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000290 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000291 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
292 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000293 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000294 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
295 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000296 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000297 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000298 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4, exclude=true}," +
Joachim Bingel832800e2014-10-17 14:46:39 +0000299 "{@type=cosmas:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0, exclude=true}," +
300 "{@type=cosmas:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3, exclude=true}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000301 "]" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000302 "}" +
303 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000304 ct = new CosmasTree(query);
305 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +0000306// assertEquals(prox3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000307
308 query="Sonne /+w4 Mond";
309 String prox4 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000310 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000311 "{@type=korap:group, operation=operation:sequence, " +
312 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000313 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000314 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
315 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000316 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000317 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
318 "]}" +
319 "], inOrder=true, " +
320 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000321 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000322 "]" +
323 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000324 "]}";
325// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000326// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000327// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000328// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
329// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000330// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000331// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
332// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000333// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000334// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000335// "{@type=korap:group, operation=operation:sequence, " +
336// "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000337// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000338// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
339// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000340// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000341// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
342// "]}" +
343// "], inOrder=true, " +
344// "distances=[" +
345// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
346// "]" +
347// "}" +
348// "]}" +
349// "]}";
350
351
Joachim Bingel2daf9862014-02-12 10:18:54 +0000352 ct = new CosmasTree(query);
353 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000354 assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000355
356 query="Sonne /-w4 Mond";
357 String prox5 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000358 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000359 "{@type=korap:group, operation=operation:sequence, " +
360 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000361 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000362 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
363 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000364 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000365 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
366 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000367 "], inOrder=true, " +
368 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000369 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000370 "]" +
371 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000372 "]}";
373// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000374// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000375// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000376// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
377// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000378// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000379// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
380// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000381// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000382// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000383// "{@type=korap:group, operation=operation:sequence, " +
384// "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000385// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000386// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
387// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000388// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000389// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
390// "]}" +
391// "], inOrder=true, " +
392// "distances=[" +
393// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
394// "]" +
395// "}" +
396// "]}" +
397// "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000398 ct = new CosmasTree(query);
399 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000400 assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000401
402 query="Sonne /w4 Mond";
403 String prox6 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000404 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000405 "{@type=korap:group, operation=operation:sequence, " +
406 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000407 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000408 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
409 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000410 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000411 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
412 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000413 "], inOrder=false, " +
414 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000415 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000416 "]" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000417 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000418 "]}";
419// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000420// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000421// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000422// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
423// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000424// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000425// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
426// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000427// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000428// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000429// "{@type=korap:group, operation=operation:sequence, " +
430// "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000431// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000432// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
433// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000434// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000435// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
436// "]}" +
437// "], inOrder=false, " +
438// "distances=[" +
439// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
440// "]" +
441// "}" +
442// "]}" +
443// "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000444 ct = new CosmasTree(query);
445 map = ct.getRequestMap().get("query").toString();
446 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000447 }
448
449 @Test
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000450 public void testOPPROXNested() throws QueryException {
Joachim Bingel09737972014-09-22 09:43:06 +0000451 query="Sonne /+w1:4 Mond /-w1:7 Sterne";
452 expected =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000453 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000454 "{@type=korap:group, operation=operation:sequence, " +
455 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000456 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000457 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
458 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000459 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
460 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000461 "{@type=korap:group, operation=operation:sequence, " +
462 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000463 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000464 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000465 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000466 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000467 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000468 "]}" +
469 "], inOrder=true, " +
470 "distances=[" +
471 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=7}, min=1, max=7}" +
472 "]" +
473 "}" +
474 "]}" +
475 "]}" +
476 "], inOrder=true, " +
477 "distances=[" +
478 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
479 "]" +
480 "}" +
481 "]}" +
482 "" ;
483 ct = new CosmasTree(query);
484 map = ct.getRequestMap().get("query").toString();
485 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
486
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000487 query="Sonne /-w4 Mond /+w2 Sterne";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000488
Joachim Bingelceb79062014-09-22 11:50:37 +0000489// String mondsterne =
490// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
491// "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" ;
Joachim Bingelfbc88792014-09-17 11:11:52 +0000492
493 String mondsterneClasses =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000494 "{@type=korap:group, operation=operation:class, class=128 , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000495 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
496 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000497 "{@type=korap:group, operation=operation:class, class=128 , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000498 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
499 "]}";
Joachim Bingelceb79062014-09-22 11:50:37 +0000500// String mondsterneSeq =
501// "{@type=korap:group, operation=operation:sequence, operands=[" +
502// mondsterne +
503// "], inOrder=true, distances=[" +
504// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
505// "]}" ;
Joachim Bingelfbc88792014-09-17 11:11:52 +0000506 String mondsterneClassesSeq =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000507 "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000508 "{@type=korap:group, operation=operation:sequence, operands=[" +
509 mondsterneClasses +
510 "], inOrder=true, distances=[" +
511 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
512 "]}" +
513 "]}" ;
Joachim Bingelceb79062014-09-22 11:50:37 +0000514// String mondsterneOv =
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000515// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelceb79062014-09-22 11:50:37 +0000516// mondsterne +
517// "]}";
Joachim Bingelfbc88792014-09-17 11:11:52 +0000518 String mondsterneClassesOv =
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000519 "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000520 mondsterneClasses +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000521 "], frame=frame:overlaps}";
Joachim Bingelceb79062014-09-22 11:50:37 +0000522// String mondsterneAll =
523// "{@type=korap:group, operation=operation:or, operands=[" +
524// mondsterneOv + "," + mondsterneClassesSeq +
525// "]}";
Joachim Bingelfbc88792014-09-17 11:11:52 +0000526 String mondsterneAllClasses =
527 "{@type=korap:group, operation=operation:or, operands=[" +
528 mondsterneClassesOv + "," + mondsterneClassesSeq +
529 "]}";
530
531
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000532 String prox6 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000533 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000534 "{@type=korap:group, operation=operation:sequence, " +
535 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000536 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
537 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000538 "{@type=korap:group, operation=operation:sequence, " +
539 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000540 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000541 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
542 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000543 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000544 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
545 "]}" +
546 "], inOrder=true, " +
547 "distances=[" +
548 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
549 "]" +
550 "}" +
551 "]}" +
552 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000553 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000554 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
555 "]}" +
556 "], inOrder=true, " +
557 "distances=[" +
558 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
559 "]" +
560 "}" +
561 "]}" +
562 "" ;
563// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000564// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000565// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000566// mondsterneAllClasses +
567// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000568// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000569// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
570// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000571// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000572// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000573// "{@type=korap:group, operation=operation:sequence, " +
574// "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000575// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000576// mondsterneAllClasses +
577// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000578// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000579// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
580// "]}" +
581// "], inOrder=true, " +
582// "distances=[" +
583// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
584// "]" +
585// "}" +
586// "]}" +
587// "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000588 ct = new CosmasTree(query);
589 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000590 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000591 }
592
593 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000594 public void testOPIN() throws QueryException {
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000595 query="wegen #IN <s>";
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000596 String opin1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000597 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000598 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000599 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000600 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000601 "{@type=korap:span, key=s}" +
602 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000603 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000604 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
605 "]}" +
606 "], frames=[], frame=frame:contains}" +
607 "]}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000608 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000609 ct = new CosmasTree(query);
610 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000611 assertEquals(opin1.replaceAll(" ", ""), map.replaceAll(" ", ""));
612
Joachim Bingel09737972014-09-22 09:43:06 +0000613 query="wegen #IN(L) <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000614 String opin2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000615 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000616 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000617 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000618 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000619 "{@type=korap:span, key=s}" +
620 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000621 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000622 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
623 "]}" +
624 "], frames=[frames:startswith], frame=frame:startswith}" +
625 "]}" +
626 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000627 ct = new CosmasTree(query);
628 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000629 assertEquals(opin2.replaceAll(" ", ""), map.replaceAll(" ", ""));
630
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000631
632 query="wegen #IN(F) <s>";
633 String opin3=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000634 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000635 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000636 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000637 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000638 "{@type=korap:span, key=s}" +
639 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000640 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000641 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
642 "]}" +
643 "], frames=[frames:matches], frame=frame:matches}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000644 "]}" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000645 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000646 ct = new CosmasTree(query);
647 map = ct.getRequestMap().get("query").toString();
648 assertEquals(opin3.replaceAll(" ", ""), map.replaceAll(" ", ""));
649
650 query="wegen #IN(FI) <s>";
651 String opin4=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000652 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000653 "{@type=korap:group, operation=operation:class, classRefCheck=[classRefCheck:unequals,classRefCheck:includes], classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000654 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000655 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000656 "{@type=korap:span, key=s}" +
657 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000658 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000659 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
660 "]}" +
661 "], frames=[frames:matches], frame=frame:matches-noident}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000662 "]}" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000663 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000664 ct = new CosmasTree(query);
665 map = ct.getRequestMap().get("query").toString();
666 assertEquals(opin4.replaceAll(" ", ""), map.replaceAll(" ", ""));
667
668 query="wegen #IN(FE) <s>";
669 String opin5=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000670 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000671 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000672 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000673 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000674 "{@type=korap:span, key=s}" +
675 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000676 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000677 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
678 "]}" +
679 "], frames=[frames:matches], frame=frame:matches}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000680 "]}" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000681 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000682 ct = new CosmasTree(query);
683 map = ct.getRequestMap().get("query").toString();
684 assertEquals(opin5.replaceAll(" ", ""), map.replaceAll(" ", ""));
685
Joachim Bingel87480d02014-01-17 14:07:46 +0000686 query="wegen #IN(%, L) <s>";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000687 String opin6 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000688 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000689 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000690 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000691 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000692 "{@type=korap:span, key=s}" +
693 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000694 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000695 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
696 "]}" +
697 "], frames=[frames:startswith], frame=frame:startswith, exclude=true}" +
698 "]}" +
699 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000700 ct = new CosmasTree(query);
701 map = ct.getRequestMap().get("query").toString();
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000702 assertEquals(opin6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000703
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000704 query="wegen #IN(FE,ALL,%,MIN) <s>";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000705 String opin7 =
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000706 "{@type=korap:reference, operation=operation:focus, reset=true, operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000707 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000708 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000709 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000710 "{@type=korap:span, key=s}" +
711 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000712 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000713 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000714 "]}" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000715
716 "], frames=[frames:matches], frame=frame:matches, exclude=true, grouping=false}" +
717 "]}" +
718 "]}" +
719 "";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000720 ct = new CosmasTree(query);
721 map = ct.getRequestMap().get("query").toString();
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000722 assertEquals(opin7.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000723 }
724
725 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000726 public void testOPOV() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000727 query="wegen #OV <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000728 String opov1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000729 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000730 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000731 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000732 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000733 "{@type=korap:span, key=s}" +
734 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000735 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000736 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
737 "]}" +
738 "], frames=[], frame=frame:overlaps}" +
739 "]}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000740 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000741 ct = new CosmasTree(query);
742 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000743 assertEquals(opov1.replaceAll(" ", ""), map.replaceAll(" ", ""));
744
745 query="wegen #OV(L) <s>";
746 String opov2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000747 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000748 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000749 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000750 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000751 "{@type=korap:span, key=s}" +
752 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000753 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000754 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
755 "]}" +
756 "], frames=[frames:startswith,frames:overlapsLeft], frame=frame:overlapsLeft}" +
757 "]}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000758 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000759 ct = new CosmasTree(query);
760 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000761 assertEquals(opov2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000762
763 query="wegen #OV(F) <s>";
764 String opov3=
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000765
Joachim Bingel6b491c22014-10-21 08:35:18 +0000766 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000767 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000768 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000769 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000770 "{@type=korap:span, key=s}" +
771 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000772 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000773 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
774 "]}" +
775 "], frames=[frames:matches], frame=frame:matches}" +
776 "]}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000777 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000778 ct = new CosmasTree(query);
779 map = ct.getRequestMap().get("query").toString();
780 assertEquals(opov3.replaceAll(" ", ""), map.replaceAll(" ", ""));
781
782 query="wegen #OV(FI) <s>";
783 String opov4=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000784 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000785 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:unequals, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000786 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000787 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000788 "{@type=korap:span, key=s}" +
789 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000790 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000791 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
792 "]}" +
793 "], frames=[frames:matches], frame=frame:matches-noident}" +
794 "]}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000795 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000796 ct = new CosmasTree(query);
797 map = ct.getRequestMap().get("query").toString();
798 assertEquals(opov4.replaceAll(" ", ""), map.replaceAll(" ", ""));
799
800 query="wegen #OV(FE) <s>";
801 String opov5=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000802 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelb4ab2502014-11-06 10:07:26 +0000803 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[129,130], classOut=131, class=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000804 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000805 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000806 "{@type=korap:span, key=s}" +
807 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000808 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000809 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
810 "]}" +
811 "], frames=[frames:matches], frame=frame:matches}" +
812 "]}" +
813 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000814 ct = new CosmasTree(query);
815 map = ct.getRequestMap().get("query").toString();
816 assertEquals(opov5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000817 }
818
819 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000820 public void testOPNOT() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000821 query="Sonne nicht Mond";
822 String opnot1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000823 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000824 "{@type=cosmas:distance, key=t, min=0, max=0, exclude=true}" +
Joachim Bingelb7a59792014-02-14 13:52:29 +0000825 "], operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000826 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
827 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000828 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000829 ct = new CosmasTree(query);
830 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000831 assertEquals(opnot1.replaceAll(" ", ""), map.replaceAll(" ", ""));
832 }
833
834 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000835 public void testBEG_END() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000836 // BEG and END operators
837 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/links.html
838 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/rechts.html
839 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/thematische-bsp/bsp-satzlaenge.html
Joachim Bingel87480d02014-01-17 14:07:46 +0000840 query="#BEG(der /w3:5 Mann)";
841 String beg1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000842 "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000843 "{@type=korap:group, operation=operation:sequence," +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000844 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000845 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
846 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000847 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000848 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000849 "]}" +
850 "]}";
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(beg1.replaceAll(" ", ""), map.replaceAll(" ", ""));
854
Joachim Bingel37a803f2014-07-28 14:21:44 +0000855
Joachim Bingelfbc88792014-09-17 11:11:52 +0000856// String dermannSeq = "{@type=korap:group, operation=operation:sequence," +
857// "operands = [" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000858// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000859// "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
860// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000861// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000862// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
863// "]}" +
864//
865// "], inOrder=false, distances=[" +
866// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
867// "]}";
868//
869// String begDermannSeq =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000870//// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000871// "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
872// dermannSeq +
873// "]}" +
874//// "]}" +
875// "";
876
Joachim Bingel37a803f2014-07-28 14:21:44 +0000877 String kommt = "{@type=korap:token, wrap={@type=korap:term, key=kommt, layer=orth, match=match:eq}}";
878
Joachim Bingel87480d02014-01-17 14:07:46 +0000879 query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group
880 String beg2 =
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000881// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000882// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000883// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000884// beg1 +
885// "]}" + "," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000886// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000887// kommt +
888// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000889// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000890// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000891// "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000892// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000893// beg1 +
894// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000895// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000896// kommt +
897// "]}" +
898// "], inOrder=true, distances=[" +
899// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
900// "]}" +
901// "]}" +
902// "]}";
903//
Joachim Bingel6b491c22014-10-21 08:35:18 +0000904 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000905 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000906 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000907 beg1 +
908 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000909 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000910 kommt +
911 "]}" +
912 "], inOrder=true, distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000913 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=10}, min=0, max=10}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000914 "]}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000915 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000916 ct = new CosmasTree(query);
917 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000918 assertEquals(beg2.replaceAll(" ", ""), map.replaceAll(" ", ""));
919
Joachim Bingel37a803f2014-07-28 14:21:44 +0000920 query="kommt /+w10 #BEG(der /w3:5 Mann)";
921 String beg3 =
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000922// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000923// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000924// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000925// kommt +
926//// "," +
927// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000928// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000929// beg1+
930// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000931// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000932// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000933// "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000934// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000935// kommt +
936// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000937// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000938// beg1+
939// "]}" +
940// "], inOrder=true, distances=[" +
941// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
942// "]}" +
943// "]}" +
944// "]}";
945
Joachim Bingel6b491c22014-10-21 08:35:18 +0000946 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000947 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000948 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000949 kommt +
950 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000951 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000952 beg1+
953 "]}" +
954 "], inOrder=true, distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000955 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=10}, min=0, max=10}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000956 "]}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000957 "]}";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000958 ct = new CosmasTree(query);
959 map = ct.getRequestMap().get("query").toString();
960 assertEquals(beg3.replaceAll(" ", ""), map.replaceAll(" ", ""));
961
Joachim Bingel87480d02014-01-17 14:07:46 +0000962 query="#END(der /w3:5 Mann)";
963 String end1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000964 "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000965 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000966 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000967 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
968 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000969 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000970 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000971 "]}" +
972 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000973 ct = new CosmasTree(query);
974 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000975 assertEquals(end1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000976 }
Joachim Bingeld5161a12014-01-08 11:15:49 +0000977
Joachim Bingel03dfd952014-07-30 08:08:53 +0000978 /*
979 * YET UNCLEAR HOW TO SERIALIZE SPAN DISTANCES. BEING DISCUSSED.
980 *
Joachim Bingel37a803f2014-07-28 14:21:44 +0000981 @Test
982 public void testSentenceDistance() throws QueryException {
Joachim Bingel03dfd952014-07-30 08:08:53 +0000983 query="Sonne /s0 Mond"; // contains(focus(1:contains({1:<s>},Sonne)),Mond)
Joachim Bingel37a803f2014-07-28 14:21:44 +0000984 expected =
Joachim Bingel93e6c702014-09-30 15:19:23 +0000985 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000986 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000987 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000988 "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000989 "{@type=korap:span, key=s}" +
990 "]}," +
991 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
992 "]}" +
993 "]}," +
994 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
995 "]}";
996 ct = new CosmasTree(query);
997 map = ct.getRequestMap().get("query").toString();
998 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
999
Joachim Bingel03dfd952014-07-30 08:08:53 +00001000 query="Sonne /s0,w5 Mond";
1001 expected =
Joachim Bingel93e6c702014-09-30 15:19:23 +00001002 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001003 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001004 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001005 "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001006 "{@type=korap:span, key=s}" +
1007 "]}," +
1008 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1009 "]}" +
1010 "]}," +
1011 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
1012 "]}";
1013// ct = new CosmasTree(query);
1014// map = ct.getRequestMap().get("query").toString();
1015// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1016
Joachim Bingel37a803f2014-07-28 14:21:44 +00001017 query="Sonne /s2:2 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond)
1018 expected =
1019 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001020 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001021 "{@type=korap:span, key=s}," +
1022 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1023 "]}," +
1024 "{@type=korap:span, key=s}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001025 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001026 "{@type=korap:span, key=s}," +
1027 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001028 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001029 "]}";
1030 ct = new CosmasTree(query);
1031 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +00001032// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel37a803f2014-07-28 14:21:44 +00001033
Joachim Bingel03dfd952014-07-30 08:08:53 +00001034 query="Sonne /s2:3 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond)
1035 expected =
1036 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001037 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001038 "{@type=korap:span, key=s}," +
1039 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1040 "]}," +
1041 "{@type=korap:group, operation=operation:repetition, operands=[" +
1042 "{@type=korap:span, key=s}" +
1043 "], boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001044 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001045 "{@type=korap:span, key=s}," +
1046 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
1047 "]}" +
1048 "]}";
1049 ct = new CosmasTree(query);
1050 map = ct.getRequestMap().get("query").toString();
1051// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1052
1053 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 +00001054 expected =
1055 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001056 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001057 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001058 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001059 "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001060 "{@type=korap:span, key=s}" +
1061 "]}," +
1062 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1063 "]}" +
1064 "]}," +
1065 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
1066 "]}," +
1067 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001068 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001069 "{@type=korap:span, key=s}," +
1070 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1071 "]}," +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001072 "{@type=korap:group, operation=operation:repetition, operands=[" +
1073 "{@type=korap:span, key=s}" +
1074 "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001075 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001076 "{@type=korap:span, key=s}," +
1077 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001078 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001079 "]}" +
1080 "]}";
1081 ct = new CosmasTree(query);
1082 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +00001083// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel37a803f2014-07-28 14:21:44 +00001084 }
Joachim Bingel03dfd952014-07-30 08:08:53 +00001085 */
Joachim Bingel37a803f2014-07-28 14:21:44 +00001086
Joachim Bingeld5161a12014-01-08 11:15:49 +00001087
1088 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001089 public void testELEM() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +00001090 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/elem.html
Joachim Bingeleecc7652014-01-11 17:21:07 +00001091 query="#ELEM(S)";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001092 String elem1 = "{@type=korap:span, key=s}";
1093 ct = new CosmasTree(query);
1094 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +00001095 assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel402c6e12014-05-08 17:09:06 +00001096
1097 query="#ELEM(W ANA=N)";
1098 String elem2 =
1099 "{@type=korap:span, key=w, attr=" +
1100 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001101 "{@type=korap:term, layer=p, key=N, match=match:eq}" +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001102 "]}" +
1103 "}";
1104 ct = new CosmasTree(query);
1105 map = ct.getRequestMap().get("query").toString();
1106 assertEquals(elem2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1107
1108 query="#ELEM(W ANA != 'N V')";
1109 String elem3 =
1110 "{@type=korap:span, key=w, attr=" +
1111 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001112 "{@type=korap:term, layer=p, key=N, match=match:ne}," +
1113 "{@type=korap:term, layer=p, key=V, match=match:ne}" +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001114 "]}" +
1115 "}";
1116 ct = new CosmasTree(query);
1117 map = ct.getRequestMap().get("query").toString();
1118 assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", ""));
1119
Joachim Bingelb674cca2014-05-09 14:00:58 +00001120 query="#ELEM(W ANA != 'N A V' Genre = Sport)";
Joachim Bingel402c6e12014-05-08 17:09:06 +00001121 String elem4 =
1122 "{@type=korap:span, key=w, attr=" +
1123 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1124 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001125 "{@type=korap:term, layer=p, key=N, match=match:ne}," +
1126 "{@type=korap:term, layer=p, key=A, match=match:ne}," +
1127 "{@type=korap:term, layer=p, key=V, match=match:ne}" +
Joachim Bingelb674cca2014-05-09 14:00:58 +00001128 "]}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001129 "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" +
1130 "]}" +
1131 "}";
1132 ct = new CosmasTree(query);
1133 map = ct.getRequestMap().get("query").toString();
1134 assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb674cca2014-05-09 14:00:58 +00001135
1136 query="#ELEM(W ANA != 'N V' Genre != 'Sport Politik')";
1137 String elem5 =
1138 "{@type=korap:span, key=w, attr=" +
1139 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1140 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001141 "{@type=korap:term, layer=p, key=N, match=match:ne}," +
1142 "{@type=korap:term, layer=p, key=V, match=match:ne}" +
Joachim Bingelb674cca2014-05-09 14:00:58 +00001143 "]}," +
1144 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1145 "{@type=korap:term, layer=Genre, key=Sport, match=match:ne}," +
1146 "{@type=korap:term, layer=Genre, key=Politik, match=match:ne}" +
1147 "]}" +
1148 "]}" +
1149 "}";
1150 ct = new CosmasTree(query);
1151 map = ct.getRequestMap().get("query").toString();
1152 assertEquals(elem5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001153 }
1154
1155 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001156 public void testOPALL() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +00001157 query="#ALL(gehen /w1:10 voran)";
Joachim Bingele98d0882014-01-21 12:58:54 +00001158 String all1 =
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001159 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +00001160 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +00001161 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
1162 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001163 "], inOrder=false, " +
1164 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001165 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001166 "]" +
1167 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001168 ct = new CosmasTree(query);
1169 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +00001170 assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001171
1172 query="#ALL(gehen /w1:10 (voran /w1:4 schnell))";
1173 String all2 =
1174 "{@type=korap:group, operation=operation:sequence, " +
1175 "operands=[" +
1176 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
1177 "{@type=korap:group, operation=operation:sequence, operands=[" +
1178 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}," +
1179 "{@type=korap:token, wrap={@type=korap:term, key=schnell, layer=orth, match=match:eq}}" +
1180 "], inOrder=false, " +
1181 "distances=[" +
1182 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
1183 "]" +
1184 "}" +
1185 "], inOrder=false, " +
1186 "distances=[" +
1187 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1188 "]" +
1189 "}";
1190 ct = new CosmasTree(query);
1191 map = ct.getRequestMap().get("query").toString();
1192 assertEquals(all2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001193 }
1194
Joachim Bingel36233b52014-02-13 10:48:24 +00001195 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001196 public void testOPNHIT() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +00001197 query="#NHIT(gehen /w1:10 voran)";
1198 String nhit1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001199 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
1200 "{@type=korap:group, operation=operation:class, classRefOp=classRefOp:inversion, classIn=[130,131], classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001201 "{@type=korap:group, operation=operation:sequence, " +
1202 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001203 "{@type=korap:group, operation=operation:class, class=130 , classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001204 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1205 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001206 "{@type=korap:group, operation=operation:class, class=131 , classOut=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001207 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1208 "]}" +
1209 "], inOrder=false, " +
1210 "distances=[" +
1211 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1212 "]" +
1213 "}" +
1214 "]}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001215 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001216 ct = new CosmasTree(query);
1217 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +00001218 assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel832800e2014-10-17 14:46:39 +00001219
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001220// query="#NHIT(gehen %w1:10 voran)";
1221// String nhit2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001222// "{@type=korap:reference, operation=operation:focus, classRef=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001223// "{@type=korap:group, operation=operation:sequence, " +
1224// "operands=[" +
1225// "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001226// "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001227// "{@type=korap:group, operation=operation:repetition, operands=[" +
1228// "{@type=korap:token}" +
1229// "], boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}}" +
1230// "]}," +
1231// "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1232// "], inOrder=false, " +
1233// "distances=[" +
1234// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1235// "]" +
1236// "}" +
1237// "]}";
1238// ct = new CosmasTree(query);
1239// map = ct.getRequestMap().get("query").toString();
1240// assertEquals(nhit2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1241
1242 query="#NHIT(gehen /+w1:10 voran /w1:10 Beispiel)";
1243 String nhit3 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001244 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
1245 "{@type=korap:group, operation=operation:class, classRefOp=classRefOp:inversion, classIn=[130,131], classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001246 "{@type=korap:group, operation=operation:sequence, " +
1247 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001248 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001249 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1250 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001251 "{@type=korap:group, operation=operation:class, class=131, classOut=131, operands=[" +
1252 "{@type=korap:reference, operation=operation:focus, classRef=[132], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001253 "{@type=korap:group, operation=operation:sequence, " +
1254 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001255 "{@type=korap:group, operation=operation:class, class=132, classOut=132, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001256 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1257 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001258 "{@type=korap:group, operation=operation:class, class=132, classOut=132, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001259 "{@type=korap:token, wrap={@type=korap:term, key=Beispiel, layer=orth, match=match:eq}}" +
1260 "]}" +
1261 "], inOrder=false, " +
1262 "distances=[" +
1263 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1264 "]" +
1265 "}" +
1266 "]}" +
1267 "]}" +
1268 "], inOrder=true, " +
1269 "distances=[" +
1270 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1271 "]" +
1272 "}" +
1273 "]}" +
1274 "]}";
1275 ct = new CosmasTree(query);
1276 map = ct.getRequestMap().get("query").toString();
1277 assertEquals(nhit3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001278 }
1279
1280 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001281 public void testOPBED() throws QueryException {
Joachim Bingeleecc7652014-01-11 17:21:07 +00001282 query = "#BED(der , sa)";
1283 String bed1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001284 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands= [" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001285 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +00001286 "{@type=korap:span, key=s}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001287 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +00001288 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
1289 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001290 "], frame=frame:startswith}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +00001291 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001292 ct = new CosmasTree(query);
1293 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +00001294 assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1295
1296 query = "#BED(der Mann , +pe)";
1297 String bed2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001298 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands= [" +
Joachim Bingel896067a2014-11-07 19:02:27 +00001299 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1300 "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
1301 "{@type=korap:span, key=p}" +
1302 "]}," +
1303 "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
1304 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
1305 "{@type=korap:group, operation=operation:sequence, operands=[" +
1306 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1307 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1308 "]}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001309 "]}" +
1310 "]}" +
Joachim Bingel896067a2014-11-07 19:02:27 +00001311 "], frame=frame:matches}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001312 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001313 ct = new CosmasTree(query);
1314 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +00001315 assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001316
1317 query = "#BED(der Mann , sa,-pa)";
1318 String bed3 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001319 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001320 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1321 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001322 "{@type=korap:span, key=s}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001323 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001324 "{@type=korap:group, operation=operation:sequence, operands=[" +
1325 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1326 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1327 "]}" +
1328 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001329 "], frame=frame:startswith}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001330 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001331 "{@type=korap:span, key=p}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001332 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001333 "{@type=korap:group, operation=operation:sequence, operands=[" +
1334 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1335 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1336 "]}" +
1337 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001338 "], frame=frame:startswith, exclude=true}" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001339 "], frame=frame:matches}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001340 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001341 ct = new CosmasTree(query);
1342 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +00001343 assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001344 }
1345
Joachim Bingel81812632014-02-18 08:55:22 +00001346 @Test
1347 public void testColonSeparatedConditions() throws QueryException {
1348
1349 query = "Der:sa";
1350 String col1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001351 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001352 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001353 "{@type=korap:span, key=s}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001354 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001355 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
1356 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001357 "], frame=frame:startswith}" +
Joachim Bingel81812632014-02-18 08:55:22 +00001358 "]}";
1359 ct = new CosmasTree(query);
1360 map = ct.getRequestMap().get("query").toString();
1361 assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1362
Joachim Bingelb4ab2502014-11-06 10:07:26 +00001363 query = "Mann:sa,-pa,+te";
Joachim Bingel81812632014-02-18 08:55:22 +00001364 String col2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001365 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001366 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1367 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001368 "{@type=korap:span, key=s}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001369 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001370 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1371 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001372 "], frame=frame:startswith}," +
Joachim Bingel896067a2014-11-07 19:02:27 +00001373 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
1374 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1375 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
1376 "{@type=korap:span, key=p}," +
1377 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
1378 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1379 "]}" +
1380 "], frame=frame:startswith, exclude=true}," +
1381 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1382 "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
1383 "{@type=korap:span, key=t}" +
1384 "]}," +
1385 "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
1386 "{@type=korap:group, operation=operation:class, class=131, classOut=131, operands=[" +
1387 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1388 "]}" +
1389 "]}" +
1390 "], frame=frame:matches}" +
1391 "], frame=frame:matches}" +
1392 "]}" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001393 "], frame=frame:matches}" +
Joachim Bingel81812632014-02-18 08:55:22 +00001394 "]}";
1395 ct = new CosmasTree(query);
1396 map = ct.getRequestMap().get("query").toString();
1397 assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1398 }
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00001399}
1400