Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1 | import static org.junit.Assert.*; |
| 2 | |
| 3 | import org.junit.Test; |
| 4 | |
| 5 | import de.ids_mannheim.korap.query.serialize.PoliqarpPlusTree; |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 6 | import de.ids_mannheim.korap.util.QueryException; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 7 | |
| 8 | public class PoliqarpPlusTreeTest { |
| 9 | |
| 10 | PoliqarpPlusTree ppt; |
| 11 | String map; |
| 12 | |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 13 | |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 14 | private boolean equalsQueryContent(String res, String query) throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 15 | res = res.replaceAll(" ", ""); |
| 16 | ppt = new PoliqarpPlusTree(query); |
| 17 | String queryMap = ppt.getRequestMap().get("query").toString().replaceAll(" ", ""); |
| 18 | return res.equals(queryMap); |
| 19 | } |
| 20 | |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 21 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 22 | public void testContext() throws QueryException { |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 23 | 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] | 24 | ppt = new PoliqarpPlusTree("Test"); |
| 25 | assertEquals(contextString.replaceAll(" ", ""), ppt.getRequestMap().get("@context").toString().replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 29 | public void testSingleTokens() throws QueryException { |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 30 | String query; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 31 | // [base=Mann] |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 32 | 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] | 33 | assertTrue(equalsQueryContent(token1, "[base=Mann]")); |
| 34 | |
| 35 | // [orth!=Frau] |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 36 | 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] | 37 | assertTrue(equalsQueryContent(token2, "[orth!=Frau]")); |
| 38 | |
| 39 | // [!p=NN] |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 40 | query = "[!p=NN]"; |
| 41 | String token3 = "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:ne}}"; |
| 42 | ppt = new PoliqarpPlusTree(query); |
| 43 | map = ppt.getRequestMap().get("query").toString(); |
| 44 | assertEquals(token3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 45 | |
| 46 | // [!p!=NN] |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 47 | query = "[!p!=NN]"; |
| 48 | String token4 = "{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}"; |
| 49 | ppt = new PoliqarpPlusTree(query); |
| 50 | map = ppt.getRequestMap().get("query").toString(); |
| 51 | assertEquals(token4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 52 | |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame^] | 53 | query = "[base=schland/x]"; |
| 54 | String token5 = "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=.*?\\Qschland\\E.*?, match=match:eq, type=type:regex}}"; |
| 55 | ppt = new PoliqarpPlusTree(query); |
| 56 | map = ppt.getRequestMap().get("query").toString(); |
| 57 | assertEquals(token5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 58 | } |
| 59 | |
| 60 | @Test |
| 61 | public void testValue() throws QueryException { |
| 62 | String query; |
| 63 | |
| 64 | query = "[mate/m=temp:pres]"; |
| 65 | String value1 = "{@type=korap:token, wrap={@type=korap:term, foundry=mate, layer=m, key=temp, value=pres, match=match:eq}}"; |
| 66 | ppt = new PoliqarpPlusTree(query); |
| 67 | map = ppt.getRequestMap().get("query").toString(); |
| 68 | assertEquals(value1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | @Test |
Joachim Bingel | 41e112e | 2014-02-12 10:46:18 +0000 | [diff] [blame] | 72 | public void testRegex() throws QueryException { |
| 73 | String query = "[orth=\"M(a|ä)nn(er)?\"]"; |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 74 | 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] | 75 | ppt = new PoliqarpPlusTree(query); |
| 76 | map = ppt.getRequestMap().get("query").toString(); |
| 77 | assertEquals(re1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 78 | |
| 79 | query = "[orth=\"M(a|ä)nn(er)?\"/x]"; |
| 80 | String re2 = "{@type=korap:token, wrap={@type=korap:term, layer=orth, type=type:regex, key=.*?M(a|ä)nn(er)?.*?, match=match:eq}}"; |
| 81 | ppt = new PoliqarpPlusTree(query); |
| 82 | map = ppt.getRequestMap().get("query").toString(); |
| 83 | assertEquals(re2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 84 | |
| 85 | query = "\"M(a|ä)nn(er)?\"/x"; |
| 86 | String re3 = "{@type=korap:token, wrap={@type=korap:term, type=type:regex, layer=orth, key=.*?M(a|ä)nn(er)?.*?, match=match:eq}}"; |
| 87 | ppt = new PoliqarpPlusTree(query); |
| 88 | map = ppt.getRequestMap().get("query").toString(); |
| 89 | assertEquals(re3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame^] | 90 | |
| 91 | query = "schland/x"; |
| 92 | String re4 = "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=.*?\\Qschland\\E.*?, match=match:eq, type=type:regex}}"; |
| 93 | ppt = new PoliqarpPlusTree(query); |
| 94 | map = ppt.getRequestMap().get("query").toString(); |
| 95 | assertEquals(re4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 96 | |
| 97 | query = "\".*?Mann.*?\""; |
| 98 | String re5 = "{@type=korap:token, wrap={@type=korap:term, type=type:regex, layer=orth, key=.*?Mann.*?, match=match:eq}}"; |
| 99 | ppt = new PoliqarpPlusTree(query); |
| 100 | map = ppt.getRequestMap().get("query").toString(); |
| 101 | assertEquals(re5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 102 | |
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 |
| 179 | public void testEmptyTokens() throws QueryException { |
| 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 | |
| 220 | // startswith(<s>, [][base=Mann] |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 221 | String et4 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 222 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 223 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 224 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 225 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
Joachim Bingel | bea1ec6 | 2014-07-11 15:00:14 +0000 | [diff] [blame] | 226 | "], leftOffset={@type=korap:boundary, min=1, max=1}}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 227 | "]}"; |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 228 | ppt = new PoliqarpPlusTree("startswith(<s>, [][base=Mann])"); |
| 229 | map = ppt.getRequestMap().get("query").toString(); |
| 230 | assertEquals(et4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 231 | |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 232 | // [base=der][]{2,5}[base=Mann][]?[][base=Frau] nested distances= |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 233 | String et5 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 234 | "{@type=korap:group, operation=operation:sequence," + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 235 | "operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 236 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 237 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 238 | "operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 239 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," + |
| 240 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Frau, match=match:eq}}" + |
| 241 | "], inOrder=true, distances=[" + |
| 242 | "{@type=korap:distance, key=w, min=2, max=3}" + |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 243 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 244 | "], inOrder=true, distances=[" + |
| 245 | "{@type=korap:distance, key=w, min=3, max=6}" + |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 246 | "]}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 247 | ppt = new PoliqarpPlusTree("[base=der][]{2,5}[base=Mann][]?[][base=Frau]"); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 248 | map = ppt.getRequestMap().get("query").toString(); |
| 249 | assertEquals(et5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 250 | |
Joachim Bingel | c15720f | 2014-05-07 14:37:23 +0000 | [diff] [blame] | 251 | // [base=der][]*[base=Mann] |
| 252 | String et6 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 253 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | c15720f | 2014-05-07 14:37:23 +0000 | [diff] [blame] | 254 | "operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 255 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 256 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 257 | "], inOrder=true, distances=[" + |
| 258 | "{@type=korap:distance, key=w, min=1, max=100}" + |
Joachim Bingel | c15720f | 2014-05-07 14:37:23 +0000 | [diff] [blame] | 259 | "]}"; |
| 260 | ppt = new PoliqarpPlusTree("[base=der][]*[base=Mann]"); |
| 261 | map = ppt.getRequestMap().get("query").toString(); |
| 262 | assertEquals(et6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 263 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 264 | // [base=der][]+[base=Mann] |
Joachim Bingel | c15720f | 2014-05-07 14:37:23 +0000 | [diff] [blame] | 265 | String et7 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 266 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | c15720f | 2014-05-07 14:37:23 +0000 | [diff] [blame] | 267 | "operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 268 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 269 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" + |
| 270 | "], inOrder=true, distances=[" + |
| 271 | "{@type=korap:distance, key=w, min=2, max=100}" + |
Joachim Bingel | c15720f | 2014-05-07 14:37:23 +0000 | [diff] [blame] | 272 | "]}"; |
| 273 | ppt = new PoliqarpPlusTree("[base=der][]+[base=Mann]"); |
| 274 | map = ppt.getRequestMap().get("query").toString(); |
| 275 | assertEquals(et7.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 276 | } |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 277 | |
| 278 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 279 | public void testCoordinatedFields() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 280 | // [base=Mann&(cas=N|cas=A)] |
| 281 | String cof1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 282 | "{@type=korap:token, wrap=" + |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 283 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 284 | "{@type=korap:term, layer=lemma, key=Mann, match=match:eq}," + |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 285 | "{@type=korap:termGroup, relation=relation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 286 | "{@type=korap:term, layer=cas, key=N, match=match:eq}," + |
| 287 | "{@type=korap:term, layer=cas, key=A, match=match:eq}" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 288 | "]}" + |
| 289 | "]}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 290 | "}"; |
| 291 | ppt = new PoliqarpPlusTree("[base=Mann&(cas=N|cas=A)]"); |
| 292 | map = ppt.getRequestMap().get("query").toString(); |
| 293 | assertEquals(cof1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Nils Diewald | 7d486c2 | 2013-12-13 16:32:18 +0000 | [diff] [blame] | 294 | |
| 295 | |
| 296 | assertEquals( |
| 297 | new PoliqarpPlusTree(" [ base=Mann & ( cas=N | cas=A)] ").getRequestMap().get("query").toString(), |
| 298 | new PoliqarpPlusTree("[base=Mann &(cas=N|cas=A)]").getRequestMap().get("query").toString() |
| 299 | ); |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 300 | |
| 301 | // [base=Mann&cas=N&gen=m] |
| 302 | String cof2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 303 | "{@type=korap:token, wrap=" + |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 304 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 305 | "{@type=korap:term, layer=lemma, key=Mann, match=match:eq}," + |
| 306 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 307 | "{@type=korap:term, layer=cas, key=N, match=match:eq}," + |
| 308 | "{@type=korap:term, layer=gen, key=m, match=match:eq}" + |
| 309 | "]}" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 310 | "]}" + |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 311 | "}"; |
| 312 | ppt = new PoliqarpPlusTree("[base=Mann&cas=N&gen=m]"); |
| 313 | map = ppt.getRequestMap().get("query").toString(); |
| 314 | assertEquals(cof2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 318 | public void testOccurrence() throws QueryException { |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 319 | // [base=foo]* |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 320 | String occ1 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 321 | "{@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] | 322 | "], min=0, max=100}"; |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 323 | ppt = new PoliqarpPlusTree("[base=foo]*"); |
| 324 | map = ppt.getRequestMap().get("query").toString(); |
| 325 | assertEquals(occ1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 326 | |
| 327 | // [base=foo]*[base=bar] |
| 328 | String occ2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 329 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 330 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 331 | "{@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] | 332 | "], min=0, max=100 }," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 333 | "{@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] | 334 | "]}"; |
| 335 | ppt = new PoliqarpPlusTree("[base=foo]*[base=bar]"); |
| 336 | map = ppt.getRequestMap().get("query").toString(); |
| 337 | assertEquals(occ2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 338 | |
| 339 | // [base=bar][base=foo]* |
| 340 | String occ3 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 341 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 342 | "{@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] | 343 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 344 | "{@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] | 345 | "], min=0, max=100 }" + |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 346 | "]}"; |
| 347 | ppt = new PoliqarpPlusTree("[base=bar][base=foo]*"); |
| 348 | map = ppt.getRequestMap().get("query").toString(); |
| 349 | assertEquals(occ3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 350 | |
| 351 | // ([base=bar][base=foo])* |
| 352 | String occ4 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 353 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 354 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 355 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 356 | "{@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] | 357 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 358 | "], min=0, max=100}" ; |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 359 | ppt = new PoliqarpPlusTree("([base=bar][base=foo])*"); |
| 360 | map = ppt.getRequestMap().get("query").toString(); |
| 361 | assertEquals(occ4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 362 | |
| 363 | // <s>([base=bar][base=foo])* |
| 364 | String occ5 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 365 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 366 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 367 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 368 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 369 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 370 | "{@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] | 371 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 372 | "], min=0, max=100 }" + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 373 | "]}" ; |
| 374 | ppt = new PoliqarpPlusTree("<s>([base=bar][base=foo])*"); |
| 375 | map = ppt.getRequestMap().get("query").toString(); |
| 376 | assertEquals(occ5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 377 | |
| 378 | // <s><np>([base=bar][base=foo])* |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 379 | String occ6 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 380 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 381 | "{@type=korap:span, key=s}," + |
| 382 | "{@type=korap:span, key=np}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 383 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 384 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 385 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 386 | "{@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] | 387 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 388 | "], min=0, max=100 }" + |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 389 | "]}" ; |
| 390 | ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*"); |
| 391 | map = ppt.getRequestMap().get("query").toString(); |
| 392 | assertEquals(occ6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 393 | |
| 394 | // <s><np>([base=bar][base=foo])*[p=NN] |
| 395 | // comment: embedded sequence shouldn't really be here, but does not really hurt, either. (?) |
| 396 | // really hard to get this behaviour out of the PQPlus grammar... |
| 397 | String occ7 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 398 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 399 | "{@type=korap:span, key=s}," + |
| 400 | "{@type=korap:span, key=np}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 401 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 402 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 403 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 404 | "{@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] | 405 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 406 | "], min=0, max=100 }," + |
| 407 | "{@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] | 408 | "]}" ; |
| 409 | ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*[p=NN]"); |
| 410 | map = ppt.getRequestMap().get("query").toString(); |
| 411 | assertEquals(occ7.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 412 | |
| 413 | // ([base=bar][base=foo])*[p=NN] |
Joachim Bingel | b4da702 | 2013-12-09 23:17:24 +0000 | [diff] [blame] | 414 | String occ8 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 415 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 416 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 417 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 418 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," + |
| 419 | "{@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] | 420 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 421 | "], min=0, max=100 }," + |
| 422 | "{@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] | 423 | "]}" ; |
| 424 | ppt = new PoliqarpPlusTree("([base=bar][base=foo])*[p=NN]"); |
| 425 | map = ppt.getRequestMap().get("query").toString(); |
| 426 | assertEquals(occ8.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 427 | |
| 428 | // [base=foo]+ |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 429 | String occ9 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 430 | "{@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] | 431 | "], min=1, max=100}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 432 | ppt = new PoliqarpPlusTree("[base=foo]+"); |
| 433 | map = ppt.getRequestMap().get("query").toString(); |
| 434 | assertEquals(occ9.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 435 | |
| 436 | // [base=foo]? |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 437 | String occ10 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 438 | "{@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] | 439 | "], min=0, max=1}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 440 | ppt = new PoliqarpPlusTree("[base=foo]?"); |
| 441 | map = ppt.getRequestMap().get("query").toString(); |
| 442 | assertEquals(occ10.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 443 | |
| 444 | // [base=foo]{2,5} |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 445 | String occ11 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 446 | "{@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] | 447 | "], min=2, max=5}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 448 | ppt = new PoliqarpPlusTree("[base=foo]{2,5}"); |
| 449 | map = ppt.getRequestMap().get("query").toString(); |
| 450 | assertEquals(occ11.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 451 | |
| 452 | // [base=foo]{2} |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 453 | String occ12 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 454 | "{@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] | 455 | "], min=2, max=2}"; |
Joachim Bingel | 2980bda | 2014-04-04 12:09:46 +0000 | [diff] [blame] | 456 | ppt = new PoliqarpPlusTree("[base=foo]{2}"); |
| 457 | map = ppt.getRequestMap().get("query").toString(); |
| 458 | assertEquals(occ12.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b2aa1c7 | 2014-07-01 12:48:46 +0000 | [diff] [blame] | 459 | |
| 460 | // [base=foo]{2} |
| 461 | String occ13 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 462 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
| 463 | "], min=2, max=100}"; |
| 464 | ppt = new PoliqarpPlusTree("[base=foo]{2,}"); |
| 465 | map = ppt.getRequestMap().get("query").toString(); |
| 466 | assertEquals(occ13.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 467 | |
| 468 | // [base=foo]{2} |
| 469 | String occ14 = "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 470 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" + |
| 471 | "], min=0, max=2}"; |
| 472 | ppt = new PoliqarpPlusTree("[base=foo]{,2}"); |
| 473 | map = ppt.getRequestMap().get("query").toString(); |
| 474 | assertEquals(occ14.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 478 | public void testTokenSequence() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 479 | // [base=Mann][orth=Frau] |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 480 | String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 481 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " + |
| 482 | "{@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] | 483 | "]}"; |
| 484 | assertTrue(equalsQueryContent(seq1, "[base=Mann][orth=Frau]")); |
| 485 | |
| 486 | // [base=Mann][orth=Frau][p=NN] |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 487 | String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 488 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}, " + |
| 489 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Frau, match=match:eq}}, " + |
| 490 | "{@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] | 491 | "]}"; |
| 492 | assertTrue(equalsQueryContent(seq2, "[base=Mann][orth=Frau][p=NN]")); |
| 493 | } |
| 494 | |
| 495 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 496 | public void testDisjSegments() throws QueryException { |
Joachim Bingel | 94a1ccd | 2013-12-10 10:37:29 +0000 | [diff] [blame] | 497 | // ([base=der]|[base=das])[base=Schild] |
| 498 | String disj1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 499 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 500 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 501 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 502 | "{@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] | 503 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 504 | "{@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] | 505 | "]}"; |
| 506 | ppt = new PoliqarpPlusTree("([base=der]|[base=das])[base=Schild]"); |
| 507 | map = ppt.getRequestMap().get("query").toString(); |
| 508 | assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 509 | |
| 510 | // [base=Schild]([base=der]|[base=das]) |
| 511 | String disj2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 512 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 513 | "{@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] | 514 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 515 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=der, match=match:eq}}," + |
| 516 | "{@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] | 517 | "]}" + |
| 518 | "]}"; |
| 519 | ppt = new PoliqarpPlusTree("[base=Schild]([base=der]|[base=das])"); |
| 520 | map = ppt.getRequestMap().get("query").toString(); |
| 521 | assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 76b498d | 2014-06-06 12:06:46 +0000 | [diff] [blame] | 522 | |
| 523 | // "([orth=der][base=katze])|([orth=eine][base=baum])" |
| 524 | String disj3 = |
| 525 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 526 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 527 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 528 | "{@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] | 529 | "]}," + |
| 530 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 531 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=eine, match=match:eq}}," + |
| 532 | "{@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] | 533 | "]}" + |
| 534 | "]}"; |
| 535 | ppt = new PoliqarpPlusTree("([orth=der][base=katze])|([orth=eine][base=baum])"); |
| 536 | map = ppt.getRequestMap().get("query").toString(); |
| 537 | assertEquals(disj3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 538 | |
| 539 | // "[orth=der][base=katze]|[orth=eine][base=baum]" |
| 540 | String disj4 = |
| 541 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 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=orth, key=der, match=match:eq}}," + |
| 544 | "{@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] | 545 | "]}," + |
| 546 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 547 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=eine, match=match:eq}}," + |
| 548 | "{@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] | 549 | "]}" + |
| 550 | "]}"; |
| 551 | ppt = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=eine][base=baum]"); |
| 552 | map = ppt.getRequestMap().get("query").toString(); |
| 553 | assertEquals(disj4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 554 | |
| 555 | PoliqarpPlusTree ppt1 = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=eine][base=baum]"); |
| 556 | PoliqarpPlusTree ppt2 = new PoliqarpPlusTree("([orth=der][base=katze])|([orth=eine][base=baum])"); |
| 557 | assertEquals(ppt1.getRequestMap().toString(), ppt2.getRequestMap().toString()); |
| 558 | |
| 559 | // "[orth=der][base=katze]|[orth=der][base=hund]|[orth=der][base=baum]" |
| 560 | String disj5 = |
| 561 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 562 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 563 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 564 | "{@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] | 565 | "]}," + |
| 566 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 567 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 568 | "{@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] | 569 | "]}," + |
| 570 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 571 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 572 | "{@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] | 573 | "]}" + |
| 574 | "]}"; |
| 575 | ppt = new PoliqarpPlusTree("[orth=der][base=katze]|[orth=der][base=hund]|[orth=der][base=baum]"); |
| 576 | map = ppt.getRequestMap().get("query").toString(); |
| 577 | assertEquals(disj5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 578 | |
| 579 | // [orth=der]([base=katze]|[base=hund]|[base=baum]) |
| 580 | String disj6 = |
| 581 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 582 | "{@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] | 583 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 584 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=katze, match=match:eq}}," + |
| 585 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=hund, match=match:eq}}," + |
| 586 | "{@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] | 587 | "]}" + |
| 588 | "]}"; |
| 589 | ppt = new PoliqarpPlusTree("[orth=der]([base=katze]|[base=hund]|[base=baum])"); |
| 590 | map = ppt.getRequestMap().get("query").toString(); |
| 591 | assertEquals(disj6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 94a1ccd | 2013-12-10 10:37:29 +0000 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 595 | public void testTokenElemSequence() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 596 | // [base=Mann]<vp> |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 597 | String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 598 | "{@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] | 599 | "{@type=korap:span, key=vp}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 600 | "]}"; |
| 601 | assertTrue(equalsQueryContent(seq1, "[base=Mann]<vp>")); |
| 602 | |
| 603 | // <vp>[base=Mann] |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 604 | String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 605 | "{@type=korap:span, key=vp}, "+ |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 606 | "{@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] | 607 | "]}"; |
| 608 | assertTrue(equalsQueryContent(seq2, "<vp>[base=Mann]")); |
| 609 | |
| 610 | // <vp>[base=Mann]<pp> |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 611 | String seq3 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 612 | "{@type=korap:span, key=vp}, "+ |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 613 | "{@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] | 614 | "{@type=korap:span, key=pp} "+ |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 615 | "]}"; |
| 616 | assertTrue(equalsQueryContent(seq3, "<vp>[base=Mann]<pp>")); |
| 617 | } |
| 618 | |
| 619 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 620 | public void testElemSequence() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 621 | // <np><vp> |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 622 | String seq1 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 623 | "{@type=korap:span, key=np}," + |
| 624 | "{@type=korap:span, key=vp}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 625 | "]}"; |
| 626 | assertTrue(equalsQueryContent(seq1, "<np><vp>")); |
| 627 | |
| 628 | // <np><vp><pp> |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 629 | String seq2 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 630 | "{@type=korap:span, key=np}," + |
| 631 | "{@type=korap:span, key=vp}," + |
| 632 | "{@type=korap:span, key=pp}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 633 | "]}"; |
| 634 | assertTrue(equalsQueryContent(seq2, "<np><vp><pp>")); |
| 635 | } |
| 636 | |
| 637 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 638 | public void testClasses() throws QueryException { |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 639 | String query; |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 640 | // {[base=Mann]} |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 641 | String cls1 = "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 642 | "{@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] | 643 | "]}"; |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 644 | ppt = new PoliqarpPlusTree("{[base=Mann]}"); |
| 645 | map = ppt.getRequestMap().get("query").toString(); |
| 646 | assertEquals(cls1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 647 | |
| 648 | // {[base=Mann][orth=Frau]} |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 649 | query = "{[base=Mann][orth=Frau]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 650 | String cls2 = "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 651 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 652 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," + |
| 653 | "{@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] | 654 | "]}" + |
| 655 | "]}"; |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 656 | ppt = new PoliqarpPlusTree(query); |
| 657 | map = ppt.getRequestMap().get("query").toString(); |
| 658 | assertEquals(cls2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 659 | |
| 660 | // [p=NN]{[base=Mann][orth=Frau]} |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 661 | String cls3 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 662 | "{@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] | 663 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 664 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 665 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," + |
| 666 | "{@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] | 667 | "]}" + |
| 668 | "]}" + |
| 669 | "]}"; |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 670 | ppt = new PoliqarpPlusTree("[p=NN]{[base=Mann][orth=Frau]}"); |
| 671 | map = ppt.getRequestMap().get("query").toString(); |
| 672 | assertEquals(cls3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 673 | |
| 674 | // {[base=Mann][orth=Frau]}[p=NN] |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 675 | String cls4 = "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 676 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 677 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 678 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," + |
| 679 | "{@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] | 680 | "]}" + |
| 681 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 682 | "{@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] | 683 | "]}"; |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 684 | ppt = new PoliqarpPlusTree("{[base=Mann][orth=Frau]}[p=NN]"); |
| 685 | map = ppt.getRequestMap().get("query").toString(); |
| 686 | assertEquals(cls4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 687 | |
| 688 | // {2:{1:[tt/p=ADJA]}[mate/p=NN]}" |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 689 | String cls5 = "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 690 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 691 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 692 | "{@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] | 693 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 694 | "{@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] | 695 | "]}" + |
| 696 | "]}"; |
| 697 | ppt = new PoliqarpPlusTree("{2: {1:[tt/p=ADJA]}[mate/p=NN]}"); |
| 698 | map = ppt.getRequestMap().get("query").toString(); |
| 699 | assertEquals(cls5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 700 | } |
| 701 | |
| 702 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 703 | public void testPositions() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 704 | // contains(<s>,<np>) |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 705 | String pos1 = "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 706 | "{@type=korap:span, key=s}," + |
| 707 | "{@type=korap:span, key=np}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 708 | "]}"; |
| 709 | assertTrue(equalsQueryContent(pos1, "contains(<s>,<np>)")); |
| 710 | |
| 711 | // contains(<s>,[base=Mann]) |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 712 | String pos2 = "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 713 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 714 | "{@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] | 715 | "]}"; |
| 716 | assertTrue(equalsQueryContent(pos2, "contains(<s>,[base=Mann])")); |
| 717 | |
| 718 | // contains(<s>,[orth=der][orth=Mann]) |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 719 | String pos3 = "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 720 | "{@type=korap:span, key=s}," + |
| 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}}," + |
| 723 | "{@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] | 724 | "]}" + |
| 725 | "]}"; |
| 726 | ppt = new PoliqarpPlusTree("contains(<s>,[orth=der][orth=Mann])"); |
| 727 | map = ppt.getRequestMap().get("query").toString(); |
| 728 | assertEquals(pos3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 729 | |
| 730 | // [base=Auto]contains(<s>,[base=Mann]) |
| 731 | String pos4 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 732 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 733 | "{@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] | 734 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 735 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 736 | "{@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] | 737 | "]}" + |
| 738 | "]}"; |
| 739 | ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[base=Mann])"); |
| 740 | map = ppt.getRequestMap().get("query").toString(); |
| 741 | assertEquals(pos4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | ef7059b | 2014-04-22 13:44:19 +0000 | [diff] [blame] | 742 | |
| 743 | // contains(<s>,[pos=N]*) |
| 744 | String pos5 = |
| 745 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 746 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 747 | "{@type=korap:group, operation=operation:repetition, " + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 748 | "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] | 749 | "], min=0, max=100" + |
Joachim Bingel | ef7059b | 2014-04-22 13:44:19 +0000 | [diff] [blame] | 750 | "}" + |
| 751 | "]}"; |
| 752 | ppt = new PoliqarpPlusTree("contains(<s>,[pos=N]*)"); |
| 753 | map = ppt.getRequestMap().get("query").toString(); |
| 754 | assertEquals(pos5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 755 | |
| 756 | // [base=Auto]contains(<s>,[pos=N]*) |
| 757 | String pos6 = |
| 758 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 759 | "{@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] | 760 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 761 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 33bd45f | 2014-06-25 15:00:54 +0000 | [diff] [blame] | 762 | "{@type=korap:group, operation=operation:repetition, " + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 763 | "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] | 764 | "], min=0, max=100" + |
Joachim Bingel | ef7059b | 2014-04-22 13:44:19 +0000 | [diff] [blame] | 765 | "}" + |
| 766 | "]}" + |
| 767 | "]}"; |
| 768 | ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[pos=N]*)"); |
| 769 | map = ppt.getRequestMap().get("query").toString(); |
| 770 | assertEquals(pos6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 774 | public void testNestedPositions() throws QueryException { |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 775 | // contains(<s>,startswith(<np>,[orth=Der])) |
| 776 | String npos1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 777 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 778 | "{@type=korap:span, key=s}," + |
| 779 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 780 | "{@type=korap:span, key=np}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 781 | "{@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] | 782 | "]}" + |
| 783 | "]}"; |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 784 | ppt = new PoliqarpPlusTree("contains(<s>, startswith(<np>,[orth=Der]))"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 785 | map = ppt.getRequestMap().get("query").toString(); |
| 786 | assertEquals(npos1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 787 | } |
| 788 | |
| 789 | @Test |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 790 | public void testShrinkSplit() throws QueryException { |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 791 | // focus([orth=Der]{[orth=Mann]}) |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 792 | String shr1 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame^] | 793 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 794 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 795 | "{@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] | 796 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 797 | "{@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] | 798 | "]}" + |
| 799 | "]}" + |
| 800 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 801 | ppt = new PoliqarpPlusTree("focus([orth=Der]{[orth=Mann]})"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 802 | map = ppt.getRequestMap().get("query").toString(); |
| 803 | assertEquals(shr1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 804 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 805 | // focus([orth=Der]{[orth=Mann][orth=geht]}) |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 806 | String shr2 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame^] | 807 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 808 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 809 | "{@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] | 810 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 811 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 812 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}," + |
| 813 | "{@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] | 814 | "]}" + |
| 815 | "]}" + |
| 816 | "]}" + |
| 817 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 818 | ppt = new PoliqarpPlusTree("focus([orth=Der]{[orth=Mann][orth=geht]})"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 819 | map = ppt.getRequestMap().get("query").toString(); |
| 820 | assertEquals(shr2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 821 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 822 | // focus(1:[orth=Der]{1:[orth=Mann][orth=geht]}) |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 823 | String shr3 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame^] | 824 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 825 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 826 | "{@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] | 827 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 828 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 829 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}," + |
| 830 | "{@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] | 831 | "]}" + |
| 832 | "]}" + |
| 833 | "]}" + |
| 834 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 835 | ppt = new PoliqarpPlusTree("focus(1:[orth=Der]{1:[orth=Mann][orth=geht]})"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 836 | map = ppt.getRequestMap().get("query").toString(); |
| 837 | assertEquals(shr3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 838 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 839 | // focus(1:startswith(<s>,{1:<np>})) |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 840 | String shr4 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame^] | 841 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 842 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 843 | "{@type=korap:span, key=s}," + |
| 844 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 845 | "{@type=korap:span, key=np}" + |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 846 | "]}" + |
| 847 | "]}" + |
| 848 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 849 | ppt = new PoliqarpPlusTree("focus(1:startswith(<s>,{1:<np>}))"); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 850 | map = ppt.getRequestMap().get("query").toString(); |
| 851 | assertEquals(shr4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | cd9ed33 | 2013-12-09 21:01:35 +0000 | [diff] [blame] | 852 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 853 | // 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] | 854 | String shr5 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame^] | 855 | "{@type=korap:reference, operation=operation:focus, classRef=[3], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 856 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 857 | "{@type=korap:span, key=s}," + |
| 858 | "{@type=korap:group, operation=operation:class, class=3, operands=[" + |
| 859 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 860 | "{@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] | 861 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 862 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 863 | "{@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] | 864 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 865 | "{@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] | 866 | "]}" + |
| 867 | "]}" + |
| 868 | "]}" + |
| 869 | "]}" + |
| 870 | "]}" + |
| 871 | "]}" + |
| 872 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 873 | 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] | 874 | map = ppt.getRequestMap().get("query").toString(); |
| 875 | assertEquals(shr5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 876 | |
| 877 | // split(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) |
| 878 | String shr6 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame^] | 879 | "{@type=korap:reference, operation=operation:split, classRef=[3], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 880 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 881 | "{@type=korap:span, key=s}," + |
| 882 | "{@type=korap:group, operation=operation:class, class=3, operands=[" + |
| 883 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 884 | "{@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] | 885 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 886 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 887 | "{@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] | 888 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 889 | "{@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] | 890 | "]}" + |
| 891 | "]}" + |
| 892 | "]}" + |
| 893 | "]}" + |
| 894 | "]}" + |
| 895 | "]}" + |
| 896 | "]}"; |
| 897 | ppt = new PoliqarpPlusTree("split(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) "); |
| 898 | map = ppt.getRequestMap().get("query").toString(); |
| 899 | assertEquals(shr6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 900 | |
| 901 | // split(2|3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) |
| 902 | String shr7 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame^] | 903 | "{@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] | 904 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 905 | "{@type=korap:span, key=s}," + |
| 906 | "{@type=korap:group, operation=operation:class, class=3, operands=[" + |
| 907 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 908 | "{@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] | 909 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 910 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 911 | "{@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] | 912 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 913 | "{@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] | 914 | "]}" + |
| 915 | "]}" + |
| 916 | "]}" + |
| 917 | "]}" + |
| 918 | "]}" + |
| 919 | "]}" + |
| 920 | "]}"; |
| 921 | ppt = new PoliqarpPlusTree("split(2|3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) "); |
| 922 | map = ppt.getRequestMap().get("query").toString(); |
| 923 | assertEquals(shr7.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 5146ebe | 2014-06-12 08:49:21 +0000 | [diff] [blame] | 924 | |
| 925 | |
| 926 | String shr8 = |
Joachim Bingel | d1a3e71 | 2014-07-16 08:02:05 +0000 | [diff] [blame^] | 927 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | add0fb1 | 2014-06-24 08:54:14 +0000 | [diff] [blame] | 928 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 929 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 930 | "{@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] | 931 | "]}," + |
| 932 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 933 | "{@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] | 934 | "]}" + |
Joachim Bingel | add0fb1 | 2014-06-24 08:54:14 +0000 | [diff] [blame] | 935 | "]}" + |
| 936 | "]}"; |
Joachim Bingel | f8dfcf8 | 2014-06-25 09:57:44 +0000 | [diff] [blame] | 937 | ppt = new PoliqarpPlusTree("focus(1:{[base=der]}{1:[pos=ADJA]})"); |
Joachim Bingel | add0fb1 | 2014-06-24 08:54:14 +0000 | [diff] [blame] | 938 | map = ppt.getRequestMap().get("query").toString(); |
| 939 | assertEquals(shr8.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 5146ebe | 2014-06-12 08:49:21 +0000 | [diff] [blame] | 940 | |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 941 | } |
| 942 | |
Joachim Bingel | 0388270 | 2013-12-31 19:53:05 +0000 | [diff] [blame] | 943 | |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 944 | @Test |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 945 | public void testFoundries() throws QueryException { |
| 946 | // [tt/base=Mann] |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 947 | 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] | 948 | ppt = new PoliqarpPlusTree("[tt/base=Mann]"); |
| 949 | map = ppt.getRequestMap().get("query").toString(); |
| 950 | assertEquals(layer1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 951 | |
| 952 | } |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 953 | |
| 954 | @Test |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 955 | public void testAlign() throws QueryException { |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 956 | // [orth=der]^[orth=Mann] |
| 957 | String align1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 958 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 959 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 960 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
| 961 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" + |
| 962 | "], align=align:left}" + |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 963 | "]}"; |
| 964 | ppt = new PoliqarpPlusTree("[orth=der]^[orth=Mann]"); |
| 965 | map = ppt.getRequestMap().get("query").toString(); |
| 966 | assertEquals(align1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 967 | |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 968 | // [orth=der]^[orth=große][orth=Mann] |
| 969 | String query = "[orth=der]^[orth=große][orth=Mann]"; |
| 970 | String align1b = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 971 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 972 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=der, match=match:eq}}," + |
| 973 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 974 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 975 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=große, match=match:eq}}," + |
| 976 | "{@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] | 977 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 978 | "], align=align:left}" + |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 979 | "]}"; |
| 980 | ppt = new PoliqarpPlusTree(query); |
| 981 | map = ppt.getRequestMap().get("query").toString(); |
| 982 | assertEquals(align1b.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 983 | |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 984 | // "([base=a]^[base=b])|[base=c]", |
| 985 | String align2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 986 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 987 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 988 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=a, match=match:eq}}," + |
| 989 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
| 990 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=b, match=match:eq}}" + |
| 991 | "], align=align:left}" + |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 992 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 993 | "{@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] | 994 | "]}"; |
| 995 | ppt = new PoliqarpPlusTree("([base=a]^[base=b])|[base=c]"); |
| 996 | map = ppt.getRequestMap().get("query").toString(); |
| 997 | assertEquals(align2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 998 | |
| 999 | // "([base=a]^[base=b][base=c])|[base=d]", |
| 1000 | String align3 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1001 | "{@type=korap:group, operation=operation:or, 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, layer=lemma, key=a, match=match:eq}}," + |
| 1004 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1005 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1006 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=b, match=match:eq}}," + |
| 1007 | "{@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] | 1008 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1009 | "], align=align:left}" + |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1010 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1011 | "{@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] | 1012 | "]}"; |
| 1013 | ppt = new PoliqarpPlusTree("([base=a]^[base=b][base=c])|[base=d]"); |
| 1014 | map = ppt.getRequestMap().get("query").toString(); |
| 1015 | assertEquals(align3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1016 | |
| 1017 | // "([base=a]^[base=b]^[base=c])|[base=d]", |
| 1018 | String align4 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1019 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 1020 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1021 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=a, match=match:eq}}," + |
| 1022 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 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=b, match=match:eq}}," + |
| 1025 | "{@type=korap:group, operation=operation:alignment, operands=[" + |
| 1026 | "{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=c, match=match:eq}}" + |
| 1027 | "], align=align:left}" + |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 1028 | "]}" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1029 | "], align=align:left}" + |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1030 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1031 | "{@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] | 1032 | "]}"; |
| 1033 | ppt = new PoliqarpPlusTree("([base=a]^[base=b]^[base=c])|[base=d]"); |
| 1034 | map = ppt.getRequestMap().get("query").toString(); |
| 1035 | assertEquals(align4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1036 | |
| 1037 | |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1038 | } |
| 1039 | |
| 1040 | @Test |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 1041 | public void testSimpleQueries() throws QueryException { |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1042 | // Baum |
| 1043 | String simple1 = |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1044 | "{@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] | 1045 | ppt = new PoliqarpPlusTree("Baum"); |
| 1046 | map = ppt.getRequestMap().get("query").toString(); |
| 1047 | assertEquals(simple1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1048 | |
| 1049 | // Baum/i |
| 1050 | String simple1b = |
| 1051 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq, caseInsensitive=true}}"; |
| 1052 | ppt = new PoliqarpPlusTree("Baum/i"); |
| 1053 | map = ppt.getRequestMap().get("query").toString(); |
| 1054 | assertEquals(simple1b.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1055 | |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1056 | // Der Baum |
| 1057 | String simple2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1058 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1059 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " + |
| 1060 | "{@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] | 1061 | "]}"; |
| 1062 | ppt = new PoliqarpPlusTree("Der Baum"); |
| 1063 | map = ppt.getRequestMap().get("query").toString(); |
| 1064 | assertEquals(simple2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1065 | |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1066 | // Der Baum/i |
| 1067 | String simple2b = |
| 1068 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1069 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " + |
| 1070 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq, caseInsensitive=true}}" + |
| 1071 | "]}"; |
| 1072 | ppt = new PoliqarpPlusTree("Der Baum/i"); |
| 1073 | map = ppt.getRequestMap().get("query").toString(); |
| 1074 | assertEquals(simple2b.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1075 | |
Joachim Bingel | a67e6a3 | 2014-01-02 18:35:24 +0000 | [diff] [blame] | 1076 | // Der große Baum |
| 1077 | String simple3 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1078 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1079 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Der, match=match:eq}}, " + |
| 1080 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=große, match=match:eq}}, " + |
| 1081 | "{@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] | 1082 | "]}"; |
| 1083 | ppt = new PoliqarpPlusTree("Der große Baum"); |
| 1084 | map = ppt.getRequestMap().get("query").toString(); |
| 1085 | assertEquals(simple3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1086 | |
| 1087 | // Baum | Stein |
| 1088 | String simple4 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1089 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1090 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}, " + |
| 1091 | "{@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] | 1092 | "]}"; |
| 1093 | ppt = new PoliqarpPlusTree("Baum | Stein"); |
| 1094 | map = ppt.getRequestMap().get("query").toString(); |
| 1095 | assertEquals(simple4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 84e33df | 2014-01-31 14:02:46 +0000 | [diff] [blame] | 1096 | |
| 1097 | // Baum | Stein Haus |
| 1098 | String query = "(Baum | Stein) Haus"; |
| 1099 | String simple5 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1100 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1101 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1102 | "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Baum, match=match:eq}}, " + |
| 1103 | "{@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] | 1104 | "]}," + |
Joachim Bingel | 0900a89 | 2014-06-30 16:26:21 +0000 | [diff] [blame] | 1105 | "{@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] | 1106 | "]}"; |
| 1107 | ppt = new PoliqarpPlusTree(query); |
| 1108 | map = ppt.getRequestMap().get("query").toString(); |
| 1109 | assertEquals(simple5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 16da4e1 | 2013-12-17 09:48:12 +0000 | [diff] [blame] | 1110 | } |
Joachim Bingel | 53333e6 | 2013-12-09 19:25:52 +0000 | [diff] [blame] | 1111 | } |
| 1112 | |