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}}," + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 389 | "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 390 | "{@type=korap:span, key=s}," + |
| 391 | "{@type=korap:span, key=np}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 392 | "], frame=frame:contains}" + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 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 | bd38636 | 2014-10-02 12:03:18 +0000 | [diff] [blame] | 403 | public void testDistancesWithClass() throws QueryException { |
| 404 | query = "[base=der]{1:[]}[base=Mann]"; |
| 405 | expected = |
| 406 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 407 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 408 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 409 | "{@type=korap:token}" + |
| 410 | "]}," + |
| 411 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 412 | "]}"; |
| 413 | ppt = new PoliqarpPlusTree(query); |
| 414 | map = ppt.getRequestMap().get("query").toString(); |
| 415 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 416 | |
| 417 | query = "{1:[]}[base=der][base=Mann]"; |
| 418 | expected = |
| 419 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 420 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 421 | "{@type=korap:token}" + |
| 422 | "]}," + |
| 423 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 424 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 425 | "]}"; |
| 426 | ppt = new PoliqarpPlusTree(query); |
| 427 | map = ppt.getRequestMap().get("query").toString(); |
| 428 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 429 | } |
| 430 | |
| 431 | @Test |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 432 | public void testLeadingTrailingEmptyTokens() throws QueryException { |
| 433 | // startswith(<s>, [][base=Mann] |
| 434 | String et1 = |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 435 | "{@type=korap:group, operation=operation:position, frames=[frame:startswith],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 436 | "{@type=korap:span, key=s}," + |
| 437 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 438 | "{@type=korap:token}," + |
| 439 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 440 | "]}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 441 | "], frame=frame:startswith}"; |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 442 | ppt = new PoliqarpPlusTree("startswith(<s>, [][base=Mann])"); |
| 443 | map = ppt.getRequestMap().get("query").toString(); |
| 444 | assertEquals(et1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 445 | |
| 446 | query = "[][base=Mann]"; |
| 447 | expected = |
| 448 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 449 | "{@type=korap:token}," + |
| 450 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 451 | "]}"; |
| 452 | ppt = new PoliqarpPlusTree(query); |
| 453 | map = ppt.getRequestMap().get("query").toString(); |
| 454 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 455 | |
| 456 | query = "[][][base=Mann]"; |
| 457 | expected = |
| 458 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 459 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 460 | "{@type=korap:token}" + |
Joachim Bingel | 6163156 | 2014-07-24 14:26:02 +0000 | [diff] [blame] | 461 | "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}," + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 462 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 463 | "]}"; |
| 464 | ppt = new PoliqarpPlusTree(query); |
| 465 | map = ppt.getRequestMap().get("query").toString(); |
| 466 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 467 | |
| 468 | query = "[][]*[base=Mann]"; |
| 469 | expected = |
| 470 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 471 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 472 | "{@type=korap:token}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 473 | "], boundary={@type=korap:boundary, min=1}, min=1}," + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 474 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 475 | "]}"; |
| 476 | ppt = new PoliqarpPlusTree(query); |
| 477 | map = ppt.getRequestMap().get("query").toString(); |
| 478 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 479 | |
| 480 | query = "[][]*[base=Mann][][]"; |
| 481 | expected = |
| 482 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 483 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 484 | "{@type=korap:token}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 485 | "], boundary={@type=korap:boundary, min=1}, min=1}," + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 486 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," + |
| 487 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 488 | "{@type=korap:token}" + |
Joachim Bingel | 6163156 | 2014-07-24 14:26:02 +0000 | [diff] [blame] | 489 | "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}" + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 490 | "]}"; |
| 491 | ppt = new PoliqarpPlusTree(query); |
| 492 | map = ppt.getRequestMap().get("query").toString(); |
| 493 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 494 | |
| 495 | query = "[][]*contains(<s>, <np>)[][]"; |
| 496 | expected = |
| 497 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 498 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 499 | "{@type=korap:token}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 500 | "], boundary={@type=korap:boundary, min=1}, min=1}," + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 501 | "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 502 | "{@type=korap:span, key=s}," + |
| 503 | "{@type=korap:span, key=np}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 504 | "], frame=frame:contains}," + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 505 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 506 | "{@type=korap:token}" + |
Joachim Bingel | 6163156 | 2014-07-24 14:26:02 +0000 | [diff] [blame] | 507 | "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}" + |
Joachim Bingel | 14239d8 | 2014-07-22 09:55:04 +0000 | [diff] [blame] | 508 | "]}"; |
| 509 | ppt = new PoliqarpPlusTree(query); |
| 510 | map = ppt.getRequestMap().get("query").toString(); |
| 511 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 512 | } |
| 513 | |
| 514 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 515 | public void testCoordinatedFields() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 516 | // [base=Mann&(cas=N|cas=A)] |
| 517 | String cof1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 518 | "{@type=korap:token, wrap=" + |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 519 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 520 | "{@type=korap:term, layer=lemma, key=Mann, match=match:eq}," + |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 521 | "{@type=korap:termGroup, relation=relation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 522 | "{@type=korap:term, layer=cas, key=N, match=match:eq}," + |
| 523 | "{@type=korap:term, layer=cas, key=A, match=match:eq}" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 524 | "]}" + |
| 525 | "]}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 526 | "}"; |
| 527 | ppt = new PoliqarpPlusTree("[base=Mann&(cas=N|cas=A)]"); |
| 528 | map = ppt.getRequestMap().get("query").toString(); |
| 529 | assertEquals(cof1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Nils Diewald | 7d486c2 | 2013-12-13 16:32:18 +0000 | [diff] [blame] | 530 | |
| 531 | |
| 532 | assertEquals( |
| 533 | new PoliqarpPlusTree(" [ base=Mann & ( cas=N | cas=A)] ").getRequestMap().get("query").toString(), |
| 534 | new PoliqarpPlusTree("[base=Mann &(cas=N|cas=A)]").getRequestMap().get("query").toString() |
| 535 | ); |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 536 | |
| 537 | // [base=Mann&cas=N&gen=m] |
| 538 | String cof2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 539 | "{@type=korap:token, wrap=" + |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 540 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 541 | "{@type=korap:term, layer=lemma, key=Mann, match=match:eq}," + |
| 542 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 543 | "{@type=korap:term, layer=cas, key=N, match=match:eq}," + |
| 544 | "{@type=korap:term, layer=gen, key=m, match=match:eq}" + |
| 545 | "]}" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 546 | "]}" + |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 547 | "}"; |
| 548 | ppt = new PoliqarpPlusTree("[base=Mann&cas=N&gen=m]"); |
| 549 | map = ppt.getRequestMap().get("query").toString(); |
| 550 | assertEquals(cof2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 554 | public void testOccurrence() throws QueryException { |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 555 | // [base=foo]* |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 556 | String occ1 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 557 | "{@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] | 558 | "], boundary={@type=korap:boundary, min=0}, min=0}"; |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 559 | ppt = new PoliqarpPlusTree("[base=foo]*"); |
| 560 | map = ppt.getRequestMap().get("query").toString(); |
| 561 | assertEquals(occ1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 562 | |
| 563 | // [base=foo]*[base=bar] |
| 564 | String occ2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 565 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 566 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 567 | "{@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] | 568 | "], boundary={@type=korap:boundary, min=0}, min=0 }," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 569 | "{@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] | 570 | "]}"; |
| 571 | ppt = new PoliqarpPlusTree("[base=foo]*[base=bar]"); |
| 572 | map = ppt.getRequestMap().get("query").toString(); |
| 573 | assertEquals(occ2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 574 | |
| 575 | // [base=bar][base=foo]* |
| 576 | String occ3 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 577 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 578 | "{@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] | 579 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 580 | "{@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] | 581 | "], boundary={@type=korap:boundary, min=0}, min=0 }" + |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 582 | "]}"; |
| 583 | ppt = new PoliqarpPlusTree("[base=bar][base=foo]*"); |
| 584 | map = ppt.getRequestMap().get("query").toString(); |
| 585 | assertEquals(occ3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 586 | |
| 587 | // ([base=bar][base=foo])* |
| 588 | String occ4 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 589 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 590 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 591 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 592 | "{@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] | 593 | "]}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 594 | "], boundary={@type=korap:boundary, min=0}, min=0}" ; |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 595 | ppt = new PoliqarpPlusTree("([base=bar][base=foo])*"); |
| 596 | map = ppt.getRequestMap().get("query").toString(); |
| 597 | assertEquals(occ4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 598 | |
| 599 | // <s>([base=bar][base=foo])* |
| 600 | String occ5 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 601 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 602 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 603 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 604 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 605 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 606 | "{@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] | 607 | "]}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 608 | "], boundary={@type=korap:boundary, min=0}, min=0 }" + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 609 | "]}" ; |
| 610 | ppt = new PoliqarpPlusTree("<s>([base=bar][base=foo])*"); |
| 611 | map = ppt.getRequestMap().get("query").toString(); |
| 612 | assertEquals(occ5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 613 | |
| 614 | // <s><np>([base=bar][base=foo])* |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 615 | String occ6 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 616 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 617 | "{@type=korap:span, key=s}," + |
| 618 | "{@type=korap:span, key=np}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 619 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 620 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 621 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 622 | "{@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] | 623 | "]}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 624 | "], boundary={@type=korap:boundary, min=0}, min=0 }" + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 625 | "]}" ; |
| 626 | ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*"); |
| 627 | map = ppt.getRequestMap().get("query").toString(); |
| 628 | assertEquals(occ6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 629 | |
| 630 | // <s><np>([base=bar][base=foo])*[p=NN] |
| 631 | // comment: embedded sequence shouldn't really be here, but does not really hurt, either. (?) |
| 632 | // really hard to get this behaviour out of the PQPlus grammar... |
| 633 | String occ7 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 634 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 635 | "{@type=korap:span, key=s}," + |
| 636 | "{@type=korap:span, key=np}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 637 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 638 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 639 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 640 | "{@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] | 641 | "]}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 642 | "], boundary={@type=korap:boundary, min=0}, min=0 }," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 643 | "{@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] | 644 | "]}" ; |
| 645 | ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*[p=NN]"); |
| 646 | map = ppt.getRequestMap().get("query").toString(); |
| 647 | assertEquals(occ7.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 648 | |
| 649 | // ([base=bar][base=foo])*[p=NN] |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 650 | String occ8 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 651 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 652 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 653 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 654 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 655 | "{@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] | 656 | "]}" + |
Joachim Bingel | 687e4d4 | 2014-07-30 09:34:18 +0000 | [diff] [blame] | 657 | "], boundary={@type=korap:boundary, min=0}, min=0 }," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 658 | "{@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] | 659 | "]}" ; |
| 660 | ppt = new PoliqarpPlusTree("([base=bar][base=foo])*[p=NN]"); |
| 661 | map = ppt.getRequestMap().get("query").toString(); |
| 662 | assertEquals(occ8.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 663 | |
| 664 | // [base=foo]+ |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 665 | String occ9 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 666 | "{@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] | 667 | "], boundary={@type=korap:boundary, min=1}, min=1}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 668 | ppt = new PoliqarpPlusTree("[base=foo]+"); |
| 669 | map = ppt.getRequestMap().get("query").toString(); |
| 670 | assertEquals(occ9.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 671 | |
| 672 | // [base=foo]? |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 673 | String occ10 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 674 | "{@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] | 675 | "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 676 | ppt = new PoliqarpPlusTree("[base=foo]?"); |
| 677 | map = ppt.getRequestMap().get("query").toString(); |
| 678 | assertEquals(occ10.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 679 | |
| 680 | // [base=foo]{2,5} |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 681 | String occ11 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 682 | "{@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] | 683 | "], boundary={@type=korap:boundary, min=2, max=5}, min=2, max=5}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 684 | ppt = new PoliqarpPlusTree("[base=foo]{2,5}"); |
| 685 | map = ppt.getRequestMap().get("query").toString(); |
| 686 | assertEquals(occ11.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 687 | |
| 688 | // [base=foo]{2} |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 689 | String occ12 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 690 | "{@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] | 691 | "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}"; |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 692 | ppt = new PoliqarpPlusTree("[base=foo]{2}"); |
| 693 | map = ppt.getRequestMap().get("query").toString(); |
| 694 | assertEquals(occ12.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b2aa1c7 | 2014-07-01 12:48:46 +0000 | [diff] [blame] | 695 | |
| 696 | // [base=foo]{2} |
| 697 | String occ13 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 698 | "{@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] | 699 | "], boundary={@type=korap:boundary, min=2}, min=2}"; |
Joachim Bingel | b2aa1c7 | 2014-07-01 12:48:46 +0000 | [diff] [blame] | 700 | ppt = new PoliqarpPlusTree("[base=foo]{2,}"); |
| 701 | map = ppt.getRequestMap().get("query").toString(); |
| 702 | assertEquals(occ13.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 703 | |
| 704 | // [base=foo]{2} |
| 705 | String occ14 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 706 | "{@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] | 707 | "], boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}"; |
Joachim Bingel | b2aa1c7 | 2014-07-01 12:48:46 +0000 | [diff] [blame] | 708 | ppt = new PoliqarpPlusTree("[base=foo]{,2}"); |
| 709 | map = ppt.getRequestMap().get("query").toString(); |
| 710 | assertEquals(occ14.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 714 | public void testTokenSequence() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 715 | // [base=Mann][orth=Frau] |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 716 | String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 717 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " + |
| 718 | "{@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] | 719 | "]}"; |
| 720 | assertTrue(equalsQueryContent(seq1, "[base=Mann][orth=Frau]")); |
| 721 | |
| 722 | // [base=Mann][orth=Frau][p=NN] |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 723 | String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 724 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " + |
| 725 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}, " + |
| 726 | "{@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] | 727 | "]}"; |
| 728 | assertTrue(equalsQueryContent(seq2, "[base=Mann][orth=Frau][p=NN]")); |
| 729 | } |
| 730 | |
| 731 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 732 | public void testDisjSegments() throws QueryException { |
Joachim Bingel | 94a1ccd | 2013-12-10 10:37:29 +0000 | [diff] [blame] | 733 | // ([base=der]|[base=das])[base=Schild] |
| 734 | String disj1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 735 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 736 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 737 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 738 | "{@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] | 739 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 740 | "{@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] | 741 | "]}"; |
| 742 | ppt = new PoliqarpPlusTree("([base=der]|[base=das])[base=Schild]"); |
| 743 | map = ppt.getRequestMap().get("query").toString(); |
| 744 | assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 745 | |
| 746 | // [base=Schild]([base=der]|[base=das]) |
| 747 | String disj2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 748 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 749 | "{@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] | 750 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 751 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 752 | "{@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] | 753 | "]}" + |
| 754 | "]}"; |
| 755 | ppt = new PoliqarpPlusTree("[base=Schild]([base=der]|[base=das])"); |
| 756 | map = ppt.getRequestMap().get("query").toString(); |
| 757 | assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 76b498d | 2014-06-06 12:06:46 +0000 | [diff] [blame] | 758 | |
| 759 | // "([orth=der][base=katze])|([orth=eine][base=baum])" |
| 760 | String disj3 = |
| 761 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 762 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 763 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 764 | "{@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] | 765 | "]}," + |
| 766 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 767 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=eine, match=match:eq}}," + |
| 768 | "{@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] | 769 | "]}" + |
| 770 | "]}"; |
| 771 | ppt = new PoliqarpPlusTree("([orth=der][base=katze])|([orth=eine][base=baum])"); |
| 772 | map = ppt.getRequestMap().get("query").toString(); |
| 773 | assertEquals(disj3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 774 | |
| 775 | // "[orth=der][base=katze]|[orth=eine][base=baum]" |
| 776 | String disj4 = |
| 777 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 778 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 779 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 780 | "{@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] | 781 | "]}," + |
| 782 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 783 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=eine, match=match:eq}}," + |
| 784 | "{@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] | 785 | "]}" + |
| 786 | "]}"; |
| 787 | ppt = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=eine][base=baum]"); |
| 788 | map = ppt.getRequestMap().get("query").toString(); |
| 789 | assertEquals(disj4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 790 | |
| 791 | PoliqarpPlusTree ppt1 = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=eine][base=baum]"); |
| 792 | PoliqarpPlusTree ppt2 = new PoliqarpPlusTree("([orth=der][base=katze])|([orth=eine][base=baum])"); |
| 793 | assertEquals(ppt1.getRequestMap().toString(), ppt2.getRequestMap().toString()); |
| 794 | |
| 795 | // "[orth=der][base=katze]|[orth=der][base=hund]|[orth=der][base=baum]" |
| 796 | String disj5 = |
| 797 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 798 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 799 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 800 | "{@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] | 801 | "]}," + |
| 802 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 803 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 804 | "{@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] | 805 | "]}," + |
| 806 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 807 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 808 | "{@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] | 809 | "]}" + |
| 810 | "]}"; |
| 811 | ppt = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=der][base=hund]|[orth=der][base=baum]"); |
| 812 | map = ppt.getRequestMap().get("query").toString(); |
| 813 | assertEquals(disj5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 814 | |
| 815 | // [orth=der]([base=katze]|[base=hund]|[base=baum]) |
| 816 | String disj6 = |
| 817 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 818 | "{@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] | 819 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 820 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=katze, match=match:eq}}," + |
| 821 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=hund, match=match:eq}}," + |
| 822 | "{@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] | 823 | "]}" + |
| 824 | "]}"; |
| 825 | ppt = new PoliqarpPlusTree("[orth=der]([base=katze]|[base=hund]|[base=baum])"); |
| 826 | map = ppt.getRequestMap().get("query").toString(); |
| 827 | assertEquals(disj6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 94a1ccd | 2013-12-10 10:37:29 +0000 | [diff] [blame] | 828 | } |
| 829 | |
| 830 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 831 | public void testTokenElemSequence() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 832 | // [base=Mann]<vp> |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 833 | String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 834 | "{@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] | 835 | "{@type=korap:span, key=vp}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 836 | "]}"; |
| 837 | assertTrue(equalsQueryContent(seq1, "[base=Mann]<vp>")); |
| 838 | |
| 839 | // <vp>[base=Mann] |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 840 | String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 841 | "{@type=korap:span, key=vp}, "+ |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 842 | "{@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] | 843 | "]}"; |
| 844 | assertTrue(equalsQueryContent(seq2, "<vp>[base=Mann]")); |
| 845 | |
| 846 | // <vp>[base=Mann]<pp> |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 847 | String seq3 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 848 | "{@type=korap:span, key=vp}, "+ |
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 | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 850 | "{@type=korap:span, key=pp} "+ |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 851 | "]}"; |
| 852 | assertTrue(equalsQueryContent(seq3, "<vp>[base=Mann]<pp>")); |
| 853 | } |
| 854 | |
| 855 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 856 | public void testElemSequence() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 857 | // <np><vp> |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 858 | String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 859 | "{@type=korap:span, key=np}," + |
| 860 | "{@type=korap:span, key=vp}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 861 | "]}"; |
| 862 | assertTrue(equalsQueryContent(seq1, "<np><vp>")); |
| 863 | |
| 864 | // <np><vp><pp> |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 865 | String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 866 | "{@type=korap:span, key=np}," + |
| 867 | "{@type=korap:span, key=vp}," + |
| 868 | "{@type=korap:span, key=pp}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 869 | "]}"; |
| 870 | assertTrue(equalsQueryContent(seq2, "<np><vp><pp>")); |
| 871 | } |
| 872 | |
| 873 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 874 | public void testClasses() throws QueryException { |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 875 | String query; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 876 | // {[base=Mann]} |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 877 | String cls1 = "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 878 | "{@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] | 879 | "]}"; |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 880 | ppt = new PoliqarpPlusTree("{[base=Mann]}"); |
| 881 | map = ppt.getRequestMap().get("query").toString(); |
| 882 | assertEquals(cls1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 883 | |
| 884 | // {[base=Mann][orth=Frau]} |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 885 | query = "{[base=Mann][orth=Frau]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 886 | String cls2 = "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 887 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 888 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," + |
| 889 | "{@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] | 890 | "]}" + |
| 891 | "]}"; |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 892 | ppt = new PoliqarpPlusTree(query); |
| 893 | map = ppt.getRequestMap().get("query").toString(); |
| 894 | assertEquals(cls2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 895 | |
| 896 | // [p=NN]{[base=Mann][orth=Frau]} |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 897 | String cls3 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 898 | "{@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] | 899 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 900 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 901 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," + |
| 902 | "{@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] | 903 | "]}" + |
| 904 | "]}" + |
| 905 | "]}"; |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 906 | ppt = new PoliqarpPlusTree("[p=NN]{[base=Mann][orth=Frau]}"); |
| 907 | map = ppt.getRequestMap().get("query").toString(); |
| 908 | assertEquals(cls3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 909 | |
| 910 | // {[base=Mann][orth=Frau]}[p=NN] |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 911 | String cls4 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 912 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 913 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 914 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," + |
| 915 | "{@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] | 916 | "]}" + |
| 917 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 918 | "{@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] | 919 | "]}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 920 | ppt = new PoliqarpPlusTree("{[base=Mann][orth=Frau]}[p=NN]"); |
| 921 | map = ppt.getRequestMap().get("query").toString(); |
| 922 | assertEquals(cls4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 923 | |
| 924 | // {2:{1:[tt/p=ADJA]}[mate/p=NN]}" |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 925 | String cls5 = "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 926 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 927 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 928 | "{@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] | 929 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 930 | "{@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] | 931 | "]}" + |
| 932 | "]}"; |
| 933 | ppt = new PoliqarpPlusTree("{2: {1:[tt/p=ADJA]}[mate/p=NN]}"); |
| 934 | map = ppt.getRequestMap().get("query").toString(); |
| 935 | assertEquals(cls5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 939 | public void testPositions() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 940 | // contains(<s>,<np>) |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 941 | String pos1 = "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 942 | "{@type=korap:span, key=s}," + |
| 943 | "{@type=korap:span, key=np}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 944 | "], frame=frame:contains}"; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 945 | assertTrue(equalsQueryContent(pos1, "contains(<s>,<np>)")); |
| 946 | |
| 947 | // contains(<s>,[base=Mann]) |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 948 | String pos2 = "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 949 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 950 | "{@type=korap:token, wrap= {@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 951 | "], frame=frame:contains}"; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 952 | assertTrue(equalsQueryContent(pos2, "contains(<s>,[base=Mann])")); |
| 953 | |
| 954 | // contains(<s>,[orth=der][orth=Mann]) |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 955 | String pos3 = "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 956 | "{@type=korap:span, key=s}," + |
| 957 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 958 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 959 | "{@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] | 960 | "]}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 961 | "], frame=frame:contains}"; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 962 | ppt = new PoliqarpPlusTree("contains(<s>,[orth=der][orth=Mann])"); |
| 963 | map = ppt.getRequestMap().get("query").toString(); |
| 964 | assertEquals(pos3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 965 | |
| 966 | // [base=Auto]contains(<s>,[base=Mann]) |
| 967 | String pos4 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 968 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 969 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Auto, match=match:eq}}," + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 970 | "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 971 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 972 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 973 | "], frame=frame:contains}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 974 | "]}"; |
| 975 | ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[base=Mann])"); |
| 976 | map = ppt.getRequestMap().get("query").toString(); |
| 977 | assertEquals(pos4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | ef7059b | 2014-04-22 13:44:19 +0000 | [diff] [blame] | 978 | |
| 979 | // contains(<s>,[pos=N]*) |
| 980 | String pos5 = |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 981 | "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | ef7059b | 2014-04-22 13:44:19 +0000 | [diff] [blame] | 982 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 983 | "{@type=korap:group, operation=operation:repetition, " + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 984 | "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] | 985 | "], boundary={@type=korap:boundary, min=0}, min=0" + |
Joachim Bingel | ef7059b | 2014-04-22 13:44:19 +0000 | [diff] [blame] | 986 | "}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 987 | "], frame=frame:contains}"; |
Joachim Bingel | ef7059b | 2014-04-22 13:44:19 +0000 | [diff] [blame] | 988 | ppt = new PoliqarpPlusTree("contains(<s>,[pos=N]*)"); |
| 989 | map = ppt.getRequestMap().get("query").toString(); |
| 990 | assertEquals(pos5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 991 | |
| 992 | // [base=Auto]contains(<s>,[pos=N]*) |
| 993 | String pos6 = |
| 994 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 995 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Auto, match=match:eq}}," + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 996 | "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | ef7059b | 2014-04-22 13:44:19 +0000 | [diff] [blame] | 997 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 998 | "{@type=korap:group, operation=operation:repetition, " + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 999 | "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] | 1000 | "], boundary={@type=korap:boundary, min=0}, min=0" + |
Joachim Bingel | ef7059b | 2014-04-22 13:44:19 +0000 | [diff] [blame] | 1001 | "}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 1002 | "], frame=frame:contains}" + |
Joachim Bingel | ef7059b | 2014-04-22 13:44:19 +0000 | [diff] [blame] | 1003 | "]}"; |
| 1004 | ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[pos=N]*)"); |
| 1005 | map = ppt.getRequestMap().get("query").toString(); |
| 1006 | assertEquals(pos6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1007 | } |
| 1008 | |
| 1009 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1010 | public void testNestedPositions() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1011 | // contains(<s>,startswith(<np>,[orth=Der])) |
| 1012 | String npos1 = |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 1013 | "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1014 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 1015 | "{@type=korap:group, operation=operation:position, frames=[frame:startswith],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1016 | "{@type=korap:span, key=np}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1017 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 1018 | "], frame=frame:startswith}" + |
| 1019 | "], frame=frame:contains}"; |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 1020 | ppt = new PoliqarpPlusTree("contains(<s>, startswith(<np>,[orth=Der]))"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1021 | map = ppt.getRequestMap().get("query").toString(); |
| 1022 | assertEquals(npos1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1023 | } |
| 1024 | |
| 1025 | @Test |
Joachim Bingel | 23c31ad | 2014-08-11 09:44:46 +0000 | [diff] [blame] | 1026 | public void testFocusSplit() throws QueryException { |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1027 | // focus([orth=Der]{[orth=Mann]}) |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1028 | String shr1 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1029 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1030 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1031 | "{@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] | 1032 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1033 | "{@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] | 1034 | "]}" + |
| 1035 | "]}" + |
| 1036 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 1037 | ppt = new PoliqarpPlusTree("focus([orth=Der]{[orth=Mann]})"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1038 | map = ppt.getRequestMap().get("query").toString(); |
| 1039 | assertEquals(shr1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1040 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1041 | // focus([orth=Der]{[orth=Mann][orth=geht]}) |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1042 | String shr2 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1043 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1044 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1045 | "{@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] | 1046 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 1047 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1048 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}," + |
| 1049 | "{@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] | 1050 | "]}" + |
| 1051 | "]}" + |
| 1052 | "]}" + |
| 1053 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 1054 | ppt = new PoliqarpPlusTree("focus([orth=Der]{[orth=Mann][orth=geht]})"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1055 | map = ppt.getRequestMap().get("query").toString(); |
| 1056 | assertEquals(shr2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1057 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1058 | // focus(1:[orth=Der]{1:[orth=Mann][orth=geht]}) |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1059 | String shr3 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1060 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1061 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1062 | "{@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] | 1063 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1064 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1065 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}," + |
| 1066 | "{@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] | 1067 | "]}" + |
| 1068 | "]}" + |
| 1069 | "]}" + |
| 1070 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 1071 | ppt = new PoliqarpPlusTree("focus(1:[orth=Der]{1:[orth=Mann][orth=geht]})"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1072 | map = ppt.getRequestMap().get("query").toString(); |
| 1073 | assertEquals(shr3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1074 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1075 | // focus(1:startswith(<s>,{1:<np>})) |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1076 | String shr4 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1077 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 1078 | "{@type=korap:group, operation=operation:position, frames=[frame:startswith],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1079 | "{@type=korap:span, key=s}," + |
| 1080 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1081 | "{@type=korap:span, key=np}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1082 | "]}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 1083 | "], frame=frame:startswith}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1084 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 1085 | ppt = new PoliqarpPlusTree("focus(1:startswith(<s>,{1:<np>}))"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1086 | map = ppt.getRequestMap().get("query").toString(); |
| 1087 | assertEquals(shr4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 1088 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1089 | // 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] | 1090 | String shr5 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1091 | "{@type=korap:reference, operation=operation:focus, classRef=[3], operands=[" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 1092 | "{@type=korap:group, operation=operation:position, frames=[frame:startswith],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1093 | "{@type=korap:span, key=s}," + |
| 1094 | "{@type=korap:group, operation=operation:class, class=3, operands=[" + |
| 1095 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1096 | "{@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] | 1097 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1098 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1099 | "{@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] | 1100 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1101 | "{@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] | 1102 | "]}" + |
| 1103 | "]}" + |
| 1104 | "]}" + |
| 1105 | "]}" + |
| 1106 | "]}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 1107 | "], frame=frame:startswith}" + |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 1108 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 1109 | 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] | 1110 | map = ppt.getRequestMap().get("query").toString(); |
| 1111 | assertEquals(shr5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 1112 | |
| 1113 | // split(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) |
| 1114 | String shr6 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1115 | "{@type=korap:reference, operation=operation:split, classRef=[3], operands=[" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 1116 | "{@type=korap:group, operation=operation:position, frames=[frame:startswith],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1117 | "{@type=korap:span, key=s}," + |
| 1118 | "{@type=korap:group, operation=operation:class, class=3, operands=[" + |
| 1119 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1120 | "{@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] | 1121 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1122 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1123 | "{@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] | 1124 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1125 | "{@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] | 1126 | "]}" + |
| 1127 | "]}" + |
| 1128 | "]}" + |
| 1129 | "]}" + |
| 1130 | "]}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 1131 | "], frame=frame:startswith}" + |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 1132 | "]}"; |
| 1133 | ppt = new PoliqarpPlusTree("split(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) "); |
| 1134 | map = ppt.getRequestMap().get("query").toString(); |
| 1135 | assertEquals(shr6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 1136 | |
| 1137 | // split(2|3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) |
| 1138 | String shr7 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1139 | "{@type=korap:reference, operation=operation:split, classRef=[2, 3], classRefOp=classRefOp:intersection, operands=[" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 1140 | "{@type=korap:group, operation=operation:position, frames=[frame:startswith],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1141 | "{@type=korap:span, key=s}," + |
| 1142 | "{@type=korap:group, operation=operation:class, class=3, operands=[" + |
| 1143 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1144 | "{@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] | 1145 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1146 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1147 | "{@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] | 1148 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1149 | "{@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] | 1150 | "]}" + |
| 1151 | "]}" + |
| 1152 | "]}" + |
| 1153 | "]}" + |
| 1154 | "]}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 1155 | "], frame=frame:startswith}" + |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 1156 | "]}"; |
| 1157 | ppt = new PoliqarpPlusTree("split(2|3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) "); |
| 1158 | map = ppt.getRequestMap().get("query").toString(); |
| 1159 | assertEquals(shr7.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 5146ebe | 2014-06-12 08:49:21 +0000 | [diff] [blame] | 1160 | |
| 1161 | |
| 1162 | String shr8 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame] | 1163 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | add0fb1 | 2014-06-24 08:54:14 +0000 | [diff] [blame] | 1164 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1165 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1166 | "{@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] | 1167 | "]}," + |
| 1168 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1169 | "{@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] | 1170 | "]}" + |
Joachim Bingel | add0fb1 | 2014-06-24 08:54:14 +0000 | [diff] [blame] | 1171 | "]}" + |
| 1172 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 1173 | ppt = new PoliqarpPlusTree("focus(1:{[base=der]}{1:[pos=ADJA]})"); |
Joachim Bingel | add0fb1 | 2014-06-24 08:54:14 +0000 | [diff] [blame] | 1174 | map = ppt.getRequestMap().get("query").toString(); |
| 1175 | assertEquals(shr8.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 5146ebe | 2014-06-12 08:49:21 +0000 | [diff] [blame] | 1176 | |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1177 | } |
| 1178 | |
Joachim Bingel | 23c31ad | 2014-08-11 09:44:46 +0000 | [diff] [blame] | 1179 | @Test |
| 1180 | public void testSubspan() throws QueryException { |
Joachim Bingel | 9bbd4fc | 2014-08-11 14:56:48 +0000 | [diff] [blame] | 1181 | query = "submatch(1,:<s>)"; |
Joachim Bingel | 23c31ad | 2014-08-11 09:44:46 +0000 | [diff] [blame] | 1182 | expected = |
| 1183 | "{@type=korap:reference, operation=operation:focus, operands=[" + |
| 1184 | "{@type=korap:span, key=s}" + |
| 1185 | "], spanRef=[1]" + |
| 1186 | "}"; |
| 1187 | ppt = new PoliqarpPlusTree(query); |
| 1188 | map = ppt.getRequestMap().get("query").toString(); |
| 1189 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1190 | |
Joachim Bingel | 9bbd4fc | 2014-08-11 14:56:48 +0000 | [diff] [blame] | 1191 | query = "submatch(1,4:<s>)"; |
Joachim Bingel | 23c31ad | 2014-08-11 09:44:46 +0000 | [diff] [blame] | 1192 | expected = |
| 1193 | "{@type=korap:reference, operation=operation:focus, operands=[" + |
| 1194 | "{@type=korap:span, key=s}" + |
| 1195 | "], spanRef=[1,4]" + |
| 1196 | "}"; |
| 1197 | ppt = new PoliqarpPlusTree(query); |
| 1198 | map = ppt.getRequestMap().get("query").toString(); |
| 1199 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1200 | |
Joachim Bingel | 9bbd4fc | 2014-08-11 14:56:48 +0000 | [diff] [blame] | 1201 | query = "submatch(1,4:contains(<s>,[base=Haus]))"; |
Joachim Bingel | 23c31ad | 2014-08-11 09:44:46 +0000 | [diff] [blame] | 1202 | expected = |
| 1203 | "{@type=korap:reference, operation=operation:focus, operands=[" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 1204 | "{@type=korap:group, operation=operation:position, frames=[],sharedClasses=[sharedClasses:includes], operands=[" + |
Joachim Bingel | 23c31ad | 2014-08-11 09:44:46 +0000 | [diff] [blame] | 1205 | "{@type=korap:span, key=s}," + |
| 1206 | "{@type=korap:token, wrap= {@type=korap:term, layer=lemma, key=Haus, match=match:eq}}" + |
Joachim Bingel | 6b52d76 | 2014-09-30 15:29:11 +0000 | [diff] [blame] | 1207 | "], frame=frame:contains}" + |
Joachim Bingel | 23c31ad | 2014-08-11 09:44:46 +0000 | [diff] [blame] | 1208 | "], spanRef=[1,4]" + |
| 1209 | "}"; |
| 1210 | ppt = new PoliqarpPlusTree(query); |
| 1211 | map = ppt.getRequestMap().get("query").toString(); |
| 1212 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1213 | } |
| 1214 | |
| 1215 | @Test |
| 1216 | public void testRelations() throws QueryException { |
| 1217 | query = "relatesTo(<s>,<np>)"; |
| 1218 | expected = |
| 1219 | "{@type=korap:group, operation=operation:relation, operands=[" + |
| 1220 | "{@type=korap:span, key=s}," + |
| 1221 | "{@type=korap:span, key=np}" + |
| 1222 | "], relation={@type=korap:relation}" + |
| 1223 | "}"; |
| 1224 | ppt = new PoliqarpPlusTree(query); |
| 1225 | map = ppt.getRequestMap().get("query").toString(); |
| 1226 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1227 | |
| 1228 | query = "relatesTo([base=Baum],<np>)"; |
| 1229 | expected = |
| 1230 | "{@type=korap:group, operation=operation:relation, operands=[" + |
| 1231 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}," + |
| 1232 | "{@type=korap:span, key=np}" + |
| 1233 | "], relation={@type=korap:relation}" + |
| 1234 | "}"; |
| 1235 | ppt = new PoliqarpPlusTree(query); |
| 1236 | map = ppt.getRequestMap().get("query").toString(); |
| 1237 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1238 | |
| 1239 | query = "dominates(<np>,[base=Baum])"; |
| 1240 | expected = |
| 1241 | "{@type=korap:group, operation=operation:relation, operands=[" + |
| 1242 | "{@type=korap:span, key=np}," + |
| 1243 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" + |
| 1244 | "], relation={@type=korap:relation, layer=c}" + |
| 1245 | "}"; |
| 1246 | ppt = new PoliqarpPlusTree(query); |
| 1247 | map = ppt.getRequestMap().get("query").toString(); |
| 1248 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1249 | |
| 1250 | query = "dominates(cnx/c:<np>,[base=Baum])"; |
| 1251 | expected = |
| 1252 | "{@type=korap:group, operation=operation:relation, operands=[" + |
| 1253 | "{@type=korap:span, key=np}," + |
| 1254 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" + |
| 1255 | "], relation={@type=korap:relation, layer=c, foundry=cnx}" + |
| 1256 | "}"; |
| 1257 | ppt = new PoliqarpPlusTree(query); |
| 1258 | map = ppt.getRequestMap().get("query").toString(); |
| 1259 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1260 | |
| 1261 | query = "dominates(cnx/c*:<np>,[base=Baum])"; |
| 1262 | expected = |
| 1263 | "{@type=korap:group, operation=operation:relation, operands=[" + |
| 1264 | "{@type=korap:span, key=np}," + |
| 1265 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" + |
| 1266 | "], relation={@type=korap:relation, layer=c, foundry=cnx, boundary={@type=korap:boundary, min=0}}" + |
| 1267 | "}"; |
| 1268 | ppt = new PoliqarpPlusTree(query); |
| 1269 | map = ppt.getRequestMap().get("query").toString(); |
| 1270 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1271 | |
| 1272 | query = "dominates(cnx/c{1,5}:<np>,[base=Baum])"; |
| 1273 | expected = |
| 1274 | "{@type=korap:group, operation=operation:relation, operands=[" + |
| 1275 | "{@type=korap:span, key=np}," + |
| 1276 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" + |
| 1277 | "], relation={@type=korap:relation, layer=c, foundry=cnx, boundary={@type=korap:boundary, min=1, max=5}}" + |
| 1278 | "}"; |
| 1279 | ppt = new PoliqarpPlusTree(query); |
| 1280 | map = ppt.getRequestMap().get("query").toString(); |
| 1281 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1282 | |
| 1283 | query = "relatesTo(mate/d=HEAD:<np>,[base=Baum])"; |
| 1284 | expected = |
| 1285 | "{@type=korap:group, operation=operation:relation, operands=[" + |
| 1286 | "{@type=korap:span, key=np}," + |
| 1287 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Baum, match=match:eq}}" + |
| 1288 | "], relation={@type=korap:relation, foundry=mate, layer=d, key=HEAD}" + |
| 1289 | "}"; |
| 1290 | ppt = new PoliqarpPlusTree(query); |
| 1291 | map = ppt.getRequestMap().get("query").toString(); |
| 1292 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1293 | |
| 1294 | } |
| 1295 | |
| 1296 | |
Joachim Bingel | 0388270 | 2013-12-31 19:53:05 +0000 | [diff] [blame] | 1297 | |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1298 | @Test |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 1299 | public void testFoundries() throws QueryException { |
| 1300 | // [tt/base=Mann] |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1301 | 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] | 1302 | ppt = new PoliqarpPlusTree("[tt/base=Mann]"); |
| 1303 | map = ppt.getRequestMap().get("query").toString(); |
| 1304 | assertEquals(layer1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1305 | |
| 1306 | } |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1307 | |
| 1308 | @Test |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 1309 | public void testAlign() throws QueryException { |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1310 | // [orth=der]^[orth=Mann] |
| 1311 | String align1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 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=orth, key=der, match=match:eq}}," + |
| 1314 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
| 1315 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" + |
| 1316 | "], align=align:left}" + |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1317 | "]}"; |
| 1318 | ppt = new PoliqarpPlusTree("[orth=der]^[orth=Mann]"); |
| 1319 | map = ppt.getRequestMap().get("query").toString(); |
| 1320 | assertEquals(align1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1321 | |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 1322 | // [orth=der]^[orth=große][orth=Mann] |
| 1323 | String query = "[orth=der]^[orth=große][orth=Mann]"; |
| 1324 | String align1b = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1325 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1326 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 1327 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1328 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1329 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=große, match=match:eq}}," + |
| 1330 | "{@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] | 1331 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1332 | "], align=align:left}" + |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 1333 | "]}"; |
| 1334 | ppt = new PoliqarpPlusTree(query); |
| 1335 | map = ppt.getRequestMap().get("query").toString(); |
| 1336 | assertEquals(align1b.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1337 | |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1338 | // "([base=a]^[base=b])|[base=c]", |
| 1339 | String align2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1340 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 1341 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1342 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=a, match=match:eq}}," + |
| 1343 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
| 1344 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=b, match=match:eq}}" + |
| 1345 | "], align=align:left}" + |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1346 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1347 | "{@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] | 1348 | "]}"; |
| 1349 | ppt = new PoliqarpPlusTree("([base=a]^[base=b])|[base=c]"); |
| 1350 | map = ppt.getRequestMap().get("query").toString(); |
| 1351 | assertEquals(align2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1352 | |
| 1353 | // "([base=a]^[base=b][base=c])|[base=d]", |
| 1354 | String align3 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1355 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 1356 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1357 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=a, match=match:eq}}," + |
| 1358 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1359 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1360 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=b, match=match:eq}}," + |
| 1361 | "{@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] | 1362 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1363 | "], align=align:left}" + |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1364 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1365 | "{@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] | 1366 | "]}"; |
| 1367 | ppt = new PoliqarpPlusTree("([base=a]^[base=b][base=c])|[base=d]"); |
| 1368 | map = ppt.getRequestMap().get("query").toString(); |
| 1369 | assertEquals(align3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1370 | |
| 1371 | // "([base=a]^[base=b]^[base=c])|[base=d]", |
| 1372 | String align4 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1373 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 1374 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1375 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=a, match=match:eq}}," + |
| 1376 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1377 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1378 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=b, match=match:eq}}," + |
| 1379 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
| 1380 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=c, match=match:eq}}" + |
| 1381 | "], align=align:left}" + |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 1382 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1383 | "], align=align:left}" + |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1384 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1385 | "{@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] | 1386 | "]}"; |
| 1387 | ppt = new PoliqarpPlusTree("([base=a]^[base=b]^[base=c])|[base=d]"); |
| 1388 | map = ppt.getRequestMap().get("query").toString(); |
| 1389 | assertEquals(align4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1390 | |
| 1391 | |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1392 | } |
| 1393 | |
| 1394 | @Test |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 1395 | public void testSimpleQueries() throws QueryException { |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1396 | // Baum |
| 1397 | String simple1 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1398 | "{@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] | 1399 | ppt = new PoliqarpPlusTree("Baum"); |
| 1400 | map = ppt.getRequestMap().get("query").toString(); |
| 1401 | assertEquals(simple1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1402 | |
| 1403 | // Baum/i |
| 1404 | String simple1b = |
| 1405 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq, caseInsensitive=true}}"; |
| 1406 | ppt = new PoliqarpPlusTree("Baum/i"); |
| 1407 | map = ppt.getRequestMap().get("query").toString(); |
| 1408 | assertEquals(simple1b.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1409 | |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1410 | // Der Baum |
| 1411 | String simple2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1412 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1413 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " + |
| 1414 | "{@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] | 1415 | "]}"; |
| 1416 | ppt = new PoliqarpPlusTree("Der Baum"); |
| 1417 | map = ppt.getRequestMap().get("query").toString(); |
| 1418 | assertEquals(simple2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1419 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1420 | // Der Baum/i |
| 1421 | String simple2b = |
| 1422 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1423 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " + |
| 1424 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq, caseInsensitive=true}}" + |
| 1425 | "]}"; |
| 1426 | ppt = new PoliqarpPlusTree("Der Baum/i"); |
| 1427 | map = ppt.getRequestMap().get("query").toString(); |
| 1428 | assertEquals(simple2b.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1429 | |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1430 | // Der große Baum |
| 1431 | String simple3 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1432 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1433 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " + |
| 1434 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=große, match=match:eq}}, " + |
| 1435 | "{@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] | 1436 | "]}"; |
| 1437 | ppt = new PoliqarpPlusTree("Der große Baum"); |
| 1438 | map = ppt.getRequestMap().get("query").toString(); |
| 1439 | assertEquals(simple3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1440 | |
| 1441 | // Baum | Stein |
| 1442 | String simple4 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1443 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1444 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}, " + |
| 1445 | "{@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] | 1446 | "]}"; |
| 1447 | ppt = new PoliqarpPlusTree("Baum | Stein"); |
| 1448 | map = ppt.getRequestMap().get("query").toString(); |
| 1449 | assertEquals(simple4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 1450 | |
| 1451 | // Baum | Stein Haus |
| 1452 | String query = "(Baum | Stein) Haus"; |
| 1453 | String simple5 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1454 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1455 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1456 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}, " + |
| 1457 | "{@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] | 1458 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1459 | "{@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] | 1460 | "]}"; |
| 1461 | ppt = new PoliqarpPlusTree(query); |
| 1462 | map = ppt.getRequestMap().get("query").toString(); |
| 1463 | assertEquals(simple5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1464 | } |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1465 | } |
| 1466 | |