Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1 | import static org.junit.Assert.*; |
| 2 | |
| 3 | import org.junit.Test; |
| 4 | |
| 5 | import de.ids_mannheim.korap.query.serialize.PoliqarpPlusTree; |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 6 | import de.ids_mannheim.korap.util.QueryException; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 7 | |
| 8 | public class PoliqarpPlusTreeTest { |
| 9 | |
| 10 | PoliqarpPlusTree ppt; |
| 11 | String map; |
| 12 | |
| 13 | private boolean equalsContent(String str, Object map) { |
| 14 | str = str.replaceAll(" ", ""); |
| 15 | String mapStr = map.toString().replaceAll(" ", ""); |
| 16 | return str.equals(mapStr); |
| 17 | } |
| 18 | |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 19 | private boolean equalsQueryContent(String res, String query) throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 20 | res = res.replaceAll(" ", ""); |
| 21 | ppt = new PoliqarpPlusTree(query); |
| 22 | String queryMap = ppt.getRequestMap().get("query").toString().replaceAll(" ", ""); |
| 23 | return res.equals(queryMap); |
| 24 | } |
| 25 | |
| 26 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 27 | public void testContext() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 28 | String contextString = "{korap=http://korap.ids-mannheim.de/ns/query, @language=de, operands={@id=korap:operands, @container=@list}, relation={@id=korap:relation, @type=korap:relation#types}, class={@id=korap:class, @type=xsd:integer}, query=korap:query, filter=korap:filter, meta=korap:meta}"; |
| 29 | ppt = new PoliqarpPlusTree("[base=test]"); |
| 30 | assertTrue(equalsContent(contextString, ppt.getRequestMap().get("@context"))); |
| 31 | } |
| 32 | |
| 33 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 34 | public void testSingleTokens() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 35 | // [base=Mann] |
| 36 | String token1 = "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}"; |
| 37 | assertTrue(equalsQueryContent(token1, "[base=Mann]")); |
| 38 | |
| 39 | // [orth!=Frau] |
| 40 | String token2 = "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation=!=}}"; |
| 41 | assertTrue(equalsQueryContent(token2, "[orth!=Frau]")); |
| 42 | |
| 43 | // [!p=NN] |
| 44 | String token3 = "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation=!=}}"; |
| 45 | assertTrue(equalsQueryContent(token3, "[!p=NN]")); |
| 46 | |
| 47 | // [!p!=NN] |
| 48 | String token4 = "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}"; |
| 49 | assertTrue(equalsQueryContent(token4, "[!p!=NN]")); |
| 50 | } |
| 51 | |
| 52 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 53 | public void testElements() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 54 | // <s> |
| 55 | String elem1 = "{@type=korap:element, @value=s}"; |
| 56 | assertTrue(equalsQueryContent(elem1, "<s>")); |
| 57 | |
| 58 | // <vp> |
| 59 | String elem2 = "{@type=korap:element, @value=vp}"; |
| 60 | assertTrue(equalsQueryContent(elem2, "<vp>")); |
| 61 | } |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 62 | |
| 63 | @Test |
| 64 | public void testEmptyTokens() throws QueryException { |
| 65 | // [base=der][][base=Mann] |
| 66 | String et1 = |
| 67 | "{@type=korap:group, relation=distance, @subtype=incl, constraint=[" + |
| 68 | "{@type=korap:distance, measure=w, direction=plus, min=1, max=1}" + |
| 69 | "], " + |
| 70 | "operands=[" + |
| 71 | "{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," + |
| 72 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}" + |
| 73 | "]}"; |
| 74 | ppt = new PoliqarpPlusTree("[base=der][][base=Mann]"); |
| 75 | map = ppt.getRequestMap().get("query").toString(); |
| 76 | assertEquals(et1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 77 | |
| 78 | // [base=der][][][base=Mann] |
| 79 | String et2 = |
| 80 | "{@type=korap:group, relation=distance, @subtype=incl, constraint=[" + |
| 81 | "{@type=korap:distance, measure=w, direction=plus, min=2, max=2}" + |
| 82 | "], " + |
| 83 | "operands=[" + |
| 84 | "{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," + |
| 85 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}" + |
| 86 | "]}"; |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame^] | 87 | ppt = new PoliqarpPlusTree("[base=der][][][base=Mann]"); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 88 | map = ppt.getRequestMap().get("query").toString(); |
| 89 | assertEquals(et2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 90 | |
| 91 | // [base=der][][]?[base=Mann] |
| 92 | String et3 = |
| 93 | "{@type=korap:group, relation=distance, @subtype=incl, constraint=[" + |
| 94 | "{@type=korap:distance, measure=w, direction=plus, min=1, max=2}" + |
| 95 | "], " + |
| 96 | "operands=[" + |
| 97 | "{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," + |
| 98 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}" + |
| 99 | "]}"; |
| 100 | ppt = new PoliqarpPlusTree("[base=der][][]?[base=Mann]"); |
| 101 | map = ppt.getRequestMap().get("query").toString(); |
| 102 | assertEquals(et3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 103 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 104 | |
| 105 | // startswith(<s>, [][base=Mann] |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame^] | 106 | String et4 = |
| 107 | "{@type=korap:group, relation=position, position=startswith, operands=[" + |
| 108 | "{@type=korap:element, @value=s}," + |
| 109 | "{@type=korap:sequence, offset-min=1, offset-max=1, operands=[" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 110 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}" + |
| 111 | "]}" + |
| 112 | "]}"; |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame^] | 113 | ppt = new PoliqarpPlusTree("startswith(<s>, [][base=Mann])"); |
| 114 | map = ppt.getRequestMap().get("query").toString(); |
| 115 | assertEquals(et4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 116 | |
| 117 | String et5 = |
| 118 | "{@type=korap:group, relation=distance, @subtype=incl, constraint=[" + |
| 119 | "{@type=korap:distance, measure=w, direction=plus, min=1, max=1}" + |
| 120 | "], " + |
| 121 | "operands=[" + |
| 122 | "{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," + |
| 123 | "{@type=korap:group, relation=distance, @subtype=incl, constraint=[" + |
| 124 | "{@type=korap:distance, measure=w, direction=plus, min=2, max=2}" + |
| 125 | "], " + |
| 126 | "operands=[" + |
| 127 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}," + |
| 128 | "{@type=korap:token, @value={@type=korap:term, @value=base:Frau, relation==}}" + |
| 129 | "]}" + |
| 130 | "]}"; |
| 131 | ppt = new PoliqarpPlusTree("[base=der][][base=Mann][][][base=Frau]"); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 132 | map = ppt.getRequestMap().get("query").toString(); |
| 133 | assertEquals(et5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 134 | |
| 135 | } |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 136 | |
| 137 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 138 | public void testCoordinatedFields() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 139 | // [base=Mann&(cas=N|cas=A)] |
| 140 | String cof1 = |
| 141 | "{@type=korap:token, @value=" + |
| 142 | "{@type=korap:group, operands=[" + |
| 143 | "{@type=korap:term, @value=base:Mann, relation==}," + |
| 144 | "{@type=korap:group, operands=[" + |
| 145 | "{@type=korap:term, @value=cas:N, relation==}," + |
| 146 | "{@type=korap:term, @value=cas:A, relation==}" + |
| 147 | "], relation=or}" + |
| 148 | "], relation=and}" + |
| 149 | "}"; |
| 150 | ppt = new PoliqarpPlusTree("[base=Mann&(cas=N|cas=A)]"); |
| 151 | map = ppt.getRequestMap().get("query").toString(); |
| 152 | assertEquals(cof1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Nils Diewald | 7d486c2 | 2013-12-13 16:32:18 +0000 | [diff] [blame] | 153 | |
| 154 | |
| 155 | assertEquals( |
| 156 | new PoliqarpPlusTree(" [ base=Mann & ( cas=N | cas=A)] ").getRequestMap().get("query").toString(), |
| 157 | new PoliqarpPlusTree("[base=Mann &(cas=N|cas=A)]").getRequestMap().get("query").toString() |
| 158 | ); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 162 | public void testOccurrence() throws QueryException { |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 163 | // [base=foo]* |
| 164 | String occ1 = "{@type=korap:group, operands=[" + |
| 165 | "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" + |
| 166 | "], relation=repetition, quantifier=* }"; |
| 167 | ppt = new PoliqarpPlusTree("[base=foo]*"); |
| 168 | map = ppt.getRequestMap().get("query").toString(); |
| 169 | assertEquals(occ1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 170 | |
| 171 | // [base=foo]*[base=bar] |
| 172 | String occ2 = |
| 173 | "{@type=korap:sequence, operands=[" + |
| 174 | "{@type=korap:group, operands=[" + |
| 175 | "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" + |
| 176 | "], relation=repetition, quantifier=* }," + |
| 177 | "{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}" + |
| 178 | "]}"; |
| 179 | ppt = new PoliqarpPlusTree("[base=foo]*[base=bar]"); |
| 180 | map = ppt.getRequestMap().get("query").toString(); |
| 181 | assertEquals(occ2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 182 | |
| 183 | // [base=bar][base=foo]* |
| 184 | String occ3 = |
| 185 | "{@type=korap:sequence, operands=[" + |
| 186 | "{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," + |
| 187 | "{@type=korap:group, operands=[" + |
| 188 | "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" + |
| 189 | "], relation=repetition, quantifier=* }" + |
| 190 | "]}"; |
| 191 | ppt = new PoliqarpPlusTree("[base=bar][base=foo]*"); |
| 192 | map = ppt.getRequestMap().get("query").toString(); |
| 193 | assertEquals(occ3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 194 | |
| 195 | // ([base=bar][base=foo])* |
| 196 | String occ4 = |
| 197 | "{@type=korap:group, operands=[" + |
| 198 | "{@type=korap:sequence, operands=[" + |
| 199 | "{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," + |
| 200 | "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" + |
| 201 | "]}" + |
| 202 | "], relation=repetition, quantifier=* }" ; |
| 203 | ppt = new PoliqarpPlusTree("([base=bar][base=foo])*"); |
| 204 | map = ppt.getRequestMap().get("query").toString(); |
| 205 | assertEquals(occ4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 206 | |
| 207 | // <s>([base=bar][base=foo])* |
| 208 | String occ5 = |
| 209 | "{@type=korap:sequence, operands=[" + |
| 210 | "{@type=korap:element, @value=s}," + |
| 211 | "{@type=korap:group, operands=[" + |
| 212 | "{@type=korap:sequence, operands=[" + |
| 213 | "{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," + |
| 214 | "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" + |
| 215 | "]}" + |
| 216 | "], relation=repetition, quantifier=* }" + |
| 217 | "]}" ; |
| 218 | ppt = new PoliqarpPlusTree("<s>([base=bar][base=foo])*"); |
| 219 | map = ppt.getRequestMap().get("query").toString(); |
| 220 | assertEquals(occ5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 221 | |
| 222 | // <s><np>([base=bar][base=foo])* |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 223 | String occ6 = |
| 224 | "{@type=korap:sequence, operands=[" + |
Joachim Bingel | 94a1ccd | 2013-12-10 10:37:29 +0000 | [diff] [blame] | 225 | "{@type=korap:element, @value=s}," + |
| 226 | "{@type=korap:element, @value=np}," + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 227 | "{@type=korap:group, operands=[" + |
| 228 | "{@type=korap:sequence, operands=[" + |
| 229 | "{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," + |
| 230 | "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" + |
| 231 | "]}" + |
| 232 | "], relation=repetition, quantifier=* }" + |
| 233 | "]}" ; |
| 234 | ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*"); |
| 235 | map = ppt.getRequestMap().get("query").toString(); |
| 236 | assertEquals(occ6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 237 | |
| 238 | // <s><np>([base=bar][base=foo])*[p=NN] |
| 239 | // comment: embedded sequence shouldn't really be here, but does not really hurt, either. (?) |
| 240 | // really hard to get this behaviour out of the PQPlus grammar... |
| 241 | String occ7 = |
| 242 | "{@type=korap:sequence, operands=[" + |
Joachim Bingel | 94a1ccd | 2013-12-10 10:37:29 +0000 | [diff] [blame] | 243 | "{@type=korap:element, @value=s}," + |
| 244 | "{@type=korap:element, @value=np}," + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 245 | "{@type=korap:group, operands=[" + |
| 246 | "{@type=korap:sequence, operands=[" + |
| 247 | "{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," + |
| 248 | "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" + |
| 249 | "]}" + |
| 250 | "], relation=repetition, quantifier=* }," + |
| 251 | "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}" + |
| 252 | "]}" ; |
| 253 | ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*[p=NN]"); |
| 254 | map = ppt.getRequestMap().get("query").toString(); |
| 255 | assertEquals(occ7.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 256 | |
| 257 | // ([base=bar][base=foo])*[p=NN] |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 258 | String occ8 = |
| 259 | "{@type=korap:sequence, operands=[" + |
| 260 | "{@type=korap:group, operands=[" + |
| 261 | "{@type=korap:sequence, operands=[" + |
| 262 | "{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," + |
| 263 | "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" + |
| 264 | "]}" + |
| 265 | "], relation=repetition, quantifier=* }," + |
| 266 | "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}" + |
| 267 | "]}" ; |
| 268 | ppt = new PoliqarpPlusTree("([base=bar][base=foo])*[p=NN]"); |
| 269 | map = ppt.getRequestMap().get("query").toString(); |
| 270 | assertEquals(occ8.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 274 | public void testTokenSequence() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 275 | // [base=Mann][orth=Frau] |
| 276 | String seq1 = "{@type=korap:sequence, operands=[" + |
| 277 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}, " + |
| 278 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}" + |
| 279 | "]}"; |
| 280 | assertTrue(equalsQueryContent(seq1, "[base=Mann][orth=Frau]")); |
| 281 | |
| 282 | // [base=Mann][orth=Frau][p=NN] |
| 283 | String seq2 = "{@type=korap:sequence, operands=[" + |
| 284 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}, " + |
| 285 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}, " + |
| 286 | "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}" + |
| 287 | "]}"; |
| 288 | assertTrue(equalsQueryContent(seq2, "[base=Mann][orth=Frau][p=NN]")); |
| 289 | } |
| 290 | |
| 291 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 292 | public void testDisjSegments() throws QueryException { |
Joachim Bingel | 94a1ccd | 2013-12-10 10:37:29 +0000 | [diff] [blame] | 293 | // ([base=der]|[base=das])[base=Schild] |
| 294 | String disj1 = |
| 295 | "{@type=korap:sequence, operands=[" + |
| 296 | "{@type=korap:group, relation=or, operands=[" + |
| 297 | "{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," + |
| 298 | "{@type=korap:token, @value={@type=korap:term, @value=base:das, relation==}}" + |
| 299 | "]}," + |
| 300 | "{@type=korap:token, @value={@type=korap:term, @value=base:Schild, relation==}}" + |
| 301 | "]}"; |
| 302 | ppt = new PoliqarpPlusTree("([base=der]|[base=das])[base=Schild]"); |
| 303 | map = ppt.getRequestMap().get("query").toString(); |
| 304 | assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 305 | |
| 306 | // [base=Schild]([base=der]|[base=das]) |
| 307 | String disj2 = |
| 308 | "{@type=korap:sequence, operands=[" + |
| 309 | "{@type=korap:token, @value={@type=korap:term, @value=base:Schild, relation==}}," + |
| 310 | "{@type=korap:group, relation=or, operands=[" + |
| 311 | "{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," + |
| 312 | "{@type=korap:token, @value={@type=korap:term, @value=base:das, relation==}}" + |
| 313 | "]}" + |
| 314 | "]}"; |
| 315 | ppt = new PoliqarpPlusTree("[base=Schild]([base=der]|[base=das])"); |
| 316 | map = ppt.getRequestMap().get("query").toString(); |
| 317 | assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 318 | } |
| 319 | |
| 320 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 321 | public void testTokenElemSequence() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 322 | // [base=Mann]<vp> |
| 323 | String seq1 = "{@type=korap:sequence, operands=[" + |
| 324 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}, " + |
| 325 | "{@type=korap:element, @value=vp}" + |
| 326 | "]}"; |
| 327 | assertTrue(equalsQueryContent(seq1, "[base=Mann]<vp>")); |
| 328 | |
| 329 | // <vp>[base=Mann] |
| 330 | String seq2 = "{@type=korap:sequence, operands=[" + |
| 331 | "{@type=korap:element, @value=vp}, "+ |
| 332 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}} " + |
| 333 | "]}"; |
| 334 | assertTrue(equalsQueryContent(seq2, "<vp>[base=Mann]")); |
| 335 | |
| 336 | // <vp>[base=Mann]<pp> |
| 337 | String seq3 = "{@type=korap:sequence, operands=[" + |
| 338 | "{@type=korap:element, @value=vp}, "+ |
| 339 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}, " + |
| 340 | "{@type=korap:element, @value=pp} "+ |
| 341 | "]}"; |
| 342 | assertTrue(equalsQueryContent(seq3, "<vp>[base=Mann]<pp>")); |
| 343 | } |
| 344 | |
| 345 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 346 | public void testElemSequence() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 347 | // <np><vp> |
| 348 | String seq1 = "{@type=korap:sequence, operands=[" + |
| 349 | "{@type=korap:element, @value=np}," + |
| 350 | "{@type=korap:element, @value=vp}" + |
| 351 | "]}"; |
| 352 | assertTrue(equalsQueryContent(seq1, "<np><vp>")); |
| 353 | |
| 354 | // <np><vp><pp> |
| 355 | String seq2 = "{@type=korap:sequence, operands=[" + |
| 356 | "{@type=korap:element, @value=np}," + |
| 357 | "{@type=korap:element, @value=vp}," + |
| 358 | "{@type=korap:element, @value=pp}" + |
| 359 | "]}"; |
| 360 | assertTrue(equalsQueryContent(seq2, "<np><vp><pp>")); |
| 361 | } |
| 362 | |
| 363 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 364 | public void testClasses() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 365 | // {[base=Mann]} |
| 366 | String cls1 = "{@type=korap:group, class=0, operands=[" + |
| 367 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}" + |
| 368 | "]}"; |
| 369 | assertTrue(equalsQueryContent(cls1, "{[base=Mann]}")); |
| 370 | |
| 371 | // {[base=Mann][orth=Frau]} |
| 372 | String cls2 = "{@type=korap:group, class=0, operands=[" + |
| 373 | "{@type=korap:sequence, operands=[" + |
| 374 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}," + |
| 375 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}" + |
| 376 | "]}" + |
| 377 | "]}"; |
| 378 | assertTrue(equalsQueryContent(cls2, "{[base=Mann][orth=Frau]}")); |
| 379 | |
| 380 | // [p=NN]{[base=Mann][orth=Frau]} |
| 381 | String cls3 = "{@type=korap:sequence, operands=[" + |
| 382 | "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}," + |
| 383 | "{@type=korap:group, class=0, operands=[" + |
| 384 | "{@type=korap:sequence, operands=[" + |
| 385 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}," + |
| 386 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}" + |
| 387 | "]}" + |
| 388 | "]}" + |
| 389 | "]}"; |
| 390 | assertTrue(equalsQueryContent(cls3, "[p=NN]{[base=Mann][orth=Frau]}")); |
| 391 | |
| 392 | // {[base=Mann][orth=Frau]}[p=NN] |
| 393 | String cls4 = "{@type=korap:sequence, operands=[" + |
| 394 | "{@type=korap:group, class=0, operands=[" + |
| 395 | "{@type=korap:sequence, operands=[" + |
| 396 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}," + |
| 397 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}" + |
| 398 | "]}" + |
| 399 | "]}," + |
| 400 | "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}" + |
| 401 | "]}"; |
| 402 | assertTrue(equalsQueryContent(cls4, "{[base=Mann][orth=Frau]}[p=NN]")); |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 403 | |
| 404 | // {2:{1:[tt/p=ADJA]}[mate/p=NN]}" |
| 405 | String cls5 = "{@type=korap:group, class=2, operands=[" + |
| 406 | "{@type=korap:sequence, operands=[" + |
| 407 | "{@type=korap:group, class=1, operands=[" + |
| 408 | "{@type=korap:token, @value={@type=korap:term, @value=tt/p:ADJA, relation==}}" + |
| 409 | "]}," + |
| 410 | "{@type=korap:token, @value={@type=korap:term, @value=mate/p:NN, relation==}}" + |
| 411 | "]}" + |
| 412 | "]}"; |
| 413 | ppt = new PoliqarpPlusTree("{2: {1:[tt/p=ADJA]}[mate/p=NN]}"); |
| 414 | map = ppt.getRequestMap().get("query").toString(); |
| 415 | assertEquals(cls5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 419 | public void testPositions() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 420 | // contains(<s>,<np>) |
| 421 | String pos1 = "{@type=korap:group, relation=position, position=contains, operands=[" + |
| 422 | "{@type=korap:element, @value=s}," + |
| 423 | "{@type=korap:element, @value=np}" + |
| 424 | "]}"; |
| 425 | assertTrue(equalsQueryContent(pos1, "contains(<s>,<np>)")); |
| 426 | |
| 427 | // contains(<s>,[base=Mann]) |
| 428 | String pos2 = "{@type=korap:group, relation=position, position=contains, operands=[" + |
| 429 | "{@type=korap:element, @value=s}," + |
| 430 | "{@type=korap:token, @value= {@type=korap:term, @value=base:Mann, relation==}}" + |
| 431 | "]}"; |
| 432 | assertTrue(equalsQueryContent(pos2, "contains(<s>,[base=Mann])")); |
| 433 | |
| 434 | // contains(<s>,[orth=der][orth=Mann]) |
| 435 | String pos3 = "{@type=korap:group, relation=position, position=contains, operands=[" + |
| 436 | "{@type=korap:element, @value=s}," + |
| 437 | "{@type=korap:sequence, operands=[" + |
| 438 | "{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}," + |
| 439 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" + |
| 440 | "]}" + |
| 441 | "]}"; |
| 442 | ppt = new PoliqarpPlusTree("contains(<s>,[orth=der][orth=Mann])"); |
| 443 | map = ppt.getRequestMap().get("query").toString(); |
| 444 | assertEquals(pos3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 445 | |
| 446 | // [base=Auto]contains(<s>,[base=Mann]) |
| 447 | String pos4 = |
| 448 | "{@type=korap:sequence, operands=[" + |
| 449 | "{@type=korap:token, @value={@type=korap:term, @value=base:Auto, relation==}}," + |
| 450 | "{@type=korap:group, relation=position, position=contains, operands=[" + |
| 451 | "{@type=korap:element, @value=s}," + |
| 452 | "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}" + |
| 453 | "]}" + |
| 454 | "]}"; |
| 455 | ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[base=Mann])"); |
| 456 | map = ppt.getRequestMap().get("query").toString(); |
| 457 | assertEquals(pos4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 458 | } |
| 459 | |
| 460 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 461 | public void testNestedPositions() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 462 | // contains(<s>,startswith(<np>,[orth=Der])) |
| 463 | String npos1 = |
| 464 | "{@type=korap:group, relation=position, position=contains, operands=[" + |
| 465 | "{@type=korap:element, @value=s}," + |
| 466 | "{@type=korap:group, relation=position, position=startswith, operands=[" + |
| 467 | "{@type=korap:element, @value=np}," + |
| 468 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}" + |
| 469 | "]}" + |
| 470 | "]}"; |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 471 | ppt = new PoliqarpPlusTree("contains(<s>, startswith(<np>,[orth=Der]))"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 472 | map = ppt.getRequestMap().get("query").toString(); |
| 473 | assertEquals(npos1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 474 | } |
| 475 | |
| 476 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 477 | public void testShrinkSplit() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 478 | // shrink([orth=Der]{[orth=Mann]}) |
| 479 | String shr1 = |
| 480 | "{@type=korap:group, relation=shrink, shrink=0, operands=[" + |
| 481 | "{@type=korap:sequence, operands=[" + |
| 482 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}," + |
| 483 | "{@type=korap:group, class=0, operands=[" + |
| 484 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" + |
| 485 | "]}" + |
| 486 | "]}" + |
| 487 | "]}"; |
| 488 | ppt = new PoliqarpPlusTree("shrink([orth=Der]{[orth=Mann]})"); |
| 489 | map = ppt.getRequestMap().get("query").toString(); |
| 490 | assertEquals(shr1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 491 | |
| 492 | // shrink([orth=Der]{[orth=Mann][orth=geht]}) |
| 493 | String shr2 = |
| 494 | "{@type=korap:group, relation=shrink, shrink=0, operands=[" + |
| 495 | "{@type=korap:sequence, operands=[" + |
| 496 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}," + |
| 497 | "{@type=korap:group, class=0, operands=[" + |
| 498 | "{@type=korap:sequence, operands=[" + |
| 499 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}," + |
| 500 | "{@type=korap:token, @value={@type=korap:term, @value=orth:geht, relation==}}" + |
| 501 | "]}" + |
| 502 | "]}" + |
| 503 | "]}" + |
| 504 | "]}"; |
| 505 | ppt = new PoliqarpPlusTree("shrink([orth=Der]{[orth=Mann][orth=geht]})"); |
| 506 | map = ppt.getRequestMap().get("query").toString(); |
| 507 | assertEquals(shr2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 508 | |
| 509 | // shrink(1:[orth=Der]{1:[orth=Mann][orth=geht]}) |
| 510 | String shr3 = |
| 511 | "{@type=korap:group, relation=shrink, shrink=1, operands=[" + |
| 512 | "{@type=korap:sequence, operands=[" + |
| 513 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}," + |
| 514 | "{@type=korap:group, class=1, operands=[" + |
| 515 | "{@type=korap:sequence, operands=[" + |
| 516 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}," + |
| 517 | "{@type=korap:token, @value={@type=korap:term, @value=orth:geht, relation==}}" + |
| 518 | "]}" + |
| 519 | "]}" + |
| 520 | "]}" + |
| 521 | "]}"; |
| 522 | ppt = new PoliqarpPlusTree("shrink(1:[orth=Der]{1:[orth=Mann][orth=geht]})"); |
| 523 | map = ppt.getRequestMap().get("query").toString(); |
| 524 | assertEquals(shr3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 525 | |
| 526 | // shrink(1:startswith(<s>,{1:<np>})) |
| 527 | String shr4 = |
| 528 | "{@type=korap:group, relation=shrink, shrink=1, operands=[" + |
| 529 | "{@type=korap:group, relation=position, position=startswith, operands=[" + |
| 530 | "{@type=korap:element, @value=s}," + |
| 531 | "{@type=korap:group, class=1, operands=[" + |
| 532 | "{@type=korap:element, @value=np}" + |
| 533 | "]}" + |
| 534 | "]}" + |
| 535 | "]}"; |
Joachim Bingel | adefa62 | 2013-12-13 10:51:48 +0000 | [diff] [blame] | 536 | ppt = new PoliqarpPlusTree("shrink(1:startswith(<s>,{1:<np>}))"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 537 | map = ppt.getRequestMap().get("query").toString(); |
| 538 | assertEquals(shr4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 539 | |
| 540 | // shrink(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) |
| 541 | String shr5 = |
| 542 | "{@type=korap:group, relation=shrink, shrink=3, operands=[" + |
| 543 | "{@type=korap:group, relation=position, position=startswith, operands=[" + |
| 544 | "{@type=korap:element, @value=s}," + |
| 545 | "{@type=korap:group, class=3, operands=[" + |
| 546 | "{@type=korap:sequence, operands=[" + |
| 547 | "{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," + |
| 548 | "{@type=korap:group, class=1, operands=[" + |
| 549 | "{@type=korap:sequence, operands=[" + |
| 550 | "{@type=korap:token, @value={@type=korap:term, @value=mate/p:ADJA, relation==}}," + |
| 551 | "{@type=korap:group, class=2, operands=[" + |
| 552 | "{@type=korap:token, @value={@type=korap:term, @value=tt/p:NN, relation==}}" + |
| 553 | "]}" + |
| 554 | "]}" + |
| 555 | "]}" + |
| 556 | "]}" + |
| 557 | "]}" + |
| 558 | "]}" + |
| 559 | "]}"; |
Joachim Bingel | adefa62 | 2013-12-13 10:51:48 +0000 | [diff] [blame] | 560 | ppt = new PoliqarpPlusTree("shrink(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) "); |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 561 | map = ppt.getRequestMap().get("query").toString(); |
| 562 | assertEquals(shr5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 563 | } |
| 564 | |
Joachim Bingel | 0388270 | 2013-12-31 19:53:05 +0000 | [diff] [blame] | 565 | |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 566 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 567 | public void testLayers() throws QueryException { |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 568 | // [base=Mann] |
| 569 | String layer1 = "{@type=korap:token, @value={@type=korap:term, @value=tt/base:Mann, relation==}}"; |
| 570 | assertTrue(equalsQueryContent(layer1, "[tt/base=Mann]")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 571 | |
| 572 | } |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 573 | |
| 574 | @Test |
| 575 | public void testAlign() { |
| 576 | // [orth=der]^[orth=Mann] |
| 577 | String align1 = |
Joachim Bingel | 0388270 | 2013-12-31 19:53:05 +0000 | [diff] [blame] | 578 | "{@type=korap:sequence, operands=[" + |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 579 | "{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}," + |
Joachim Bingel | 0388270 | 2013-12-31 19:53:05 +0000 | [diff] [blame] | 580 | "{@type=korap:group, relation=left-align, operands=[" + |
| 581 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" + |
| 582 | "]}" + |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 583 | "]}"; |
| 584 | ppt = new PoliqarpPlusTree("[orth=der]^[orth=Mann]"); |
| 585 | map = ppt.getRequestMap().get("query").toString(); |
| 586 | assertEquals(align1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 587 | |
| 588 | // "([base=a]^[base=b])|[base=c]", |
| 589 | String align2 = |
| 590 | "{@type=korap:group, relation=or, operands=[" + |
Joachim Bingel | 0388270 | 2013-12-31 19:53:05 +0000 | [diff] [blame] | 591 | "{@type=korap:sequence, operands=[" + |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 592 | "{@type=korap:token, @value={@type=korap:term, @value=base:a, relation==}}," + |
Joachim Bingel | 0388270 | 2013-12-31 19:53:05 +0000 | [diff] [blame] | 593 | "{@type=korap:group, relation=left-align, operands=[" + |
| 594 | "{@type=korap:token, @value={@type=korap:term, @value=base:b, relation==}}" + |
| 595 | "]}" + |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 596 | "]}," + |
| 597 | "{@type=korap:token, @value={@type=korap:term, @value=base:c, relation==}}" + |
| 598 | "]}"; |
| 599 | ppt = new PoliqarpPlusTree("([base=a]^[base=b])|[base=c]"); |
| 600 | map = ppt.getRequestMap().get("query").toString(); |
| 601 | assertEquals(align2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 602 | |
| 603 | // "([base=a]^[base=b][base=c])|[base=d]", |
| 604 | String align3 = |
| 605 | "{@type=korap:group, relation=or, operands=[" + |
| 606 | "{@type=korap:sequence, operands=[" + |
| 607 | "{@type=korap:token, @value={@type=korap:term, @value=base:a, relation==}}," + |
| 608 | "{@type=korap:group, relation=left-align, operands=[" + |
| 609 | "{@type=korap:token, @value={@type=korap:term, @value=base:b, relation==}}" + |
| 610 | "]}," + |
| 611 | "{@type=korap:token, @value={@type=korap:term, @value=base:c, relation==}}" + |
| 612 | "]}," + |
| 613 | "{@type=korap:token, @value={@type=korap:term, @value=base:d, relation==}}" + |
| 614 | "]}"; |
| 615 | ppt = new PoliqarpPlusTree("([base=a]^[base=b][base=c])|[base=d]"); |
| 616 | map = ppt.getRequestMap().get("query").toString(); |
| 617 | assertEquals(align3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 618 | |
| 619 | // "([base=a]^[base=b]^[base=c])|[base=d]", |
| 620 | String align4 = |
| 621 | "{@type=korap:group, relation=or, operands=[" + |
| 622 | "{@type=korap:sequence, operands=[" + |
| 623 | "{@type=korap:token, @value={@type=korap:term, @value=base:a, relation==}}," + |
| 624 | "{@type=korap:group, relation=left-align, operands=[" + |
| 625 | "{@type=korap:token, @value={@type=korap:term, @value=base:b, relation==}}" + |
| 626 | "]}," + |
| 627 | "{@type=korap:group, relation=left-align, operands=[" + |
| 628 | "{@type=korap:token, @value={@type=korap:term, @value=base:c, relation==}}" + |
| 629 | "]}" + |
| 630 | "]}," + |
| 631 | "{@type=korap:token, @value={@type=korap:term, @value=base:d, relation==}}" + |
| 632 | "]}"; |
| 633 | ppt = new PoliqarpPlusTree("([base=a]^[base=b]^[base=c])|[base=d]"); |
| 634 | map = ppt.getRequestMap().get("query").toString(); |
| 635 | assertEquals(align4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 636 | |
| 637 | |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 638 | } |
| 639 | |
| 640 | @Test |
| 641 | public void testSimpleQueries() { |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 642 | // Baum |
| 643 | String simple1 = |
| 644 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Baum, relation==}}"; |
| 645 | ppt = new PoliqarpPlusTree("Baum"); |
| 646 | map = ppt.getRequestMap().get("query").toString(); |
| 647 | assertEquals(simple1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 648 | |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 649 | // Der Baum |
| 650 | String simple2 = |
| 651 | "{@type=korap:sequence, operands=[" + |
| 652 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}, " + |
| 653 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Baum, relation==}}" + |
| 654 | "]}"; |
| 655 | ppt = new PoliqarpPlusTree("Der Baum"); |
| 656 | map = ppt.getRequestMap().get("query").toString(); |
| 657 | assertEquals(simple2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 658 | |
| 659 | // Der große Baum |
| 660 | String simple3 = |
| 661 | "{@type=korap:sequence, operands=[" + |
| 662 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}, " + |
| 663 | "{@type=korap:token, @value={@type=korap:term, @value=orth:große, relation==}}, " + |
| 664 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Baum, relation==}}" + |
| 665 | "]}"; |
| 666 | ppt = new PoliqarpPlusTree("Der große Baum"); |
| 667 | map = ppt.getRequestMap().get("query").toString(); |
| 668 | assertEquals(simple3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 669 | |
| 670 | // Baum | Stein |
| 671 | String simple4 = |
| 672 | "{@type=korap:group, relation=or, operands=[" + |
| 673 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Baum, relation==}}, " + |
| 674 | "{@type=korap:token, @value={@type=korap:term, @value=orth:Stein, relation==}}" + |
| 675 | "]}"; |
| 676 | ppt = new PoliqarpPlusTree("Baum | Stein"); |
| 677 | map = ppt.getRequestMap().get("query").toString(); |
| 678 | assertEquals(simple4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 679 | } |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 680 | } |
| 681 | |