blob: 69d92938d4fa8ea1d380fd6456eb0275e784a675 [file] [log] [blame]
Joachim Bingel53333e62013-12-09 19:25:52 +00001import static org.junit.Assert.*;
2
3import org.junit.Test;
4
Joachim Bingel2daf9862014-02-12 10:18:54 +00005import de.ids_mannheim.korap.query.serialize.CosmasTree;
Joachim Bingel53333e62013-12-09 19:25:52 +00006import de.ids_mannheim.korap.query.serialize.PoliqarpPlusTree;
Joachim Bingel16da4e12013-12-17 09:48:12 +00007import de.ids_mannheim.korap.util.QueryException;
Joachim Bingel53333e62013-12-09 19:25:52 +00008
9public class PoliqarpPlusTreeTest {
10
11 PoliqarpPlusTree ppt;
12 String map;
13
14 private boolean equalsContent(String str, Object map) {
15 str = str.replaceAll(" ", "");
16 String mapStr = map.toString().replaceAll(" ", "");
17 return str.equals(mapStr);
18 }
19
Joachim Bingel16da4e12013-12-17 09:48:12 +000020 private boolean equalsQueryContent(String res, String query) throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +000021 res = res.replaceAll(" ", "");
22 ppt = new PoliqarpPlusTree(query);
23 String queryMap = ppt.getRequestMap().get("query").toString().replaceAll(" ", "");
24 return res.equals(queryMap);
25 }
26
Joachim Bingel81812632014-02-18 08:55:22 +000027 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +000028 public void testContext() throws QueryException {
Joachim Bingel81812632014-02-18 08:55:22 +000029 String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld";
Joachim Bingel2daf9862014-02-12 10:18:54 +000030 ppt = new PoliqarpPlusTree("Test");
31 assertEquals(contextString.replaceAll(" ", ""), ppt.getRequestMap().get("@context").toString().replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +000032 }
33
34 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +000035 public void testSingleTokens() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +000036 // [base=Mann]
Joachim Bingelee3b21d2014-02-12 12:34:59 +000037 String token1 = "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}";
Joachim Bingel53333e62013-12-09 19:25:52 +000038 assertTrue(equalsQueryContent(token1, "[base=Mann]"));
39
40 // [orth!=Frau]
Joachim Bingelee3b21d2014-02-12 12:34:59 +000041 String token2 = "{@type=korap:token, wrap={@type=korap:term, key=Frau, layer=orth, match=match:ne}}";
Joachim Bingel53333e62013-12-09 19:25:52 +000042 assertTrue(equalsQueryContent(token2, "[orth!=Frau]"));
43
44 // [!p=NN]
Joachim Bingelee3b21d2014-02-12 12:34:59 +000045 String token3 = "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, match=match:ne}}";
Joachim Bingel53333e62013-12-09 19:25:52 +000046 assertTrue(equalsQueryContent(token3, "[!p=NN]"));
47
48 // [!p!=NN]
Joachim Bingelee3b21d2014-02-12 12:34:59 +000049 String token4 = "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, match=match:eq}}";
Joachim Bingel53333e62013-12-09 19:25:52 +000050 assertTrue(equalsQueryContent(token4, "[!p!=NN]"));
51 }
52
53 @Test
Joachim Bingel41e112e2014-02-12 10:46:18 +000054 public void testRegex() throws QueryException {
55 String query = "[orth=\"M(a|ä)nn(er)?\"]";
Joachim Bingelbc537b62014-02-12 12:47:45 +000056 String re1 = "{@type=korap:token, wrap={@type=korap:term, type=type:regex, key=M(a|ä)nn(er)?, layer=orth, match=match:eq}}";
Joachim Bingel41e112e2014-02-12 10:46:18 +000057 ppt = new PoliqarpPlusTree(query);
58 map = ppt.getRequestMap().get("query").toString();
59 assertEquals(re1.replaceAll(" ", ""), map.replaceAll(" ", ""));
60 }
61
62 @Test
Joachim Bingel0207d5e2014-02-12 14:18:41 +000063 public void testCaseSensitivityFlag() throws QueryException {
64 String query="[orth=deutscher/i]";
65 String cs1 =
66 "{@type=korap:token, wrap={@type=korap:term, key=deutscher, layer=orth, match=match:eq, caseInsensitive=true}}";
67 ppt = new PoliqarpPlusTree(query);
68 map = ppt.getRequestMap().get("query").toString();
69 assertEquals(cs1.replaceAll(" ", ""), map.replaceAll(" ", ""));
70
71 query="[orth=deutscher/i][orth=Bundestag]";
72 String cs2 =
73 "{@type=korap:group, operation=operation:sequence, operands=[" +
74 "{@type=korap:token, wrap={@type=korap:term, key=deutscher, layer=orth, match=match:eq, caseInsensitive=true}}," +
75 "{@type=korap:token, wrap={@type=korap:term, key=Bundestag, layer=orth, match=match:eq}}" +
76 "]}";
77 ppt = new PoliqarpPlusTree(query);
78 map = ppt.getRequestMap().get("query").toString();
79 assertEquals(cs2.replaceAll(" ", ""), map.replaceAll(" ", ""));
80 }
81
82 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +000083 public void testElements() throws QueryException {
Joachim Bingelfc1fb352014-02-26 14:40:27 +000084 String query;
Joachim Bingel53333e62013-12-09 19:25:52 +000085 // <s>
Joachim Bingel2daf9862014-02-12 10:18:54 +000086 String elem1 = "{@type=korap:span, key=s}";
Joachim Bingel53333e62013-12-09 19:25:52 +000087 assertTrue(equalsQueryContent(elem1, "<s>"));
88
89 // <vp>
Joachim Bingel2daf9862014-02-12 10:18:54 +000090 String elem2 = "{@type=korap:span, key=vp}";
Joachim Bingel53333e62013-12-09 19:25:52 +000091 assertTrue(equalsQueryContent(elem2, "<vp>"));
Joachim Bingelfc1fb352014-02-26 14:40:27 +000092
93 // <cnx/c=vp>
94 query = "<c=vp>";
95 String span3 = "{@type=korap:span, layer=c, key=vp}";
96 ppt = new PoliqarpPlusTree(query);
97 map = ppt.getRequestMap().get("query").toString();
98 assertEquals(span3.replaceAll(" ", ""), map.replaceAll(" ", ""));
99
100 // <cnx/c=vp>
101 query = "<cnx/c=vp>";
102 String span4 = "{@type=korap:span, foundry=cnx, layer=c, key=vp}";
103 ppt = new PoliqarpPlusTree(query);
104 map = ppt.getRequestMap().get("query").toString();
105 assertEquals(span4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000106 }
Joachim Bingel87480d02014-01-17 14:07:46 +0000107
108 @Test
109 public void testEmptyTokens() throws QueryException {
110 // [base=der][][base=Mann]
111 String et1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000112 "{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
Joachim Bingelb8a44a12014-04-17 09:35:30 +0000113 "{@type=korap:distance, key=w, min=2, max=2}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000114 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000115 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000116 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
117 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000118 "]}";
119 ppt = new PoliqarpPlusTree("[base=der][][base=Mann]");
120 map = ppt.getRequestMap().get("query").toString();
121 assertEquals(et1.replaceAll(" ", ""), map.replaceAll(" ", ""));
122
123 // [base=der][][][base=Mann]
124 String et2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000125 "{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
Joachim Bingelb8a44a12014-04-17 09:35:30 +0000126 "{@type=korap:distance, key=w, min=3, max=3}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000127 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000128 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000129 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
130 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000131 "]}";
Joachim Bingelffd65e32014-01-22 14:22:57 +0000132 ppt = new PoliqarpPlusTree("[base=der][][][base=Mann]");
Joachim Bingel87480d02014-01-17 14:07:46 +0000133 map = ppt.getRequestMap().get("query").toString();
134 assertEquals(et2.replaceAll(" ", ""), map.replaceAll(" ", ""));
135
136 // [base=der][][]?[base=Mann]
137 String et3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000138 "{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
Joachim Bingelb8a44a12014-04-17 09:35:30 +0000139 "{@type=korap:distance, key=w, min=2, max=3}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000140 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000141 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000142 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
143 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000144 "]}";
145 ppt = new PoliqarpPlusTree("[base=der][][]?[base=Mann]");
146 map = ppt.getRequestMap().get("query").toString();
147 assertEquals(et3.replaceAll(" ", ""), map.replaceAll(" ", ""));
148
Joachim Bingel87480d02014-01-17 14:07:46 +0000149
150 // startswith(<s>, [][base=Mann]
Joachim Bingelffd65e32014-01-22 14:22:57 +0000151 String et4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000152 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
153 "{@type=korap:span, key=s}," +
154 "{@type=korap:group, operation=operation:sequence, offset-min=1, offset-max=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000155 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
Joachim Bingel87480d02014-01-17 14:07:46 +0000156 "]}" +
157 "]}";
Joachim Bingelffd65e32014-01-22 14:22:57 +0000158 ppt = new PoliqarpPlusTree("startswith(<s>, [][base=Mann])");
159 map = ppt.getRequestMap().get("query").toString();
160 assertEquals(et4.replaceAll(" ", ""), map.replaceAll(" ", ""));
161
Joachim Bingel11d5b152014-02-11 21:33:47 +0000162 // [base=der][]{2,5}[base=Mann][]?[][base=Frau] nested distances=
Joachim Bingelffd65e32014-01-22 14:22:57 +0000163 String et5 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000164 "{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
Joachim Bingelb8a44a12014-04-17 09:35:30 +0000165 "{@type=korap:distance, key=w, min=3, max=6}" +
Joachim Bingelffd65e32014-01-22 14:22:57 +0000166 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000167 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000168 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000169 "{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
Joachim Bingelb8a44a12014-04-17 09:35:30 +0000170 "{@type=korap:distance, key=w, min=2, max=3}" +
Joachim Bingelffd65e32014-01-22 14:22:57 +0000171 "], " +
Joachim Bingel11d5b152014-02-11 21:33:47 +0000172 "operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000173 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}," +
174 "{@type=korap:token, wrap={@type=korap:term, key=Frau, layer=lemma, match=match:eq}}" +
Joachim Bingelffd65e32014-01-22 14:22:57 +0000175 "]}" +
176 "]}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000177 ppt = new PoliqarpPlusTree("[base=der][]{2,5}[base=Mann][]?[][base=Frau]");
Joachim Bingel87480d02014-01-17 14:07:46 +0000178 map = ppt.getRequestMap().get("query").toString();
179 assertEquals(et5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel87480d02014-01-17 14:07:46 +0000180
181 }
Joachim Bingel53333e62013-12-09 19:25:52 +0000182
183 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000184 public void testCoordinatedFields() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000185 // [base=Mann&(cas=N|cas=A)]
186 String cof1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000187 "{@type=korap:token, wrap=" +
Joachim Bingel2980bda2014-04-04 12:09:46 +0000188 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000189 "{@type=korap:term, key=Mann, layer=lemma, match=match:eq}," +
Joachim Bingel2980bda2014-04-04 12:09:46 +0000190 "{@type=korap:termGroup, relation=relation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000191 "{@type=korap:term, key=N, layer=cas, match=match:eq}," +
192 "{@type=korap:term, key=A, layer=cas, match=match:eq}" +
193 "]}" +
194 "]}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000195 "}";
196 ppt = new PoliqarpPlusTree("[base=Mann&(cas=N|cas=A)]");
197 map = ppt.getRequestMap().get("query").toString();
198 assertEquals(cof1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Nils Diewald7d486c22013-12-13 16:32:18 +0000199
200
201 assertEquals(
202 new PoliqarpPlusTree(" [ base=Mann & ( cas=N | cas=A)] ").getRequestMap().get("query").toString(),
203 new PoliqarpPlusTree("[base=Mann &(cas=N|cas=A)]").getRequestMap().get("query").toString()
204 );
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000205
206 // [base=Mann&cas=N&gen=m]
207 String cof2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000208 "{@type=korap:token, wrap=" +
Joachim Bingel2980bda2014-04-04 12:09:46 +0000209 "{@type=korap:termGroup, relation=relation:and, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000210 "{@type=korap:term, key=Mann, layer=lemma, match=match:eq}," +
211 "{@type=korap:term, key=N, layer=cas, match=match:eq}," +
212 "{@type=korap:term, key=m, layer=gen, match=match:eq}" +
213 "]}" +
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000214 "}";
215 ppt = new PoliqarpPlusTree("[base=Mann&cas=N&gen=m]");
216 map = ppt.getRequestMap().get("query").toString();
217 assertEquals(cof2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000218 }
219
220 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000221 public void testOccurrence() throws QueryException {
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000222 // [base=foo]*
Joachim Bingel2daf9862014-02-12 10:18:54 +0000223 String occ1 = "{@type=korap:group, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000224 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000225 "], operation=operation:repetition, min=0, max=100}";
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000226 ppt = new PoliqarpPlusTree("[base=foo]*");
227 map = ppt.getRequestMap().get("query").toString();
228 assertEquals(occ1.replaceAll(" ", ""), map.replaceAll(" ", ""));
229
230 // [base=foo]*[base=bar]
231 String occ2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000232 "{@type=korap:group, operation=operation:sequence, operands=[" +
233 "{@type=korap:group, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000234 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000235 "], operation=operation:repetition, min=0, max=100 }," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000236 "{@type=korap:token, wrap={@type=korap:term, key=bar, layer=lemma, match=match:eq}}" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000237 "]}";
238 ppt = new PoliqarpPlusTree("[base=foo]*[base=bar]");
239 map = ppt.getRequestMap().get("query").toString();
240 assertEquals(occ2.replaceAll(" ", ""), map.replaceAll(" ", ""));
241
242 // [base=bar][base=foo]*
243 String occ3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000244 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000245 "{@type=korap:token, wrap={@type=korap:term, key=bar, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000246 "{@type=korap:group, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000247 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000248 "], operation=operation:repetition, min=0, max=100 }" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000249 "]}";
250 ppt = new PoliqarpPlusTree("[base=bar][base=foo]*");
251 map = ppt.getRequestMap().get("query").toString();
252 assertEquals(occ3.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelb4da7022013-12-09 23:17:24 +0000253
254 // ([base=bar][base=foo])*
255 String occ4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000256 "{@type=korap:group, operands=[" +
257 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000258 "{@type=korap:token, wrap={@type=korap:term, key=bar, layer=lemma, match=match:eq}}," +
259 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000260 "]}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000261 "], operation=operation:repetition, min=0, max=100 }" ;
Joachim Bingelb4da7022013-12-09 23:17:24 +0000262 ppt = new PoliqarpPlusTree("([base=bar][base=foo])*");
263 map = ppt.getRequestMap().get("query").toString();
264 assertEquals(occ4.replaceAll(" ", ""), map.replaceAll(" ", ""));
265
266 // <s>([base=bar][base=foo])*
267 String occ5 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000268 "{@type=korap:group, operation=operation:sequence, operands=[" +
269 "{@type=korap:span, key=s}," +
270 "{@type=korap:group, operands=[" +
271 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000272 "{@type=korap:token, wrap={@type=korap:term, key=bar, layer=lemma, match=match:eq}}," +
273 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000274 "]}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000275 "], operation=operation:repetition, min=0, max=100 }" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000276 "]}" ;
277 ppt = new PoliqarpPlusTree("<s>([base=bar][base=foo])*");
278 map = ppt.getRequestMap().get("query").toString();
279 assertEquals(occ5.replaceAll(" ", ""), map.replaceAll(" ", ""));
280
281 // <s><np>([base=bar][base=foo])*
Joachim Bingelb4da7022013-12-09 23:17:24 +0000282 String occ6 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000283 "{@type=korap:group, operation=operation:sequence, operands=[" +
284 "{@type=korap:span, key=s}," +
285 "{@type=korap:span, key=np}," +
286 "{@type=korap:group, operands=[" +
287 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000288 "{@type=korap:token, wrap={@type=korap:term, key=bar, layer=lemma, match=match:eq}}," +
289 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000290 "]}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000291 "], operation=operation:repetition, min=0, max=100 }" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000292 "]}" ;
293 ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*");
294 map = ppt.getRequestMap().get("query").toString();
295 assertEquals(occ6.replaceAll(" ", ""), map.replaceAll(" ", ""));
296
297 // <s><np>([base=bar][base=foo])*[p=NN]
298 // comment: embedded sequence shouldn't really be here, but does not really hurt, either. (?)
299 // really hard to get this behaviour out of the PQPlus grammar...
300 String occ7 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000301 "{@type=korap:group, operation=operation:sequence, operands=[" +
302 "{@type=korap:span, key=s}," +
303 "{@type=korap:span, key=np}," +
304 "{@type=korap:group, operands=[" +
305 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000306 "{@type=korap:token, wrap={@type=korap:term, key=bar, layer=lemma, match=match:eq}}," +
307 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000308 "]}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000309 "], operation=operation:repetition, min=0, max=100 }," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000310 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000311 "]}" ;
312 ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*[p=NN]");
313 map = ppt.getRequestMap().get("query").toString();
314 assertEquals(occ7.replaceAll(" ", ""), map.replaceAll(" ", ""));
315
316 // ([base=bar][base=foo])*[p=NN]
Joachim Bingelb4da7022013-12-09 23:17:24 +0000317 String occ8 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000318 "{@type=korap:group, operation=operation:sequence, operands=[" +
319 "{@type=korap:group, operands=[" +
320 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000321 "{@type=korap:token, wrap={@type=korap:term, key=bar, layer=lemma, match=match:eq}}," +
322 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000323 "]}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000324 "], operation=operation:repetition, min=0, max=100 }," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000325 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, match=match:eq}}" +
Joachim Bingelb4da7022013-12-09 23:17:24 +0000326 "]}" ;
327 ppt = new PoliqarpPlusTree("([base=bar][base=foo])*[p=NN]");
328 map = ppt.getRequestMap().get("query").toString();
329 assertEquals(occ8.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000330
331 // [base=foo]+
Joachim Bingel2daf9862014-02-12 10:18:54 +0000332 String occ9 = "{@type=korap:group, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000333 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000334 "], operation=operation:repetition, min=1, max=100}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000335 ppt = new PoliqarpPlusTree("[base=foo]+");
336 map = ppt.getRequestMap().get("query").toString();
337 assertEquals(occ9.replaceAll(" ", ""), map.replaceAll(" ", ""));
338
339 // [base=foo]?
Joachim Bingel2daf9862014-02-12 10:18:54 +0000340 String occ10 = "{@type=korap:group, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000341 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000342 "], operation=operation:repetition, min=0, max=1}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000343 ppt = new PoliqarpPlusTree("[base=foo]?");
344 map = ppt.getRequestMap().get("query").toString();
345 assertEquals(occ10.replaceAll(" ", ""), map.replaceAll(" ", ""));
346
347 // [base=foo]{2,5}
Joachim Bingel2daf9862014-02-12 10:18:54 +0000348 String occ11 = "{@type=korap:group, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000349 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000350 "], operation=operation:repetition, min=2, max=5}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000351 ppt = new PoliqarpPlusTree("[base=foo]{2,5}");
352 map = ppt.getRequestMap().get("query").toString();
353 assertEquals(occ11.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel2980bda2014-04-04 12:09:46 +0000354
355 // [base=foo]{2}
356 String occ12 = "{@type=korap:group, operands=[" +
357 "{@type=korap:token, wrap={@type=korap:term, key=foo, layer=lemma, match=match:eq}}" +
358 "], operation=operation:repetition, min=2, max=2}";
359 ppt = new PoliqarpPlusTree("[base=foo]{2}");
360 map = ppt.getRequestMap().get("query").toString();
361 assertEquals(occ12.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000362 }
363
364 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000365 public void testTokenSequence() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000366 // [base=Mann][orth=Frau]
Joachim Bingel2daf9862014-02-12 10:18:54 +0000367 String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000368 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}, " +
369 "{@type=korap:token, wrap={@type=korap:term, key=Frau, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000370 "]}";
371 assertTrue(equalsQueryContent(seq1, "[base=Mann][orth=Frau]"));
372
373 // [base=Mann][orth=Frau][p=NN]
Joachim Bingel2daf9862014-02-12 10:18:54 +0000374 String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000375 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}, " +
376 "{@type=korap:token, wrap={@type=korap:term, key=Frau, layer=orth, match=match:eq}}, " +
377 "{@type=korap:token, wrap={@type=korap:term, key=NN,layer=p, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000378 "]}";
379 assertTrue(equalsQueryContent(seq2, "[base=Mann][orth=Frau][p=NN]"));
380 }
381
382 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000383 public void testDisjSegments() throws QueryException {
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000384 // ([base=der]|[base=das])[base=Schild]
385 String disj1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000386 "{@type=korap:group, operation=operation:sequence, operands=[" +
387 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000388 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
389 "{@type=korap:token, wrap={@type=korap:term, key=das, layer=lemma, match=match:eq}}" +
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000390 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000391 "{@type=korap:token, wrap={@type=korap:term, key=Schild, layer=lemma, match=match:eq}}" +
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000392 "]}";
393 ppt = new PoliqarpPlusTree("([base=der]|[base=das])[base=Schild]");
394 map = ppt.getRequestMap().get("query").toString();
395 assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", ""));
396
397 // [base=Schild]([base=der]|[base=das])
398 String disj2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000399 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000400 "{@type=korap:token, wrap={@type=korap:term, key=Schild, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000401 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000402 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
403 "{@type=korap:token, wrap={@type=korap:term, key=das, layer=lemma, match=match:eq}}" +
Joachim Bingel94a1ccd2013-12-10 10:37:29 +0000404 "]}" +
405 "]}";
406 ppt = new PoliqarpPlusTree("[base=Schild]([base=der]|[base=das])");
407 map = ppt.getRequestMap().get("query").toString();
408 assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", ""));
409 }
410
411 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000412 public void testTokenElemSequence() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000413 // [base=Mann]<vp>
Joachim Bingel2daf9862014-02-12 10:18:54 +0000414 String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000415 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}, " +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000416 "{@type=korap:span, key=vp}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000417 "]}";
418 assertTrue(equalsQueryContent(seq1, "[base=Mann]<vp>"));
419
420 // <vp>[base=Mann]
Joachim Bingel2daf9862014-02-12 10:18:54 +0000421 String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" +
422 "{@type=korap:span, key=vp}, "+
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000423 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}} " +
Joachim Bingel53333e62013-12-09 19:25:52 +0000424 "]}";
425 assertTrue(equalsQueryContent(seq2, "<vp>[base=Mann]"));
426
427 // <vp>[base=Mann]<pp>
Joachim Bingel2daf9862014-02-12 10:18:54 +0000428 String seq3 = "{@type=korap:group, operation=operation:sequence, operands=[" +
429 "{@type=korap:span, key=vp}, "+
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000430 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}, " +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000431 "{@type=korap:span, key=pp} "+
Joachim Bingel53333e62013-12-09 19:25:52 +0000432 "]}";
433 assertTrue(equalsQueryContent(seq3, "<vp>[base=Mann]<pp>"));
434 }
435
436 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000437 public void testElemSequence() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000438 // <np><vp>
Joachim Bingel2daf9862014-02-12 10:18:54 +0000439 String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" +
440 "{@type=korap:span, key=np}," +
441 "{@type=korap:span, key=vp}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000442 "]}";
443 assertTrue(equalsQueryContent(seq1, "<np><vp>"));
444
445 // <np><vp><pp>
Joachim Bingel2daf9862014-02-12 10:18:54 +0000446 String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" +
447 "{@type=korap:span, key=np}," +
448 "{@type=korap:span, key=vp}," +
449 "{@type=korap:span, key=pp}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000450 "]}";
451 assertTrue(equalsQueryContent(seq2, "<np><vp><pp>"));
452 }
453
454 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000455 public void testClasses() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000456 // {[base=Mann]}
Joachim Bingel2daf9862014-02-12 10:18:54 +0000457 String cls1 = "{@type=korap:group, operation=operation:class, class=0, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000458 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000459 "]}";
Joachim Bingel8c640e42014-02-07 16:20:47 +0000460 ppt = new PoliqarpPlusTree("{[base=Mann]}");
461 map = ppt.getRequestMap().get("query").toString();
462 assertEquals(cls1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000463
464 // {[base=Mann][orth=Frau]}
Joachim Bingel2daf9862014-02-12 10:18:54 +0000465 String cls2 = "{@type=korap:group, operation=operation:class, class=0, operands=[" +
466 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000467 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}," +
468 "{@type=korap:token, wrap={@type=korap:term, key=Frau, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000469 "]}" +
470 "]}";
471 assertTrue(equalsQueryContent(cls2, "{[base=Mann][orth=Frau]}"));
472
473 // [p=NN]{[base=Mann][orth=Frau]}
Joachim Bingel2daf9862014-02-12 10:18:54 +0000474 String cls3 = "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000475 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000476 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
477 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000478 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}," +
479 "{@type=korap:token, wrap={@type=korap:term, key=Frau, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000480 "]}" +
481 "]}" +
482 "]}";
483 assertTrue(equalsQueryContent(cls3, "[p=NN]{[base=Mann][orth=Frau]}"));
484
485 // {[base=Mann][orth=Frau]}[p=NN]
Joachim Bingel2daf9862014-02-12 10:18:54 +0000486 String cls4 = "{@type=korap:group, operation=operation:sequence, operands=[" +
487 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
488 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000489 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}," +
490 "{@type=korap:token, wrap={@type=korap:term, key=Frau, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000491 "]}" +
492 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000493 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000494 "]}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000495 ppt = new PoliqarpPlusTree("{[base=Mann][orth=Frau]}[p=NN]");
496 map = ppt.getRequestMap().get("query").toString();
497 assertEquals(cls4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000498
499 // {2:{1:[tt/p=ADJA]}[mate/p=NN]}"
Joachim Bingel2daf9862014-02-12 10:18:54 +0000500 String cls5 = "{@type=korap:group, operation=operation:class, class=2, operands=[" +
501 "{@type=korap:group, operation=operation:sequence, operands=[" +
502 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000503 "{@type=korap:token, wrap={@type=korap:term, key=ADJA, layer=p, foundry=tt, match=match:eq}}" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000504 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000505 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, foundry=mate, match=match:eq}}" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000506 "]}" +
507 "]}";
508 ppt = new PoliqarpPlusTree("{2: {1:[tt/p=ADJA]}[mate/p=NN]}");
509 map = ppt.getRequestMap().get("query").toString();
510 assertEquals(cls5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000511 }
512
513 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000514 public void testPositions() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000515 // contains(<s>,<np>)
Joachim Bingel2daf9862014-02-12 10:18:54 +0000516 String pos1 = "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
517 "{@type=korap:span, key=s}," +
518 "{@type=korap:span, key=np}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000519 "]}";
520 assertTrue(equalsQueryContent(pos1, "contains(<s>,<np>)"));
521
522 // contains(<s>,[base=Mann])
Joachim Bingel2daf9862014-02-12 10:18:54 +0000523 String pos2 = "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
524 "{@type=korap:span, key=s}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000525 "{@type=korap:token, wrap= {@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000526 "]}";
527 assertTrue(equalsQueryContent(pos2, "contains(<s>,[base=Mann])"));
528
529 // contains(<s>,[orth=der][orth=Mann])
Joachim Bingel2daf9862014-02-12 10:18:54 +0000530 String pos3 = "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
531 "{@type=korap:span, key=s}," +
532 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000533 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
534 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000535 "]}" +
536 "]}";
537 ppt = new PoliqarpPlusTree("contains(<s>,[orth=der][orth=Mann])");
538 map = ppt.getRequestMap().get("query").toString();
539 assertEquals(pos3.replaceAll(" ", ""), map.replaceAll(" ", ""));
540
541 // [base=Auto]contains(<s>,[base=Mann])
542 String pos4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000543 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000544 "{@type=korap:token, wrap={@type=korap:term, key=Auto, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000545 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
546 "{@type=korap:span, key=s}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000547 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000548 "]}" +
549 "]}";
550 ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[base=Mann])");
551 map = ppt.getRequestMap().get("query").toString();
552 assertEquals(pos4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelef7059b2014-04-22 13:44:19 +0000553
554 // contains(<s>,[pos=N]*)
555 String pos5 =
556 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
557 "{@type=korap:span, key=s}," +
558 "{@type=korap:group, " +
559 "operands=[{@type=korap:token, wrap={@type=korap:term, key=N, layer=pos, match=match:eq}}" +
560 "], operation=operation:repetition, min=0, max=100" +
561 "}" +
562 "]}";
563 ppt = new PoliqarpPlusTree("contains(<s>,[pos=N]*)");
564 map = ppt.getRequestMap().get("query").toString();
565 assertEquals(pos5.replaceAll(" ", ""), map.replaceAll(" ", ""));
566
567 // [base=Auto]contains(<s>,[pos=N]*)
568 String pos6 =
569 "{@type=korap:group, operation=operation:sequence, operands=[" +
570 "{@type=korap:token, wrap={@type=korap:term, key=Auto, layer=lemma, match=match:eq}}," +
571 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
572 "{@type=korap:span, key=s}," +
573 "{@type=korap:group, " +
574 "operands=[{@type=korap:token, wrap={@type=korap:term, key=N, layer=pos, match=match:eq}}" +
575 "], operation=operation:repetition, min=0, max=100" +
576 "}" +
577 "]}" +
578 "]}";
579 ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[pos=N]*)");
580 map = ppt.getRequestMap().get("query").toString();
581 assertEquals(pos6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000582 }
583
584 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000585 public void testNestedPositions() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000586 // contains(<s>,startswith(<np>,[orth=Der]))
587 String npos1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000588 "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
589 "{@type=korap:span, key=s}," +
590 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
591 "{@type=korap:span, key=np}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000592 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000593 "]}" +
594 "]}";
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000595 ppt = new PoliqarpPlusTree("contains(<s>, startswith(<np>,[orth=Der]))");
Joachim Bingel53333e62013-12-09 19:25:52 +0000596 map = ppt.getRequestMap().get("query").toString();
597 assertEquals(npos1.replaceAll(" ", ""), map.replaceAll(" ", ""));
598 }
599
600 @Test
Joachim Bingel16da4e12013-12-17 09:48:12 +0000601 public void testShrinkSplit() throws QueryException {
Joachim Bingel53333e62013-12-09 19:25:52 +0000602 // shrink([orth=Der]{[orth=Mann]})
603 String shr1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000604 "{@type=korap:group, operation=operation:submatch, classRef=[0], operands=[" +
605 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000606 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000607 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000608 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000609 "]}" +
610 "]}" +
611 "]}";
612 ppt = new PoliqarpPlusTree("shrink([orth=Der]{[orth=Mann]})");
613 map = ppt.getRequestMap().get("query").toString();
614 assertEquals(shr1.replaceAll(" ", ""), map.replaceAll(" ", ""));
615
616 // shrink([orth=Der]{[orth=Mann][orth=geht]})
617 String shr2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000618 "{@type=korap:group, operation=operation:submatch, classRef=[0], operands=[" +
619 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000620 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000621 "{@type=korap:group, operation=operation:class, class=0, operands=[" +
622 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000623 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
624 "{@type=korap:token, wrap={@type=korap:term, key=geht, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000625 "]}" +
626 "]}" +
627 "]}" +
628 "]}";
629 ppt = new PoliqarpPlusTree("shrink([orth=Der]{[orth=Mann][orth=geht]})");
630 map = ppt.getRequestMap().get("query").toString();
631 assertEquals(shr2.replaceAll(" ", ""), map.replaceAll(" ", ""));
632
633 // shrink(1:[orth=Der]{1:[orth=Mann][orth=geht]})
634 String shr3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000635 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
636 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000637 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000638 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
639 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000640 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
641 "{@type=korap:token, wrap={@type=korap:term, key=geht, layer=orth, match=match:eq}}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000642 "]}" +
643 "]}" +
644 "]}" +
645 "]}";
646 ppt = new PoliqarpPlusTree("shrink(1:[orth=Der]{1:[orth=Mann][orth=geht]})");
647 map = ppt.getRequestMap().get("query").toString();
648 assertEquals(shr3.replaceAll(" ", ""), map.replaceAll(" ", ""));
649
650 // shrink(1:startswith(<s>,{1:<np>}))
651 String shr4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000652 "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
653 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
654 "{@type=korap:span, key=s}," +
655 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
656 "{@type=korap:span, key=np}" +
Joachim Bingel53333e62013-12-09 19:25:52 +0000657 "]}" +
658 "]}" +
659 "]}";
Joachim Bingeladefa622013-12-13 10:51:48 +0000660 ppt = new PoliqarpPlusTree("shrink(1:startswith(<s>,{1:<np>}))");
Joachim Bingel53333e62013-12-09 19:25:52 +0000661 map = ppt.getRequestMap().get("query").toString();
662 assertEquals(shr4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000663
664 // shrink(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}}))
665 String shr5 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000666 "{@type=korap:group, operation=operation:submatch, classRef=[3], operands=[" +
667 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
668 "{@type=korap:span, key=s}," +
669 "{@type=korap:group, operation=operation:class, class=3, operands=[" +
670 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000671 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000672 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
673 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000674 "{@type=korap:token, wrap={@type=korap:term, key=ADJA, layer=p, foundry=mate, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000675 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000676 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, foundry=tt, match=match:eq}}" +
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000677 "]}" +
678 "]}" +
679 "]}" +
680 "]}" +
681 "]}" +
682 "]}" +
683 "]}";
Joachim Bingeladefa622013-12-13 10:51:48 +0000684 ppt = new PoliqarpPlusTree("shrink(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
Joachim Bingelcd9ed332013-12-09 21:01:35 +0000685 map = ppt.getRequestMap().get("query").toString();
686 assertEquals(shr5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000687
688 // split(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}}))
689 String shr6 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000690 "{@type=korap:group, operation=operation:split, classRef=[3], operands=[" +
691 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
692 "{@type=korap:span, key=s}," +
693 "{@type=korap:group, operation=operation:class, class=3, operands=[" +
694 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000695 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000696 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
697 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000698 "{@type=korap:token, wrap={@type=korap:term, key=ADJA, layer=p, foundry=mate, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000699 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000700 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, foundry=tt, match=match:eq}}" +
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000701 "]}" +
702 "]}" +
703 "]}" +
704 "]}" +
705 "]}" +
706 "]}" +
707 "]}";
708 ppt = new PoliqarpPlusTree("split(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
709 map = ppt.getRequestMap().get("query").toString();
710 assertEquals(shr6.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel8c640e42014-02-07 16:20:47 +0000711
712 // split(2|3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}}))
713 String shr7 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000714 "{@type=korap:group, operation=operation:split, classRef=[2, 3], classRefOp=classRefOp:intersection, operands=[" +
715 "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
716 "{@type=korap:span, key=s}," +
717 "{@type=korap:group, operation=operation:class, class=3, operands=[" +
718 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000719 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000720 "{@type=korap:group, operation=operation:class, class=1, operands=[" +
721 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000722 "{@type=korap:token, wrap={@type=korap:term, key=ADJA, layer=p, foundry=mate, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000723 "{@type=korap:group, operation=operation:class, class=2, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000724 "{@type=korap:token, wrap={@type=korap:term, key=NN, layer=p, foundry=tt, match=match:eq}}" +
Joachim Bingel8c640e42014-02-07 16:20:47 +0000725 "]}" +
726 "]}" +
727 "]}" +
728 "]}" +
729 "]}" +
730 "]}" +
731 "]}";
732 ppt = new PoliqarpPlusTree("split(2|3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
733 map = ppt.getRequestMap().get("query").toString();
734 assertEquals(shr7.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000735 }
736
Joachim Bingel03882702013-12-31 19:53:05 +0000737
Joachim Bingel53333e62013-12-09 19:25:52 +0000738 @Test
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000739 public void testFoundries() throws QueryException {
740 // [tt/base=Mann]
Joachim Bingelac13a472014-02-14 21:18:52 +0000741 String layer1 = "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, foundry=tt, match=match:eq}}";
Joachim Bingelba9a0ab2014-01-29 10:12:25 +0000742 ppt = new PoliqarpPlusTree("[tt/base=Mann]");
743 map = ppt.getRequestMap().get("query").toString();
744 assertEquals(layer1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel53333e62013-12-09 19:25:52 +0000745
746 }
Joachim Bingel16da4e12013-12-17 09:48:12 +0000747
748 @Test
Joachim Bingel8c640e42014-02-07 16:20:47 +0000749 public void testAlign() throws QueryException {
Joachim Bingel16da4e12013-12-17 09:48:12 +0000750 // [orth=der]^[orth=Mann]
751 String align1 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000752 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000753 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000754 "{@type=korap:group, alignment=left, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000755 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel03882702013-12-31 19:53:05 +0000756 "]}" +
Joachim Bingel16da4e12013-12-17 09:48:12 +0000757 "]}";
758 ppt = new PoliqarpPlusTree("[orth=der]^[orth=Mann]");
759 map = ppt.getRequestMap().get("query").toString();
760 assertEquals(align1.replaceAll(" ", ""), map.replaceAll(" ", ""));
761
Joachim Bingel84e33df2014-01-31 14:02:46 +0000762 // [orth=der]^[orth=große][orth=Mann]
763 String query = "[orth=der]^[orth=große][orth=Mann]";
764 String align1b =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000765 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000766 "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000767 "{@type=korap:group, alignment=left, operands=[" +
768 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000769 "{@type=korap:token, wrap={@type=korap:term, key=große, layer=orth, match=match:eq}}," +
770 "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
Joachim Bingel84e33df2014-01-31 14:02:46 +0000771 "]}" +
772 "]}" +
773 "]}";
774 ppt = new PoliqarpPlusTree(query);
775 map = ppt.getRequestMap().get("query").toString();
776 assertEquals(align1b.replaceAll(" ", ""), map.replaceAll(" ", ""));
777
Joachim Bingel16da4e12013-12-17 09:48:12 +0000778 // "([base=a]^[base=b])|[base=c]",
779 String align2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000780 "{@type=korap:group, operation=operation:or, operands=[" +
781 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000782 "{@type=korap:token, wrap={@type=korap:term, key=a, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000783 "{@type=korap:group, alignment=left, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000784 "{@type=korap:token, wrap={@type=korap:term, key=b, layer=lemma, match=match:eq}}" +
Joachim Bingel03882702013-12-31 19:53:05 +0000785 "]}" +
Joachim Bingel16da4e12013-12-17 09:48:12 +0000786 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000787 "{@type=korap:token, wrap={@type=korap:term, key=c, layer=lemma, match=match:eq}}" +
Joachim Bingel16da4e12013-12-17 09:48:12 +0000788 "]}";
789 ppt = new PoliqarpPlusTree("([base=a]^[base=b])|[base=c]");
790 map = ppt.getRequestMap().get("query").toString();
791 assertEquals(align2.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingela67e6a32014-01-02 18:35:24 +0000792
793 // "([base=a]^[base=b][base=c])|[base=d]",
794 String align3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000795 "{@type=korap:group, operation=operation:or, operands=[" +
796 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000797 "{@type=korap:token, wrap={@type=korap:term, key=a, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000798 "{@type=korap:group, alignment=left, operands=[" +
799 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000800 "{@type=korap:token, wrap={@type=korap:term, key=b, layer=lemma, match=match:eq}}," +
801 "{@type=korap:token, wrap={@type=korap:term, key=c, layer=lemma, match=match:eq}}" +
Joachim Bingel84e33df2014-01-31 14:02:46 +0000802 "]}" +
803 "]}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +0000804 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000805 "{@type=korap:token, wrap={@type=korap:term, key=d, layer=lemma, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +0000806 "]}";
807 ppt = new PoliqarpPlusTree("([base=a]^[base=b][base=c])|[base=d]");
808 map = ppt.getRequestMap().get("query").toString();
809 assertEquals(align3.replaceAll(" ", ""), map.replaceAll(" ", ""));
810
811 // "([base=a]^[base=b]^[base=c])|[base=d]",
812 String align4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000813 "{@type=korap:group, operation=operation:or, operands=[" +
814 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000815 "{@type=korap:token, wrap={@type=korap:term, key=a, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000816 "{@type=korap:group, alignment=left, operands=[" +
817 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000818 "{@type=korap:token, wrap={@type=korap:term, key=b, layer=lemma, match=match:eq}}," +
Joachim Bingel2daf9862014-02-12 10:18:54 +0000819 "{@type=korap:group, alignment=left, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000820 "{@type=korap:token, wrap={@type=korap:term, key=c, layer=lemma, match=match:eq}}" +
Joachim Bingel84e33df2014-01-31 14:02:46 +0000821 "]}" +
822 "]}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +0000823 "]}" +
824 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000825 "{@type=korap:token, wrap={@type=korap:term, key=d, layer=lemma, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +0000826 "]}";
827 ppt = new PoliqarpPlusTree("([base=a]^[base=b]^[base=c])|[base=d]");
828 map = ppt.getRequestMap().get("query").toString();
829 assertEquals(align4.replaceAll(" ", ""), map.replaceAll(" ", ""));
830
831
Joachim Bingel16da4e12013-12-17 09:48:12 +0000832 }
833
834 @Test
Joachim Bingel8c640e42014-02-07 16:20:47 +0000835 public void testSimpleQueries() throws QueryException {
Joachim Bingela67e6a32014-01-02 18:35:24 +0000836 // Baum
837 String simple1 =
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000838 "{@type=korap:token, wrap={@type=korap:term, key=Baum, layer=orth, match=match:eq}}";
Joachim Bingela67e6a32014-01-02 18:35:24 +0000839 ppt = new PoliqarpPlusTree("Baum");
840 map = ppt.getRequestMap().get("query").toString();
841 assertEquals(simple1.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel16da4e12013-12-17 09:48:12 +0000842
Joachim Bingela67e6a32014-01-02 18:35:24 +0000843 // Der Baum
844 String simple2 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000845 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000846 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}, " +
847 "{@type=korap:token, wrap={@type=korap:term, key=Baum, layer=orth, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +0000848 "]}";
849 ppt = new PoliqarpPlusTree("Der Baum");
850 map = ppt.getRequestMap().get("query").toString();
851 assertEquals(simple2.replaceAll(" ", ""), map.replaceAll(" ", ""));
852
853 // Der große Baum
854 String simple3 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000855 "{@type=korap:group, operation=operation:sequence, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000856 "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}, " +
857 "{@type=korap:token, wrap={@type=korap:term, key=große, layer=orth, match=match:eq}}, " +
858 "{@type=korap:token, wrap={@type=korap:term, key=Baum, layer=orth, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +0000859 "]}";
860 ppt = new PoliqarpPlusTree("Der große Baum");
861 map = ppt.getRequestMap().get("query").toString();
862 assertEquals(simple3.replaceAll(" ", ""), map.replaceAll(" ", ""));
863
864 // Baum | Stein
865 String simple4 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000866 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000867 "{@type=korap:token, wrap={@type=korap:term, key=Baum, layer=orth, match=match:eq}}, " +
868 "{@type=korap:token, wrap={@type=korap:term, key=Stein, layer=orth, match=match:eq}}" +
Joachim Bingela67e6a32014-01-02 18:35:24 +0000869 "]}";
870 ppt = new PoliqarpPlusTree("Baum | Stein");
871 map = ppt.getRequestMap().get("query").toString();
872 assertEquals(simple4.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel84e33df2014-01-31 14:02:46 +0000873
874 // Baum | Stein Haus
875 String query = "(Baum | Stein) Haus";
876 String simple5 =
Joachim Bingel2daf9862014-02-12 10:18:54 +0000877 "{@type=korap:group, operation=operation:sequence, operands=[" +
878 "{@type=korap:group, operation=operation:or, operands=[" +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000879 "{@type=korap:token, wrap={@type=korap:term, key=Baum, layer=orth, match=match:eq}}, " +
880 "{@type=korap:token, wrap={@type=korap:term, key=Stein, layer=orth, match=match:eq}}" +
Joachim Bingel84e33df2014-01-31 14:02:46 +0000881 "]}," +
Joachim Bingelee3b21d2014-02-12 12:34:59 +0000882 "{@type=korap:token, wrap={@type=korap:term, key=Haus, layer=orth, match=match:eq}} " +
Joachim Bingel84e33df2014-01-31 14:02:46 +0000883 "]}";
884 ppt = new PoliqarpPlusTree(query);
885 map = ppt.getRequestMap().get("query").toString();
886 assertEquals(simple5.replaceAll(" ", ""), map.replaceAll(" ", ""));
Joachim Bingel16da4e12013-12-17 09:48:12 +0000887 }
Joachim Bingel53333e62013-12-09 19:25:52 +0000888}
889