Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 1 | import static org.junit.Assert.*; |
| 2 | |
| 3 | import org.junit.Test; |
| 4 | |
| 5 | import de.ids_mannheim.korap.query.serialize.CosmasTree; |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 6 | import de.ids_mannheim.korap.util.QueryException; |
| 7 | |
| 8 | public class CosmasTreeTest { |
| 9 | |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 10 | CosmasTree ct; |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 11 | String map; |
| 12 | String query; |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 13 | String expected; |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 14 | |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 15 | @Test |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 16 | public void testContext() throws QueryException { |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 17 | String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 18 | ct = new CosmasTree("Test"); |
| 19 | assertEquals(contextString.replaceAll(" ", ""), ct.getRequestMap().get("@context").toString().replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | |
| 23 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 24 | public void testSingleToken() throws QueryException { |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 25 | query="der"; |
| 26 | String single1 = |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 27 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 28 | ct = new CosmasTree(query); |
| 29 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 30 | assertEquals(single1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Michael Hanl | baf1a5e | 2014-05-15 19:51:40 +0000 | [diff] [blame] | 31 | |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 32 | query="Mann"; |
| 33 | String single2 = |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 34 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 35 | ct = new CosmasTree(query); |
| 36 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 37 | assertEquals(single2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 38 | |
| 39 | query="&Mann"; |
| 40 | String single3 = |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 41 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=lemma, match=match:eq}}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 42 | ct = new CosmasTree(query); |
| 43 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 44 | assertEquals(single3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 45 | } |
| 46 | |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 47 | @Test |
Joachim Bingel | 9a202ab | 2014-10-07 12:35:17 +0000 | [diff] [blame] | 48 | public void testWildcardToken() throws QueryException { |
| 49 | query="*der"; |
| 50 | String wc1 = |
| 51 | "{@type=korap:token, wrap={@type=korap:term, type=type:wildcard, key=*der, layer=orth, match=match:eq}}"; |
| 52 | ct = new CosmasTree(query); |
| 53 | map = ct.getRequestMap().get("query").toString(); |
| 54 | assertEquals(wc1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 55 | } |
| 56 | |
| 57 | @Test |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 58 | public void testCaseSensitivityFlag() throws QueryException { |
Joachim Bingel | 0207d5e | 2014-02-12 14:18:41 +0000 | [diff] [blame] | 59 | query="$deutscher"; |
| 60 | String cs1 = |
| 61 | "{@type=korap:token, wrap={@type=korap:term, caseInsensitive=true, key=deutscher, layer=orth, match=match:eq}}"; |
| 62 | ct = new CosmasTree(query); |
| 63 | map = ct.getRequestMap().get("query").toString(); |
| 64 | assertEquals(cs1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 65 | |
| 66 | query="$deutscher Bundestag"; |
| 67 | String cs2 = |
| 68 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 69 | "{@type=korap:token, wrap={@type=korap:term, caseInsensitive=true, key=deutscher, layer=orth, match=match:eq}}," + |
| 70 | "{@type=korap:token, wrap={@type=korap:term, key=Bundestag, layer=orth, match=match:eq}}" + |
| 71 | "]}"; |
| 72 | ct = new CosmasTree(query); |
| 73 | map = ct.getRequestMap().get("query").toString(); |
| 74 | assertEquals(cs2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | @Test |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 78 | public void testMORPH() throws QueryException { |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 79 | query="MORPH(pos=V)"; |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 80 | String morph1 = |
Joachim Bingel | 0207d5e | 2014-02-12 14:18:41 +0000 | [diff] [blame] | 81 | "{@type=korap:token, wrap={@type=korap:term, key=V, layer=pos, match=match:eq}}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 82 | ct = new CosmasTree(query); |
| 83 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 84 | assertEquals(morph1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d73a185 | 2014-12-01 11:06:23 +0000 | [diff] [blame] | 85 | |
| 86 | query="MORPH(V)"; |
| 87 | expected = |
| 88 | "{@type=korap:token, wrap={@type=korap:term, key=V, match=match:eq}}"; |
| 89 | ct = new CosmasTree(query); |
| 90 | map = ct.getRequestMap().get("query").toString(); |
| 91 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 94 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 95 | public void testSequence() throws QueryException { |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 96 | query="der Mann"; |
| 97 | String seq1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 98 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 99 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 100 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 101 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 102 | ct = new CosmasTree(query); |
| 103 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 104 | assertEquals(seq1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 105 | |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 106 | query="der Mann schläft"; |
| 107 | String seq2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 108 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 109 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 110 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," + |
| 111 | "{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}" + |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 112 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 113 | ct = new CosmasTree(query); |
| 114 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 115 | assertEquals(seq2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 116 | |
| 117 | query="der Mann schläft lang"; |
| 118 | String seq3 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 119 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 120 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 121 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," + |
| 122 | "{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}," + |
| 123 | "{@type=korap:token, wrap={@type=korap:term, key=lang, layer=orth, match=match:eq}}" + |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 124 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 125 | ct = new CosmasTree(query); |
| 126 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 127 | assertEquals(seq3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 896067a | 2014-11-07 19:02:27 +0000 | [diff] [blame] | 128 | |
| 129 | query="der #ELEM(S)"; |
| 130 | expected = |
| 131 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 132 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 133 | "{@type=korap:span, key=s}" + |
| 134 | "]}"; |
| 135 | ct = new CosmasTree(query); |
| 136 | map = ct.getRequestMap().get("query").toString(); |
| 137 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 138 | |
| 139 | query="der MORPH(mate/p=ADJA)"; |
| 140 | expected = |
| 141 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 142 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 143 | "{@type=korap:token, wrap={@type=korap:term, key=ADJA, foundry=mate, layer=p, match=match:eq}}" + |
| 144 | "]}"; |
| 145 | ct = new CosmasTree(query); |
| 146 | map = ct.getRequestMap().get("query").toString(); |
| 147 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | @Test |
| 151 | public void testOPOR() throws QueryException { |
| 152 | query="Sonne oder Mond"; |
| 153 | String disj1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 154 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 155 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 156 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 157 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 158 | ct = new CosmasTree(query); |
| 159 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 160 | assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 161 | |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 162 | query="(Sonne scheint) oder Mond"; |
| 163 | String disj2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 164 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 165 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 166 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 167 | "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" + |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 168 | "]}," + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 169 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 170 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 171 | ct = new CosmasTree(query); |
| 172 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 173 | assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 174 | |
| 175 | query="(Sonne scheint) oder (Mond scheint)"; |
| 176 | String disj3 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 177 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 178 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 179 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 180 | "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" + |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 181 | "]}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 182 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 183 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," + |
| 184 | "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" + |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 185 | "]}" + |
| 186 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 187 | ct = new CosmasTree(query); |
| 188 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 189 | assertEquals(disj3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 190 | |
| 191 | } |
| 192 | |
| 193 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 194 | public void testOPORAND() throws QueryException { |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 195 | query="(Sonne oder Mond) und scheint"; |
| 196 | String orand1 = |
Joachim Bingel | b7a5979 | 2014-02-14 13:52:29 +0000 | [diff] [blame] | 197 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
Joachim Bingel | 832800e | 2014-10-17 14:46:39 +0000 | [diff] [blame] | 198 | "{@type=cosmas:distance, key=t, min=0, max=0}" + |
Joachim Bingel | b7a5979 | 2014-02-14 13:52:29 +0000 | [diff] [blame] | 199 | "], operands=[" + |
| 200 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 201 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 202 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 203 | "]}," + |
| 204 | "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" + |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 205 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 206 | ct = new CosmasTree(query); |
| 207 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 208 | assertEquals(orand1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 209 | |
| 210 | query="scheint und (Sonne oder Mond)"; |
| 211 | String orand2 = |
Joachim Bingel | b7a5979 | 2014-02-14 13:52:29 +0000 | [diff] [blame] | 212 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
Joachim Bingel | 832800e | 2014-10-17 14:46:39 +0000 | [diff] [blame] | 213 | "{@type=cosmas:distance, key=t, min=0, max=0}" + |
Joachim Bingel | b7a5979 | 2014-02-14 13:52:29 +0000 | [diff] [blame] | 214 | "], operands=[" + |
| 215 | "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," + |
| 216 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 217 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 218 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 219 | "]}" + |
| 220 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 221 | ct = new CosmasTree(query); |
| 222 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 223 | assertEquals(orand2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 92f9c9c | 2014-06-25 15:01:17 +0000 | [diff] [blame] | 224 | |
| 225 | query="Regen und scheint und (Sonne oder Mond)"; |
| 226 | String orand3 = |
| 227 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
Joachim Bingel | 832800e | 2014-10-17 14:46:39 +0000 | [diff] [blame] | 228 | "{@type=cosmas:distance, key=t, min=0, max=0}" + |
Joachim Bingel | 92f9c9c | 2014-06-25 15:01:17 +0000 | [diff] [blame] | 229 | "], operands=[" + |
| 230 | "{@type=korap:token, wrap={@type=korap:term, key=Regen, layer=orth, match=match:eq}}," + |
| 231 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
Joachim Bingel | 832800e | 2014-10-17 14:46:39 +0000 | [diff] [blame] | 232 | "{@type=cosmas:distance, key=t, min=0, max=0}" + |
Joachim Bingel | 92f9c9c | 2014-06-25 15:01:17 +0000 | [diff] [blame] | 233 | "], operands=[" + |
| 234 | "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," + |
| 235 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 236 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 237 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 238 | "]}" + |
| 239 | "]}" + |
| 240 | "]}"; |
| 241 | ct = new CosmasTree(query); |
| 242 | map = ct.getRequestMap().get("query").toString(); |
| 243 | assertEquals(orand3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 247 | public void testOPPROX() throws QueryException { |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 248 | query="Sonne /+w1:4 Mond"; |
| 249 | String prox1 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 250 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 251 | "{@type=korap:group, operation=operation:sequence, " + |
| 252 | "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 253 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 254 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 255 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 256 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 257 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 258 | "]}" + |
| 259 | "], inOrder=true, " + |
| 260 | "distances=[" + |
| 261 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" + |
| 262 | "]" + |
| 263 | "}" + |
| 264 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 265 | ct = new CosmasTree(query); |
| 266 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 267 | assertEquals(prox1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 268 | |
| 269 | query="Sonne /+w1:4,s0,p1:3 Mond"; |
| 270 | String prox2 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 271 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 272 | "{@type=korap:group, operation=operation:sequence, " + |
| 273 | "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 274 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 275 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 276 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 277 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 278 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 279 | "]}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 280 | "], inOrder=true, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 281 | "distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 282 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}," + |
Joachim Bingel | 832800e | 2014-10-17 14:46:39 +0000 | [diff] [blame] | 283 | "{@type=cosmas:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}," + |
| 284 | "{@type=cosmas:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3}" + |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 285 | "]" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 286 | "}" + |
| 287 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 288 | ct = new CosmasTree(query); |
| 289 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 290 | assertEquals(prox2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 291 | |
| 292 | query="Sonne %+w1:4,s0,p1:3 Mond"; |
| 293 | String prox3 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 294 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 295 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 296 | "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 297 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 298 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 299 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 300 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 301 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 302 | "]}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 303 | "], inOrder=true, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 304 | "distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 305 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4, exclude=true}," + |
Joachim Bingel | 832800e | 2014-10-17 14:46:39 +0000 | [diff] [blame] | 306 | "{@type=cosmas:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0, exclude=true}," + |
| 307 | "{@type=cosmas:distance, key=p, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3, exclude=true}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 308 | "]" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 309 | "}" + |
| 310 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 311 | ct = new CosmasTree(query); |
| 312 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 313 | // assertEquals(prox3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 314 | |
| 315 | query="Sonne /+w4 Mond"; |
| 316 | String prox4 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 317 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 318 | "{@type=korap:group, operation=operation:sequence, " + |
| 319 | "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 320 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 321 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 322 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 323 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 324 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 325 | "]}" + |
| 326 | "], inOrder=true, " + |
| 327 | "distances=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 328 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 329 | "]" + |
| 330 | "}" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 331 | "]}"; |
| 332 | // "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 333 | // "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 334 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 335 | // "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 336 | // "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 337 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 338 | // "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 339 | // "]}" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 340 | // "], frame=frame:overlaps}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 341 | // "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 342 | // "{@type=korap:group, operation=operation:sequence, " + |
| 343 | // "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 344 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 345 | // "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 346 | // "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 347 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 348 | // "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 349 | // "]}" + |
| 350 | // "], inOrder=true, " + |
| 351 | // "distances=[" + |
| 352 | // "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" + |
| 353 | // "]" + |
| 354 | // "}" + |
| 355 | // "]}" + |
| 356 | // "]}"; |
| 357 | |
| 358 | |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 359 | ct = new CosmasTree(query); |
| 360 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 361 | assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 362 | |
| 363 | query="Sonne /-w4 Mond"; |
| 364 | String prox5 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 365 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 366 | "{@type=korap:group, operation=operation:sequence, " + |
| 367 | "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 368 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 369 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 370 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 371 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 372 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 373 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 374 | "], inOrder=true, " + |
| 375 | "distances=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 376 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 377 | "]" + |
| 378 | "}" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 379 | "]}"; |
| 380 | // "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 381 | // "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 382 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 383 | // "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 384 | // "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 385 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 386 | // "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 387 | // "]}" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 388 | // "], frame=frame:overlaps}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 389 | // "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 390 | // "{@type=korap:group, operation=operation:sequence, " + |
| 391 | // "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 392 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 393 | // "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 394 | // "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 395 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 396 | // "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 397 | // "]}" + |
| 398 | // "], inOrder=true, " + |
| 399 | // "distances=[" + |
| 400 | // "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" + |
| 401 | // "]" + |
| 402 | // "}" + |
| 403 | // "]}" + |
| 404 | // "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 405 | ct = new CosmasTree(query); |
| 406 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 407 | assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 408 | |
| 409 | query="Sonne /w4 Mond"; |
| 410 | String prox6 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 411 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 412 | "{@type=korap:group, operation=operation:sequence, " + |
| 413 | "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 414 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 415 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 416 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 417 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 418 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 419 | "]}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 420 | "], inOrder=false, " + |
| 421 | "distances=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 422 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 423 | "]" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 424 | "}" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 425 | "]}"; |
| 426 | // "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 427 | // "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 428 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 429 | // "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 430 | // "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 431 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 432 | // "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 433 | // "]}" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 434 | // "], frame=frame:overlaps}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 435 | // "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 436 | // "{@type=korap:group, operation=operation:sequence, " + |
| 437 | // "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 438 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 439 | // "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 440 | // "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 441 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 442 | // "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 443 | // "]}" + |
| 444 | // "], inOrder=false, " + |
| 445 | // "distances=[" + |
| 446 | // "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" + |
| 447 | // "]" + |
| 448 | // "}" + |
| 449 | // "]}" + |
| 450 | // "]}"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 451 | ct = new CosmasTree(query); |
| 452 | map = ct.getRequestMap().get("query").toString(); |
| 453 | assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | @Test |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 457 | public void testOPPROXNested() throws QueryException { |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 458 | query="Sonne /+w1:4 Mond /-w1:7 Sterne"; |
| 459 | expected = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 460 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 461 | "{@type=korap:group, operation=operation:sequence, " + |
| 462 | "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 463 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 464 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 465 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 466 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
| 467 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 468 | "{@type=korap:group, operation=operation:sequence, " + |
| 469 | "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 470 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 471 | "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 472 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 473 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 474 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 475 | "]}" + |
| 476 | "], inOrder=true, " + |
| 477 | "distances=[" + |
| 478 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=7}, min=1, max=7}" + |
| 479 | "]" + |
| 480 | "}" + |
| 481 | "]}" + |
| 482 | "]}" + |
| 483 | "], inOrder=true, " + |
| 484 | "distances=[" + |
| 485 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" + |
| 486 | "]" + |
| 487 | "}" + |
| 488 | "]}" + |
| 489 | "" ; |
| 490 | ct = new CosmasTree(query); |
| 491 | map = ct.getRequestMap().get("query").toString(); |
| 492 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 493 | |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 494 | query="Sonne /-w4 Mond /+w2 Sterne"; |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 495 | |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 496 | // String mondsterne = |
| 497 | // "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," + |
| 498 | // "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" ; |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 499 | |
| 500 | String mondsterneClasses = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 501 | "{@type=korap:group, operation=operation:class, class=128 , classOut=128, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 502 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 503 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 504 | "{@type=korap:group, operation=operation:class, class=128 , classOut=128, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 505 | "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" + |
| 506 | "]}"; |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 507 | // String mondsterneSeq = |
| 508 | // "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 509 | // mondsterne + |
| 510 | // "], inOrder=true, distances=[" + |
| 511 | // "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" + |
| 512 | // "]}" ; |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 513 | String mondsterneClassesSeq = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 514 | "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 515 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 516 | mondsterneClasses + |
| 517 | "], inOrder=true, distances=[" + |
| 518 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" + |
| 519 | "]}" + |
| 520 | "]}" ; |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 521 | // String mondsterneOv = |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 522 | // "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 523 | // mondsterne + |
| 524 | // "]}"; |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 525 | String mondsterneClassesOv = |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 526 | "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 527 | mondsterneClasses + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 528 | "], frame=frame:overlaps}"; |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 529 | // String mondsterneAll = |
| 530 | // "{@type=korap:group, operation=operation:or, operands=[" + |
| 531 | // mondsterneOv + "," + mondsterneClassesSeq + |
| 532 | // "]}"; |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 533 | String mondsterneAllClasses = |
| 534 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 535 | mondsterneClassesOv + "," + mondsterneClassesSeq + |
| 536 | "]}"; |
| 537 | |
| 538 | |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 539 | String prox6 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 540 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 541 | "{@type=korap:group, operation=operation:sequence, " + |
| 542 | "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 543 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
| 544 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 545 | "{@type=korap:group, operation=operation:sequence, " + |
| 546 | "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 547 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 548 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 549 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 550 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 551 | "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" + |
| 552 | "]}" + |
| 553 | "], inOrder=true, " + |
| 554 | "distances=[" + |
| 555 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" + |
| 556 | "]" + |
| 557 | "}" + |
| 558 | "]}" + |
| 559 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 560 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 561 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 562 | "]}" + |
| 563 | "], inOrder=true, " + |
| 564 | "distances=[" + |
| 565 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" + |
| 566 | "]" + |
| 567 | "}" + |
| 568 | "]}" + |
| 569 | "" ; |
| 570 | // "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 571 | // "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 572 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 573 | // mondsterneAllClasses + |
| 574 | // "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 575 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 576 | // "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 577 | // "]}" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 578 | // "], frame=frame:overlaps}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 579 | // "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 580 | // "{@type=korap:group, operation=operation:sequence, " + |
| 581 | // "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 582 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 583 | // mondsterneAllClasses + |
| 584 | // "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 585 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 586 | // "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 587 | // "]}" + |
| 588 | // "], inOrder=true, " + |
| 589 | // "distances=[" + |
| 590 | // "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" + |
| 591 | // "]" + |
| 592 | // "}" + |
| 593 | // "]}" + |
| 594 | // "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 595 | ct = new CosmasTree(query); |
| 596 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 597 | assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 601 | public void testOPIN() throws QueryException { |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 602 | query="wegen #IN <s>"; |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 603 | String opin1 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 604 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 605 | "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, class=131, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 606 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 607 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 608 | "{@type=korap:span, key=s}" + |
| 609 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 610 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 611 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 612 | "]}" + |
| 613 | "], frames=[], frame=frame:contains}" + |
| 614 | "]}" + |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 615 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 616 | ct = new CosmasTree(query); |
| 617 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 618 | assertEquals(opin1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 619 | |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 620 | query="wegen #IN(L) <s>"; |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 621 | String opin2 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 622 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 623 | "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, class=131, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 624 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 625 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 626 | "{@type=korap:span, key=s}" + |
| 627 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 628 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 629 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 630 | "]}" + |
| 631 | "], frames=[frames:startswith], frame=frame:startswith}" + |
| 632 | "]}" + |
| 633 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 634 | ct = new CosmasTree(query); |
| 635 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 636 | assertEquals(opin2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 637 | |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 638 | |
| 639 | query="wegen #IN(F) <s>"; |
| 640 | String opin3= |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 641 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 642 | "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, class=131, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 643 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 644 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 645 | "{@type=korap:span, key=s}" + |
| 646 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 647 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 648 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 649 | "]}" + |
| 650 | "], frames=[frames:matches], frame=frame:matches}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 651 | "]}" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 652 | "]}"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 653 | ct = new CosmasTree(query); |
| 654 | map = ct.getRequestMap().get("query").toString(); |
| 655 | assertEquals(opin3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 656 | |
| 657 | query="wegen #IN(FI) <s>"; |
| 658 | String opin4= |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 659 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 660 | "{@type=korap:group, operation=operation:class, classRefCheck=[classRefCheck:unequals,classRefCheck:includes], classIn=[129,130], classOut=131, class=131, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 661 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 662 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 663 | "{@type=korap:span, key=s}" + |
| 664 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 665 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 666 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 667 | "]}" + |
| 668 | "], frames=[frames:matches], frame=frame:matches-noident}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 669 | "]}" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 670 | "]}"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 671 | ct = new CosmasTree(query); |
| 672 | map = ct.getRequestMap().get("query").toString(); |
| 673 | assertEquals(opin4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 674 | |
| 675 | query="wegen #IN(FE) <s>"; |
| 676 | String opin5= |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 677 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 678 | "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[129,130], classOut=131, class=131, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 679 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 680 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 681 | "{@type=korap:span, key=s}" + |
| 682 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 683 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 684 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 685 | "]}" + |
| 686 | "], frames=[frames:matches], frame=frame:matches}" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 687 | "]}" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 688 | "]}"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 689 | ct = new CosmasTree(query); |
| 690 | map = ct.getRequestMap().get("query").toString(); |
| 691 | assertEquals(opin5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 692 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 693 | query="wegen #IN(%, L) <s>"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 694 | String opin6 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 695 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 696 | "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:includes, classIn=[129,130], classOut=131, class=131, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 697 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 698 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 699 | "{@type=korap:span, key=s}" + |
| 700 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 701 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 702 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 703 | "]}" + |
| 704 | "], frames=[frames:startswith], frame=frame:startswith, exclude=true}" + |
| 705 | "]}" + |
| 706 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 707 | ct = new CosmasTree(query); |
| 708 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 709 | assertEquals(opin6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 710 | |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 711 | query="wegen #IN(FE,ALL,%,MIN) <s>"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 712 | String opin7 = |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 713 | "{@type=korap:reference, operation=operation:focus, reset=true, operands=[" + |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 714 | "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[129,130], classOut=131, class=131, operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 715 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 716 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 717 | "{@type=korap:span, key=s}" + |
| 718 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 719 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 720 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 721 | "]}" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 722 | |
| 723 | "], frames=[frames:matches], frame=frame:matches, exclude=true, grouping=false}" + |
| 724 | "]}" + |
| 725 | "]}" + |
| 726 | ""; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 727 | ct = new CosmasTree(query); |
| 728 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 729 | assertEquals(opin7.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 730 | } |
| 731 | |
| 732 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 733 | public void testOPOV() throws QueryException { |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 734 | query="wegen #OV <s>"; |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 735 | String opov1 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 736 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 737 | "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[129,130], classOut=131, class=131, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 738 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 739 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 740 | "{@type=korap:span, key=s}" + |
| 741 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 742 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 743 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 744 | "]}" + |
| 745 | "], frames=[], frame=frame:overlaps}" + |
| 746 | "]}" + |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 747 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 748 | ct = new CosmasTree(query); |
| 749 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 750 | assertEquals(opov1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 751 | |
| 752 | query="wegen #OV(L) <s>"; |
| 753 | String opov2 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 754 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 755 | "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[129,130], classOut=131, class=131, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 756 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 757 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 758 | "{@type=korap:span, key=s}" + |
| 759 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 760 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 761 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 762 | "]}" + |
| 763 | "], frames=[frames:startswith,frames:overlapsLeft], frame=frame:overlapsLeft}" + |
| 764 | "]}" + |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 765 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 766 | ct = new CosmasTree(query); |
| 767 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 768 | assertEquals(opov2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 769 | |
| 770 | query="wegen #OV(F) <s>"; |
| 771 | String opov3= |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 772 | |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 773 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 774 | "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:intersects, classIn=[129,130], classOut=131, class=131, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 775 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 776 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 777 | "{@type=korap:span, key=s}" + |
| 778 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 779 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 780 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 781 | "]}" + |
| 782 | "], frames=[frames:matches], frame=frame:matches}" + |
| 783 | "]}" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 784 | "]}"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 785 | ct = new CosmasTree(query); |
| 786 | map = ct.getRequestMap().get("query").toString(); |
| 787 | assertEquals(opov3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 788 | |
| 789 | query="wegen #OV(FI) <s>"; |
| 790 | String opov4= |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 791 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 792 | "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:unequals, classIn=[129,130], classOut=131, class=131, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 793 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 794 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 795 | "{@type=korap:span, key=s}" + |
| 796 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 797 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 798 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 799 | "]}" + |
| 800 | "], frames=[frames:matches], frame=frame:matches-noident}" + |
| 801 | "]}" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 802 | "]}"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 803 | ct = new CosmasTree(query); |
| 804 | map = ct.getRequestMap().get("query").toString(); |
| 805 | assertEquals(opov4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 806 | |
| 807 | query="wegen #OV(FE) <s>"; |
| 808 | String opov5= |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 809 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 810 | "{@type=korap:group, operation=operation:class, classRefCheck=classRefCheck:equals, classIn=[129,130], classOut=131, class=131, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 811 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 812 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 813 | "{@type=korap:span, key=s}" + |
| 814 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 815 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 816 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 817 | "]}" + |
| 818 | "], frames=[frames:matches], frame=frame:matches}" + |
| 819 | "]}" + |
| 820 | "]}"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 821 | ct = new CosmasTree(query); |
| 822 | map = ct.getRequestMap().get("query").toString(); |
| 823 | assertEquals(opov5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 824 | } |
| 825 | |
| 826 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 827 | public void testOPNOT() throws QueryException { |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 828 | query="Sonne nicht Mond"; |
| 829 | String opnot1 = |
Joachim Bingel | b7a5979 | 2014-02-14 13:52:29 +0000 | [diff] [blame] | 830 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
Joachim Bingel | 832800e | 2014-10-17 14:46:39 +0000 | [diff] [blame] | 831 | "{@type=cosmas:distance, key=t, min=0, max=0, exclude=true}" + |
Joachim Bingel | b7a5979 | 2014-02-14 13:52:29 +0000 | [diff] [blame] | 832 | "], operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 833 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 834 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 835 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 836 | ct = new CosmasTree(query); |
| 837 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 838 | assertEquals(opnot1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 839 | } |
| 840 | |
| 841 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 842 | public void testBEG_END() throws QueryException { |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 843 | // BEG and END operators |
| 844 | // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/links.html |
| 845 | // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/rechts.html |
| 846 | // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/thematische-bsp/bsp-satzlaenge.html |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 847 | query="#BEG(der /w3:5 Mann)"; |
| 848 | String beg1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 849 | "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 850 | "{@type=korap:group, operation=operation:sequence," + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 851 | "operands = [" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 852 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 853 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 854 | "], inOrder=false, distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 855 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 856 | "]}" + |
| 857 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 858 | ct = new CosmasTree(query); |
| 859 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 860 | assertEquals(beg1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 861 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 862 | |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 863 | // String dermannSeq = "{@type=korap:group, operation=operation:sequence," + |
| 864 | // "operands = [" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 865 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 866 | // "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" + |
| 867 | // "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 868 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 869 | // "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 870 | // "]}" + |
| 871 | // |
| 872 | // "], inOrder=false, distances=[" + |
| 873 | // "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" + |
| 874 | // "]}"; |
| 875 | // |
| 876 | // String begDermannSeq = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 877 | //// "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 878 | // "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" + |
| 879 | // dermannSeq + |
| 880 | // "]}" + |
| 881 | //// "]}" + |
| 882 | // ""; |
| 883 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 884 | String kommt = "{@type=korap:token, wrap={@type=korap:term, key=kommt, layer=orth, match=match:eq}}"; |
| 885 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 886 | query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group |
| 887 | String beg2 = |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 888 | // "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 889 | // "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 890 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 891 | // beg1 + |
| 892 | // "]}" + "," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 893 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 894 | // kommt + |
| 895 | // "]}" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 896 | // "], frame=frame:overlaps}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 897 | // "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 898 | // "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 899 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 900 | // beg1 + |
| 901 | // "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 902 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 903 | // kommt + |
| 904 | // "]}" + |
| 905 | // "], inOrder=true, distances=[" + |
| 906 | // "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" + |
| 907 | // "]}" + |
| 908 | // "]}" + |
| 909 | // "]}"; |
| 910 | // |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 911 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 912 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 913 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 914 | beg1 + |
| 915 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 916 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 917 | kommt + |
| 918 | "]}" + |
| 919 | "], inOrder=true, distances=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 920 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=10}, min=0, max=10}" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 921 | "]}" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 922 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 923 | ct = new CosmasTree(query); |
| 924 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 925 | assertEquals(beg2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 926 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 927 | query="kommt /+w10 #BEG(der /w3:5 Mann)"; |
| 928 | String beg3 = |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 929 | // "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 930 | // "{@type=korap:group, operation=operation:position, frames=[frames:], sharedClasses=[sharedClasses:intersects], operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 931 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 932 | // kommt + |
| 933 | //// "," + |
| 934 | // "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 935 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 936 | // beg1+ |
| 937 | // "]}" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 938 | // "], frame=frame:overlaps}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 939 | // "{@type=korap:reference, operation=operation:focus, classRef=[128], operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 940 | // "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 941 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 942 | // kommt + |
| 943 | // "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 944 | // "{@type=korap:group, operation=operation:class, class= , classOut=128, operands=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 945 | // beg1+ |
| 946 | // "]}" + |
| 947 | // "], inOrder=true, distances=[" + |
| 948 | // "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" + |
| 949 | // "]}" + |
| 950 | // "]}" + |
| 951 | // "]}"; |
| 952 | |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 953 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 954 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 955 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 956 | kommt + |
| 957 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 958 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 959 | beg1+ |
| 960 | "]}" + |
| 961 | "], inOrder=true, distances=[" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 962 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=10}, min=0, max=10}" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 963 | "]}" + |
Joachim Bingel | acb2ab3 | 2014-09-24 15:36:14 +0000 | [diff] [blame] | 964 | "]}"; |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 965 | ct = new CosmasTree(query); |
| 966 | map = ct.getRequestMap().get("query").toString(); |
| 967 | assertEquals(beg3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 968 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 969 | query="#END(der /w3:5 Mann)"; |
| 970 | String end1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 971 | "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 972 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 973 | "operands = [" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 974 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 975 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 976 | "], inOrder=false, distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 977 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 978 | "]}" + |
| 979 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 980 | ct = new CosmasTree(query); |
| 981 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 982 | assertEquals(end1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 983 | } |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 984 | |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 985 | /* |
| 986 | * YET UNCLEAR HOW TO SERIALIZE SPAN DISTANCES. BEING DISCUSSED. |
| 987 | * |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 988 | @Test |
| 989 | public void testSentenceDistance() throws QueryException { |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 990 | query="Sonne /s0 Mond"; // contains(focus(1:contains({1:<s>},Sonne)),Mond) |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 991 | expected = |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 992 | "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 993 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 994 | "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 995 | "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 996 | "{@type=korap:span, key=s}" + |
| 997 | "]}," + |
| 998 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 999 | "]}" + |
| 1000 | "]}," + |
| 1001 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 1002 | "]}"; |
| 1003 | ct = new CosmasTree(query); |
| 1004 | map = ct.getRequestMap().get("query").toString(); |
| 1005 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1006 | |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1007 | query="Sonne /s0,w5 Mond"; |
| 1008 | expected = |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1009 | "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1010 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1011 | "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1012 | "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1013 | "{@type=korap:span, key=s}" + |
| 1014 | "]}," + |
| 1015 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 1016 | "]}" + |
| 1017 | "]}," + |
| 1018 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 1019 | "]}"; |
| 1020 | // ct = new CosmasTree(query); |
| 1021 | // map = ct.getRequestMap().get("query").toString(); |
| 1022 | // assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1023 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1024 | query="Sonne /s2:2 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond) |
| 1025 | expected = |
| 1026 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1027 | "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1028 | "{@type=korap:span, key=s}," + |
| 1029 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 1030 | "]}," + |
| 1031 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1032 | "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1033 | "{@type=korap:span, key=s}," + |
| 1034 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1035 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1036 | "]}"; |
| 1037 | ct = new CosmasTree(query); |
| 1038 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1039 | // assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1040 | |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1041 | query="Sonne /s2:3 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond) |
| 1042 | expected = |
| 1043 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1044 | "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1045 | "{@type=korap:span, key=s}," + |
| 1046 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 1047 | "]}," + |
| 1048 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 1049 | "{@type=korap:span, key=s}" + |
| 1050 | "], boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}," + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1051 | "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1052 | "{@type=korap:span, key=s}," + |
| 1053 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 1054 | "]}" + |
| 1055 | "]}"; |
| 1056 | ct = new CosmasTree(query); |
| 1057 | map = ct.getRequestMap().get("query").toString(); |
| 1058 | // assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1059 | |
| 1060 | query="Sonne /s2 Mond"; // contains(focus(1:contains({1:<s>},Sonne)),Mond) | contains(<s>,Sonne)<s>?contains(<s>,Mond) |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1061 | expected = |
| 1062 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1063 | "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1064 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1065 | "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1066 | "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1067 | "{@type=korap:span, key=s}" + |
| 1068 | "]}," + |
| 1069 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 1070 | "]}" + |
| 1071 | "]}," + |
| 1072 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 1073 | "]}," + |
| 1074 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1075 | "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1076 | "{@type=korap:span, key=s}," + |
| 1077 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 1078 | "]}," + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1079 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 1080 | "{@type=korap:span, key=s}" + |
| 1081 | "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}," + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1082 | "{@type=korap:group, operation=operation:position, frame=frame:frame:contains, operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1083 | "{@type=korap:span, key=s}," + |
| 1084 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1085 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1086 | "]}" + |
| 1087 | "]}"; |
| 1088 | ct = new CosmasTree(query); |
| 1089 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1090 | // assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1091 | } |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1092 | */ |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1093 | |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 1094 | |
| 1095 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 1096 | public void testELEM() throws QueryException { |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 1097 | // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/elem.html |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 1098 | query="#ELEM(S)"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1099 | String elem1 = "{@type=korap:span, key=s}"; |
| 1100 | ct = new CosmasTree(query); |
| 1101 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 1102 | assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 1103 | |
| 1104 | query="#ELEM(W ANA=N)"; |
| 1105 | String elem2 = |
| 1106 | "{@type=korap:span, key=w, attr=" + |
| 1107 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1108 | "{@type=korap:term, layer=p, key=N, match=match:eq}" + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 1109 | "]}" + |
| 1110 | "}"; |
| 1111 | ct = new CosmasTree(query); |
| 1112 | map = ct.getRequestMap().get("query").toString(); |
| 1113 | assertEquals(elem2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1114 | |
| 1115 | query="#ELEM(W ANA != 'N V')"; |
| 1116 | String elem3 = |
| 1117 | "{@type=korap:span, key=w, attr=" + |
| 1118 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1119 | "{@type=korap:term, layer=p, key=N, match=match:ne}," + |
| 1120 | "{@type=korap:term, layer=p, key=V, match=match:ne}" + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 1121 | "]}" + |
| 1122 | "}"; |
| 1123 | ct = new CosmasTree(query); |
| 1124 | map = ct.getRequestMap().get("query").toString(); |
| 1125 | assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1126 | |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 1127 | query="#ELEM(W ANA != 'N A V' Genre = Sport)"; |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 1128 | String elem4 = |
| 1129 | "{@type=korap:span, key=w, attr=" + |
| 1130 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 1131 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1132 | "{@type=korap:term, layer=p, key=N, match=match:ne}," + |
| 1133 | "{@type=korap:term, layer=p, key=A, match=match:ne}," + |
| 1134 | "{@type=korap:term, layer=p, key=V, match=match:ne}" + |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 1135 | "]}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 1136 | "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" + |
| 1137 | "]}" + |
| 1138 | "}"; |
| 1139 | ct = new CosmasTree(query); |
| 1140 | map = ct.getRequestMap().get("query").toString(); |
| 1141 | assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 1142 | |
| 1143 | query="#ELEM(W ANA != 'N V' Genre != 'Sport Politik')"; |
| 1144 | String elem5 = |
| 1145 | "{@type=korap:span, key=w, attr=" + |
| 1146 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 1147 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1148 | "{@type=korap:term, layer=p, key=N, match=match:ne}," + |
| 1149 | "{@type=korap:term, layer=p, key=V, match=match:ne}" + |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 1150 | "]}," + |
| 1151 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 1152 | "{@type=korap:term, layer=Genre, key=Sport, match=match:ne}," + |
| 1153 | "{@type=korap:term, layer=Genre, key=Politik, match=match:ne}" + |
| 1154 | "]}" + |
| 1155 | "]}" + |
| 1156 | "}"; |
| 1157 | ct = new CosmasTree(query); |
| 1158 | map = ct.getRequestMap().get("query").toString(); |
| 1159 | assertEquals(elem5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 1160 | } |
| 1161 | |
| 1162 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 1163 | public void testOPALL() throws QueryException { |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 1164 | query="#ALL(gehen /w1:10 voran)"; |
Joachim Bingel | e98d088 | 2014-01-21 12:58:54 +0000 | [diff] [blame] | 1165 | String all1 = |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 1166 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 1167 | "operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 1168 | "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," + |
| 1169 | "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 1170 | "], inOrder=false, " + |
| 1171 | "distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1172 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" + |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 1173 | "]" + |
| 1174 | "}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1175 | ct = new CosmasTree(query); |
| 1176 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 1177 | assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1178 | |
| 1179 | query="#ALL(gehen /w1:10 (voran /w1:4 schnell))"; |
| 1180 | String all2 = |
| 1181 | "{@type=korap:group, operation=operation:sequence, " + |
| 1182 | "operands=[" + |
| 1183 | "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," + |
| 1184 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1185 | "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}," + |
| 1186 | "{@type=korap:token, wrap={@type=korap:term, key=schnell, layer=orth, match=match:eq}}" + |
| 1187 | "], inOrder=false, " + |
| 1188 | "distances=[" + |
| 1189 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" + |
| 1190 | "]" + |
| 1191 | "}" + |
| 1192 | "], inOrder=false, " + |
| 1193 | "distances=[" + |
| 1194 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" + |
| 1195 | "]" + |
| 1196 | "}"; |
| 1197 | ct = new CosmasTree(query); |
| 1198 | map = ct.getRequestMap().get("query").toString(); |
| 1199 | assertEquals(all2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 1200 | } |
| 1201 | |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1202 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 1203 | public void testOPNHIT() throws QueryException { |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 1204 | query="#NHIT(gehen /w1:10 voran)"; |
| 1205 | String nhit1 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1206 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
| 1207 | "{@type=korap:group, operation=operation:class, classRefOp=classRefOp:inversion, classIn=[130,131], classOut=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1208 | "{@type=korap:group, operation=operation:sequence, " + |
| 1209 | "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1210 | "{@type=korap:group, operation=operation:class, class=130 , classOut=130, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1211 | "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" + |
| 1212 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1213 | "{@type=korap:group, operation=operation:class, class=131 , classOut=131, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1214 | "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" + |
| 1215 | "]}" + |
| 1216 | "], inOrder=false, " + |
| 1217 | "distances=[" + |
| 1218 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" + |
| 1219 | "]" + |
| 1220 | "}" + |
| 1221 | "]}" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1222 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1223 | ct = new CosmasTree(query); |
| 1224 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 1225 | assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 832800e | 2014-10-17 14:46:39 +0000 | [diff] [blame] | 1226 | |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1227 | // query="#NHIT(gehen %w1:10 voran)"; |
| 1228 | // String nhit2 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1229 | // "{@type=korap:reference, operation=operation:focus, classRef=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1230 | // "{@type=korap:group, operation=operation:sequence, " + |
| 1231 | // "operands=[" + |
| 1232 | // "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1233 | // "{@type=korap:group, operation=operation:class, class= , classOut=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1234 | // "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 1235 | // "{@type=korap:token}" + |
| 1236 | // "], boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}}" + |
| 1237 | // "]}," + |
| 1238 | // "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" + |
| 1239 | // "], inOrder=false, " + |
| 1240 | // "distances=[" + |
| 1241 | // "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" + |
| 1242 | // "]" + |
| 1243 | // "}" + |
| 1244 | // "]}"; |
| 1245 | // ct = new CosmasTree(query); |
| 1246 | // map = ct.getRequestMap().get("query").toString(); |
| 1247 | // assertEquals(nhit2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1248 | |
| 1249 | query="#NHIT(gehen /+w1:10 voran /w1:10 Beispiel)"; |
| 1250 | String nhit3 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1251 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
| 1252 | "{@type=korap:group, operation=operation:class, classRefOp=classRefOp:inversion, classIn=[130,131], classOut=129, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1253 | "{@type=korap:group, operation=operation:sequence, " + |
| 1254 | "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1255 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1256 | "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" + |
| 1257 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1258 | "{@type=korap:group, operation=operation:class, class=131, classOut=131, operands=[" + |
| 1259 | "{@type=korap:reference, operation=operation:focus, classRef=[132], operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1260 | "{@type=korap:group, operation=operation:sequence, " + |
| 1261 | "operands=[" + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1262 | "{@type=korap:group, operation=operation:class, class=132, classOut=132, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1263 | "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" + |
| 1264 | "]}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1265 | "{@type=korap:group, operation=operation:class, class=132, classOut=132, operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1266 | "{@type=korap:token, wrap={@type=korap:term, key=Beispiel, layer=orth, match=match:eq}}" + |
| 1267 | "]}" + |
| 1268 | "], inOrder=false, " + |
| 1269 | "distances=[" + |
| 1270 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" + |
| 1271 | "]" + |
| 1272 | "}" + |
| 1273 | "]}" + |
| 1274 | "]}" + |
| 1275 | "], inOrder=true, " + |
| 1276 | "distances=[" + |
| 1277 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" + |
| 1278 | "]" + |
| 1279 | "}" + |
| 1280 | "]}" + |
| 1281 | "]}"; |
| 1282 | ct = new CosmasTree(query); |
| 1283 | map = ct.getRequestMap().get("query").toString(); |
| 1284 | assertEquals(nhit3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 1285 | } |
| 1286 | |
| 1287 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 1288 | public void testOPBED() throws QueryException { |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 1289 | query = "#BED(der , sa)"; |
| 1290 | String bed1 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1291 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands= [" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1292 | "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" + |
Joachim Bingel | cd7b725 | 2014-02-13 08:49:14 +0000 | [diff] [blame] | 1293 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1294 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | cd7b725 | 2014-02-13 08:49:14 +0000 | [diff] [blame] | 1295 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" + |
| 1296 | "]}" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1297 | "], frame=frame:startswith}" + |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 1298 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1299 | ct = new CosmasTree(query); |
| 1300 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 1301 | assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1302 | |
| 1303 | query = "#BED(der Mann , +pe)"; |
| 1304 | String bed2 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1305 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands= [" + |
Joachim Bingel | 896067a | 2014-11-07 19:02:27 +0000 | [diff] [blame] | 1306 | "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" + |
| 1307 | "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" + |
| 1308 | "{@type=korap:span, key=p}" + |
| 1309 | "]}," + |
| 1310 | "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" + |
| 1311 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
| 1312 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1313 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 1314 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1315 | "]}" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1316 | "]}" + |
| 1317 | "]}" + |
Joachim Bingel | 896067a | 2014-11-07 19:02:27 +0000 | [diff] [blame] | 1318 | "], frame=frame:matches}" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1319 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1320 | ct = new CosmasTree(query); |
| 1321 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1322 | assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 1323 | |
| 1324 | query = "#BED(der Mann , sa,-pa)"; |
| 1325 | String bed3 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1326 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1327 | "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" + |
| 1328 | "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1329 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1330 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1331 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1332 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 1333 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1334 | "]}" + |
| 1335 | "]}" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1336 | "], frame=frame:startswith}," + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1337 | "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1338 | "{@type=korap:span, key=p}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1339 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1340 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1341 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 1342 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1343 | "]}" + |
| 1344 | "]}" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1345 | "], frame=frame:startswith, exclude=true}" + |
Joachim Bingel | bd38636 | 2014-10-02 12:03:18 +0000 | [diff] [blame] | 1346 | "], frame=frame:matches}" + |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 1347 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1348 | ct = new CosmasTree(query); |
| 1349 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1350 | assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 1351 | } |
| 1352 | |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1353 | @Test |
| 1354 | public void testColonSeparatedConditions() throws QueryException { |
| 1355 | |
| 1356 | query = "Der:sa"; |
| 1357 | String col1 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1358 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1359 | "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1360 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1361 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1362 | "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" + |
| 1363 | "]}" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1364 | "], frame=frame:startswith}" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1365 | "]}"; |
| 1366 | ct = new CosmasTree(query); |
| 1367 | map = ct.getRequestMap().get("query").toString(); |
| 1368 | assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1369 | |
Joachim Bingel | b4ab250 | 2014-11-06 10:07:26 +0000 | [diff] [blame] | 1370 | query = "Mann:sa,-pa,+te"; |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1371 | String col2 = |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1372 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
Joachim Bingel | 9e6b948 | 2014-10-15 12:02:49 +0000 | [diff] [blame] | 1373 | "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" + |
| 1374 | "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1375 | "{@type=korap:span, key=s}," + |
Joachim Bingel | 6b491c2 | 2014-10-21 08:35:18 +0000 | [diff] [blame] | 1376 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1377 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1378 | "]}" + |
Joachim Bingel | 93e6c70 | 2014-09-30 15:19:23 +0000 | [diff] [blame] | 1379 | "], frame=frame:startswith}," + |
Joachim Bingel | 896067a | 2014-11-07 19:02:27 +0000 | [diff] [blame] | 1380 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
| 1381 | "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" + |
| 1382 | "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" + |
| 1383 | "{@type=korap:span, key=p}," + |
| 1384 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
| 1385 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1386 | "]}" + |
| 1387 | "], frame=frame:startswith, exclude=true}," + |
| 1388 | "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" + |
| 1389 | "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" + |
| 1390 | "{@type=korap:span, key=t}" + |
| 1391 | "]}," + |
| 1392 | "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" + |
| 1393 | "{@type=korap:group, operation=operation:class, class=131, classOut=131, operands=[" + |
| 1394 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1395 | "]}" + |
| 1396 | "]}" + |
| 1397 | "], frame=frame:matches}" + |
| 1398 | "], frame=frame:matches}" + |
| 1399 | "]}" + |
Joachim Bingel | bd38636 | 2014-10-02 12:03:18 +0000 | [diff] [blame] | 1400 | "], frame=frame:matches}" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1401 | "]}"; |
| 1402 | ct = new CosmasTree(query); |
| 1403 | map = ct.getRequestMap().get("query").toString(); |
| 1404 | assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | f204a67 | 2014-11-07 19:40:23 +0000 | [diff] [blame] | 1405 | |
| 1406 | query = "Mann:sa,-pa,+te,se"; |
| 1407 | expected = |
| 1408 | "{@type=korap:reference, operation=operation:focus, classRef=[129], operands=[" + |
| 1409 | "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" + |
| 1410 | "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" + |
| 1411 | "{@type=korap:span, key=s}," + |
| 1412 | "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" + |
| 1413 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1414 | "]}" + |
| 1415 | "], frame=frame:startswith}," + |
| 1416 | "{@type=korap:reference, operation=operation:focus, classRef=[130], operands=[" + |
| 1417 | "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" + |
| 1418 | "{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" + |
| 1419 | "{@type=korap:span, key=p}," + |
| 1420 | "{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" + |
| 1421 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1422 | "]}" + |
| 1423 | "], frame=frame:startswith, exclude=true}," + |
| 1424 | "{@type=korap:reference, operation=operation:focus, classRef=[131], operands=[" + |
| 1425 | "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" + |
| 1426 | "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" + |
| 1427 | "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" + |
| 1428 | "{@type=korap:span, key=t}" + |
| 1429 | "]}," + |
| 1430 | "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" + |
| 1431 | "{@type=korap:group, operation=operation:class, class=131, classOut=131, operands=[" + |
| 1432 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1433 | "]}" + |
| 1434 | "]}" + |
| 1435 | "], frame=frame:matches}," + |
| 1436 | "{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" + |
| 1437 | "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" + |
| 1438 | "{@type=korap:span, key=s}" + |
| 1439 | "]}," + |
| 1440 | "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" + |
| 1441 | "{@type=korap:group, operation=operation:class, class=132, classOut=132, operands=[" + |
| 1442 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1443 | "]}" + |
| 1444 | "]}" + |
| 1445 | "], frame=frame:matches}" + |
| 1446 | "], frame=frame:matches}" + |
| 1447 | "]}" + |
| 1448 | "], frame=frame:matches}" + |
| 1449 | "]}" + |
| 1450 | "], frame=frame:matches}" + |
| 1451 | "]}"; |
| 1452 | ct = new CosmasTree(query); |
| 1453 | map = ct.getRequestMap().get("query").toString(); |
| 1454 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1455 | } |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 1456 | } |
| 1457 | |