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