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