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 | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 17 | String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 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 | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 48 | public void testCaseSensitivityFlag() throws QueryException { |
Joachim Bingel | 0207d5e | 2014-02-12 14:18:41 +0000 | [diff] [blame] | 49 | query="$deutscher"; |
| 50 | String cs1 = |
| 51 | "{@type=korap:token, wrap={@type=korap:term, caseInsensitive=true, key=deutscher, layer=orth, match=match:eq}}"; |
| 52 | ct = new CosmasTree(query); |
| 53 | map = ct.getRequestMap().get("query").toString(); |
| 54 | assertEquals(cs1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 55 | |
| 56 | query="$deutscher Bundestag"; |
| 57 | String cs2 = |
| 58 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 59 | "{@type=korap:token, wrap={@type=korap:term, caseInsensitive=true, key=deutscher, layer=orth, match=match:eq}}," + |
| 60 | "{@type=korap:token, wrap={@type=korap:term, key=Bundestag, layer=orth, match=match:eq}}" + |
| 61 | "]}"; |
| 62 | ct = new CosmasTree(query); |
| 63 | map = ct.getRequestMap().get("query").toString(); |
| 64 | assertEquals(cs2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | @Test |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 68 | public void testMORPH() throws QueryException { |
| 69 | query="#MORPH(V)"; |
| 70 | String morph1 = |
Joachim Bingel | 0207d5e | 2014-02-12 14:18:41 +0000 | [diff] [blame] | 71 | "{@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] | 72 | ct = new CosmasTree(query); |
| 73 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 74 | assertEquals(morph1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 75 | } |
| 76 | |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 77 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 78 | public void testSequence() throws QueryException { |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 79 | query="der Mann"; |
| 80 | String seq1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 81 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 82 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 83 | "{@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] | 84 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 85 | ct = new CosmasTree(query); |
| 86 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 87 | assertEquals(seq1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 88 | |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 89 | query="der Mann schläft"; |
| 90 | String seq2 = |
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}}," + |
| 94 | "{@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] | 95 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 96 | ct = new CosmasTree(query); |
| 97 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 98 | assertEquals(seq2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 99 | |
| 100 | query="der Mann schläft lang"; |
| 101 | String seq3 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 102 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 103 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 104 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," + |
| 105 | "{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}," + |
| 106 | "{@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] | 107 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 108 | ct = new CosmasTree(query); |
| 109 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 110 | assertEquals(seq3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | @Test |
| 114 | public void testOPOR() throws QueryException { |
| 115 | query="Sonne oder Mond"; |
| 116 | String disj1 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 117 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 118 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 119 | "{@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] | 120 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 121 | ct = new CosmasTree(query); |
| 122 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 123 | assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 124 | |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 125 | query="(Sonne scheint) oder Mond"; |
| 126 | String disj2 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 127 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 128 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 129 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 130 | "{@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] | 131 | "]}," + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 132 | "{@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] | 133 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 134 | ct = new CosmasTree(query); |
| 135 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 136 | assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 137 | |
| 138 | query="(Sonne scheint) oder (Mond scheint)"; |
| 139 | String disj3 = |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 140 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 141 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 142 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 143 | "{@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] | 144 | "]}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 145 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 146 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," + |
| 147 | "{@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] | 148 | "]}" + |
| 149 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 150 | ct = new CosmasTree(query); |
| 151 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 152 | assertEquals(disj3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 153 | |
| 154 | } |
| 155 | |
| 156 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 157 | public void testOPORAND() throws QueryException { |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 158 | query="(Sonne oder Mond) und scheint"; |
| 159 | String orand1 = |
Joachim Bingel | b7a5979 | 2014-02-14 13:52:29 +0000 | [diff] [blame] | 160 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
| 161 | "{@type=korap:distance, key=t, min=0, max=0}" + |
| 162 | "], operands=[" + |
| 163 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 164 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 165 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 166 | "]}," + |
| 167 | "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" + |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 168 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 169 | ct = new CosmasTree(query); |
| 170 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 171 | assertEquals(orand1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 172 | |
| 173 | query="scheint und (Sonne oder Mond)"; |
| 174 | String orand2 = |
Joachim Bingel | b7a5979 | 2014-02-14 13:52:29 +0000 | [diff] [blame] | 175 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
| 176 | "{@type=korap:distance, key=t, min=0, max=0}" + |
| 177 | "], operands=[" + |
| 178 | "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," + |
| 179 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 180 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 181 | "{@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] | 182 | "]}" + |
| 183 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 184 | ct = new CosmasTree(query); |
| 185 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 186 | assertEquals(orand2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 92f9c9c | 2014-06-25 15:01:17 +0000 | [diff] [blame] | 187 | |
| 188 | query="Regen und scheint und (Sonne oder Mond)"; |
| 189 | String orand3 = |
| 190 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
| 191 | "{@type=korap:distance, key=t, min=0, max=0}" + |
| 192 | "], operands=[" + |
| 193 | "{@type=korap:token, wrap={@type=korap:term, key=Regen, layer=orth, match=match:eq}}," + |
| 194 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
| 195 | "{@type=korap:distance, key=t, min=0, max=0}" + |
| 196 | "], operands=[" + |
| 197 | "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}," + |
| 198 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 199 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 200 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 201 | "]}" + |
| 202 | "]}" + |
| 203 | "]}"; |
| 204 | ct = new CosmasTree(query); |
| 205 | map = ct.getRequestMap().get("query").toString(); |
| 206 | assertEquals(orand3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 210 | public void testOPPROX() throws QueryException { |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 211 | query="Sonne /+w1:4 Mond"; |
| 212 | String prox1 = |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 213 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 214 | "{@type=korap:group, operation=operation:sequence, " + |
| 215 | "operands=[" + |
| 216 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 217 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 218 | "]}," + |
| 219 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 220 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 221 | "]}" + |
| 222 | "], inOrder=true, " + |
| 223 | "distances=[" + |
| 224 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" + |
| 225 | "]" + |
| 226 | "}" + |
| 227 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 228 | ct = new CosmasTree(query); |
| 229 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 230 | assertEquals(prox1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 231 | |
| 232 | query="Sonne /+w1:4,s0,p1:3 Mond"; |
| 233 | String prox2 = |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 234 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 235 | "{@type=korap:group, operation=operation:sequence, " + |
| 236 | "operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 237 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 238 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 239 | "]}," + |
| 240 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 241 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 242 | "]}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 243 | "], inOrder=true, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 244 | "distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 245 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}," + |
| 246 | "{@type=korap:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}," + |
| 247 | "{@type=korap: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] | 248 | "]" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 249 | "}" + |
| 250 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 251 | ct = new CosmasTree(query); |
| 252 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 253 | assertEquals(prox2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 254 | |
| 255 | query="Sonne %+w1:4,s0,p1:3 Mond"; |
| 256 | String prox3 = |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 257 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 258 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 259 | "operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 260 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 261 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 262 | "]}," + |
| 263 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 264 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 265 | "]}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 266 | "], inOrder=true, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 267 | "distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 268 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4, exclude=true}," + |
| 269 | "{@type=korap:distance, key=s, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0, exclude=true}," + |
| 270 | "{@type=korap: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] | 271 | "]" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 272 | "}" + |
| 273 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 274 | ct = new CosmasTree(query); |
| 275 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 276 | // assertEquals(prox3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 277 | |
| 278 | query="Sonne /+w4 Mond"; |
| 279 | String prox4 = |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 280 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 281 | "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 282 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 283 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 284 | "]}," + |
| 285 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 286 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 287 | "]}" + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 288 | "], frame=overlaps}," + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 289 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 290 | "{@type=korap:group, operation=operation:sequence, " + |
| 291 | "operands=[" + |
| 292 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 293 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 294 | "]}," + |
| 295 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 296 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 297 | "]}" + |
| 298 | "], inOrder=true, " + |
| 299 | "distances=[" + |
| 300 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" + |
| 301 | "]" + |
| 302 | "}" + |
| 303 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 304 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 305 | ct = new CosmasTree(query); |
| 306 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 307 | assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 308 | |
| 309 | query="Sonne /-w4 Mond"; |
| 310 | String prox5 = |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 311 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 312 | "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 313 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 314 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 315 | "]}," + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 316 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 317 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 318 | "]}" + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 319 | "], frame=overlaps}," + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 320 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 321 | "{@type=korap:group, operation=operation:sequence, " + |
| 322 | "operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 323 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 324 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 325 | "]}," + |
| 326 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 327 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 328 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 329 | "], inOrder=true, " + |
| 330 | "distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 331 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 332 | "]" + |
| 333 | "}" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 334 | "]}" + |
| 335 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 336 | ct = new CosmasTree(query); |
| 337 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 338 | assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 339 | |
| 340 | query="Sonne /w4 Mond"; |
| 341 | String prox6 = |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 342 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 343 | "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 344 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 345 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 346 | "]}," + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 347 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 348 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 349 | "]}" + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 350 | "], frame=overlaps}," + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 351 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 352 | "{@type=korap:group, operation=operation:sequence, " + |
| 353 | "operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 354 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 355 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 356 | "]}," + |
| 357 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 358 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 359 | "]}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 360 | "], inOrder=false, " + |
| 361 | "distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 362 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 363 | "]" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 364 | "}" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 365 | "]}" + |
| 366 | "]}"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 367 | ct = new CosmasTree(query); |
| 368 | map = ct.getRequestMap().get("query").toString(); |
| 369 | assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | @Test |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 373 | public void testOPPROXNested() throws QueryException { |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 374 | query="Sonne /+w1:4 Mond /-w1:7 Sterne"; |
| 375 | expected = |
| 376 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 377 | "{@type=korap:group, operation=operation:sequence, " + |
| 378 | "operands=[" + |
| 379 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 380 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 381 | "]}," + |
| 382 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 383 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 384 | "{@type=korap:group, operation=operation:sequence, " + |
| 385 | "operands=[" + |
| 386 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 387 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 388 | "]}," + |
| 389 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 390 | "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" + |
| 391 | "]}" + |
| 392 | "], inOrder=true, " + |
| 393 | "distances=[" + |
| 394 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=7}, min=1, max=7}" + |
| 395 | "]" + |
| 396 | "}" + |
| 397 | "]}" + |
| 398 | "]}" + |
| 399 | "], inOrder=true, " + |
| 400 | "distances=[" + |
| 401 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" + |
| 402 | "]" + |
| 403 | "}" + |
| 404 | "]}" + |
| 405 | "" ; |
| 406 | ct = new CosmasTree(query); |
| 407 | map = ct.getRequestMap().get("query").toString(); |
| 408 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 409 | |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 410 | query="Sonne /-w4 Mond /+w2 Sterne"; |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 411 | |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 412 | // String mondsterne = |
| 413 | // "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," + |
| 414 | // "{@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] | 415 | |
| 416 | String mondsterneClasses = |
| 417 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 418 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 419 | "]}," + |
| 420 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 421 | "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" + |
| 422 | "]}"; |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 423 | // String mondsterneSeq = |
| 424 | // "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 425 | // mondsterne + |
| 426 | // "], inOrder=true, distances=[" + |
| 427 | // "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" + |
| 428 | // "]}" ; |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 429 | String mondsterneClassesSeq = |
| 430 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 431 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 432 | mondsterneClasses + |
| 433 | "], inOrder=true, distances=[" + |
| 434 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" + |
| 435 | "]}" + |
| 436 | "]}" ; |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 437 | // String mondsterneOv = |
| 438 | // "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" + |
| 439 | // mondsterne + |
| 440 | // "]}"; |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 441 | String mondsterneClassesOv = |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 442 | "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 443 | mondsterneClasses + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 444 | "], frame=overlaps}"; |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 445 | // String mondsterneAll = |
| 446 | // "{@type=korap:group, operation=operation:or, operands=[" + |
| 447 | // mondsterneOv + "," + mondsterneClassesSeq + |
| 448 | // "]}"; |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 449 | String mondsterneAllClasses = |
| 450 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 451 | mondsterneClassesOv + "," + mondsterneClassesSeq + |
| 452 | "]}"; |
| 453 | |
| 454 | |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 455 | String prox6 = |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 456 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 457 | "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 458 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 459 | mondsterneAllClasses + |
| 460 | "]}," + |
| 461 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 462 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 463 | "]}" + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 464 | "], frame=overlaps}," + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 465 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 466 | "{@type=korap:group, operation=operation:sequence, " + |
| 467 | "operands=[" + |
| 468 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 469 | mondsterneAllClasses + |
| 470 | "]}," + |
| 471 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 472 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 473 | "]}" + |
| 474 | "], inOrder=true, " + |
| 475 | "distances=[" + |
| 476 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" + |
| 477 | "]" + |
| 478 | "}" + |
| 479 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 480 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 481 | ct = new CosmasTree(query); |
| 482 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 483 | assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 487 | public void testOPIN() throws QueryException { |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 488 | query="wegen #IN <s>"; |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 489 | String opin1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 490 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 491 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 492 | "{@type=korap:span, key=s}," + |
| 493 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 494 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 495 | "]}" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 496 | "], frames=[], sharedClasses=[includes]}" + |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 497 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 498 | ct = new CosmasTree(query); |
| 499 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 500 | assertEquals(opin1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 501 | |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 502 | query="wegen #IN(L) <s>"; |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 503 | String opin2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 504 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 505 | "{@type=korap:group, operation=operation:position, operands=[" + |
| 506 | "{@type=korap:span, key=s}," + |
| 507 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 508 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 509 | "]}" + |
| 510 | "], frames=[startswith], sharedClasses=[includes]}" + |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 511 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 512 | ct = new CosmasTree(query); |
| 513 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 514 | assertEquals(opin2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 515 | |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 516 | |
| 517 | query="wegen #IN(F) <s>"; |
| 518 | String opin3= |
| 519 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 520 | "{@type=korap:group, operation=operation:position, operands=[" + |
| 521 | "{@type=korap:span, key=s}," + |
| 522 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 523 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 524 | "]}" + |
| 525 | "], frames=[matches], sharedClasses=[includes]}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 526 | "]}" + |
| 527 | ""; |
| 528 | ct = new CosmasTree(query); |
| 529 | map = ct.getRequestMap().get("query").toString(); |
| 530 | assertEquals(opin3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 531 | |
| 532 | query="wegen #IN(FI) <s>"; |
| 533 | String opin4= |
| 534 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 535 | "{@type=korap:group, operation=operation:position, operands=[" + |
| 536 | "{@type=korap:span, key=s}," + |
| 537 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 538 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 539 | "]}" + |
| 540 | "], frames=[matches], sharedClasses=[unequals,includes]}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 541 | "]}" + |
| 542 | ""; |
| 543 | ct = new CosmasTree(query); |
| 544 | map = ct.getRequestMap().get("query").toString(); |
| 545 | assertEquals(opin4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 546 | |
| 547 | query="wegen #IN(FE) <s>"; |
| 548 | String opin5= |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 549 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 550 | "{@type=korap:group, operation=operation:position, operands=[" + |
| 551 | "{@type=korap:span, key=s}," + |
| 552 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 553 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 554 | "]}" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 555 | "], frames=[matches], sharedClasses=[equals]}" + |
| 556 | "]}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 557 | ""; |
| 558 | ct = new CosmasTree(query); |
| 559 | map = ct.getRequestMap().get("query").toString(); |
| 560 | assertEquals(opin5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 561 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 562 | query="wegen #IN(%, L) <s>"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 563 | String opin6 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 564 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 565 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 566 | "{@type=korap:span, key=s}," + |
| 567 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 568 | "{@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] | 569 | "]}" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 570 | "], frames=[startswith], sharedClasses=[includes], exclude=true}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 571 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 572 | ct = new CosmasTree(query); |
| 573 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 574 | assertEquals(opin6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 575 | |
| 576 | query="wegen #IN('FE,ALL,%,MIN') <s>"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 577 | String opin7 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 578 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 579 | "{@type=korap:group, operation=operation:position, operands=[" + |
| 580 | "{@type=korap:reference, operation=operation:focus, reset=true, operands=[" + |
| 581 | "{@type=korap:span, key=s}" + |
| 582 | "]}," + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 583 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 584 | "{@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] | 585 | "]}" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 586 | "], frames=[matches], sharedClasses=[equals], exclude=true, grouping=false}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 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 | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 590 | assertEquals(opin7.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 591 | } |
| 592 | |
| 593 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 594 | public void testOPOV() throws QueryException { |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 595 | query="wegen #OV <s>"; |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 596 | String opov1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 597 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 598 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 599 | "{@type=korap:span, key=s}," + |
| 600 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 601 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 602 | "]}" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 603 | "], frames=[], sharedClasses=[intersects]}" + |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 604 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 605 | ct = new CosmasTree(query); |
| 606 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 607 | assertEquals(opov1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 608 | |
| 609 | query="wegen #OV(L) <s>"; |
| 610 | String opov2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 611 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 612 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 613 | "{@type=korap:span, key=s}," + |
| 614 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 615 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 616 | "]}" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 617 | "], frames=[startswith,overlapsLeft], sharedClasses=[intersects]}" + |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 618 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 619 | ct = new CosmasTree(query); |
| 620 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 621 | assertEquals(opov2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 622 | |
| 623 | query="wegen #OV(F) <s>"; |
| 624 | String opov3= |
| 625 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 626 | "{@type=korap:group, operation=operation:position, operands=[" + |
| 627 | "{@type=korap:span, key=s}," + |
| 628 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 629 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 630 | "]}" + |
| 631 | "], frames=[matches], sharedClasses=[intersects]}" + |
| 632 | "]}"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 633 | ct = new CosmasTree(query); |
| 634 | map = ct.getRequestMap().get("query").toString(); |
| 635 | assertEquals(opov3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 636 | |
| 637 | query="wegen #OV(FI) <s>"; |
| 638 | String opov4= |
| 639 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 640 | "{@type=korap:group, operation=operation:position, operands=[" + |
| 641 | "{@type=korap:span, key=s}," + |
| 642 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 643 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 644 | "]}" + |
| 645 | "], frames=[matches], sharedClasses=[unequals]}" + |
| 646 | "]}"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 647 | ct = new CosmasTree(query); |
| 648 | map = ct.getRequestMap().get("query").toString(); |
| 649 | assertEquals(opov4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 650 | |
| 651 | query="wegen #OV(FE) <s>"; |
| 652 | String opov5= |
| 653 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 654 | "{@type=korap:group, operation=operation:position, operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 655 | "{@type=korap:span, key=s}," + |
| 656 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 657 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 658 | "]}" + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 659 | "], frames=[matches], sharedClasses=[equals]}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 660 | "]}" + |
| 661 | ""; |
| 662 | ct = new CosmasTree(query); |
| 663 | map = ct.getRequestMap().get("query").toString(); |
| 664 | assertEquals(opov5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 668 | public void testOPNOT() throws QueryException { |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 669 | query="Sonne nicht Mond"; |
| 670 | String opnot1 = |
Joachim Bingel | b7a5979 | 2014-02-14 13:52:29 +0000 | [diff] [blame] | 671 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
| 672 | "{@type=korap:distance, key=t, min=0, max=0, exclude=true}" + |
| 673 | "], operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 674 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 675 | "{@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] | 676 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 677 | ct = new CosmasTree(query); |
| 678 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 679 | assertEquals(opnot1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 680 | } |
| 681 | |
| 682 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 683 | public void testBEG_END() throws QueryException { |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 684 | // BEG and END operators |
| 685 | // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/links.html |
| 686 | // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/rechts.html |
| 687 | // 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] | 688 | query="#BEG(der /w3:5 Mann)"; |
| 689 | String beg1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 690 | "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 691 | "{@type=korap:group, operation=operation:sequence," + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 692 | "operands = [" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 693 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 694 | "{@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] | 695 | "], inOrder=false, distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 696 | "{@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] | 697 | "]}" + |
| 698 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 699 | ct = new CosmasTree(query); |
| 700 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 701 | assertEquals(beg1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 702 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 703 | |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 704 | // String dermannSeq = "{@type=korap:group, operation=operation:sequence," + |
| 705 | // "operands = [" + |
| 706 | // "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 707 | // "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" + |
| 708 | // "]}," + |
| 709 | // "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 710 | // "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 711 | // "]}" + |
| 712 | // |
| 713 | // "], inOrder=false, distances=[" + |
| 714 | // "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" + |
| 715 | // "]}"; |
| 716 | // |
| 717 | // String begDermannSeq = |
| 718 | //// "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 719 | // "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" + |
| 720 | // dermannSeq + |
| 721 | // "]}" + |
| 722 | //// "]}" + |
| 723 | // ""; |
| 724 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 725 | String kommt = "{@type=korap:token, wrap={@type=korap:term, key=kommt, layer=orth, match=match:eq}}"; |
| 726 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 727 | query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group |
| 728 | String beg2 = |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 729 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 730 | "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 731 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 732 | beg1 + |
| 733 | "]}" + "," + |
| 734 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 735 | kommt + |
| 736 | "]}" + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 737 | "], frame=overlaps}," + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 738 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 739 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 740 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 741 | beg1 + |
| 742 | "]}," + |
| 743 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 744 | kommt + |
| 745 | "]}" + |
| 746 | "], inOrder=true, distances=[" + |
| 747 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" + |
| 748 | "]}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 749 | "]}" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 750 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 751 | ct = new CosmasTree(query); |
| 752 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 753 | assertEquals(beg2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 754 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 755 | query="kommt /+w10 #BEG(der /w3:5 Mann)"; |
| 756 | String beg3 = |
| 757 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 758 | "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 759 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 760 | kommt + |
| 761 | // "," + |
| 762 | "]}," + |
| 763 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 764 | beg1+ |
| 765 | "]}" + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 766 | "], frame=overlaps}," + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 767 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 768 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 769 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 770 | kommt + |
| 771 | "]}," + |
| 772 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 773 | beg1+ |
| 774 | "]}" + |
| 775 | "], inOrder=true, distances=[" + |
| 776 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" + |
| 777 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 778 | "]}" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame] | 779 | "]}"; |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 780 | ct = new CosmasTree(query); |
| 781 | map = ct.getRequestMap().get("query").toString(); |
| 782 | assertEquals(beg3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 783 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 784 | query="#END(der /w3:5 Mann)"; |
| 785 | String end1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 786 | "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 787 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 788 | "operands = [" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 789 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 790 | "{@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] | 791 | "], inOrder=false, distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 792 | "{@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] | 793 | "]}" + |
| 794 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 795 | ct = new CosmasTree(query); |
| 796 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 797 | assertEquals(end1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 798 | } |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 799 | |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 800 | /* |
| 801 | * YET UNCLEAR HOW TO SERIALIZE SPAN DISTANCES. BEING DISCUSSED. |
| 802 | * |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 803 | @Test |
| 804 | public void testSentenceDistance() throws QueryException { |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 805 | query="Sonne /s0 Mond"; // contains(focus(1:contains({1:<s>},Sonne)),Mond) |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 806 | expected = |
| 807 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 808 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 809 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 810 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 811 | "{@type=korap:span, key=s}" + |
| 812 | "]}," + |
| 813 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 814 | "]}" + |
| 815 | "]}," + |
| 816 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 817 | "]}"; |
| 818 | ct = new CosmasTree(query); |
| 819 | map = ct.getRequestMap().get("query").toString(); |
| 820 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 821 | |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 822 | query="Sonne /s0,w5 Mond"; |
| 823 | expected = |
| 824 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 825 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 826 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 827 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 828 | "{@type=korap:span, key=s}" + |
| 829 | "]}," + |
| 830 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 831 | "]}" + |
| 832 | "]}," + |
| 833 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 834 | "]}"; |
| 835 | // ct = new CosmasTree(query); |
| 836 | // map = ct.getRequestMap().get("query").toString(); |
| 837 | // assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 838 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 839 | query="Sonne /s2:2 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond) |
| 840 | expected = |
| 841 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 842 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 843 | "{@type=korap:span, key=s}," + |
| 844 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 845 | "]}," + |
| 846 | "{@type=korap:span, key=s}," + |
| 847 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 848 | "{@type=korap:span, key=s}," + |
| 849 | "{@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] | 850 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 851 | "]}"; |
| 852 | ct = new CosmasTree(query); |
| 853 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 854 | // assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 855 | |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 856 | query="Sonne /s2:3 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond) |
| 857 | expected = |
| 858 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 859 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 860 | "{@type=korap:span, key=s}," + |
| 861 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 862 | "]}," + |
| 863 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 864 | "{@type=korap:span, key=s}" + |
| 865 | "], boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}," + |
| 866 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 867 | "{@type=korap:span, key=s}," + |
| 868 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 869 | "]}" + |
| 870 | "]}"; |
| 871 | ct = new CosmasTree(query); |
| 872 | map = ct.getRequestMap().get("query").toString(); |
| 873 | // assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 874 | |
| 875 | 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] | 876 | expected = |
| 877 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 878 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 879 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 880 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 881 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 882 | "{@type=korap:span, key=s}" + |
| 883 | "]}," + |
| 884 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 885 | "]}" + |
| 886 | "]}," + |
| 887 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 888 | "]}," + |
| 889 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 890 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 891 | "{@type=korap:span, key=s}," + |
| 892 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 893 | "]}," + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 894 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 895 | "{@type=korap:span, key=s}" + |
| 896 | "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}," + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 897 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 898 | "{@type=korap:span, key=s}," + |
| 899 | "{@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] | 900 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 901 | "]}" + |
| 902 | "]}"; |
| 903 | ct = new CosmasTree(query); |
| 904 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 905 | // assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 906 | } |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 907 | */ |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 908 | |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 909 | |
| 910 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 911 | public void testELEM() throws QueryException { |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 912 | // 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] | 913 | query="#ELEM(S)"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 914 | String elem1 = "{@type=korap:span, key=s}"; |
| 915 | ct = new CosmasTree(query); |
| 916 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 917 | assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 918 | |
| 919 | query="#ELEM(W ANA=N)"; |
| 920 | String elem2 = |
| 921 | "{@type=korap:span, key=w, attr=" + |
| 922 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 923 | "{@type=korap:term, layer=pos, key=N, match=match:eq}" + |
| 924 | "]}" + |
| 925 | "}"; |
| 926 | ct = new CosmasTree(query); |
| 927 | map = ct.getRequestMap().get("query").toString(); |
| 928 | assertEquals(elem2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 929 | |
| 930 | query="#ELEM(W ANA != 'N V')"; |
| 931 | String elem3 = |
| 932 | "{@type=korap:span, key=w, attr=" + |
| 933 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 934 | "{@type=korap:term, layer=pos, key=N, match=match:ne}," + |
| 935 | "{@type=korap:term, layer=pos, key=V, match=match:ne}" + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 936 | "]}" + |
| 937 | "}"; |
| 938 | ct = new CosmasTree(query); |
| 939 | map = ct.getRequestMap().get("query").toString(); |
| 940 | assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 941 | |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 942 | query="#ELEM(W ANA != 'N A V' Genre = Sport)"; |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 943 | String elem4 = |
| 944 | "{@type=korap:span, key=w, attr=" + |
| 945 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 946 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 947 | "{@type=korap:term, layer=pos, key=N, match=match:ne}," + |
| 948 | "{@type=korap:term, layer=pos, key=A, match=match:ne}," + |
| 949 | "{@type=korap:term, layer=pos, key=V, match=match:ne}" + |
| 950 | "]}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 951 | "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" + |
| 952 | "]}" + |
| 953 | "}"; |
| 954 | ct = new CosmasTree(query); |
| 955 | map = ct.getRequestMap().get("query").toString(); |
| 956 | assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 957 | |
| 958 | query="#ELEM(W ANA != 'N V' Genre != 'Sport Politik')"; |
| 959 | String elem5 = |
| 960 | "{@type=korap:span, key=w, attr=" + |
| 961 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 962 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 963 | "{@type=korap:term, layer=pos, key=N, match=match:ne}," + |
| 964 | "{@type=korap:term, layer=pos, key=V, match=match:ne}" + |
| 965 | "]}," + |
| 966 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 967 | "{@type=korap:term, layer=Genre, key=Sport, match=match:ne}," + |
| 968 | "{@type=korap:term, layer=Genre, key=Politik, match=match:ne}" + |
| 969 | "]}" + |
| 970 | "]}" + |
| 971 | "}"; |
| 972 | ct = new CosmasTree(query); |
| 973 | map = ct.getRequestMap().get("query").toString(); |
| 974 | assertEquals(elem5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 975 | } |
| 976 | |
| 977 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 978 | public void testOPALL() throws QueryException { |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 979 | query="#ALL(gehen /w1:10 voran)"; |
Joachim Bingel | e98d088 | 2014-01-21 12:58:54 +0000 | [diff] [blame] | 980 | String all1 = |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 981 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 982 | "operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 983 | "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," + |
| 984 | "{@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] | 985 | "], inOrder=false, " + |
| 986 | "distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 987 | "{@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] | 988 | "]" + |
| 989 | "}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 990 | ct = new CosmasTree(query); |
| 991 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 992 | assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 993 | } |
| 994 | |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 995 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 996 | public void testOPNHIT() throws QueryException { |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 997 | query="#NHIT(gehen /w1:10 voran)"; |
| 998 | String nhit1 = |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 999 | "{@type=korap:reference, operation=operation:focus, classRef=[1], classRefOp=classRefOp:inversion, operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 1000 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1001 | "operands=[" + |
| 1002 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1003 | "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" + |
| 1004 | "]}," + |
Joachim Bingel | 0973797 | 2014-09-22 09:43:06 +0000 | [diff] [blame] | 1005 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1006 | "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" + |
| 1007 | "]}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 1008 | "], inOrder=false, " + |
| 1009 | "distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1010 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1011 | "]" + |
| 1012 | "}" + |
| 1013 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1014 | ct = new CosmasTree(query); |
| 1015 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 1016 | assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 1017 | } |
| 1018 | |
| 1019 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 1020 | public void testOPBED() throws QueryException { |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 1021 | query = "#BED(der , sa)"; |
| 1022 | String bed1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 1023 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands= [" + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 1024 | "{@type=korap:group, operation=operation:position, frames=[startswith], sharedClasses=[includes], operands=[" + |
Joachim Bingel | cd7b725 | 2014-02-13 08:49:14 +0000 | [diff] [blame] | 1025 | "{@type=korap:span, key=s}," + |
| 1026 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1027 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" + |
| 1028 | "]}" + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 1029 | "], frame=startswith}" + |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 1030 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1031 | ct = new CosmasTree(query); |
| 1032 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 1033 | assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1034 | |
| 1035 | query = "#BED(der Mann , +pe)"; |
| 1036 | String bed2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 1037 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands= [" + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 1038 | "{@type=korap:group, operation=operation:position, frames=[endswith], sharedClasses=[includes], operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1039 | "{@type=korap:span, key=p}," + |
| 1040 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1041 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1042 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 1043 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1044 | "]}" + |
| 1045 | "]}" + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 1046 | "], frame=endswith}" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1047 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1048 | ct = new CosmasTree(query); |
| 1049 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1050 | assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 1051 | |
| 1052 | query = "#BED(der Mann , sa,-pa)"; |
| 1053 | String bed3 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 1054 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1055 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 1056 | "{@type=korap:group, operation=operation:position, frames=[startswith], sharedClasses=[includes], operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1057 | "{@type=korap:span, key=s}," + |
| 1058 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1059 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1060 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 1061 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1062 | "]}" + |
| 1063 | "]}" + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 1064 | "], frame=startswith}," + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 1065 | "{@type=korap:group, operation=operation:position, frames=[startswith], sharedClasses=[includes], operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1066 | "{@type=korap:span, key=p}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 1067 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1068 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1069 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 1070 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1071 | "]}" + |
| 1072 | "]}" + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 1073 | "], frame=startswith, exclude=true}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1074 | "], distances=[" + |
| 1075 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}" + |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 1076 | "]}" + |
| 1077 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1078 | ct = new CosmasTree(query); |
| 1079 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1080 | assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 1081 | } |
| 1082 | |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1083 | @Test |
| 1084 | public void testColonSeparatedConditions() throws QueryException { |
| 1085 | |
| 1086 | query = "Der:sa"; |
| 1087 | String col1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 1088 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 1089 | "{@type=korap:group, operation=operation:position, frames=[startswith], sharedClasses=[includes], operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1090 | "{@type=korap:span, key=s}," + |
| 1091 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1092 | "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" + |
| 1093 | "]}" + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 1094 | "], frame=startswith}" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1095 | "]}"; |
| 1096 | ct = new CosmasTree(query); |
| 1097 | map = ct.getRequestMap().get("query").toString(); |
| 1098 | assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1099 | |
| 1100 | query = "Mann:sa,-pa,+te)"; |
| 1101 | String col2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 1102 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1103 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 1104 | "{@type=korap:group, operation=operation:position, frames=[startswith], sharedClasses=[includes], operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1105 | "{@type=korap:span, key=s}," + |
| 1106 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1107 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1108 | "]}" + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 1109 | "], frame=startswith}," + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 1110 | "{@type=korap:group, operation=operation:position, frames=[startswith], sharedClasses=[includes], operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1111 | "{@type=korap:span, key=p}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 1112 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1113 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1114 | "]}" + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 1115 | "], frame=startswith, exclude=true}," + |
Joachim Bingel | ceb7906 | 2014-09-22 11:50:37 +0000 | [diff] [blame] | 1116 | "{@type=korap:group, operation=operation:position, frames=[endswith], sharedClasses=[includes], operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1117 | "{@type=korap:span, key=t}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 1118 | "{@type=korap:group, operation=operation:class, class=3, operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1119 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
Joachim Bingel | aaabb72 | 2014-09-24 14:29:10 +0000 | [diff] [blame^] | 1120 | "]}" + |
| 1121 | "], frame=endswith}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1122 | "], distances=[" + |
| 1123 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=0}, min=0, max=0}" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1124 | "]}" + |
| 1125 | "]}"; |
| 1126 | ct = new CosmasTree(query); |
| 1127 | map = ct.getRequestMap().get("query").toString(); |
| 1128 | assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1129 | } |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 1130 | } |
| 1131 | |