blob: b664c517adf12d08e2c252a9da63bfc33534cc37 [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 Bingel6b491c22014-10-21 08:35:18 +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 Bingelb5f7bf02014-01-07 16:36:54 +0000121 }
122
123 @Test
124 public void testOPOR() throws QueryException {
125 query="Sonne oder Mond";
126 String disj1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000127 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000128 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
129 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000130 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000131 ct = new CosmasTree(query);
132 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000133 assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", ""));
134
Joachim Bingeld5161a12014-01-08 11:15:49 +0000135 query="(Sonne scheint) oder Mond";
136 String disj2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000137 "{@type=korap:group, operation=operation:or, operands=[" +
138 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000139 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
140 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000141 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000142 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000143 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000144 ct = new CosmasTree(query);
145 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000146 assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", ""));
147
148 query="(Sonne scheint) oder (Mond scheint)";
149 String disj3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000150 "{@type=korap:group, operation=operation:or, operands=[" +
151 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000152 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
153 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000154 "]}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000155 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000156 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
157 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000158 "]}" +
159 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000160 ct = new CosmasTree(query);
161 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000162 assertEquals(disj3.replaceAll(" ", ""), map.replaceAll(" ", ""));
163
164 }
165
166 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000167 public void testOPORAND() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000168 query="(Sonne oder Mond) und scheint";
169 String orand1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000170 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000171 "{@type=cosmas:distance, key=t, min=0, max=0}" +
Joachim Bingelb7a59792014-02-14 13:52:29 +0000172 "], operands=[" +
173 "{@type=korap:group, operation=operation:or, operands=[" +
174 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
175 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
176 "]}," +
177 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000178 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000179 ct = new CosmasTree(query);
180 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000181 assertEquals(orand1.replaceAll(" ", ""), map.replaceAll(" ", ""));
182
183 query="scheint und (Sonne oder Mond)";
184 String orand2 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000185 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000186 "{@type=cosmas:distance, key=t, min=0, max=0}" +
Joachim Bingelb7a59792014-02-14 13:52:29 +0000187 "], operands=[" +
188 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," +
189 "{@type=korap:group, operation=operation:or, operands=[" +
190 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
191 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000192 "]}" +
193 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000194 ct = new CosmasTree(query);
195 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000196 assertEquals(orand2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel92f9c9c2014-06-25 15:01:17 +0000197
198 query="Regen und scheint und (Sonne oder Mond)";
199 String orand3 =
200 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000201 "{@type=cosmas:distance, key=t, min=0, max=0}" +
Joachim Bingel92f9c9c2014-06-25 15:01:17 +0000202 "], operands=[" +
203 "{@type=korap:token, wrap={@type=korap:term, key=Regen, layer=orth, match=match:eq}}," +
204 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000205 "{@type=cosmas:distance, key=t, min=0, max=0}" +
Joachim Bingel92f9c9c2014-06-25 15:01:17 +0000206 "], operands=[" +
207 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," +
208 "{@type=korap:group, operation=operation:or, operands=[" +
209 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
210 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
211 "]}" +
212 "]}" +
213 "]}";
214 ct = new CosmasTree(query);
215 map = ct.getRequestMap().get("query").toString();
216 assertEquals(orand3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000217 }
218
219 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000220 public void testOPPROX() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000221 query="Sonne /+w1:4 Mond";
222 String prox1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000223 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000224 "{@type=korap:group, operation=operation:sequence, " +
225 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000226 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000227 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
228 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000229 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000230 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
231 "]}" +
232 "], inOrder=true, " +
233 "distances=[" +
234 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
235 "]" +
236 "}" +
237 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000238 ct = new CosmasTree(query);
239 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000240 assertEquals(prox1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel89cceac2014-01-08 15:51:08 +0000241
242 query="Sonne /+w1:4,s0,p1:3 Mond";
243 String prox2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000244 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000245 "{@type=korap:group, operation=operation:sequence, " +
246 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000247 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000248 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
249 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000250 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000251 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
252 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000253 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000254 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000255 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}," +
Joachim Bingel832800e2014-10-17 14:46:39 +0000256 "{@type=cosmas:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}," +
257 "{@type=cosmas:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3}" +
Joachim Bingel89cceac2014-01-08 15:51:08 +0000258 "]" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000259 "}" +
260 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000261 ct = new CosmasTree(query);
262 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000263 assertEquals(prox2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000264
265 query="Sonne %+w1:4,s0,p1:3 Mond";
266 String prox3 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000267 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000268 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000269 "operands=[" +
Joachim 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=Sonne, layer=orth, match=match:eq}}" +
272 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000273 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000274 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
275 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000276 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000277 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000278 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4, exclude=true}," +
Joachim Bingel832800e2014-10-17 14:46:39 +0000279 "{@type=cosmas:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0, exclude=true}," +
280 "{@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 +0000281 "]" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000282 "}" +
283 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000284 ct = new CosmasTree(query);
285 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +0000286// assertEquals(prox3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000287
288 query="Sonne /+w4 Mond";
289 String prox4 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000290 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000291 "{@type=korap:group, operation=operation:sequence, " +
292 "operands=[" +
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=Sonne, layer=orth, match=match:eq}}" +
295 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000296 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000297 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
298 "]}" +
299 "], inOrder=true, " +
300 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000301 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000302 "]" +
303 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000304 "]}";
305// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000306// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000307// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000308// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
309// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000310// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000311// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
312// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000313// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000314// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000315// "{@type=korap:group, operation=operation:sequence, " +
316// "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000317// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000318// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
319// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000320// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000321// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
322// "]}" +
323// "], inOrder=true, " +
324// "distances=[" +
325// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
326// "]" +
327// "}" +
328// "]}" +
329// "]}";
330
331
Joachim Bingel2daf9862014-02-12 10:18:54 +0000332 ct = new CosmasTree(query);
333 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000334 assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000335
336 query="Sonne /-w4 Mond";
337 String prox5 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000338 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000339 "{@type=korap:group, operation=operation:sequence, " +
340 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000341 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000342 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
343 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000344 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000345 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
346 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000347 "], inOrder=true, " +
348 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000349 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000350 "]" +
351 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000352 "]}";
353// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000354// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000355// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000356// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
357// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000358// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000359// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
360// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000361// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000362// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000363// "{@type=korap:group, operation=operation:sequence, " +
364// "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000365// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000366// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
367// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000368// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000369// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
370// "]}" +
371// "], inOrder=true, " +
372// "distances=[" +
373// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
374// "]" +
375// "}" +
376// "]}" +
377// "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000378 ct = new CosmasTree(query);
379 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000380 assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000381
382 query="Sonne /w4 Mond";
383 String prox6 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000384 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000385 "{@type=korap:group, operation=operation:sequence, " +
386 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000387 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000388 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
389 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000390 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000391 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
392 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000393 "], inOrder=false, " +
394 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000395 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000396 "]" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000397 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000398 "]}";
399// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000400// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000401// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000402// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
403// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000404// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000405// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
406// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000407// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000408// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000409// "{@type=korap:group, operation=operation:sequence, " +
410// "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000411// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000412// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
413// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000414// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000415// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
416// "]}" +
417// "], inOrder=false, " +
418// "distances=[" +
419// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
420// "]" +
421// "}" +
422// "]}" +
423// "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000424 ct = new CosmasTree(query);
425 map = ct.getRequestMap().get("query").toString();
426 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000427 }
428
429 @Test
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000430 public void testOPPROXNested() throws QueryException {
Joachim Bingel09737972014-09-22 09:43:06 +0000431 query="Sonne /+w1:4 Mond /-w1:7 Sterne";
432 expected =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000433 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000434 "{@type=korap:group, operation=operation:sequence, " +
435 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000436 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000437 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
438 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000439 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
440 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000441 "{@type=korap:group, operation=operation:sequence, " +
442 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000443 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000444 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000445 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000446 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000447 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000448 "]}" +
449 "], inOrder=true, " +
450 "distances=[" +
451 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=7}, min=1, max=7}" +
452 "]" +
453 "}" +
454 "]}" +
455 "]}" +
456 "], inOrder=true, " +
457 "distances=[" +
458 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
459 "]" +
460 "}" +
461 "]}" +
462 "" ;
463 ct = new CosmasTree(query);
464 map = ct.getRequestMap().get("query").toString();
465 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
466
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000467 query="Sonne /-w4 Mond /+w2 Sterne";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000468
Joachim Bingelceb79062014-09-22 11:50:37 +0000469// String mondsterne =
470// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
471// "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" ;
Joachim Bingelfbc88792014-09-17 11:11:52 +0000472
473 String mondsterneClasses =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000474 "{@type=korap:group, operation=operation:class, class=128 , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000475 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
476 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000477 "{@type=korap:group, operation=operation:class, class=128 , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000478 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
479 "]}";
Joachim Bingelceb79062014-09-22 11:50:37 +0000480// String mondsterneSeq =
481// "{@type=korap:group, operation=operation:sequence, operands=[" +
482// mondsterne +
483// "], inOrder=true, distances=[" +
484// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
485// "]}" ;
Joachim Bingelfbc88792014-09-17 11:11:52 +0000486 String mondsterneClassesSeq =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000487 "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000488 "{@type=korap:group, operation=operation:sequence, operands=[" +
489 mondsterneClasses +
490 "], inOrder=true, distances=[" +
491 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
492 "]}" +
493 "]}" ;
Joachim Bingelceb79062014-09-22 11:50:37 +0000494// String mondsterneOv =
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000495// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelceb79062014-09-22 11:50:37 +0000496// mondsterne +
497// "]}";
Joachim Bingelfbc88792014-09-17 11:11:52 +0000498 String mondsterneClassesOv =
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000499 "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000500 mondsterneClasses +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000501 "], frame=frame:overlaps}";
Joachim Bingelceb79062014-09-22 11:50:37 +0000502// String mondsterneAll =
503// "{@type=korap:group, operation=operation:or, operands=[" +
504// mondsterneOv + "," + mondsterneClassesSeq +
505// "]}";
Joachim Bingelfbc88792014-09-17 11:11:52 +0000506 String mondsterneAllClasses =
507 "{@type=korap:group, operation=operation:or, operands=[" +
508 mondsterneClassesOv + "," + mondsterneClassesSeq +
509 "]}";
510
511
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000512 String prox6 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000513 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000514 "{@type=korap:group, operation=operation:sequence, " +
515 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000516 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
517 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000518 "{@type=korap:group, operation=operation:sequence, " +
519 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000520 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000521 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
522 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000523 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000524 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
525 "]}" +
526 "], inOrder=true, " +
527 "distances=[" +
528 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
529 "]" +
530 "}" +
531 "]}" +
532 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000533 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000534 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
535 "]}" +
536 "], inOrder=true, " +
537 "distances=[" +
538 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
539 "]" +
540 "}" +
541 "]}" +
542 "" ;
543// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000544// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000545// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000546// mondsterneAllClasses +
547// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000548// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000549// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
550// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000551// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000552// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000553// "{@type=korap:group, operation=operation:sequence, " +
554// "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000555// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000556// mondsterneAllClasses +
557// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000558// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000559// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
560// "]}" +
561// "], inOrder=true, " +
562// "distances=[" +
563// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
564// "]" +
565// "}" +
566// "]}" +
567// "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000568 ct = new CosmasTree(query);
569 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000570 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000571 }
572
573 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000574 public void testOPIN() throws QueryException {
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000575 query="wegen #IN <s>";
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000576 String opin1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000577 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
578 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000579 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000580 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000581 "{@type=korap:span, key=s}" +
582 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000583 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000584 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
585 "]}" +
586 "], frames=[], frame=frame:contains}" +
587 "]}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000588 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000589 ct = new CosmasTree(query);
590 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000591 assertEquals(opin1.replaceAll(" ", ""), map.replaceAll(" ", ""));
592
Joachim Bingel09737972014-09-22 09:43:06 +0000593 query="wegen #IN(L) <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000594 String opin2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000595 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
596 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000597 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000598 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000599 "{@type=korap:span, key=s}" +
600 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000601 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000602 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
603 "]}" +
604 "], frames=[frames:startswith], frame=frame:startswith}" +
605 "]}" +
606 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000607 ct = new CosmasTree(query);
608 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000609 assertEquals(opin2.replaceAll(" ", ""), map.replaceAll(" ", ""));
610
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000611
612 query="wegen #IN(F) <s>";
613 String opin3=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000614 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
615 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000616 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000617 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000618 "{@type=korap:span, key=s}" +
619 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000620 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000621 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
622 "]}" +
623 "], frames=[frames:matches], frame=frame:matches}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000624 "]}" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000625 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000626 ct = new CosmasTree(query);
627 map = ct.getRequestMap().get("query").toString();
628 assertEquals(opin3.replaceAll(" ", ""), map.replaceAll(" ", ""));
629
630 query="wegen #IN(FI) <s>";
631 String opin4=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000632 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
633 "{@type=korap:group, operation=operation:class, classRefCheck=[classRefCheck:unequals,classRefCheck:includes], classIn=[129,130], classOut=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000634 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000635 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000636 "{@type=korap:span, key=s}" +
637 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000638 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000639 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
640 "]}" +
641 "], frames=[frames:matches], frame=frame:matches-noident}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000642 "]}" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000643 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000644 ct = new CosmasTree(query);
645 map = ct.getRequestMap().get("query").toString();
646 assertEquals(opin4.replaceAll(" ", ""), map.replaceAll(" ", ""));
647
648 query="wegen #IN(FE) <s>";
649 String opin5=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000650 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
651 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[129,130], classOut=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000652 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000653 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000654 "{@type=korap:span, key=s}" +
655 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000656 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000657 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
658 "]}" +
659 "], frames=[frames:matches], frame=frame:matches}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000660 "]}" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000661 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000662 ct = new CosmasTree(query);
663 map = ct.getRequestMap().get("query").toString();
664 assertEquals(opin5.replaceAll(" ", ""), map.replaceAll(" ", ""));
665
Joachim Bingel87480d02014-01-17 14:07:46 +0000666 query="wegen #IN(%, L) <s>";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000667 String opin6 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000668 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
669 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000670 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000671 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000672 "{@type=korap:span, key=s}" +
673 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000674 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000675 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
676 "]}" +
677 "], frames=[frames:startswith], frame=frame:startswith, exclude=true}" +
678 "]}" +
679 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000680 ct = new CosmasTree(query);
681 map = ct.getRequestMap().get("query").toString();
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000682 assertEquals(opin6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000683
684 query="wegen #IN('FE,ALL,%,MIN') <s>";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000685 String opin7 =
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000686 "{@type=korap:reference, operation=operation:focus, reset=true, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000687 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[129,130], classOut=131, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000688 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000689 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000690 "{@type=korap:span, key=s}" +
691 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000692 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000693 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000694 "]}" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000695
696 "], frames=[frames:matches], frame=frame:matches, exclude=true, grouping=false}" +
697 "]}" +
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(opin7.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +0000703 }
704
705 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000706 public void testOPOV() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000707 query="wegen #OV <s>";
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000708 String opov1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000709 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
710 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[129,130], classOut=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000711 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000712 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000713 "{@type=korap:span, key=s}" +
714 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000715 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000716 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
717 "]}" +
718 "], frames=[], frame=frame:overlaps}" +
719 "]}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000720 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000721 ct = new CosmasTree(query);
722 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000723 assertEquals(opov1.replaceAll(" ", ""), map.replaceAll(" ", ""));
724
725 query="wegen #OV(L) <s>";
726 String opov2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000727 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
728 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[129,130], classOut=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000729 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000730 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000731 "{@type=korap:span, key=s}" +
732 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000733 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000734 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
735 "]}" +
736 "], frames=[frames:startswith,frames:overlapsLeft], frame=frame:overlapsLeft}" +
737 "]}" +
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000738 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000739 ct = new CosmasTree(query);
740 map = ct.getRequestMap().get("query").toString();
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000741 assertEquals(opov2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000742
743 query="wegen #OV(F) <s>";
744 String opov3=
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000745
Joachim Bingel6b491c22014-10-21 08:35:18 +0000746 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
747 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[129,130], classOut=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000748 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000749 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000750 "{@type=korap:span, key=s}" +
751 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000752 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000753 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
754 "]}" +
755 "], frames=[frames:matches], frame=frame:matches}" +
756 "]}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000757 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000758 ct = new CosmasTree(query);
759 map = ct.getRequestMap().get("query").toString();
760 assertEquals(opov3.replaceAll(" ", ""), map.replaceAll(" ", ""));
761
762 query="wegen #OV(FI) <s>";
763 String opov4=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000764 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
765 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:unequals, classIn=[129,130], classOut=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000766 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000767 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000768 "{@type=korap:span, key=s}" +
769 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000770 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000771 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
772 "]}" +
773 "], frames=[frames:matches], frame=frame:matches-noident}" +
774 "]}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000775 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000776 ct = new CosmasTree(query);
777 map = ct.getRequestMap().get("query").toString();
778 assertEquals(opov4.replaceAll(" ", ""), map.replaceAll(" ", ""));
779
780 query="wegen #OV(FE) <s>";
781 String opov5=
Joachim Bingel6b491c22014-10-21 08:35:18 +0000782 "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" +
783 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[129,130], classOut=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000784 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000785 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000786 "{@type=korap:span, key=s}" +
787 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000788 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000789 "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
790 "]}" +
791 "], frames=[frames:matches], frame=frame:matches}" +
792 "]}" +
793 "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000794 ct = new CosmasTree(query);
795 map = ct.getRequestMap().get("query").toString();
796 assertEquals(opov5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000797 }
798
799 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000800 public void testOPNOT() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000801 query="Sonne nicht Mond";
802 String opnot1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000803 "{@type=korap:group, operation=operation:sequence, distances=[" +
Joachim Bingel832800e2014-10-17 14:46:39 +0000804 "{@type=cosmas:distance, key=t, min=0, max=0, exclude=true}" +
Joachim Bingelb7a59792014-02-14 13:52:29 +0000805 "], operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000806 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
807 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000808 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000809 ct = new CosmasTree(query);
810 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000811 assertEquals(opnot1.replaceAll(" ", ""), map.replaceAll(" ", ""));
812 }
813
814 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000815 public void testBEG_END() throws QueryException {
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000816 // BEG and END operators
817 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/links.html
818 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/rechts.html
819 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/thematische-bsp/bsp-satzlaenge.html
Joachim Bingel87480d02014-01-17 14:07:46 +0000820 query="#BEG(der /w3:5 Mann)";
821 String beg1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000822 "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000823 "{@type=korap:group, operation=operation:sequence," +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000824 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000825 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
826 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000827 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000828 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000829 "]}" +
830 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000831 ct = new CosmasTree(query);
832 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000833 assertEquals(beg1.replaceAll(" ", ""), map.replaceAll(" ", ""));
834
Joachim Bingel37a803f2014-07-28 14:21:44 +0000835
Joachim Bingelfbc88792014-09-17 11:11:52 +0000836// String dermannSeq = "{@type=korap:group, operation=operation:sequence," +
837// "operands = [" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000838// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000839// "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
840// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000841// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000842// "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
843// "]}" +
844//
845// "], inOrder=false, distances=[" +
846// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
847// "]}";
848//
849// String begDermannSeq =
Joachim Bingel6b491c22014-10-21 08:35:18 +0000850//// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000851// "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
852// dermannSeq +
853// "]}" +
854//// "]}" +
855// "";
856
Joachim Bingel37a803f2014-07-28 14:21:44 +0000857 String kommt = "{@type=korap:token, wrap={@type=korap:term, key=kommt, layer=orth, match=match:eq}}";
858
Joachim Bingel87480d02014-01-17 14:07:46 +0000859 query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group
860 String beg2 =
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000861// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000862// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000863// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000864// beg1 +
865// "]}" + "," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000866// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000867// kommt +
868// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000869// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000870// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000871// "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000872// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000873// beg1 +
874// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000875// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000876// kommt +
877// "]}" +
878// "], inOrder=true, distances=[" +
879// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
880// "]}" +
881// "]}" +
882// "]}";
883//
Joachim Bingel6b491c22014-10-21 08:35:18 +0000884 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000885 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000886 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000887 beg1 +
888 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000889 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000890 kommt +
891 "]}" +
892 "], inOrder=true, distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000893 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=10}, min=0, max=10}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000894 "]}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000895 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000896 ct = new CosmasTree(query);
897 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000898 assertEquals(beg2.replaceAll(" ", ""), map.replaceAll(" ", ""));
899
Joachim Bingel37a803f2014-07-28 14:21:44 +0000900 query="kommt /+w10 #BEG(der /w3:5 Mann)";
901 String beg3 =
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000902// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000903// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000904// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000905// kommt +
906//// "," +
907// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000908// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000909// beg1+
910// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000911// "], frame=frame:overlaps}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000912// "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000913// "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000914// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000915// kommt +
916// "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000917// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000918// beg1+
919// "]}" +
920// "], inOrder=true, distances=[" +
921// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
922// "]}" +
923// "]}" +
924// "]}";
925
Joachim Bingel6b491c22014-10-21 08:35:18 +0000926 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000927 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000928 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000929 kommt +
930 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000931 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000932 beg1+
933 "]}" +
934 "], inOrder=true, distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000935 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=10}, min=0, max=10}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000936 "]}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000937 "]}";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000938 ct = new CosmasTree(query);
939 map = ct.getRequestMap().get("query").toString();
940 assertEquals(beg3.replaceAll(" ", ""), map.replaceAll(" ", ""));
941
Joachim Bingel87480d02014-01-17 14:07:46 +0000942 query="#END(der /w3:5 Mann)";
943 String end1 =
Joachim Bingel0de1b412014-07-02 14:51:48 +0000944 "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000945 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000946 "operands = [" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000947 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
948 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000949 "], inOrder=false, distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000950 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000951 "]}" +
952 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000953 ct = new CosmasTree(query);
954 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000955 assertEquals(end1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000956 }
Joachim Bingeld5161a12014-01-08 11:15:49 +0000957
Joachim Bingel03dfd952014-07-30 08:08:53 +0000958 /*
959 * YET UNCLEAR HOW TO SERIALIZE SPAN DISTANCES. BEING DISCUSSED.
960 *
Joachim Bingel37a803f2014-07-28 14:21:44 +0000961 @Test
962 public void testSentenceDistance() throws QueryException {
Joachim Bingel03dfd952014-07-30 08:08:53 +0000963 query="Sonne /s0 Mond"; // contains(focus(1:contains({1:<s>},Sonne)),Mond)
Joachim Bingel37a803f2014-07-28 14:21:44 +0000964 expected =
Joachim Bingel93e6c702014-09-30 15:19:23 +0000965 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000966 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000967 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000968 "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000969 "{@type=korap:span, key=s}" +
970 "]}," +
971 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
972 "]}" +
973 "]}," +
974 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
975 "]}";
976 ct = new CosmasTree(query);
977 map = ct.getRequestMap().get("query").toString();
978 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
979
Joachim Bingel03dfd952014-07-30 08:08:53 +0000980 query="Sonne /s0,w5 Mond";
981 expected =
Joachim Bingel93e6c702014-09-30 15:19:23 +0000982 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000983 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000984 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +0000985 "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000986 "{@type=korap:span, key=s}" +
987 "]}," +
988 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
989 "]}" +
990 "]}," +
991 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
992 "]}";
993// ct = new CosmasTree(query);
994// map = ct.getRequestMap().get("query").toString();
995// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
996
Joachim Bingel37a803f2014-07-28 14:21:44 +0000997 query="Sonne /s2:2 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond)
998 expected =
999 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001000 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001001 "{@type=korap:span, key=s}," +
1002 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1003 "]}," +
1004 "{@type=korap:span, key=s}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001005 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001006 "{@type=korap:span, key=s}," +
1007 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001008 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001009 "]}";
1010 ct = new CosmasTree(query);
1011 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +00001012// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel37a803f2014-07-28 14:21:44 +00001013
Joachim Bingel03dfd952014-07-30 08:08:53 +00001014 query="Sonne /s2:3 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond)
1015 expected =
1016 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001017 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001018 "{@type=korap:span, key=s}," +
1019 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1020 "]}," +
1021 "{@type=korap:group, operation=operation:repetition, operands=[" +
1022 "{@type=korap:span, key=s}" +
1023 "], boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001024 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001025 "{@type=korap:span, key=s}," +
1026 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
1027 "]}" +
1028 "]}";
1029 ct = new CosmasTree(query);
1030 map = ct.getRequestMap().get("query").toString();
1031// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
1032
1033 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 +00001034 expected =
1035 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001036 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001037 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001038 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001039 "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001040 "{@type=korap:span, key=s}" +
1041 "]}," +
1042 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1043 "]}" +
1044 "]}," +
1045 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
1046 "]}," +
1047 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001048 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001049 "{@type=korap:span, key=s}," +
1050 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
1051 "]}," +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001052 "{@type=korap:group, operation=operation:repetition, operands=[" +
1053 "{@type=korap:span, key=s}" +
1054 "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}," +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001055 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001056 "{@type=korap:span, key=s}," +
1057 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001058 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +00001059 "]}" +
1060 "]}";
1061 ct = new CosmasTree(query);
1062 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +00001063// assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel37a803f2014-07-28 14:21:44 +00001064 }
Joachim Bingel03dfd952014-07-30 08:08:53 +00001065 */
Joachim Bingel37a803f2014-07-28 14:21:44 +00001066
Joachim Bingeld5161a12014-01-08 11:15:49 +00001067
1068 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001069 public void testELEM() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +00001070 // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/elem.html
Joachim Bingeleecc7652014-01-11 17:21:07 +00001071 query="#ELEM(S)";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001072 String elem1 = "{@type=korap:span, key=s}";
1073 ct = new CosmasTree(query);
1074 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +00001075 assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel402c6e12014-05-08 17:09:06 +00001076
1077 query="#ELEM(W ANA=N)";
1078 String elem2 =
1079 "{@type=korap:span, key=w, attr=" +
1080 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001081 "{@type=korap:term, layer=p, key=N, match=match:eq}" +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001082 "]}" +
1083 "}";
1084 ct = new CosmasTree(query);
1085 map = ct.getRequestMap().get("query").toString();
1086 assertEquals(elem2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1087
1088 query="#ELEM(W ANA != 'N V')";
1089 String elem3 =
1090 "{@type=korap:span, key=w, attr=" +
1091 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001092 "{@type=korap:term, layer=p, key=N, match=match:ne}," +
1093 "{@type=korap:term, layer=p, key=V, match=match:ne}" +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001094 "]}" +
1095 "}";
1096 ct = new CosmasTree(query);
1097 map = ct.getRequestMap().get("query").toString();
1098 assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", ""));
1099
Joachim Bingelb674cca2014-05-09 14:00:58 +00001100 query="#ELEM(W ANA != 'N A V' Genre = Sport)";
Joachim Bingel402c6e12014-05-08 17:09:06 +00001101 String elem4 =
1102 "{@type=korap:span, key=w, attr=" +
1103 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1104 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001105 "{@type=korap:term, layer=p, key=N, match=match:ne}," +
1106 "{@type=korap:term, layer=p, key=A, match=match:ne}," +
1107 "{@type=korap:term, layer=p, key=V, match=match:ne}" +
Joachim Bingelb674cca2014-05-09 14:00:58 +00001108 "]}," +
Joachim Bingel402c6e12014-05-08 17:09:06 +00001109 "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" +
1110 "]}" +
1111 "}";
1112 ct = new CosmasTree(query);
1113 map = ct.getRequestMap().get("query").toString();
1114 assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb674cca2014-05-09 14:00:58 +00001115
1116 query="#ELEM(W ANA != 'N V' Genre != 'Sport Politik')";
1117 String elem5 =
1118 "{@type=korap:span, key=w, attr=" +
1119 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1120 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001121 "{@type=korap:term, layer=p, key=N, match=match:ne}," +
1122 "{@type=korap:term, layer=p, key=V, match=match:ne}" +
Joachim Bingelb674cca2014-05-09 14:00:58 +00001123 "]}," +
1124 "{@type=korap:termGroup, relation=relation:and, operands=[" +
1125 "{@type=korap:term, layer=Genre, key=Sport, match=match:ne}," +
1126 "{@type=korap:term, layer=Genre, key=Politik, match=match:ne}" +
1127 "]}" +
1128 "]}" +
1129 "}";
1130 ct = new CosmasTree(query);
1131 map = ct.getRequestMap().get("query").toString();
1132 assertEquals(elem5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001133 }
1134
1135 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001136 public void testOPALL() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +00001137 query="#ALL(gehen /w1:10 voran)";
Joachim Bingele98d0882014-01-21 12:58:54 +00001138 String all1 =
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001139 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +00001140 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +00001141 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
1142 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +00001143 "], inOrder=false, " +
1144 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +00001145 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001146 "]" +
1147 "}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001148 ct = new CosmasTree(query);
1149 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +00001150 assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001151
1152 query="#ALL(gehen /w1:10 (voran /w1:4 schnell))";
1153 String all2 =
1154 "{@type=korap:group, operation=operation:sequence, " +
1155 "operands=[" +
1156 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," +
1157 "{@type=korap:group, operation=operation:sequence, operands=[" +
1158 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}," +
1159 "{@type=korap:token, wrap={@type=korap:term, key=schnell, layer=orth, match=match:eq}}" +
1160 "], inOrder=false, " +
1161 "distances=[" +
1162 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
1163 "]" +
1164 "}" +
1165 "], inOrder=false, " +
1166 "distances=[" +
1167 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1168 "]" +
1169 "}";
1170 ct = new CosmasTree(query);
1171 map = ct.getRequestMap().get("query").toString();
1172 assertEquals(all2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001173 }
1174
Joachim Bingel36233b52014-02-13 10:48:24 +00001175 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001176 public void testOPNHIT() throws QueryException {
Joachim Bingel89cceac2014-01-08 15:51:08 +00001177 query="#NHIT(gehen /w1:10 voran)";
1178 String nhit1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001179 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
1180 "{@type=korap:group, operation=operation:class, classRefOp=classRefOp:inversion, classIn=[130,131], classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001181 "{@type=korap:group, operation=operation:sequence, " +
1182 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001183 "{@type=korap:group, operation=operation:class, class=130 , classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001184 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1185 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001186 "{@type=korap:group, operation=operation:class, class=131 , classOut=131, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001187 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1188 "]}" +
1189 "], inOrder=false, " +
1190 "distances=[" +
1191 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1192 "]" +
1193 "}" +
1194 "]}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001195 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001196 ct = new CosmasTree(query);
1197 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +00001198 assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel832800e2014-10-17 14:46:39 +00001199
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001200// query="#NHIT(gehen %w1:10 voran)";
1201// String nhit2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001202// "{@type=korap:reference, operation=operation:focus, classRef=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001203// "{@type=korap:group, operation=operation:sequence, " +
1204// "operands=[" +
1205// "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001206// "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001207// "{@type=korap:group, operation=operation:repetition, operands=[" +
1208// "{@type=korap:token}" +
1209// "], boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}}" +
1210// "]}," +
1211// "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1212// "], inOrder=false, " +
1213// "distances=[" +
1214// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1215// "]" +
1216// "}" +
1217// "]}";
1218// ct = new CosmasTree(query);
1219// map = ct.getRequestMap().get("query").toString();
1220// assertEquals(nhit2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1221
1222 query="#NHIT(gehen /+w1:10 voran /w1:10 Beispiel)";
1223 String nhit3 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001224 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
1225 "{@type=korap:group, operation=operation:class, classRefOp=classRefOp:inversion, classIn=[130,131], classOut=129, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001226 "{@type=korap:group, operation=operation:sequence, " +
1227 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001228 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001229 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1230 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001231 "{@type=korap:group, operation=operation:class, class=131, classOut=131, operands=[" +
1232 "{@type=korap:reference, operation=operation:focus, classRef=[132], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001233 "{@type=korap:group, operation=operation:sequence, " +
1234 "operands=[" +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001235 "{@type=korap:group, operation=operation:class, class=132, classOut=132, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001236 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1237 "]}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001238 "{@type=korap:group, operation=operation:class, class=132, classOut=132, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001239 "{@type=korap:token, wrap={@type=korap:term, key=Beispiel, layer=orth, match=match:eq}}" +
1240 "]}" +
1241 "], inOrder=false, " +
1242 "distances=[" +
1243 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1244 "]" +
1245 "}" +
1246 "]}" +
1247 "]}" +
1248 "], inOrder=true, " +
1249 "distances=[" +
1250 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1251 "]" +
1252 "}" +
1253 "]}" +
1254 "]}";
1255 ct = new CosmasTree(query);
1256 map = ct.getRequestMap().get("query").toString();
1257 assertEquals(nhit3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001258 }
1259
1260 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001261 public void testOPBED() throws QueryException {
Joachim Bingeleecc7652014-01-11 17:21:07 +00001262 query = "#BED(der , sa)";
1263 String bed1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001264 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands= [" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001265 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +00001266 "{@type=korap:span, key=s}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001267 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +00001268 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
1269 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001270 "], frame=frame:startswith}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +00001271 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001272 ct = new CosmasTree(query);
1273 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +00001274 assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1275
1276 query = "#BED(der Mann , +pe)";
1277 String bed2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001278 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands= [" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001279 "{@type=korap:group, operation=operation:position, frames=[frames:endswith], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001280 "{@type=korap:span, key=p}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001281 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001282 "{@type=korap:group, operation=operation:sequence, operands=[" +
1283 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1284 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1285 "]}" +
1286 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001287 "], frame=frame:endswith}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001288 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001289 ct = new CosmasTree(query);
1290 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +00001291 assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001292
1293 query = "#BED(der Mann , sa,-pa)";
1294 String bed3 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001295 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001296 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1297 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001298 "{@type=korap:span, key=s}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001299 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001300 "{@type=korap:group, operation=operation:sequence, operands=[" +
1301 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1302 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1303 "]}" +
1304 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001305 "], frame=frame:startswith}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001306 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001307 "{@type=korap:span, key=p}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001308 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001309 "{@type=korap:group, operation=operation:sequence, operands=[" +
1310 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1311 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1312 "]}" +
1313 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001314 "], frame=frame:startswith, exclude=true}" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001315 "], frame=frame:matches}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001316 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001317 ct = new CosmasTree(query);
1318 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +00001319 assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001320 }
1321
Joachim Bingel81812632014-02-18 08:55:22 +00001322 @Test
1323 public void testColonSeparatedConditions() throws QueryException {
1324
1325 query = "Der:sa";
1326 String col1 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001327 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001328 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001329 "{@type=korap:span, key=s}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001330 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001331 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
1332 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001333 "], frame=frame:startswith}" +
Joachim Bingel81812632014-02-18 08:55:22 +00001334 "]}";
1335 ct = new CosmasTree(query);
1336 map = ct.getRequestMap().get("query").toString();
1337 assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1338
1339 query = "Mann:sa,-pa,+te)";
1340 String col2 =
Joachim Bingel6b491c22014-10-21 08:35:18 +00001341 "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001342 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1343 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001344 "{@type=korap:span, key=s}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001345 "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001346 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1347 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001348 "], frame=frame:startswith}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001349 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001350 "{@type=korap:span, key=p}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001351 "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001352 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1353 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001354 "], frame=frame:startswith, exclude=true}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001355 "{@type=korap:group, operation=operation:position, frames=[frames:endswith], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001356 "{@type=korap:span, key=t}," +
Joachim Bingel6b491c22014-10-21 08:35:18 +00001357 "{@type=korap:group, operation=operation:class, class=131, classOut=131, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001358 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingelaaabb722014-09-24 14:29:10 +00001359 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001360 "], frame=frame:endswith}" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001361 "], frame=frame:matches}" +
Joachim Bingel81812632014-02-18 08:55:22 +00001362 "]}";
1363 ct = new CosmasTree(query);
1364 map = ct.getRequestMap().get("query").toString();
1365 assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1366 }
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00001367}
1368