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; |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 12 | String expected; |
| 13 | String query; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 14 | |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 15 | private boolean equalsQueryContent(String res, String query) throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 16 | res = res.replaceAll(" ", ""); |
| 17 | ppt = new PoliqarpPlusTree(query); |
| 18 | String queryMap = ppt.getRequestMap().get("query").toString().replaceAll(" ", ""); |
| 19 | return res.equals(queryMap); |
| 20 | } |
| 21 | |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 22 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 23 | public void testContext() throws QueryException { |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 24 | String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 25 | ppt = new PoliqarpPlusTree("Test"); |
| 26 | assertEquals(contextString.replaceAll(" ", ""), ppt.getRequestMap().get("@context").toString().replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 30 | public void testSingleTokens() throws QueryException { |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 31 | String query; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 32 | // [base=Mann] |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 33 | String token1 = "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}"; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 34 | assertTrue(equalsQueryContent(token1, "[base=Mann]")); |
| 35 | |
| 36 | // [orth!=Frau] |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 37 | String token2 = "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:ne}}"; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 38 | assertTrue(equalsQueryContent(token2, "[orth!=Frau]")); |
| 39 | |
| 40 | // [!p=NN] |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 41 | query = "[!p=NN]"; |
| 42 | String token3 = "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:ne}}"; |
| 43 | ppt = new PoliqarpPlusTree(query); |
| 44 | map = ppt.getRequestMap().get("query").toString(); |
| 45 | assertEquals(token3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 46 | |
| 47 | // [!p!=NN] |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 48 | query = "[!p!=NN]"; |
| 49 | String token4 = "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}"; |
| 50 | ppt = new PoliqarpPlusTree(query); |
| 51 | map = ppt.getRequestMap().get("query").toString(); |
| 52 | assertEquals(token4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 53 | |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 54 | query = "[base=schland/x]"; |
Joachim Bingel | a83f8cc | 2014-08-05 14:12:59 +0000 | [diff] [blame] | 55 | String token5 = "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=.*?schland.*?, match=match:eq, type=type:regex}}"; |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 56 | ppt = new PoliqarpPlusTree(query); |
| 57 | map = ppt.getRequestMap().get("query").toString(); |
| 58 | assertEquals(token5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 59 | } |
| 60 | |
| 61 | @Test |
| 62 | public void testValue() throws QueryException { |
| 63 | String query; |
| 64 | |
| 65 | query = "[mate/m=temp:pres]"; |
| 66 | String value1 = "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=m, key=temp, value=pres, match=match:eq}}"; |
| 67 | ppt = new PoliqarpPlusTree(query); |
| 68 | map = ppt.getRequestMap().get("query").toString(); |
| 69 | assertEquals(value1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | @Test |
Joachim Bingel | 41e112e | 2014-02-12 10:46:18 +0000 | [diff] [blame] | 73 | public void testRegex() throws QueryException { |
| 74 | String query = "[orth=\"M(a|ä)nn(er)?\"]"; |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 75 | String re1 = "{@type=korap:token, wrap={@type=korap:term, layer=orth, type=type:regex, key=M(a|ä)nn(er)?, match=match:eq}}"; |
Joachim Bingel | 41e112e | 2014-02-12 10:46:18 +0000 | [diff] [blame] | 76 | ppt = new PoliqarpPlusTree(query); |
| 77 | map = ppt.getRequestMap().get("query").toString(); |
| 78 | assertEquals(re1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 79 | |
| 80 | query = "[orth=\"M(a|ä)nn(er)?\"/x]"; |
| 81 | String re2 = "{@type=korap:token, wrap={@type=korap:term, layer=orth, type=type:regex, key=.*?M(a|ä)nn(er)?.*?, match=match:eq}}"; |
| 82 | ppt = new PoliqarpPlusTree(query); |
| 83 | map = ppt.getRequestMap().get("query").toString(); |
| 84 | assertEquals(re2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 85 | |
| 86 | query = "\"M(a|ä)nn(er)?\"/x"; |
| 87 | String re3 = "{@type=korap:token, wrap={@type=korap:term, type=type:regex, layer=orth, key=.*?M(a|ä)nn(er)?.*?, match=match:eq}}"; |
| 88 | ppt = new PoliqarpPlusTree(query); |
| 89 | map = ppt.getRequestMap().get("query").toString(); |
| 90 | assertEquals(re3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 91 | |
| 92 | query = "schland/x"; |
Joachim Bingel | a83f8cc | 2014-08-05 14:12:59 +0000 | [diff] [blame] | 93 | String re4 = "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=.*?schland.*?, match=match:eq, type=type:regex}}"; |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 94 | ppt = new PoliqarpPlusTree(query); |
| 95 | map = ppt.getRequestMap().get("query").toString(); |
| 96 | assertEquals(re4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 97 | |
| 98 | query = "\".*?Mann.*?\""; |
| 99 | String re5 = "{@type=korap:token, wrap={@type=korap:term, type=type:regex, layer=orth, key=.*?Mann.*?, match=match:eq}}"; |
| 100 | ppt = new PoliqarpPlusTree(query); |
| 101 | map = ppt.getRequestMap().get("query").toString(); |
| 102 | assertEquals(re5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | a83f8cc | 2014-08-05 14:12:59 +0000 | [diff] [blame] | 103 | |
| 104 | query = "z.B./x"; |
| 105 | String re6 = "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=.*?z\\.B\\..*?, match=match:eq, type=type:regex}}"; |
| 106 | ppt = new PoliqarpPlusTree(query); |
| 107 | map = ppt.getRequestMap().get("query").toString(); |
| 108 | assertEquals(re6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 41e112e | 2014-02-12 10:46:18 +0000 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | @Test |
Joachim Bingel | 0207d5e | 2014-02-12 14:18:41 +0000 | [diff] [blame] | 112 | public void testCaseSensitivityFlag() throws QueryException { |
| 113 | String query="[orth=deutscher/i]"; |
| 114 | String cs1 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 115 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=deutscher, match=match:eq, caseInsensitive=true}}"; |
Joachim Bingel | 0207d5e | 2014-02-12 14:18:41 +0000 | [diff] [blame] | 116 | ppt = new PoliqarpPlusTree(query); |
| 117 | map = ppt.getRequestMap().get("query").toString(); |
| 118 | assertEquals(cs1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 119 | |
| 120 | query="[orth=deutscher/i][orth=Bundestag]"; |
| 121 | String cs2 = |
| 122 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 123 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=deutscher, match=match:eq, caseInsensitive=true}}," + |
| 124 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Bundestag, match=match:eq}}" + |
Joachim Bingel | 0207d5e | 2014-02-12 14:18:41 +0000 | [diff] [blame] | 125 | "]}"; |
| 126 | ppt = new PoliqarpPlusTree(query); |
| 127 | map = ppt.getRequestMap().get("query").toString(); |
| 128 | assertEquals(cs2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | add0fb1 | 2014-06-24 08:54:14 +0000 | [diff] [blame] | 129 | |
| 130 | query="deutscher/i"; |
| 131 | String cs3 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 132 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=deutscher, match=match:eq, caseInsensitive=true}}"; |
Joachim Bingel | add0fb1 | 2014-06-24 08:54:14 +0000 | [diff] [blame] | 133 | ppt = new PoliqarpPlusTree(query); |
| 134 | map = ppt.getRequestMap().get("query").toString(); |
| 135 | assertEquals(cs3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 136 | |
| 137 | query="deutscher/i Bundestag"; |
| 138 | String cs4 = |
| 139 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 140 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=deutscher, match=match:eq, caseInsensitive=true}}," + |
| 141 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Bundestag, match=match:eq}}" + |
Joachim Bingel | add0fb1 | 2014-06-24 08:54:14 +0000 | [diff] [blame] | 142 | "]}"; |
| 143 | ppt = new PoliqarpPlusTree(query); |
| 144 | map = ppt.getRequestMap().get("query").toString(); |
| 145 | assertEquals(cs4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 146 | |
| 147 | query="deutscher Bundestag/i"; |
| 148 | String cs5 = |
| 149 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 150 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=deutscher, match=match:eq}}," + |
| 151 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Bundestag, match=match:eq, caseInsensitive=true}}" + |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 152 | "]}"; |
| 153 | ppt = new PoliqarpPlusTree(query); |
| 154 | map = ppt.getRequestMap().get("query").toString(); |
| 155 | assertEquals(cs5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 0207d5e | 2014-02-12 14:18:41 +0000 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | @Test |
Joachim Bingel | 3a41a44 | 2014-07-22 12:16:16 +0000 | [diff] [blame] | 159 | public void testSpans() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 160 | // <s> |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 161 | String elem1 = "{@type=korap:span, key=s}"; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 162 | assertTrue(equalsQueryContent(elem1, "<s>")); |
| 163 | |
| 164 | // <vp> |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 165 | String elem2 = "{@type=korap:span, key=vp}"; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 166 | assertTrue(equalsQueryContent(elem2, "<vp>")); |
Joachim Bingel | fc1fb35 | 2014-02-26 14:40:27 +0000 | [diff] [blame] | 167 | |
| 168 | // <cnx/c=vp> |
| 169 | query = "<c=vp>"; |
| 170 | String span3 = "{@type=korap:span, layer=c, key=vp}"; |
| 171 | ppt = new PoliqarpPlusTree(query); |
| 172 | map = ppt.getRequestMap().get("query").toString(); |
| 173 | assertEquals(span3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 174 | |
| 175 | // <cnx/c=vp> |
| 176 | query = "<cnx/c=vp>"; |
| 177 | String span4 = "{@type=korap:span, foundry=cnx, layer=c, key=vp}"; |
| 178 | ppt = new PoliqarpPlusTree(query); |
| 179 | map = ppt.getRequestMap().get("query").toString(); |
| 180 | assertEquals(span4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 3a41a44 | 2014-07-22 12:16:16 +0000 | [diff] [blame] | 181 | |
| 182 | // span negation |
| 183 | query = "<cnx/c!=vp>"; |
| 184 | expected = "{@type=korap:span, foundry=cnx, layer=c, key=vp, match=match:ne}"; |
| 185 | ppt = new PoliqarpPlusTree(query); |
| 186 | map = ppt.getRequestMap().get("query").toString(); |
| 187 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 188 | |
| 189 | // span negation |
| 190 | query = "<cnx/c!=vp>"; |
| 191 | expected = "{@type=korap:span, foundry=cnx, layer=c, key=vp, match=match:ne}"; |
| 192 | ppt = new PoliqarpPlusTree(query); |
| 193 | map = ppt.getRequestMap().get("query").toString(); |
| 194 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 195 | |
| 196 | query = "<cnx/c=vp class!=header>"; |
| 197 | expected = "{@type=korap:span, foundry=cnx, layer=c, key=vp, attr={@type=korap:term, key=class, value=header, match=match:ne}}"; |
| 198 | ppt = new PoliqarpPlusTree(query); |
| 199 | map = ppt.getRequestMap().get("query").toString(); |
| 200 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 201 | |
| 202 | query = "<cnx/c=vp !(class=header&id=7)>"; |
| 203 | expected = |
| 204 | "{@type=korap:span, foundry=cnx, layer=c, key=vp, attr=" + |
| 205 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 206 | "{@type=korap:term, key=class, value=header, match=match:ne}," + |
| 207 | "{@type=korap:term, key=id, value=7, match=match:ne}" + |
| 208 | "]}" + |
| 209 | "}"; |
| 210 | ppt = new PoliqarpPlusTree(query); |
| 211 | map = ppt.getRequestMap().get("query").toString(); |
| 212 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 213 | |
| 214 | query = "<cnx/c!=vp (class=header&id=7)>"; |
| 215 | expected = |
| 216 | "{@type=korap:span, foundry=cnx, layer=c, key=vp, match=match:ne, attr=" + |
| 217 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 218 | "{@type=korap:term, key=class, value=header, match=match:eq}," + |
| 219 | "{@type=korap:term, key=id, value=7, match=match:eq}" + |
| 220 | "]}" + |
| 221 | "}"; |
| 222 | ppt = new PoliqarpPlusTree(query); |
| 223 | map = ppt.getRequestMap().get("query").toString(); |
| 224 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 225 | |
| 226 | query = "<cnx/c=vp !!class=header>"; |
| 227 | expected = "{@type=korap:span, foundry=cnx, layer=c, key=vp, attr={@type=korap:term, key=class, value=header, match=match:eq}}"; |
| 228 | ppt = new PoliqarpPlusTree(query); |
| 229 | map = ppt.getRequestMap().get("query").toString(); |
| 230 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | a0ef08f | 2014-07-24 08:27:57 +0000 | [diff] [blame] | 231 | |
| 232 | query = "<cnx/c!=vp (foundry/class=header&id=7)>"; |
| 233 | expected = |
| 234 | "{@type=korap:span, foundry=cnx, layer=c, key=vp, match=match:ne, attr=" + |
| 235 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 236 | "{@type=korap:term, foundry=foundry, key=class, value=header, match=match:eq}," + |
| 237 | "{@type=korap:term, key=id, value=7, match=match:eq}" + |
| 238 | "]}" + |
| 239 | "}"; |
| 240 | ppt = new PoliqarpPlusTree(query); |
| 241 | map = ppt.getRequestMap().get("query").toString(); |
| 242 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 243 | } |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 244 | |
| 245 | @Test |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 246 | public void testDistances() throws QueryException { |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 247 | // [base=der][][base=Mann] |
| 248 | String et1 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 249 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 250 | "operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 251 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 252 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 253 | "], inOrder=true, distances=[" + |
Joachim Bingel | 5a146cd | 2014-07-24 14:44:57 +0000 | [diff] [blame] | 254 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 255 | "]}"; |
| 256 | ppt = new PoliqarpPlusTree("[base=der][][base=Mann]"); |
| 257 | map = ppt.getRequestMap().get("query").toString(); |
| 258 | assertEquals(et1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 259 | |
| 260 | // [base=der][][][base=Mann] |
| 261 | String et2 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 262 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 263 | "operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 264 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 265 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 266 | "], inOrder=true, distances=[" + |
Joachim Bingel | 5a146cd | 2014-07-24 14:44:57 +0000 | [diff] [blame] | 267 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=3}, min=3, max=3}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 268 | "]}"; |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 269 | ppt = new PoliqarpPlusTree("[base=der][][][base=Mann]"); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 270 | map = ppt.getRequestMap().get("query").toString(); |
| 271 | assertEquals(et2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 272 | |
| 273 | // [base=der][][]?[base=Mann] |
| 274 | String et3 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 275 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 276 | "operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 277 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 278 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 279 | "], inOrder=true, distances=[" + |
Joachim Bingel | 5a146cd | 2014-07-24 14:44:57 +0000 | [diff] [blame] | 280 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=3}, min=2, max=3}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 281 | "]}"; |
| 282 | ppt = new PoliqarpPlusTree("[base=der][][]?[base=Mann]"); |
| 283 | map = ppt.getRequestMap().get("query").toString(); |
| 284 | assertEquals(et3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 285 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 286 | |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 287 | |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 288 | |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 289 | // [base=der][]{2,5}[base=Mann][]?[][base=Frau] nested distances= |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 290 | String et5 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 291 | "{@type=korap:group, operation=operation:sequence," + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 292 | "operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 293 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 294 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 295 | "operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 296 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," + |
| 297 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Frau, match=match:eq}}" + |
| 298 | "], inOrder=true, distances=[" + |
Joachim Bingel | 5a146cd | 2014-07-24 14:44:57 +0000 | [diff] [blame] | 299 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=3}, min=2, max=3}" + |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 300 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 301 | "], inOrder=true, distances=[" + |
Joachim Bingel | 5a146cd | 2014-07-24 14:44:57 +0000 | [diff] [blame] | 302 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=6}, min=3, max=6}" + |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 303 | "]}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 304 | ppt = new PoliqarpPlusTree("[base=der][]{2,5}[base=Mann][]?[][base=Frau]"); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 305 | map = ppt.getRequestMap().get("query").toString(); |
| 306 | assertEquals(et5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 307 | |
Joachim Bingel | c15720f | 2014-05-07 14:37:23 +0000 | [diff] [blame] | 308 | // [base=der][]*[base=Mann] |
| 309 | String et6 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 310 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | c15720f | 2014-05-07 14:37:23 +0000 | [diff] [blame] | 311 | "operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 312 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 313 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 314 | "], inOrder=true, distances=[" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 315 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1}, min=1}" + |
Joachim Bingel | c15720f | 2014-05-07 14:37:23 +0000 | [diff] [blame] | 316 | "]}"; |
| 317 | ppt = new PoliqarpPlusTree("[base=der][]*[base=Mann]"); |
| 318 | map = ppt.getRequestMap().get("query").toString(); |
| 319 | assertEquals(et6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 320 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 321 | // [base=der][]+[base=Mann] |
Joachim Bingel | c15720f | 2014-05-07 14:37:23 +0000 | [diff] [blame] | 322 | String et7 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 323 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | c15720f | 2014-05-07 14:37:23 +0000 | [diff] [blame] | 324 | "operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 325 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 326 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 327 | "], inOrder=true, distances=[" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 328 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2}, min=2}" + |
Joachim Bingel | c15720f | 2014-05-07 14:37:23 +0000 | [diff] [blame] | 329 | "]}"; |
| 330 | ppt = new PoliqarpPlusTree("[base=der][]+[base=Mann]"); |
| 331 | map = ppt.getRequestMap().get("query").toString(); |
| 332 | assertEquals(et7.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 333 | |
| 334 | // [base=der][]+[base=Mann] |
| 335 | String et8 = |
| 336 | "{@type=korap:group, operation=operation:sequence, " + |
| 337 | "operands=[" + |
| 338 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 339 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 340 | "], inOrder=true, distances=[" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 341 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=103}, min=2, max=103}" + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 342 | "]}"; |
| 343 | ppt = new PoliqarpPlusTree("[base=der][]{1,102}[base=Mann]"); |
| 344 | map = ppt.getRequestMap().get("query").toString(); |
| 345 | assertEquals(et8.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 346 | |
| 347 | // [base=geht][base=der][]*[base=Mann] |
| 348 | String et9 = |
| 349 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 350 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=geht, match=match:eq}}," + |
| 351 | "{@type=korap:group, operation=operation:sequence, " + |
| 352 | "operands=[" + |
| 353 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 354 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 355 | "], inOrder=true, distances=[" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 356 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1}, min=1}" + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 357 | "]}" + |
| 358 | "]}"; |
| 359 | ppt = new PoliqarpPlusTree("[base=geht][base=der][]*[base=Mann]"); |
| 360 | map = ppt.getRequestMap().get("query").toString(); |
| 361 | assertEquals(et9.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 362 | |
| 363 | query = "[base=geht][base=der][]*[base=Mann][base=da]"; |
| 364 | expected = |
| 365 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 366 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=geht, match=match:eq}}," + |
| 367 | "{@type=korap:group, operation=operation:sequence, " + |
| 368 | "operands=[" + |
| 369 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 370 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 371 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," + |
| 372 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=da, match=match:eq}}" + |
| 373 | "]}" + |
| 374 | "], inOrder=true, distances=[" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 375 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1}, min=1}" + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 376 | "]}" + |
| 377 | "]}"; |
| 378 | ppt = new PoliqarpPlusTree(query); |
| 379 | map = ppt.getRequestMap().get("query").toString(); |
| 380 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 381 | |
| 382 | query = "[base=geht][base=der][]*contains(<s>,<np>)"; |
| 383 | expected = |
| 384 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 385 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=geht, match=match:eq}}," + |
| 386 | "{@type=korap:group, operation=operation:sequence, " + |
| 387 | "operands=[" + |
| 388 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 389 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 390 | "{@type=korap:span, key=s}," + |
| 391 | "{@type=korap:span, key=np}" + |
| 392 | "]}" + |
| 393 | "], inOrder=true, distances=[" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 394 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1}, min=1}" + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 395 | "]}" + |
| 396 | "]}"; |
| 397 | ppt = new PoliqarpPlusTree(query); |
| 398 | map = ppt.getRequestMap().get("query").toString(); |
| 399 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 400 | } |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 401 | |
| 402 | @Test |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 403 | public void testLeadingTrailingEmptyTokens() throws QueryException { |
| 404 | // startswith(<s>, [][base=Mann] |
| 405 | String et1 = |
| 406 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 407 | "{@type=korap:span, key=s}," + |
| 408 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 409 | "{@type=korap:token}," + |
| 410 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 411 | "]}" + |
| 412 | "]}"; |
| 413 | ppt = new PoliqarpPlusTree("startswith(<s>, [][base=Mann])"); |
| 414 | map = ppt.getRequestMap().get("query").toString(); |
| 415 | assertEquals(et1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 416 | |
| 417 | query = "[][base=Mann]"; |
| 418 | expected = |
| 419 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 420 | "{@type=korap:token}," + |
| 421 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 422 | "]}"; |
| 423 | ppt = new PoliqarpPlusTree(query); |
| 424 | map = ppt.getRequestMap().get("query").toString(); |
| 425 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 426 | |
| 427 | query = "[][][base=Mann]"; |
| 428 | expected = |
| 429 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 430 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 431 | "{@type=korap:token}" + |
Joachim Bingel | 6163156 | 2014-07-24 14:26:02 +0000 | [diff] [blame] | 432 | "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}," + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 433 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 434 | "]}"; |
| 435 | ppt = new PoliqarpPlusTree(query); |
| 436 | map = ppt.getRequestMap().get("query").toString(); |
| 437 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 438 | |
| 439 | query = "[][]*[base=Mann]"; |
| 440 | expected = |
| 441 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 442 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 443 | "{@type=korap:token}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 444 | "], boundary={@type=korap:boundary, min=1}, min=1}," + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 445 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 446 | "]}"; |
| 447 | ppt = new PoliqarpPlusTree(query); |
| 448 | map = ppt.getRequestMap().get("query").toString(); |
| 449 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 450 | |
| 451 | query = "[][]*[base=Mann][][]"; |
| 452 | expected = |
| 453 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 454 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 455 | "{@type=korap:token}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 456 | "], boundary={@type=korap:boundary, min=1}, min=1}," + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 457 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," + |
| 458 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 459 | "{@type=korap:token}" + |
Joachim Bingel | 6163156 | 2014-07-24 14:26:02 +0000 | [diff] [blame] | 460 | "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}" + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 461 | "]}"; |
| 462 | ppt = new PoliqarpPlusTree(query); |
| 463 | map = ppt.getRequestMap().get("query").toString(); |
| 464 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 465 | |
| 466 | query = "[][]*contains(<s>, <np>)[][]"; |
| 467 | expected = |
| 468 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 469 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 470 | "{@type=korap:token}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 471 | "], boundary={@type=korap:boundary, min=1}, min=1}," + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 472 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 473 | "{@type=korap:span, key=s}," + |
| 474 | "{@type=korap:span, key=np}" + |
| 475 | "]}," + |
| 476 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 477 | "{@type=korap:token}" + |
Joachim Bingel | 6163156 | 2014-07-24 14:26:02 +0000 | [diff] [blame] | 478 | "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}" + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 479 | "]}"; |
| 480 | ppt = new PoliqarpPlusTree(query); |
| 481 | map = ppt.getRequestMap().get("query").toString(); |
| 482 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 483 | } |
| 484 | |
| 485 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 486 | public void testCoordinatedFields() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 487 | // [base=Mann&(cas=N|cas=A)] |
| 488 | String cof1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 489 | "{@type=korap:token, wrap=" + |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 490 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 491 | "{@type=korap:term, layer=lemma, key=Mann, match=match:eq}," + |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 492 | "{@type=korap:termGroup, relation=relation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 493 | "{@type=korap:term, layer=cas, key=N, match=match:eq}," + |
| 494 | "{@type=korap:term, layer=cas, key=A, match=match:eq}" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 495 | "]}" + |
| 496 | "]}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 497 | "}"; |
| 498 | ppt = new PoliqarpPlusTree("[base=Mann&(cas=N|cas=A)]"); |
| 499 | map = ppt.getRequestMap().get("query").toString(); |
| 500 | assertEquals(cof1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Nils Diewald | 7d486c2 | 2013-12-13 16:32:18 +0000 | [diff] [blame] | 501 | |
| 502 | |
| 503 | assertEquals( |
| 504 | new PoliqarpPlusTree(" [ base=Mann & ( cas=N | cas=A)] ").getRequestMap().get("query").toString(), |
| 505 | new PoliqarpPlusTree("[base=Mann &(cas=N|cas=A)]").getRequestMap().get("query").toString() |
| 506 | ); |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 507 | |
| 508 | // [base=Mann&cas=N&gen=m] |
| 509 | String cof2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 510 | "{@type=korap:token, wrap=" + |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 511 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 512 | "{@type=korap:term, layer=lemma, key=Mann, match=match:eq}," + |
| 513 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 514 | "{@type=korap:term, layer=cas, key=N, match=match:eq}," + |
| 515 | "{@type=korap:term, layer=gen, key=m, match=match:eq}" + |
| 516 | "]}" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 517 | "]}" + |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 518 | "}"; |
| 519 | ppt = new PoliqarpPlusTree("[base=Mann&cas=N&gen=m]"); |
| 520 | map = ppt.getRequestMap().get("query").toString(); |
| 521 | assertEquals(cof2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 525 | public void testOccurrence() throws QueryException { |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 526 | // [base=foo]* |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 527 | String occ1 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 528 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 529 | "], boundary={@type=korap:boundary, min=0}, min=0}"; |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 530 | ppt = new PoliqarpPlusTree("[base=foo]*"); |
| 531 | map = ppt.getRequestMap().get("query").toString(); |
| 532 | assertEquals(occ1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 533 | |
| 534 | // [base=foo]*[base=bar] |
| 535 | String occ2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 536 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 537 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 538 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 539 | "], boundary={@type=korap:boundary, min=0}, min=0 }," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 540 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}" + |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 541 | "]}"; |
| 542 | ppt = new PoliqarpPlusTree("[base=foo]*[base=bar]"); |
| 543 | map = ppt.getRequestMap().get("query").toString(); |
| 544 | assertEquals(occ2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 545 | |
| 546 | // [base=bar][base=foo]* |
| 547 | String occ3 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 548 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 549 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 550 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 551 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 552 | "], boundary={@type=korap:boundary, min=0}, min=0 }" + |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 553 | "]}"; |
| 554 | ppt = new PoliqarpPlusTree("[base=bar][base=foo]*"); |
| 555 | map = ppt.getRequestMap().get("query").toString(); |
| 556 | assertEquals(occ3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 557 | |
| 558 | // ([base=bar][base=foo])* |
| 559 | String occ4 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 560 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 561 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 562 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 563 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 564 | "]}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 565 | "], boundary={@type=korap:boundary, min=0}, min=0}" ; |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 566 | ppt = new PoliqarpPlusTree("([base=bar][base=foo])*"); |
| 567 | map = ppt.getRequestMap().get("query").toString(); |
| 568 | assertEquals(occ4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 569 | |
| 570 | // <s>([base=bar][base=foo])* |
| 571 | String occ5 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 572 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 573 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 574 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 575 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 576 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 577 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 578 | "]}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 579 | "], boundary={@type=korap:boundary, min=0}, min=0 }" + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 580 | "]}" ; |
| 581 | ppt = new PoliqarpPlusTree("<s>([base=bar][base=foo])*"); |
| 582 | map = ppt.getRequestMap().get("query").toString(); |
| 583 | assertEquals(occ5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 584 | |
| 585 | // <s><np>([base=bar][base=foo])* |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 586 | String occ6 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 587 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 588 | "{@type=korap:span, key=s}," + |
| 589 | "{@type=korap:span, key=np}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 590 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 591 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 592 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 593 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 594 | "]}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 595 | "], boundary={@type=korap:boundary, min=0}, min=0 }" + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 596 | "]}" ; |
| 597 | ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*"); |
| 598 | map = ppt.getRequestMap().get("query").toString(); |
| 599 | assertEquals(occ6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 600 | |
| 601 | // <s><np>([base=bar][base=foo])*[p=NN] |
| 602 | // comment: embedded sequence shouldn't really be here, but does not really hurt, either. (?) |
| 603 | // really hard to get this behaviour out of the PQPlus grammar... |
| 604 | String occ7 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 605 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 606 | "{@type=korap:span, key=s}," + |
| 607 | "{@type=korap:span, key=np}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 608 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 609 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 610 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 611 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 612 | "]}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 613 | "], boundary={@type=korap:boundary, min=0}, min=0 }," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 614 | "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}" + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 615 | "]}" ; |
| 616 | ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*[p=NN]"); |
| 617 | map = ppt.getRequestMap().get("query").toString(); |
| 618 | assertEquals(occ7.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 619 | |
| 620 | // ([base=bar][base=foo])*[p=NN] |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 621 | String occ8 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 622 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 623 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 624 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 625 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 626 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 627 | "]}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 628 | "], boundary={@type=korap:boundary, min=0}, min=0 }," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 629 | "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}" + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 630 | "]}" ; |
| 631 | ppt = new PoliqarpPlusTree("([base=bar][base=foo])*[p=NN]"); |
| 632 | map = ppt.getRequestMap().get("query").toString(); |
| 633 | assertEquals(occ8.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 634 | |
| 635 | // [base=foo]+ |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 636 | String occ9 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 637 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 638 | "], boundary={@type=korap:boundary, min=1}, min=1}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 639 | ppt = new PoliqarpPlusTree("[base=foo]+"); |
| 640 | map = ppt.getRequestMap().get("query").toString(); |
| 641 | assertEquals(occ9.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 642 | |
| 643 | // [base=foo]? |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 644 | String occ10 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 645 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
Joachim Bingel | 6163156 | 2014-07-24 14:26:02 +0000 | [diff] [blame] | 646 | "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 647 | ppt = new PoliqarpPlusTree("[base=foo]?"); |
| 648 | map = ppt.getRequestMap().get("query").toString(); |
| 649 | assertEquals(occ10.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 650 | |
| 651 | // [base=foo]{2,5} |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 652 | String occ11 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 653 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
Joachim Bingel | 6163156 | 2014-07-24 14:26:02 +0000 | [diff] [blame] | 654 | "], boundary={@type=korap:boundary, min=2, max=5}, min=2, max=5}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 655 | ppt = new PoliqarpPlusTree("[base=foo]{2,5}"); |
| 656 | map = ppt.getRequestMap().get("query").toString(); |
| 657 | assertEquals(occ11.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 658 | |
| 659 | // [base=foo]{2} |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 660 | String occ12 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 661 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
Joachim Bingel | 6163156 | 2014-07-24 14:26:02 +0000 | [diff] [blame] | 662 | "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}"; |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 663 | ppt = new PoliqarpPlusTree("[base=foo]{2}"); |
| 664 | map = ppt.getRequestMap().get("query").toString(); |
| 665 | assertEquals(occ12.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b2aa1c7 | 2014-07-01 12:48:46 +0000 | [diff] [blame] | 666 | |
| 667 | // [base=foo]{2} |
| 668 | String occ13 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 669 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 670 | "], boundary={@type=korap:boundary, min=2}, min=2}"; |
Joachim Bingel | b2aa1c7 | 2014-07-01 12:48:46 +0000 | [diff] [blame] | 671 | ppt = new PoliqarpPlusTree("[base=foo]{2,}"); |
| 672 | map = ppt.getRequestMap().get("query").toString(); |
| 673 | assertEquals(occ13.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 674 | |
| 675 | // [base=foo]{2} |
| 676 | String occ14 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 677 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
Joachim Bingel | 6163156 | 2014-07-24 14:26:02 +0000 | [diff] [blame] | 678 | "], boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}"; |
Joachim Bingel | b2aa1c7 | 2014-07-01 12:48:46 +0000 | [diff] [blame] | 679 | ppt = new PoliqarpPlusTree("[base=foo]{,2}"); |
| 680 | map = ppt.getRequestMap().get("query").toString(); |
| 681 | assertEquals(occ14.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 682 | } |
| 683 | |
| 684 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 685 | public void testTokenSequence() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 686 | // [base=Mann][orth=Frau] |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 687 | String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 688 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " + |
| 689 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 690 | "]}"; |
| 691 | assertTrue(equalsQueryContent(seq1, "[base=Mann][orth=Frau]")); |
| 692 | |
| 693 | // [base=Mann][orth=Frau][p=NN] |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 694 | String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 695 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " + |
| 696 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}, " + |
| 697 | "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 698 | "]}"; |
| 699 | assertTrue(equalsQueryContent(seq2, "[base=Mann][orth=Frau][p=NN]")); |
| 700 | } |
| 701 | |
| 702 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 703 | public void testDisjSegments() throws QueryException { |
Joachim Bingel | 94a1ccd | 2013-12-10 10:37:29 +0000 | [diff] [blame] | 704 | // ([base=der]|[base=das])[base=Schild] |
| 705 | String disj1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 706 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 707 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 708 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 709 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=das, match=match:eq}}" + |
Joachim Bingel | 94a1ccd | 2013-12-10 10:37:29 +0000 | [diff] [blame] | 710 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 711 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Schild, match=match:eq}}" + |
Joachim Bingel | 94a1ccd | 2013-12-10 10:37:29 +0000 | [diff] [blame] | 712 | "]}"; |
| 713 | ppt = new PoliqarpPlusTree("([base=der]|[base=das])[base=Schild]"); |
| 714 | map = ppt.getRequestMap().get("query").toString(); |
| 715 | assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 716 | |
| 717 | // [base=Schild]([base=der]|[base=das]) |
| 718 | String disj2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 719 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 720 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Schild, match=match:eq}}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 721 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 722 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 723 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=das, match=match:eq}}" + |
Joachim Bingel | 94a1ccd | 2013-12-10 10:37:29 +0000 | [diff] [blame] | 724 | "]}" + |
| 725 | "]}"; |
| 726 | ppt = new PoliqarpPlusTree("[base=Schild]([base=der]|[base=das])"); |
| 727 | map = ppt.getRequestMap().get("query").toString(); |
| 728 | assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 76b498d | 2014-06-06 12:06:46 +0000 | [diff] [blame] | 729 | |
| 730 | // "([orth=der][base=katze])|([orth=eine][base=baum])" |
| 731 | String disj3 = |
| 732 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 733 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 734 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 735 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=katze, match=match:eq}}" + |
Joachim Bingel | 76b498d | 2014-06-06 12:06:46 +0000 | [diff] [blame] | 736 | "]}," + |
| 737 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 738 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=eine, match=match:eq}}," + |
| 739 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=baum, match=match:eq}}" + |
Joachim Bingel | 76b498d | 2014-06-06 12:06:46 +0000 | [diff] [blame] | 740 | "]}" + |
| 741 | "]}"; |
| 742 | ppt = new PoliqarpPlusTree("([orth=der][base=katze])|([orth=eine][base=baum])"); |
| 743 | map = ppt.getRequestMap().get("query").toString(); |
| 744 | assertEquals(disj3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 745 | |
| 746 | // "[orth=der][base=katze]|[orth=eine][base=baum]" |
| 747 | String disj4 = |
| 748 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 749 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 750 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 751 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=katze, match=match:eq}}" + |
Joachim Bingel | 76b498d | 2014-06-06 12:06:46 +0000 | [diff] [blame] | 752 | "]}," + |
| 753 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 754 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=eine, match=match:eq}}," + |
| 755 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=baum, match=match:eq}}" + |
Joachim Bingel | 76b498d | 2014-06-06 12:06:46 +0000 | [diff] [blame] | 756 | "]}" + |
| 757 | "]}"; |
| 758 | ppt = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=eine][base=baum]"); |
| 759 | map = ppt.getRequestMap().get("query").toString(); |
| 760 | assertEquals(disj4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 761 | |
| 762 | PoliqarpPlusTree ppt1 = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=eine][base=baum]"); |
| 763 | PoliqarpPlusTree ppt2 = new PoliqarpPlusTree("([orth=der][base=katze])|([orth=eine][base=baum])"); |
| 764 | assertEquals(ppt1.getRequestMap().toString(), ppt2.getRequestMap().toString()); |
| 765 | |
| 766 | // "[orth=der][base=katze]|[orth=der][base=hund]|[orth=der][base=baum]" |
| 767 | String disj5 = |
| 768 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 769 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 770 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 771 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=katze, match=match:eq}}" + |
Joachim Bingel | 76b498d | 2014-06-06 12:06:46 +0000 | [diff] [blame] | 772 | "]}," + |
| 773 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 774 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 775 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=hund, match=match:eq}}" + |
Joachim Bingel | 76b498d | 2014-06-06 12:06:46 +0000 | [diff] [blame] | 776 | "]}," + |
| 777 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 778 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 779 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=baum, match=match:eq}}" + |
Joachim Bingel | 76b498d | 2014-06-06 12:06:46 +0000 | [diff] [blame] | 780 | "]}" + |
| 781 | "]}"; |
| 782 | ppt = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=der][base=hund]|[orth=der][base=baum]"); |
| 783 | map = ppt.getRequestMap().get("query").toString(); |
| 784 | assertEquals(disj5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 785 | |
| 786 | // [orth=der]([base=katze]|[base=hund]|[base=baum]) |
| 787 | String disj6 = |
| 788 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 789 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
Joachim Bingel | 76b498d | 2014-06-06 12:06:46 +0000 | [diff] [blame] | 790 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 791 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=katze, match=match:eq}}," + |
| 792 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=hund, match=match:eq}}," + |
| 793 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=baum, match=match:eq}}" + |
Joachim Bingel | 76b498d | 2014-06-06 12:06:46 +0000 | [diff] [blame] | 794 | "]}" + |
| 795 | "]}"; |
| 796 | ppt = new PoliqarpPlusTree("[orth=der]([base=katze]|[base=hund]|[base=baum])"); |
| 797 | map = ppt.getRequestMap().get("query").toString(); |
| 798 | assertEquals(disj6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 94a1ccd | 2013-12-10 10:37:29 +0000 | [diff] [blame] | 799 | } |
| 800 | |
| 801 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 802 | public void testTokenElemSequence() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 803 | // [base=Mann]<vp> |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 804 | String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 805 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 806 | "{@type=korap:span, key=vp}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 807 | "]}"; |
| 808 | assertTrue(equalsQueryContent(seq1, "[base=Mann]<vp>")); |
| 809 | |
| 810 | // <vp>[base=Mann] |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 811 | String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 812 | "{@type=korap:span, key=vp}, "+ |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 813 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}} " + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 814 | "]}"; |
| 815 | assertTrue(equalsQueryContent(seq2, "<vp>[base=Mann]")); |
| 816 | |
| 817 | // <vp>[base=Mann]<pp> |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 818 | String seq3 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 819 | "{@type=korap:span, key=vp}, "+ |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 820 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 821 | "{@type=korap:span, key=pp} "+ |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 822 | "]}"; |
| 823 | assertTrue(equalsQueryContent(seq3, "<vp>[base=Mann]<pp>")); |
| 824 | } |
| 825 | |
| 826 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 827 | public void testElemSequence() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 828 | // <np><vp> |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 829 | String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 830 | "{@type=korap:span, key=np}," + |
| 831 | "{@type=korap:span, key=vp}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 832 | "]}"; |
| 833 | assertTrue(equalsQueryContent(seq1, "<np><vp>")); |
| 834 | |
| 835 | // <np><vp><pp> |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 836 | String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 837 | "{@type=korap:span, key=np}," + |
| 838 | "{@type=korap:span, key=vp}," + |
| 839 | "{@type=korap:span, key=pp}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 840 | "]}"; |
| 841 | assertTrue(equalsQueryContent(seq2, "<np><vp><pp>")); |
| 842 | } |
| 843 | |
| 844 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 845 | public void testClasses() throws QueryException { |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 846 | String query; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 847 | // {[base=Mann]} |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 848 | String cls1 = "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 849 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 850 | "]}"; |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 851 | ppt = new PoliqarpPlusTree("{[base=Mann]}"); |
| 852 | map = ppt.getRequestMap().get("query").toString(); |
| 853 | assertEquals(cls1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 854 | |
| 855 | // {[base=Mann][orth=Frau]} |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 856 | query = "{[base=Mann][orth=Frau]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 857 | String cls2 = "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 858 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 859 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," + |
| 860 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 861 | "]}" + |
| 862 | "]}"; |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 863 | ppt = new PoliqarpPlusTree(query); |
| 864 | map = ppt.getRequestMap().get("query").toString(); |
| 865 | assertEquals(cls2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 866 | |
| 867 | // [p=NN]{[base=Mann][orth=Frau]} |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 868 | String cls3 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 869 | "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 870 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 871 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 872 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," + |
| 873 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 874 | "]}" + |
| 875 | "]}" + |
| 876 | "]}"; |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 877 | ppt = new PoliqarpPlusTree("[p=NN]{[base=Mann][orth=Frau]}"); |
| 878 | map = ppt.getRequestMap().get("query").toString(); |
| 879 | assertEquals(cls3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 880 | |
| 881 | // {[base=Mann][orth=Frau]}[p=NN] |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 882 | String cls4 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 883 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 884 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 885 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," + |
| 886 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 887 | "]}" + |
| 888 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 889 | "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 890 | "]}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 891 | ppt = new PoliqarpPlusTree("{[base=Mann][orth=Frau]}[p=NN]"); |
| 892 | map = ppt.getRequestMap().get("query").toString(); |
| 893 | assertEquals(cls4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 894 | |
| 895 | // {2:{1:[tt/p=ADJA]}[mate/p=NN]}" |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 896 | String cls5 = "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 897 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 898 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 899 | "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=p, key=ADJA, match=match:eq}}" + |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 900 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 901 | "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=p, key=NN, match=match:eq}}" + |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 902 | "]}" + |
| 903 | "]}"; |
| 904 | ppt = new PoliqarpPlusTree("{2: {1:[tt/p=ADJA]}[mate/p=NN]}"); |
| 905 | map = ppt.getRequestMap().get("query").toString(); |
| 906 | assertEquals(cls5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 907 | } |
| 908 | |
| 909 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 910 | public void testPositions() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 911 | // contains(<s>,<np>) |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 912 | String pos1 = "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 913 | "{@type=korap:span, key=s}," + |
| 914 | "{@type=korap:span, key=np}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 915 | "]}"; |
| 916 | assertTrue(equalsQueryContent(pos1, "contains(<s>,<np>)")); |
| 917 | |
| 918 | // contains(<s>,[base=Mann]) |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 919 | String pos2 = "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 920 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 921 | "{@type=korap:token, wrap= {@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 922 | "]}"; |
| 923 | assertTrue(equalsQueryContent(pos2, "contains(<s>,[base=Mann])")); |
| 924 | |
| 925 | // contains(<s>,[orth=der][orth=Mann]) |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 926 | String pos3 = "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 927 | "{@type=korap:span, key=s}," + |
| 928 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 929 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 930 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 931 | "]}" + |
| 932 | "]}"; |
| 933 | ppt = new PoliqarpPlusTree("contains(<s>,[orth=der][orth=Mann])"); |
| 934 | map = ppt.getRequestMap().get("query").toString(); |
| 935 | assertEquals(pos3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 936 | |
| 937 | // [base=Auto]contains(<s>,[base=Mann]) |
| 938 | String pos4 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 939 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 940 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Auto, match=match:eq}}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 941 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 942 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 943 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 944 | "]}" + |
| 945 | "]}"; |
| 946 | ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[base=Mann])"); |
| 947 | map = ppt.getRequestMap().get("query").toString(); |
| 948 | assertEquals(pos4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | ef7059b | 2014-04-22 13:44:19 +0000 | [diff] [blame] | 949 | |
| 950 | // contains(<s>,[pos=N]*) |
| 951 | String pos5 = |
| 952 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 953 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 954 | "{@type=korap:group, operation=operation:repetition, " + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 955 | "operands=[{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 956 | "], boundary={@type=korap:boundary, min=0}, min=0" + |
Joachim Bingel | ef7059b | 2014-04-22 13:44:19 +0000 | [diff] [blame] | 957 | "}" + |
| 958 | "]}"; |
| 959 | ppt = new PoliqarpPlusTree("contains(<s>,[pos=N]*)"); |
| 960 | map = ppt.getRequestMap().get("query").toString(); |
| 961 | assertEquals(pos5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 962 | |
| 963 | // [base=Auto]contains(<s>,[pos=N]*) |
| 964 | String pos6 = |
| 965 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 966 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Auto, match=match:eq}}," + |
Joachim Bingel | ef7059b | 2014-04-22 13:44:19 +0000 | [diff] [blame] | 967 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 968 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 969 | "{@type=korap:group, operation=operation:repetition, " + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 970 | "operands=[{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 971 | "], boundary={@type=korap:boundary, min=0}, min=0" + |
Joachim Bingel | ef7059b | 2014-04-22 13:44:19 +0000 | [diff] [blame] | 972 | "}" + |
| 973 | "]}" + |
| 974 | "]}"; |
| 975 | ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[pos=N]*)"); |
| 976 | map = ppt.getRequestMap().get("query").toString(); |
| 977 | assertEquals(pos6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 978 | } |
| 979 | |
| 980 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 981 | public void testNestedPositions() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 982 | // contains(<s>,startswith(<np>,[orth=Der])) |
| 983 | String npos1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 984 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 985 | "{@type=korap:span, key=s}," + |
| 986 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 987 | "{@type=korap:span, key=np}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 988 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 989 | "]}" + |
| 990 | "]}"; |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 991 | ppt = new PoliqarpPlusTree("contains(<s>, startswith(<np>,[orth=Der]))"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 992 | map = ppt.getRequestMap().get("query").toString(); |
| 993 | assertEquals(npos1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 994 | } |
| 995 | |
| 996 | @Test |
Joachim Bingel | 23c31ad | 2014-08-11 09:44:46 +0000 | [diff] [blame] | 997 | public void testFocusSplit() throws QueryException { |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 998 | // focus([orth=Der]{[orth=Mann]}) |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 999 | String shr1 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1000 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1001 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1002 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1003 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1004 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1005 | "]}" + |
| 1006 | "]}" + |
| 1007 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 1008 | ppt = new PoliqarpPlusTree("focus([orth=Der]{[orth=Mann]})"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1009 | map = ppt.getRequestMap().get("query").toString(); |
| 1010 | assertEquals(shr1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1011 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1012 | // focus([orth=Der]{[orth=Mann][orth=geht]}) |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1013 | String shr2 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1014 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1015 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1016 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1017 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 1018 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1019 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}," + |
| 1020 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=geht, match=match:eq}}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1021 | "]}" + |
| 1022 | "]}" + |
| 1023 | "]}" + |
| 1024 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 1025 | ppt = new PoliqarpPlusTree("focus([orth=Der]{[orth=Mann][orth=geht]})"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1026 | map = ppt.getRequestMap().get("query").toString(); |
| 1027 | assertEquals(shr2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1028 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1029 | // focus(1:[orth=Der]{1:[orth=Mann][orth=geht]}) |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1030 | String shr3 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1031 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1032 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1033 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1034 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1035 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1036 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}," + |
| 1037 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=geht, match=match:eq}}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1038 | "]}" + |
| 1039 | "]}" + |
| 1040 | "]}" + |
| 1041 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 1042 | ppt = new PoliqarpPlusTree("focus(1:[orth=Der]{1:[orth=Mann][orth=geht]})"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1043 | map = ppt.getRequestMap().get("query").toString(); |
| 1044 | assertEquals(shr3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1045 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1046 | // focus(1:startswith(<s>,{1:<np>})) |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1047 | String shr4 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1048 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1049 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 1050 | "{@type=korap:span, key=s}," + |
| 1051 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1052 | "{@type=korap:span, key=np}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1053 | "]}" + |
| 1054 | "]}" + |
| 1055 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 1056 | ppt = new PoliqarpPlusTree("focus(1:startswith(<s>,{1:<np>}))"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1057 | map = ppt.getRequestMap().get("query").toString(); |
| 1058 | assertEquals(shr4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 1059 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1060 | // focus(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] | 1061 | String shr5 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1062 | "{@type=korap:reference, operation=operation:focus, classRef=[3], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1063 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 1064 | "{@type=korap:span, key=s}," + |
| 1065 | "{@type=korap:group, operation=operation:class, class=3, operands=[" + |
| 1066 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1067 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1068 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1069 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1070 | "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=p, key=ADJA, match=match:eq}}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1071 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1072 | "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=p, key=NN, match=match:eq}}" + |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 1073 | "]}" + |
| 1074 | "]}" + |
| 1075 | "]}" + |
| 1076 | "]}" + |
| 1077 | "]}" + |
| 1078 | "]}" + |
| 1079 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 1080 | ppt = new PoliqarpPlusTree("focus(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] | 1081 | map = ppt.getRequestMap().get("query").toString(); |
| 1082 | assertEquals(shr5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 1083 | |
| 1084 | // split(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) |
| 1085 | String shr6 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1086 | "{@type=korap:reference, operation=operation:split, classRef=[3], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1087 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 1088 | "{@type=korap:span, key=s}," + |
| 1089 | "{@type=korap:group, operation=operation:class, class=3, operands=[" + |
| 1090 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1091 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1092 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1093 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1094 | "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=p, key=ADJA, match=match:eq}}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1095 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1096 | "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=p, key=NN, match=match:eq}}" + |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 1097 | "]}" + |
| 1098 | "]}" + |
| 1099 | "]}" + |
| 1100 | "]}" + |
| 1101 | "]}" + |
| 1102 | "]}" + |
| 1103 | "]}"; |
| 1104 | ppt = new PoliqarpPlusTree("split(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) "); |
| 1105 | map = ppt.getRequestMap().get("query").toString(); |
| 1106 | assertEquals(shr6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 1107 | |
| 1108 | // split(2|3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) |
| 1109 | String shr7 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1110 | "{@type=korap:reference, operation=operation:split, classRef=[2, 3], classRefOp=classRefOp:intersection, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1111 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 1112 | "{@type=korap:span, key=s}," + |
| 1113 | "{@type=korap:group, operation=operation:class, class=3, operands=[" + |
| 1114 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1115 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1116 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1117 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1118 | "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=p, key=ADJA, match=match:eq}}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1119 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1120 | "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=p, key=NN, match=match:eq}}" + |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 1121 | "]}" + |
| 1122 | "]}" + |
| 1123 | "]}" + |
| 1124 | "]}" + |
| 1125 | "]}" + |
| 1126 | "]}" + |
| 1127 | "]}"; |
| 1128 | ppt = new PoliqarpPlusTree("split(2|3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) "); |
| 1129 | map = ppt.getRequestMap().get("query").toString(); |
| 1130 | assertEquals(shr7.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 5146ebe | 2014-06-12 08:49:21 +0000 | [diff] [blame] | 1131 | |
| 1132 | |
| 1133 | String shr8 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1134 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | add0fb1 | 2014-06-24 08:54:14 +0000 | [diff] [blame] | 1135 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1136 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1137 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}" + |
Joachim Bingel | add0fb1 | 2014-06-24 08:54:14 +0000 | [diff] [blame] | 1138 | "]}," + |
| 1139 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1140 | "{@type=korap:token, wrap={@type=korap:term, layer=pos, key=ADJA, match=match:eq}}" + |
Joachim Bingel | 5146ebe | 2014-06-12 08:49:21 +0000 | [diff] [blame] | 1141 | "]}" + |
Joachim Bingel | add0fb1 | 2014-06-24 08:54:14 +0000 | [diff] [blame] | 1142 | "]}" + |
| 1143 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 1144 | ppt = new PoliqarpPlusTree("focus(1:{[base=der]}{1:[pos=ADJA]})"); |
Joachim Bingel | add0fb1 | 2014-06-24 08:54:14 +0000 | [diff] [blame] | 1145 | map = ppt.getRequestMap().get("query").toString(); |
| 1146 | assertEquals(shr8.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 5146ebe | 2014-06-12 08:49:21 +0000 | [diff] [blame] | 1147 | |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1148 | } |
| 1149 | |
Joachim Bingel | 23c31ad | 2014-08-11 09:44:46 +0000 | [diff] [blame] | 1150 | @Test |
| 1151 | public void testSubspan() throws QueryException { |
Joachim Bingel | 9bbd4fc | 2014-08-11 14:56:48 +0000 | [diff] [blame] | 1152 | query = "submatch(1,:<s>)"; |
Joachim Bingel | 23c31ad | 2014-08-11 09:44:46 +0000 | [diff] [blame] | 1153 | expected = |
| 1154 | "{@type=korap:reference, operation=operation:focus, operands=[" + |
| 1155 | "{@type=korap:span, key=s}" + |
| 1156 | "], spanRef=[1]" + |
| 1157 | "}"; |
| 1158 | ppt = new PoliqarpPlusTree(query); |
| 1159 | map = ppt.getRequestMap().get("query").toString(); |
| 1160 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1161 | |
Joachim Bingel | 9bbd4fc | 2014-08-11 14:56:48 +0000 | [diff] [blame] | 1162 | query = "submatch(1,4:<s>)"; |
Joachim Bingel | 23c31ad | 2014-08-11 09:44:46 +0000 | [diff] [blame] | 1163 | expected = |
| 1164 | "{@type=korap:reference, operation=operation:focus, operands=[" + |
| 1165 | "{@type=korap:span, key=s}" + |
| 1166 | "], spanRef=[1,4]" + |
| 1167 | "}"; |
| 1168 | ppt = new PoliqarpPlusTree(query); |
| 1169 | map = ppt.getRequestMap().get("query").toString(); |
| 1170 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1171 | |
Joachim Bingel | 9bbd4fc | 2014-08-11 14:56:48 +0000 | [diff] [blame] | 1172 | query = "submatch(1,4:contains(<s>,[base=Haus]))"; |
Joachim Bingel | 23c31ad | 2014-08-11 09:44:46 +0000 | [diff] [blame] | 1173 | expected = |
| 1174 | "{@type=korap:reference, operation=operation:focus, operands=[" + |
| 1175 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 1176 | "{@type=korap:span, key=s}," + |
| 1177 | "{@type=korap:token, wrap= {@type=korap:term, layer=lemma, key=Haus, match=match:eq}}" + |
| 1178 | "]}" + |
| 1179 | "], spanRef=[1,4]" + |
| 1180 | "}"; |
| 1181 | ppt = new PoliqarpPlusTree(query); |
| 1182 | map = ppt.getRequestMap().get("query").toString(); |
| 1183 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1184 | } |
| 1185 | |
| 1186 | @Test |
| 1187 | public void testRelations() throws QueryException { |
| 1188 | query = "relatesTo(<s>,<np>)"; |
| 1189 | expected = |
| 1190 | "{@type=korap:group, operation=operation:relation, operands=[" + |
| 1191 | "{@type=korap:span, key=s}," + |
| 1192 | "{@type=korap:span, key=np}" + |
| 1193 | "], relation={@type=korap:relation}" + |
| 1194 | "}"; |
| 1195 | ppt = new PoliqarpPlusTree(query); |
| 1196 | map = ppt.getRequestMap().get("query").toString(); |
| 1197 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1198 | |
| 1199 | query = "relatesTo([base=Baum],<np>)"; |
| 1200 | expected = |
| 1201 | "{@type=korap:group, operation=operation:relation, operands=[" + |
| 1202 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}," + |
| 1203 | "{@type=korap:span, key=np}" + |
| 1204 | "], relation={@type=korap:relation}" + |
| 1205 | "}"; |
| 1206 | ppt = new PoliqarpPlusTree(query); |
| 1207 | map = ppt.getRequestMap().get("query").toString(); |
| 1208 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1209 | |
| 1210 | query = "dominates(<np>,[base=Baum])"; |
| 1211 | expected = |
| 1212 | "{@type=korap:group, operation=operation:relation, operands=[" + |
| 1213 | "{@type=korap:span, key=np}," + |
| 1214 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" + |
| 1215 | "], relation={@type=korap:relation, layer=c}" + |
| 1216 | "}"; |
| 1217 | ppt = new PoliqarpPlusTree(query); |
| 1218 | map = ppt.getRequestMap().get("query").toString(); |
| 1219 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1220 | |
| 1221 | query = "dominates(cnx/c:<np>,[base=Baum])"; |
| 1222 | expected = |
| 1223 | "{@type=korap:group, operation=operation:relation, operands=[" + |
| 1224 | "{@type=korap:span, key=np}," + |
| 1225 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" + |
| 1226 | "], relation={@type=korap:relation, layer=c, foundry=cnx}" + |
| 1227 | "}"; |
| 1228 | ppt = new PoliqarpPlusTree(query); |
| 1229 | map = ppt.getRequestMap().get("query").toString(); |
| 1230 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1231 | |
| 1232 | query = "dominates(cnx/c*:<np>,[base=Baum])"; |
| 1233 | expected = |
| 1234 | "{@type=korap:group, operation=operation:relation, operands=[" + |
| 1235 | "{@type=korap:span, key=np}," + |
| 1236 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" + |
| 1237 | "], relation={@type=korap:relation, layer=c, foundry=cnx, boundary={@type=korap:boundary, min=0}}" + |
| 1238 | "}"; |
| 1239 | ppt = new PoliqarpPlusTree(query); |
| 1240 | map = ppt.getRequestMap().get("query").toString(); |
| 1241 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1242 | |
| 1243 | query = "dominates(cnx/c{1,5}:<np>,[base=Baum])"; |
| 1244 | expected = |
| 1245 | "{@type=korap:group, operation=operation:relation, operands=[" + |
| 1246 | "{@type=korap:span, key=np}," + |
| 1247 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" + |
| 1248 | "], relation={@type=korap:relation, layer=c, foundry=cnx, boundary={@type=korap:boundary, min=1, max=5}}" + |
| 1249 | "}"; |
| 1250 | ppt = new PoliqarpPlusTree(query); |
| 1251 | map = ppt.getRequestMap().get("query").toString(); |
| 1252 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1253 | |
| 1254 | query = "relatesTo(mate/d=HEAD:<np>,[base=Baum])"; |
| 1255 | expected = |
| 1256 | "{@type=korap:group, operation=operation:relation, operands=[" + |
| 1257 | "{@type=korap:span, key=np}," + |
| 1258 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" + |
| 1259 | "], relation={@type=korap:relation, foundry=mate, layer=d, key=HEAD}" + |
| 1260 | "}"; |
| 1261 | ppt = new PoliqarpPlusTree(query); |
| 1262 | map = ppt.getRequestMap().get("query").toString(); |
| 1263 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1264 | |
| 1265 | } |
| 1266 | |
| 1267 | |
Joachim Bingel | 0388270 | 2013-12-31 19:53:05 +0000 | [diff] [blame] | 1268 | |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1269 | @Test |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 1270 | public void testFoundries() throws QueryException { |
| 1271 | // [tt/base=Mann] |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1272 | String layer1 = "{@type=korap:token, wrap={@type=korap:term, foundry=tt, layer=lemma, key=Mann, match=match:eq}}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 1273 | ppt = new PoliqarpPlusTree("[tt/base=Mann]"); |
| 1274 | map = ppt.getRequestMap().get("query").toString(); |
| 1275 | assertEquals(layer1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1276 | |
| 1277 | } |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1278 | |
| 1279 | @Test |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 1280 | public void testAlign() throws QueryException { |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1281 | // [orth=der]^[orth=Mann] |
| 1282 | String align1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1283 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1284 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 1285 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
| 1286 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" + |
| 1287 | "], align=align:left}" + |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1288 | "]}"; |
| 1289 | ppt = new PoliqarpPlusTree("[orth=der]^[orth=Mann]"); |
| 1290 | map = ppt.getRequestMap().get("query").toString(); |
| 1291 | assertEquals(align1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1292 | |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 1293 | // [orth=der]^[orth=große][orth=Mann] |
| 1294 | String query = "[orth=der]^[orth=große][orth=Mann]"; |
| 1295 | String align1b = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1296 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1297 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 1298 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1299 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1300 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=große, match=match:eq}}," + |
| 1301 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" + |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 1302 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1303 | "], align=align:left}" + |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 1304 | "]}"; |
| 1305 | ppt = new PoliqarpPlusTree(query); |
| 1306 | map = ppt.getRequestMap().get("query").toString(); |
| 1307 | assertEquals(align1b.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1308 | |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1309 | // "([base=a]^[base=b])|[base=c]", |
| 1310 | String align2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1311 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 1312 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1313 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=a, match=match:eq}}," + |
| 1314 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
| 1315 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=b, match=match:eq}}" + |
| 1316 | "], align=align:left}" + |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1317 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1318 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=c, match=match:eq}}" + |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1319 | "]}"; |
| 1320 | ppt = new PoliqarpPlusTree("([base=a]^[base=b])|[base=c]"); |
| 1321 | map = ppt.getRequestMap().get("query").toString(); |
| 1322 | assertEquals(align2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1323 | |
| 1324 | // "([base=a]^[base=b][base=c])|[base=d]", |
| 1325 | String align3 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1326 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 1327 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1328 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=a, match=match:eq}}," + |
| 1329 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1330 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1331 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=b, match=match:eq}}," + |
| 1332 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=c, match=match:eq}}" + |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 1333 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1334 | "], align=align:left}" + |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1335 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1336 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=d, match=match:eq}}" + |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1337 | "]}"; |
| 1338 | ppt = new PoliqarpPlusTree("([base=a]^[base=b][base=c])|[base=d]"); |
| 1339 | map = ppt.getRequestMap().get("query").toString(); |
| 1340 | assertEquals(align3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1341 | |
| 1342 | // "([base=a]^[base=b]^[base=c])|[base=d]", |
| 1343 | String align4 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1344 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 1345 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1346 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=a, match=match:eq}}," + |
| 1347 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1348 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1349 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=b, match=match:eq}}," + |
| 1350 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
| 1351 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=c, match=match:eq}}" + |
| 1352 | "], align=align:left}" + |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 1353 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1354 | "], align=align:left}" + |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1355 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1356 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=d, match=match:eq}}" + |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1357 | "]}"; |
| 1358 | ppt = new PoliqarpPlusTree("([base=a]^[base=b]^[base=c])|[base=d]"); |
| 1359 | map = ppt.getRequestMap().get("query").toString(); |
| 1360 | assertEquals(align4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1361 | |
| 1362 | |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1363 | } |
| 1364 | |
| 1365 | @Test |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 1366 | public void testSimpleQueries() throws QueryException { |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1367 | // Baum |
| 1368 | String simple1 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1369 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}"; |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1370 | ppt = new PoliqarpPlusTree("Baum"); |
| 1371 | map = ppt.getRequestMap().get("query").toString(); |
| 1372 | assertEquals(simple1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1373 | |
| 1374 | // Baum/i |
| 1375 | String simple1b = |
| 1376 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq, caseInsensitive=true}}"; |
| 1377 | ppt = new PoliqarpPlusTree("Baum/i"); |
| 1378 | map = ppt.getRequestMap().get("query").toString(); |
| 1379 | assertEquals(simple1b.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1380 | |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1381 | // Der Baum |
| 1382 | String simple2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1383 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1384 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " + |
| 1385 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}" + |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1386 | "]}"; |
| 1387 | ppt = new PoliqarpPlusTree("Der Baum"); |
| 1388 | map = ppt.getRequestMap().get("query").toString(); |
| 1389 | assertEquals(simple2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1390 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1391 | // Der Baum/i |
| 1392 | String simple2b = |
| 1393 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1394 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " + |
| 1395 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq, caseInsensitive=true}}" + |
| 1396 | "]}"; |
| 1397 | ppt = new PoliqarpPlusTree("Der Baum/i"); |
| 1398 | map = ppt.getRequestMap().get("query").toString(); |
| 1399 | assertEquals(simple2b.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1400 | |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1401 | // Der große Baum |
| 1402 | String simple3 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1403 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1404 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " + |
| 1405 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=große, match=match:eq}}, " + |
| 1406 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}" + |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1407 | "]}"; |
| 1408 | ppt = new PoliqarpPlusTree("Der große Baum"); |
| 1409 | map = ppt.getRequestMap().get("query").toString(); |
| 1410 | assertEquals(simple3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1411 | |
| 1412 | // Baum | Stein |
| 1413 | String simple4 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1414 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1415 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}, " + |
| 1416 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Stein, match=match:eq}}" + |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1417 | "]}"; |
| 1418 | ppt = new PoliqarpPlusTree("Baum | Stein"); |
| 1419 | map = ppt.getRequestMap().get("query").toString(); |
| 1420 | assertEquals(simple4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 1421 | |
| 1422 | // Baum | Stein Haus |
| 1423 | String query = "(Baum | Stein) Haus"; |
| 1424 | String simple5 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1425 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1426 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1427 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}, " + |
| 1428 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Stein, match=match:eq}}" + |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 1429 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1430 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Haus, match=match:eq}} " + |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 1431 | "]}"; |
| 1432 | ppt = new PoliqarpPlusTree(query); |
| 1433 | map = ppt.getRequestMap().get("query").toString(); |
| 1434 | assertEquals(simple5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1435 | } |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1436 | } |
| 1437 | |