blob: e074ee845899f228324bdc89d694b6e4bab6c94b [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 {
79 query="#MORPH(V)";
80 String morph1 =
Joachim Bingel0207d5e2014-02-12 14:18:41 +000081 "{@type=korap:token, wrap={@type=korap:term, key=V, layer=pos, match=match:eq}}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000082 ct = new CosmasTree(query);
83 map = ct.getRequestMap().get("query").toString();
Joachim Bingelffd65e32014-01-22 14:22:57 +000084 assertEquals(morph1.replaceAll(" ", ""), map.replaceAll(" ", ""));
85 }
86
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000087 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +000088 public void testSequence() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000089 query="der Mann";
90 String seq1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +000091 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +000092 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
93 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000094 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +000095 ct = new CosmasTree(query);
96 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +000097 assertEquals(seq1.replaceAll(" ", ""), map.replaceAll(" ", ""));
98
Joachim Bingeld5161a12014-01-08 11:15:49 +000099 query="der Mann schläft";
100 String seq2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000101 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000102 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
103 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
104 "{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000105 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000106 ct = new CosmasTree(query);
107 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000108 assertEquals(seq2.replaceAll(" ", ""), map.replaceAll(" ", ""));
109
110 query="der Mann schläft lang";
111 String seq3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000112 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000113 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
114 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
115 "{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}," +
116 "{@type=korap:token, wrap={@type=korap:term, key=lang, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000117 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000118 ct = new CosmasTree(query);
119 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000120 assertEquals(seq3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000121 }
122
123 @Test
124 public void testOPOR() throws QueryException {
125 query="Sonne oder Mond";
126 String disj1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000127 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000128 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
129 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000130 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000131 ct = new CosmasTree(query);
132 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000133 assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", ""));
134
Joachim Bingeld5161a12014-01-08 11:15:49 +0000135 query="(Sonne scheint) oder Mond";
136 String disj2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000137 "{@type=korap:group, operation=operation:or, operands=[" +
138 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000139 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
140 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000141 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000142 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000143 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000144 ct = new CosmasTree(query);
145 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000146 assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", ""));
147
148 query="(Sonne scheint) oder (Mond scheint)";
149 String disj3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000150 "{@type=korap:group, operation=operation:or, operands=[" +
151 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000152 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
153 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000154 "]}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000155 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000156 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
157 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000158 "]}" +
159 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000160 ct = new CosmasTree(query);
161 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000162 assertEquals(disj3.replaceAll(" ", ""), map.replaceAll(" ", ""));
163
164 }
165
166 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000167 public void testOPORAND() throws QueryException {
Joachim Bingeld5161a12014-01-08 11:15:49 +0000168 query="(Sonne oder Mond) und scheint";
169 String orand1 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000170 "{@type=korap:group, operation=operation:sequence, distances=[" +
171 "{@type=korap:distance, key=t, min=0, max=0}" +
172 "], operands=[" +
173 "{@type=korap:group, operation=operation:or, operands=[" +
174 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
175 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
176 "]}," +
177 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000178 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000179 ct = new CosmasTree(query);
180 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000181 assertEquals(orand1.replaceAll(" ", ""), map.replaceAll(" ", ""));
182
183 query="scheint und (Sonne oder Mond)";
184 String orand2 =
Joachim Bingelb7a59792014-02-14 13:52:29 +0000185 "{@type=korap:group, operation=operation:sequence, distances=[" +
186 "{@type=korap:distance, key=t, min=0, max=0}" +
187 "], operands=[" +
188 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," +
189 "{@type=korap:group, operation=operation:or, operands=[" +
190 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
191 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingeld5161a12014-01-08 11:15:49 +0000192 "]}" +
193 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000194 ct = new CosmasTree(query);
195 map = ct.getRequestMap().get("query").toString();
Joachim Bingeld5161a12014-01-08 11:15:49 +0000196 assertEquals(orand2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel92f9c9c2014-06-25 15:01:17 +0000197
198 query="Regen und scheint und (Sonne oder Mond)";
199 String orand3 =
200 "{@type=korap:group, operation=operation:sequence, distances=[" +
201 "{@type=korap:distance, key=t, min=0, max=0}" +
202 "], operands=[" +
203 "{@type=korap:token, wrap={@type=korap:term, key=Regen, layer=orth, match=match:eq}}," +
204 "{@type=korap:group, operation=operation:sequence, distances=[" +
205 "{@type=korap:distance, key=t, min=0, max=0}" +
206 "], operands=[" +
207 "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," +
208 "{@type=korap:group, operation=operation:or, operands=[" +
209 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
210 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
211 "]}" +
212 "]}" +
213 "]}";
214 ct = new CosmasTree(query);
215 map = ct.getRequestMap().get("query").toString();
216 assertEquals(orand3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000217 }
218
219 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000220 public void testOPPROX() throws QueryException {
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000221 query="Sonne /+w1:4 Mond";
222 String prox1 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000223 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000224 "{@type=korap:group, operation=operation:sequence, " +
225 "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000226 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000227 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
228 "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000229 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000230 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
231 "]}" +
232 "], inOrder=true, " +
233 "distances=[" +
234 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
235 "]" +
236 "}" +
237 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000238 ct = new CosmasTree(query);
239 map = ct.getRequestMap().get("query").toString();
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000240 assertEquals(prox1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel89cceac2014-01-08 15:51:08 +0000241
242 query="Sonne /+w1:4,s0,p1:3 Mond";
243 String prox2 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000244 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000245 "{@type=korap:group, operation=operation:sequence, " +
246 "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000247 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000248 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
249 "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000250 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000251 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
252 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000253 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000254 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000255 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}," +
256 "{@type=korap:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}," +
257 "{@type=korap:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3}" +
Joachim Bingel89cceac2014-01-08 15:51:08 +0000258 "]" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000259 "}" +
260 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000261 ct = new CosmasTree(query);
262 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +0000263 assertEquals(prox2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000264
265 query="Sonne %+w1:4,s0,p1:3 Mond";
266 String prox3 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000267 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000268 "{@type=korap:group, operation=operation:sequence, " +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000269 "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000270 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000271 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
272 "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000273 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000274 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
275 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000276 "], inOrder=true, " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000277 "distances=[" +
Joachim Bingel03dfd952014-07-30 08:08:53 +0000278 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4, exclude=true}," +
279 "{@type=korap:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0, exclude=true}," +
280 "{@type=korap:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3, exclude=true}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000281 "]" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000282 "}" +
283 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000284 ct = new CosmasTree(query);
285 map = ct.getRequestMap().get("query").toString();
Joachim Bingel03dfd952014-07-30 08:08:53 +0000286// assertEquals(prox3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000287
288 query="Sonne /+w4 Mond";
289 String prox4 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000290 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000291 "{@type=korap:group, operation=operation:sequence, " +
292 "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000293 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000294 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
295 "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000296 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000297 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
298 "]}" +
299 "], inOrder=true, " +
300 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000301 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000302 "]" +
303 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000304 "]}";
305// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000306// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
307// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000308// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
309// "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000310// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000311// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
312// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000313// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000314// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000315// "{@type=korap:group, operation=operation:sequence, " +
316// "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000317// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000318// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
319// "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000320// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000321// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
322// "]}" +
323// "], inOrder=true, " +
324// "distances=[" +
325// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
326// "]" +
327// "}" +
328// "]}" +
329// "]}";
330
331
Joachim Bingel2daf9862014-02-12 10:18:54 +0000332 ct = new CosmasTree(query);
333 map = ct.getRequestMap().get("query").toString();
Joachim Bingel87480d02014-01-17 14:07:46 +0000334 assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000335
336 query="Sonne /-w4 Mond";
337 String prox5 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000338 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000339 "{@type=korap:group, operation=operation:sequence, " +
340 "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000341 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000342 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
343 "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000344 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000345 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
346 "]}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000347 "], inOrder=true, " +
348 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000349 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000350 "]" +
351 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000352 "]}";
353// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000354// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
355// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000356// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
357// "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000358// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000359// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
360// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000361// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000362// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000363// "{@type=korap:group, operation=operation:sequence, " +
364// "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000365// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000366// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
367// "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000368// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000369// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
370// "]}" +
371// "], inOrder=true, " +
372// "distances=[" +
373// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
374// "]" +
375// "}" +
376// "]}" +
377// "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000378 ct = new CosmasTree(query);
379 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000380 assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000381
382 query="Sonne /w4 Mond";
383 String prox6 =
Joachim Bingelbd386362014-10-02 12:03:18 +0000384 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000385 "{@type=korap:group, operation=operation:sequence, " +
386 "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000387 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000388 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
389 "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000390 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000391 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
392 "]}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000393 "], inOrder=false, " +
394 "distances=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000395 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000396 "]" +
Joachim Bingel37a803f2014-07-28 14:21:44 +0000397 "}" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000398 "]}";
399// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000400// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
401// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000402// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
403// "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000404// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000405// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
406// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000407// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000408// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000409// "{@type=korap:group, operation=operation:sequence, " +
410// "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000411// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000412// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
413// "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000414// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000415// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
416// "]}" +
417// "], inOrder=false, " +
418// "distances=[" +
419// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
420// "]" +
421// "}" +
422// "]}" +
423// "]}";
Joachim Bingel097c1eb2014-07-11 14:57:25 +0000424 ct = new CosmasTree(query);
425 map = ct.getRequestMap().get("query").toString();
426 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000427 }
428
429 @Test
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000430 public void testOPPROXNested() throws QueryException {
Joachim Bingel09737972014-09-22 09:43:06 +0000431 query="Sonne /+w1:4 Mond /-w1:7 Sterne";
432 expected =
Joachim Bingelbd386362014-10-02 12:03:18 +0000433 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000434 "{@type=korap:group, operation=operation:sequence, " +
435 "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000436 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000437 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
438 "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000439 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000440 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000441 "{@type=korap:group, operation=operation:sequence, " +
442 "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000443 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000444 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000445 "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000446 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000447 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
Joachim Bingel09737972014-09-22 09:43:06 +0000448 "]}" +
449 "], inOrder=true, " +
450 "distances=[" +
451 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=7}, min=1, max=7}" +
452 "]" +
453 "}" +
454 "]}" +
455 "]}" +
456 "], inOrder=true, " +
457 "distances=[" +
458 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
459 "]" +
460 "}" +
461 "]}" +
462 "" ;
463 ct = new CosmasTree(query);
464 map = ct.getRequestMap().get("query").toString();
465 assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
466
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000467 query="Sonne /-w4 Mond /+w2 Sterne";
Joachim Bingel37a803f2014-07-28 14:21:44 +0000468
Joachim Bingelceb79062014-09-22 11:50:37 +0000469// String mondsterne =
470// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
471// "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" ;
Joachim Bingelfbc88792014-09-17 11:11:52 +0000472
473 String mondsterneClasses =
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000474 "{@type=korap:group, operation=operation:class, class=1024 , classOut=1024, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000475 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
476 "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000477 "{@type=korap:group, operation=operation:class, class=1024 , classOut=1024, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000478 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
479 "]}";
Joachim Bingelceb79062014-09-22 11:50:37 +0000480// String mondsterneSeq =
481// "{@type=korap:group, operation=operation:sequence, operands=[" +
482// mondsterne +
483// "], inOrder=true, distances=[" +
484// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
485// "]}" ;
Joachim Bingelfbc88792014-09-17 11:11:52 +0000486 String mondsterneClassesSeq =
Joachim Bingelbd386362014-10-02 12:03:18 +0000487 "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000488 "{@type=korap:group, operation=operation:sequence, operands=[" +
489 mondsterneClasses +
490 "], inOrder=true, distances=[" +
491 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" +
492 "]}" +
493 "]}" ;
Joachim Bingelceb79062014-09-22 11:50:37 +0000494// String mondsterneOv =
Joachim 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 Bingelbd386362014-10-02 12:03:18 +0000513 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000514 "{@type=korap:group, operation=operation:sequence, " +
515 "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000516 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +0000517 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000518 "{@type=korap:group, operation=operation:sequence, " +
519 "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000520 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000521 "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
522 "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000523 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000524 "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
525 "]}" +
526 "], inOrder=true, " +
527 "distances=[" +
528 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
529 "]" +
530 "}" +
531 "]}" +
532 "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000533 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000534 "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
535 "]}" +
536 "], inOrder=true, " +
537 "distances=[" +
538 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
539 "]" +
540 "}" +
541 "]}" +
542 "" ;
543// "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000544// "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" +
545// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000546// mondsterneAllClasses +
547// "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000548// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000549// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
550// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000551// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000552// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000553// "{@type=korap:group, operation=operation:sequence, " +
554// "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000555// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000556// mondsterneAllClasses +
557// "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000558// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000559// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
560// "]}" +
561// "], inOrder=true, " +
562// "distances=[" +
563// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
564// "]" +
565// "}" +
566// "]}" +
567// "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +0000568 ct = new CosmasTree(query);
569 map = ct.getRequestMap().get("query").toString();
Joachim Bingel3f0850c2014-01-17 16:50:10 +0000570 assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb5f7bf02014-01-07 16:36:54 +0000571 }
572
573 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +0000574 public void testOPIN() throws QueryException {
Joachim Bingelcc1dc242014-01-15 09:32:38 +0000575 query="wegen #IN <s>";
Joachim Bingel3a9f7932014-01-07 17:11:31 +0000576 String opin1 =
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000577 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
578 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[1025,1026], classOut=1027, operands=[" +
579 "{@type=korap:group, operation=operation:position, operands=[" +
580 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
581 "{@type=korap:span, key=s}" +
582 "]}," +
583 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
584 "{@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 Bingel9e6b9482014-10-15 12:02:49 +0000595 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
596 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[1025,1026], classOut=1027, operands=[" +
597 "{@type=korap:group, operation=operation:position, operands=[" +
598 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
599 "{@type=korap:span, key=s}" +
600 "]}," +
601 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
602 "{@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 Bingel9e6b9482014-10-15 12:02:49 +0000614 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
615 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[1025,1026], classOut=1027, operands=[" +
616 "{@type=korap:group, operation=operation:position, operands=[" +
617 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
618 "{@type=korap:span, key=s}" +
619 "]}," +
620 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
621 "{@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 Bingel9e6b9482014-10-15 12:02:49 +0000632 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
633 "{@type=korap:group, operation=operation:class, classRefCheck=[classRefCheck:unequals,classRefCheck:includes], classIn=[1025,1026], classOut=1027, operands=[" +
634 "{@type=korap:group, operation=operation:position, operands=[" +
635 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
636 "{@type=korap:span, key=s}" +
637 "]}," +
638 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
639 "{@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 Bingel9e6b9482014-10-15 12:02:49 +0000650 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
651 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[1025,1026], classOut=1027, operands=[" +
652 "{@type=korap:group, operation=operation:position, operands=[" +
653 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
654 "{@type=korap:span, key=s}" +
655 "]}," +
656 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
657 "{@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 Bingel9e6b9482014-10-15 12:02:49 +0000668 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
669 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[1025,1026], classOut=1027, operands=[" +
670 "{@type=korap:group, operation=operation:position, operands=[" +
671 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
672 "{@type=korap:span, key=s}" +
673 "]}," +
674 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
675 "{@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=[" +
687 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[1025,1026], classOut=1027, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000688 "{@type=korap:group, operation=operation:position, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000689 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingel09737972014-09-22 09:43:06 +0000690 "{@type=korap:span, key=s}" +
691 "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000692 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, 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 Bingel9e6b9482014-10-15 12:02:49 +0000709 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
710 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[1025,1026], classOut=1027, operands=[" +
711 "{@type=korap:group, operation=operation:position, operands=[" +
712 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
713 "{@type=korap:span, key=s}" +
714 "]}," +
715 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
716 "{@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 Bingel9e6b9482014-10-15 12:02:49 +0000727 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
728 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[1025,1026], classOut=1027, operands=[" +
729 "{@type=korap:group, operation=operation:position, operands=[" +
730 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
731 "{@type=korap:span, key=s}" +
732 "]}," +
733 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
734 "{@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
746 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
747 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[1025,1026], classOut=1027, operands=[" +
748 "{@type=korap:group, operation=operation:position, operands=[" +
749 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
750 "{@type=korap:span, key=s}" +
751 "]}," +
752 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
753 "{@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 Bingel9e6b9482014-10-15 12:02:49 +0000764 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
765 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:unequals, classIn=[1025,1026], classOut=1027, operands=[" +
766 "{@type=korap:group, operation=operation:position, operands=[" +
767 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
768 "{@type=korap:span, key=s}" +
769 "]}," +
770 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
771 "{@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 Bingel9e6b9482014-10-15 12:02:49 +0000782 "{@type=korap:reference, operation=operation:focus, classRef=[1026], operands=[" +
783 "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[1025,1026], classOut=1027, operands=[" +
784 "{@type=korap:group, operation=operation:position, operands=[" +
785 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
786 "{@type=korap:span, key=s}" +
787 "]}," +
788 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
789 "{@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=[" +
804 "{@type=korap:distance, key=t, min=0, max=0, exclude=true}" +
805 "], 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 Bingel9e6b9482014-10-15 12:02:49 +0000838// "{@type=korap:group, operation=operation:class, class= , classOut=1024, 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 Bingel9e6b9482014-10-15 12:02:49 +0000841// "{@type=korap:group, operation=operation:class, class= , classOut=1024, 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 Bingel9e6b9482014-10-15 12:02:49 +0000850//// "{@type=korap:group, operation=operation:class, class= , classOut=1024, 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=[" +
863// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000864// beg1 +
865// "]}" + "," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000866// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000867// kommt +
868// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000869// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000870// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000871// "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000872// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000873// beg1 +
874// "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000875// "{@type=korap:group, operation=operation:class, class= , classOut=1024, 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 Bingelbd386362014-10-02 12:03:18 +0000884 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000885 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000886 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000887 beg1 +
888 "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000889 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, 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=[" +
904// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000905// kommt +
906//// "," +
907// "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000908// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000909// beg1+
910// "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000911// "], frame=frame:overlaps}," +
Joachim Bingelbd386362014-10-02 12:03:18 +0000912// "{@type=korap:reference, operation=operation:focus, classRef=[1024], operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000913// "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000914// "{@type=korap:group, operation=operation:class, class= , classOut=1024, operands=[" +
Joachim Bingelacb2ab32014-09-24 15:36:14 +0000915// kommt +
916// "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000917// "{@type=korap:group, operation=operation:class, class= , classOut=1024, 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 Bingelbd386362014-10-02 12:03:18 +0000926 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000927 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000928 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelfbc88792014-09-17 11:11:52 +0000929 kommt +
930 "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000931 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, 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 Bingelbd386362014-10-02 12:03:18 +0000966 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000967 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000968 "{@type=korap:group, operation=operation:class, class= , classOut=1025, 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 Bingelbd386362014-10-02 12:03:18 +0000983 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +0000984 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +0000985 "{@type=korap:group, operation=operation:class, class= , classOut=1025, 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 Bingelbd386362014-10-02 12:03:18 +00001037 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001038 "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001039 "{@type=korap:group, operation=operation:class, class= , classOut=1025, 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)";
Joachim Bingelbd386362014-10-02 12:03:18 +00001178// String nhit1 =
1179// "{@type=korap:reference, operation=operation:focus, classRef=[1025], classRefOp=classRefOp:inversion, operands=[" +
1180// "{@type=korap:group, operation=operation:sequence, " +
1181// "operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001182// "{@type=korap:group, operation=operation:class, class= , classOut=1025, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001183// "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1184// "]}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001185// "{@type=korap:group, operation=operation:class, class= , classOut=1025, operands=[" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001186// "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1187// "]}" +
1188// "], inOrder=false, " +
1189// "distances=[" +
1190// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1191// "]" +
1192// "}" +
1193// "]}";
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001194//
Joachim Bingel89cceac2014-01-08 15:51:08 +00001195 String nhit1 =
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001196 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
1197 "{@type=korap:group, operation=operation:class, classRefOp=classRefOp:inversion, classIn=[1026,1027], classOut=1025, operands=[" +
1198 "{@type=korap:group, operation=operation:sequence, " +
1199 "operands=[" +
1200 "{@type=korap:group, operation=operation:class, class=1026 , classOut=1026, operands=[" +
1201 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1202 "]}," +
1203 "{@type=korap:group, operation=operation:class, class=1027 , classOut=1027, operands=[" +
1204 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1205 "]}" +
1206 "], inOrder=false, " +
1207 "distances=[" +
1208 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1209 "]" +
1210 "}" +
1211 "]}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001212 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001213 ct = new CosmasTree(query);
1214 map = ct.getRequestMap().get("query").toString();
Joachim Bingel89cceac2014-01-08 15:51:08 +00001215 assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001216//
1217// query="#NHIT(gehen %w1:10 voran)";
1218// String nhit2 =
1219// "{@type=korap:reference, operation=operation:focus, classRef=1025, operands=[" +
1220// "{@type=korap:group, operation=operation:sequence, " +
1221// "operands=[" +
1222// "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1223// "{@type=korap:group, operation=operation:class, class= , classOut=1025, operands=[" +
1224// "{@type=korap:group, operation=operation:repetition, operands=[" +
1225// "{@type=korap:token}" +
1226// "], boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}}" +
1227// "]}," +
1228// "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1229// "], inOrder=false, " +
1230// "distances=[" +
1231// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1232// "]" +
1233// "}" +
1234// "]}";
1235// ct = new CosmasTree(query);
1236// map = ct.getRequestMap().get("query").toString();
1237// assertEquals(nhit2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1238
1239 query="#NHIT(gehen /+w1:10 voran /w1:10 Beispiel)";
1240 String nhit3 =
1241 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
1242 "{@type=korap:group, operation=operation:class, classRefOp=classRefOp:inversion, classIn=[1026,1027], classOut=1025, operands=[" +
1243 "{@type=korap:group, operation=operation:sequence, " +
1244 "operands=[" +
1245 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
1246 "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" +
1247 "]}," +
1248 "{@type=korap:group, operation=operation:class, class=1027, classOut=1027, operands=[" +
1249 "{@type=korap:reference, operation=operation:focus, classRef=[1028], operands=[" +
1250 "{@type=korap:group, operation=operation:sequence, " +
1251 "operands=[" +
1252 "{@type=korap:group, operation=operation:class, class=1028, classOut=1028, operands=[" +
1253 "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" +
1254 "]}," +
1255 "{@type=korap:group, operation=operation:class, class=1028, classOut=1028, operands=[" +
1256 "{@type=korap:token, wrap={@type=korap:term, key=Beispiel, layer=orth, match=match:eq}}" +
1257 "]}" +
1258 "], inOrder=false, " +
1259 "distances=[" +
1260 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1261 "]" +
1262 "}" +
1263 "]}" +
1264 "]}" +
1265 "], inOrder=true, " +
1266 "distances=[" +
1267 "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
1268 "]" +
1269 "}" +
1270 "]}" +
1271 "]}";
1272 ct = new CosmasTree(query);
1273 map = ct.getRequestMap().get("query").toString();
1274 assertEquals(nhit3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001275 }
1276
1277 @Test
Joachim Bingel87480d02014-01-17 14:07:46 +00001278 public void testOPBED() throws QueryException {
Joachim Bingeleecc7652014-01-11 17:21:07 +00001279 query = "#BED(der , sa)";
1280 String bed1 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001281 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands= [" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001282 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +00001283 "{@type=korap:span, key=s}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001284 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingelcd7b7252014-02-13 08:49:14 +00001285 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" +
1286 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001287 "], frame=frame:startswith}" +
Joachim Bingeleecc7652014-01-11 17:21:07 +00001288 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001289 ct = new CosmasTree(query);
1290 map = ct.getRequestMap().get("query").toString();
Joachim Bingeleecc7652014-01-11 17:21:07 +00001291 assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1292
1293 query = "#BED(der Mann , +pe)";
1294 String bed2 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001295 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands= [" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001296 "{@type=korap:group, operation=operation:position, frames=[frames:endswith], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001297 "{@type=korap:span, key=p}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001298 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001299 "{@type=korap:group, operation=operation:sequence, operands=[" +
1300 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1301 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1302 "]}" +
1303 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001304 "], frame=frame:endswith}" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001305 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001306 ct = new CosmasTree(query);
1307 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +00001308 assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001309
1310 query = "#BED(der Mann , sa,-pa)";
1311 String bed3 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001312 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001313 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1314 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001315 "{@type=korap:span, key=s}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001316 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001317 "{@type=korap:group, operation=operation:sequence, operands=[" +
1318 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1319 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1320 "]}" +
1321 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001322 "], frame=frame:startswith}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001323 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001324 "{@type=korap:span, key=p}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001325 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
Joachim Bingel36233b52014-02-13 10:48:24 +00001326 "{@type=korap:group, operation=operation:sequence, operands=[" +
1327 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
1328 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1329 "]}" +
1330 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001331 "], frame=frame:startswith, exclude=true}" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001332 "], frame=frame:matches}" +
Joachim Bingel3f0850c2014-01-17 16:50:10 +00001333 "]}";
Joachim Bingel2daf9862014-02-12 10:18:54 +00001334 ct = new CosmasTree(query);
1335 map = ct.getRequestMap().get("query").toString();
Joachim Bingel36233b52014-02-13 10:48:24 +00001336 assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingeld5161a12014-01-08 11:15:49 +00001337 }
1338
Joachim Bingel81812632014-02-18 08:55:22 +00001339 @Test
1340 public void testColonSeparatedConditions() throws QueryException {
1341
1342 query = "Der:sa";
1343 String col1 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001344 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001345 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001346 "{@type=korap:span, key=s}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001347 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001348 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
1349 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001350 "], frame=frame:startswith}" +
Joachim Bingel81812632014-02-18 08:55:22 +00001351 "]}";
1352 ct = new CosmasTree(query);
1353 map = ct.getRequestMap().get("query").toString();
1354 assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", ""));
1355
1356 query = "Mann:sa,-pa,+te)";
1357 String col2 =
Joachim Bingelbd386362014-10-02 12:03:18 +00001358 "{@type=korap:reference, operation=operation:focus, classRef=[1025], operands=[" +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001359 "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
1360 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001361 "{@type=korap:span, key=s}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001362 "{@type=korap:group, operation=operation:class, class=1025, classOut=1025, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001363 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1364 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001365 "], frame=frame:startswith}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001366 "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001367 "{@type=korap:span, key=p}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001368 "{@type=korap:group, operation=operation:class, class=1026, classOut=1026, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001369 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
1370 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001371 "], frame=frame:startswith, exclude=true}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001372 "{@type=korap:group, operation=operation:position, frames=[frames:endswith], operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001373 "{@type=korap:span, key=t}," +
Joachim Bingel9e6b9482014-10-15 12:02:49 +00001374 "{@type=korap:group, operation=operation:class, class=1027, classOut=1027, operands=[" +
Joachim Bingel81812632014-02-18 08:55:22 +00001375 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingelaaabb722014-09-24 14:29:10 +00001376 "]}" +
Joachim Bingel93e6c702014-09-30 15:19:23 +00001377 "], frame=frame:endswith}" +
Joachim Bingelbd386362014-10-02 12:03:18 +00001378 "], frame=frame:matches}" +
Joachim Bingel81812632014-02-18 08:55:22 +00001379 "]}";
1380 ct = new CosmasTree(query);
1381 map = ct.getRequestMap().get("query").toString();
1382 assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", ""));
1383 }
Joachim Bingelb5f7bf02014-01-07 16:36:54 +00001384}
1385