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=[" + |
| 281 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, 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 | "]}" + |
| 288 | "]}," + |
| 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 | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 312 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
| 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 | "]}" + |
| 319 | "]}," + |
| 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 | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 343 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
| 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 | "]}" + |
| 350 | "]}," + |
| 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 | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 374 | query="Sonne /-w4 Mond /+w2 Sterne"; |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 375 | |
| 376 | String mondsterne = |
| 377 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," + |
| 378 | "{@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^] | 379 | |
| 380 | String mondsterneClasses = |
| 381 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 382 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 383 | "]}," + |
| 384 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 385 | "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" + |
| 386 | "]}"; |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 387 | String mondsterneSeq = |
| 388 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 389 | mondsterne + |
| 390 | "], inOrder=true, distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 391 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 392 | "]}" ; |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 393 | String mondsterneClassesSeq = |
| 394 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 395 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 396 | mondsterneClasses + |
| 397 | "], inOrder=true, distances=[" + |
| 398 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}" + |
| 399 | "]}" + |
| 400 | "]}" ; |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 401 | String mondsterneOv = |
| 402 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
| 403 | mondsterne + |
| 404 | "]}"; |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 405 | String mondsterneClassesOv = |
| 406 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
| 407 | mondsterneClasses + |
| 408 | "]}"; |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 409 | String mondsterneAll = |
| 410 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 411 | mondsterneOv + "," + mondsterneClassesSeq + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 412 | "]}"; |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 413 | String mondsterneAllClasses = |
| 414 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 415 | mondsterneClassesOv + "," + mondsterneClassesSeq + |
| 416 | "]}"; |
| 417 | |
| 418 | |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 419 | String prox6 = |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 420 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 421 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 422 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 423 | mondsterneAllClasses + |
| 424 | "]}," + |
| 425 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 426 | "{@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^] | 427 | "]}" + |
| 428 | "]}," + |
| 429 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 430 | "{@type=korap:group, operation=operation:sequence, " + |
| 431 | "operands=[" + |
| 432 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 433 | mondsterneAllClasses + |
| 434 | "]}," + |
| 435 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 436 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 437 | "]}" + |
| 438 | "], inOrder=true, " + |
| 439 | "distances=[" + |
| 440 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" + |
| 441 | "]" + |
| 442 | "}" + |
| 443 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 444 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 445 | ct = new CosmasTree(query); |
| 446 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 447 | assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 451 | public void testOPIN() throws QueryException { |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 452 | query="wegen #IN <s>"; |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 453 | String opin1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 454 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 455 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 456 | "{@type=korap:span, key=s}," + |
| 457 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 458 | "{@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] | 459 | "]}" + |
| 460 | "]}" + |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 461 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 462 | ct = new CosmasTree(query); |
| 463 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 464 | assertEquals(opin1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 465 | |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 466 | query="wegen #IN(L) <s>"; //wrap an *excluded* matches-position around a startwith-position constraint in order to |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 467 | String opin2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 468 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 469 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 470 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 471 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 472 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 473 | "{@type=korap:span, key=s}" + |
| 474 | "]}," + |
| 475 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 476 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 477 | "]}" + |
| 478 | "]}" + |
| 479 | "]}," + |
| 480 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 481 | "], exclude=true}" + |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 482 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 483 | ct = new CosmasTree(query); |
| 484 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 485 | assertEquals(opin2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 486 | |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 487 | |
| 488 | query="wegen #IN(F) <s>"; |
| 489 | String opin3= |
| 490 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 491 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 492 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 493 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 494 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 495 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 496 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 497 | "{@type=korap:span, key=s}" + |
| 498 | "]}," + |
| 499 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 500 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 501 | "]}" + |
| 502 | "]}" + |
| 503 | "]}," + |
| 504 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 505 | "]}" + |
| 506 | "]}," + |
| 507 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 508 | "]}" + |
| 509 | "]}" + |
| 510 | ""; |
| 511 | ct = new CosmasTree(query); |
| 512 | map = ct.getRequestMap().get("query").toString(); |
| 513 | assertEquals(opin3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 514 | |
| 515 | query="wegen #IN(FI) <s>"; |
| 516 | String opin4= |
| 517 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 518 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 519 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 520 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 521 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 522 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 523 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 524 | "{@type=korap:span, key=s}" + |
| 525 | "]}," + |
| 526 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 527 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 528 | "]}" + |
| 529 | "]}" + |
| 530 | "]}," + |
| 531 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 532 | "]}" + |
| 533 | "]}," + |
| 534 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 535 | "], exclude=true}" + |
| 536 | "]}" + |
| 537 | ""; |
| 538 | ct = new CosmasTree(query); |
| 539 | map = ct.getRequestMap().get("query").toString(); |
| 540 | assertEquals(opin4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 541 | |
| 542 | query="wegen #IN(FE) <s>"; |
| 543 | String opin5= |
| 544 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 545 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 546 | "{@type=korap:span, key=s}," + |
| 547 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 548 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 549 | "]}" + |
| 550 | "]}" + |
| 551 | "]}" + |
| 552 | ""; |
| 553 | ct = new CosmasTree(query); |
| 554 | map = ct.getRequestMap().get("query").toString(); |
| 555 | assertEquals(opin5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 556 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 557 | query="wegen #IN(%, L) <s>"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 558 | String opin6 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 559 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 560 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 561 | "{@type=korap:span, key=s}," + |
| 562 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 563 | "{@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] | 564 | "]}" + |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 565 | "], exclude=true}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 566 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 567 | ct = new CosmasTree(query); |
| 568 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 569 | assertEquals(opin6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 570 | |
| 571 | query="wegen #IN('FE,ALL,%,MIN') <s>"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 572 | String opin7 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 573 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 574 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 575 | "{@type=korap:span, key=s}," + |
| 576 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 577 | "{@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] | 578 | "]}" + |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 579 | "], range=all, exclude=true, grouping=false}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 580 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 581 | ct = new CosmasTree(query); |
| 582 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 583 | assertEquals(opin7.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 587 | public void testOPOV() throws QueryException { |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 588 | query="wegen #OV <s>"; |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 589 | String opov1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 590 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 591 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
| 592 | "{@type=korap:span, key=s}," + |
| 593 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 594 | "{@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] | 595 | "]}" + |
| 596 | "]}" + |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 597 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 598 | ct = new CosmasTree(query); |
| 599 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 600 | assertEquals(opov1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 601 | |
| 602 | query="wegen #OV(L) <s>"; |
| 603 | String opov2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 604 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 605 | "{@type=korap:group, operation=operation:position, frame=frame:overlapsLeft, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 606 | "{@type=korap:span, key=s}," + |
| 607 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 608 | "{@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] | 609 | "]}" + |
| 610 | "]}" + |
| 611 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 612 | ct = new CosmasTree(query); |
| 613 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 614 | assertEquals(opov2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 615 | |
| 616 | query="wegen #OV(F) <s>"; |
| 617 | String opov3= |
| 618 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 619 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 620 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 621 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 622 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 623 | "{@type=korap:span, key=s}" + |
| 624 | "]}," + |
| 625 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 626 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 627 | "]}" + |
| 628 | "]}" + |
| 629 | "]}," + |
| 630 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 631 | "]}" + |
| 632 | "]}" + |
| 633 | ""; |
| 634 | ct = new CosmasTree(query); |
| 635 | map = ct.getRequestMap().get("query").toString(); |
| 636 | assertEquals(opov3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 637 | |
| 638 | query="wegen #OV(FI) <s>"; |
| 639 | String opov4= |
| 640 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 641 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 642 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 643 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 644 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 645 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 646 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 647 | "{@type=korap:span, key=s}" + |
| 648 | "]}," + |
| 649 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 650 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 651 | "]}" + |
| 652 | "]}" + |
| 653 | "]}," + |
| 654 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 655 | "]}" + |
| 656 | "]}," + |
| 657 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 658 | "], exclude=true}" + |
| 659 | "]}" + |
| 660 | ""; |
| 661 | ct = new CosmasTree(query); |
| 662 | map = ct.getRequestMap().get("query").toString(); |
| 663 | assertEquals(opov4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 664 | |
| 665 | query="wegen #OV(FE) <s>"; |
| 666 | String opov5= |
| 667 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 668 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 669 | "{@type=korap:span, key=s}," + |
| 670 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 671 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 672 | "]}" + |
| 673 | "]}" + |
| 674 | "]}" + |
| 675 | ""; |
| 676 | ct = new CosmasTree(query); |
| 677 | map = ct.getRequestMap().get("query").toString(); |
| 678 | assertEquals(opov5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 682 | public void testOPNOT() throws QueryException { |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 683 | query="Sonne nicht Mond"; |
| 684 | String opnot1 = |
Joachim Bingel | b7a5979 | 2014-02-14 13:52:29 +0000 | [diff] [blame] | 685 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
| 686 | "{@type=korap:distance, key=t, min=0, max=0, exclude=true}" + |
| 687 | "], operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 688 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 689 | "{@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] | 690 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 691 | ct = new CosmasTree(query); |
| 692 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 693 | assertEquals(opnot1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 694 | } |
| 695 | |
| 696 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 697 | public void testBEG_END() throws QueryException { |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 698 | // BEG and END operators |
| 699 | // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/links.html |
| 700 | // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/rechts.html |
| 701 | // 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] | 702 | query="#BEG(der /w3:5 Mann)"; |
| 703 | String beg1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 704 | "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 705 | "{@type=korap:group, operation=operation:sequence," + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 706 | "operands = [" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 707 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 708 | "{@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] | 709 | "], inOrder=false, distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 710 | "{@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] | 711 | "]}" + |
| 712 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 713 | ct = new CosmasTree(query); |
| 714 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 715 | assertEquals(beg1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 716 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 717 | |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 718 | // String dermannSeq = "{@type=korap:group, operation=operation:sequence," + |
| 719 | // "operands = [" + |
| 720 | // "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 721 | // "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" + |
| 722 | // "]}," + |
| 723 | // "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 724 | // "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 725 | // "]}" + |
| 726 | // |
| 727 | // "], inOrder=false, distances=[" + |
| 728 | // "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=3, max=5}, min=3, max=5}" + |
| 729 | // "]}"; |
| 730 | // |
| 731 | // String begDermannSeq = |
| 732 | //// "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 733 | // "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" + |
| 734 | // dermannSeq + |
| 735 | // "]}" + |
| 736 | //// "]}" + |
| 737 | // ""; |
| 738 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 739 | String kommt = "{@type=korap:token, wrap={@type=korap:term, key=kommt, layer=orth, match=match:eq}}"; |
| 740 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 741 | query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group |
| 742 | String beg2 = |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 743 | "{@type=korap:group, operation=operation:or, operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 744 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 745 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 746 | beg1 + |
| 747 | "]}" + "," + |
| 748 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 749 | kommt + |
| 750 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 751 | "]}," + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 752 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 753 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 754 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 755 | beg1 + |
| 756 | "]}," + |
| 757 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 758 | kommt + |
| 759 | "]}" + |
| 760 | "], inOrder=true, distances=[" + |
| 761 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" + |
| 762 | "]}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 763 | "]}" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 764 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 765 | ct = new CosmasTree(query); |
| 766 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 767 | assertEquals(beg2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 768 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 769 | query="kommt /+w10 #BEG(der /w3:5 Mann)"; |
| 770 | String beg3 = |
| 771 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 772 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 773 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 774 | kommt + |
| 775 | // "," + |
| 776 | "]}," + |
| 777 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 778 | beg1+ |
| 779 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 780 | "]}," + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 781 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 782 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 783 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 784 | kommt + |
| 785 | "]}," + |
| 786 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 787 | beg1+ |
| 788 | "]}" + |
| 789 | "], inOrder=true, distances=[" + |
| 790 | "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" + |
| 791 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 792 | "]}" + |
Joachim Bingel | fbc8879 | 2014-09-17 11:11:52 +0000 | [diff] [blame^] | 793 | "]}"; |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 794 | ct = new CosmasTree(query); |
| 795 | map = ct.getRequestMap().get("query").toString(); |
| 796 | assertEquals(beg3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 797 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 798 | query="#END(der /w3:5 Mann)"; |
| 799 | String end1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 800 | "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 801 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 802 | "operands = [" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 803 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 804 | "{@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] | 805 | "], inOrder=false, distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 806 | "{@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] | 807 | "]}" + |
| 808 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 809 | ct = new CosmasTree(query); |
| 810 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 811 | assertEquals(end1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 812 | } |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 813 | |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 814 | /* |
| 815 | * YET UNCLEAR HOW TO SERIALIZE SPAN DISTANCES. BEING DISCUSSED. |
| 816 | * |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 817 | @Test |
| 818 | public void testSentenceDistance() throws QueryException { |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 819 | query="Sonne /s0 Mond"; // contains(focus(1:contains({1:<s>},Sonne)),Mond) |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 820 | expected = |
| 821 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 822 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 823 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 824 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 825 | "{@type=korap:span, key=s}" + |
| 826 | "]}," + |
| 827 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 828 | "]}" + |
| 829 | "]}," + |
| 830 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 831 | "]}"; |
| 832 | ct = new CosmasTree(query); |
| 833 | map = ct.getRequestMap().get("query").toString(); |
| 834 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 835 | |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 836 | query="Sonne /s0,w5 Mond"; |
| 837 | expected = |
| 838 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 839 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 840 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 841 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 842 | "{@type=korap:span, key=s}" + |
| 843 | "]}," + |
| 844 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 845 | "]}" + |
| 846 | "]}," + |
| 847 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 848 | "]}"; |
| 849 | // ct = new CosmasTree(query); |
| 850 | // map = ct.getRequestMap().get("query").toString(); |
| 851 | // assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 852 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 853 | query="Sonne /s2:2 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond) |
| 854 | expected = |
| 855 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 856 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 857 | "{@type=korap:span, key=s}," + |
| 858 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 859 | "]}," + |
| 860 | "{@type=korap:span, key=s}," + |
| 861 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 862 | "{@type=korap:span, key=s}," + |
| 863 | "{@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] | 864 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 865 | "]}"; |
| 866 | ct = new CosmasTree(query); |
| 867 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 868 | // assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 869 | |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 870 | query="Sonne /s2:3 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond) |
| 871 | expected = |
| 872 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 873 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 874 | "{@type=korap:span, key=s}," + |
| 875 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 876 | "]}," + |
| 877 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 878 | "{@type=korap:span, key=s}" + |
| 879 | "], boundary={@type=korap:boundary, min=1, max=2}, min=1, max=2}," + |
| 880 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 881 | "{@type=korap:span, key=s}," + |
| 882 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 883 | "]}" + |
| 884 | "]}"; |
| 885 | ct = new CosmasTree(query); |
| 886 | map = ct.getRequestMap().get("query").toString(); |
| 887 | // assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 888 | |
| 889 | 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] | 890 | expected = |
| 891 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 892 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 893 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 894 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 895 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 896 | "{@type=korap:span, key=s}" + |
| 897 | "]}," + |
| 898 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 899 | "]}" + |
| 900 | "]}," + |
| 901 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 902 | "]}," + |
| 903 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 904 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 905 | "{@type=korap:span, key=s}," + |
| 906 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 907 | "]}," + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 908 | "{@type=korap:group, operation=operation:repetition, operands=[" + |
| 909 | "{@type=korap:span, key=s}" + |
| 910 | "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}," + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 911 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 912 | "{@type=korap:span, key=s}," + |
| 913 | "{@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] | 914 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 915 | "]}" + |
| 916 | "]}"; |
| 917 | ct = new CosmasTree(query); |
| 918 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 919 | // assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 920 | } |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 921 | */ |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 922 | |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 923 | |
| 924 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 925 | public void testELEM() throws QueryException { |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 926 | // 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] | 927 | query="#ELEM(S)"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 928 | String elem1 = "{@type=korap:span, key=s}"; |
| 929 | ct = new CosmasTree(query); |
| 930 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 931 | assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 932 | |
| 933 | query="#ELEM(W ANA=N)"; |
| 934 | String elem2 = |
| 935 | "{@type=korap:span, key=w, attr=" + |
| 936 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 937 | "{@type=korap:term, layer=pos, key=N, match=match:eq}" + |
| 938 | "]}" + |
| 939 | "}"; |
| 940 | ct = new CosmasTree(query); |
| 941 | map = ct.getRequestMap().get("query").toString(); |
| 942 | assertEquals(elem2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 943 | |
| 944 | query="#ELEM(W ANA != 'N V')"; |
| 945 | String elem3 = |
| 946 | "{@type=korap:span, key=w, attr=" + |
| 947 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 948 | "{@type=korap:term, layer=pos, key=N, match=match:ne}," + |
| 949 | "{@type=korap:term, layer=pos, key=V, match=match:ne}" + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 950 | "]}" + |
| 951 | "}"; |
| 952 | ct = new CosmasTree(query); |
| 953 | map = ct.getRequestMap().get("query").toString(); |
| 954 | assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 955 | |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 956 | query="#ELEM(W ANA != 'N A V' Genre = Sport)"; |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 957 | String elem4 = |
| 958 | "{@type=korap:span, key=w, attr=" + |
| 959 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 960 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 961 | "{@type=korap:term, layer=pos, key=N, match=match:ne}," + |
| 962 | "{@type=korap:term, layer=pos, key=A, match=match:ne}," + |
| 963 | "{@type=korap:term, layer=pos, key=V, match=match:ne}" + |
| 964 | "]}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 965 | "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" + |
| 966 | "]}" + |
| 967 | "}"; |
| 968 | ct = new CosmasTree(query); |
| 969 | map = ct.getRequestMap().get("query").toString(); |
| 970 | assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 971 | |
| 972 | query="#ELEM(W ANA != 'N V' Genre != 'Sport Politik')"; |
| 973 | String elem5 = |
| 974 | "{@type=korap:span, key=w, attr=" + |
| 975 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 976 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 977 | "{@type=korap:term, layer=pos, key=N, match=match:ne}," + |
| 978 | "{@type=korap:term, layer=pos, key=V, match=match:ne}" + |
| 979 | "]}," + |
| 980 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 981 | "{@type=korap:term, layer=Genre, key=Sport, match=match:ne}," + |
| 982 | "{@type=korap:term, layer=Genre, key=Politik, match=match:ne}" + |
| 983 | "]}" + |
| 984 | "]}" + |
| 985 | "}"; |
| 986 | ct = new CosmasTree(query); |
| 987 | map = ct.getRequestMap().get("query").toString(); |
| 988 | assertEquals(elem5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 989 | } |
| 990 | |
| 991 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 992 | public void testOPALL() throws QueryException { |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 993 | query="#ALL(gehen /w1:10 voran)"; |
Joachim Bingel | e98d088 | 2014-01-21 12:58:54 +0000 | [diff] [blame] | 994 | String all1 = |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 995 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 996 | "operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 997 | "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," + |
| 998 | "{@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] | 999 | "], inOrder=false, " + |
| 1000 | "distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1001 | "{@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] | 1002 | "]" + |
| 1003 | "}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1004 | ct = new CosmasTree(query); |
| 1005 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 1006 | assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 1007 | } |
| 1008 | |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1009 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 1010 | public void testOPNHIT() throws QueryException { |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 1011 | query="#NHIT(gehen /w1:10 voran)"; |
| 1012 | String nhit1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 1013 | "{@type=korap:reference, operation=operation:focus, classRef=[1,2], classRefOp=classRefOp:intersection, operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 1014 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1015 | "operands=[" + |
| 1016 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1017 | "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" + |
| 1018 | "]}," + |
| 1019 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 1020 | "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" + |
| 1021 | "]}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 1022 | "], inOrder=false, " + |
| 1023 | "distances=[" + |
Joachim Bingel | 03dfd95 | 2014-07-30 08:08:53 +0000 | [diff] [blame] | 1024 | "{@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] | 1025 | "]" + |
| 1026 | "}" + |
| 1027 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1028 | ct = new CosmasTree(query); |
| 1029 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 1030 | assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 1031 | } |
| 1032 | |
| 1033 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 1034 | public void testOPBED() throws QueryException { |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 1035 | query = "#BED(der , sa)"; |
| 1036 | String bed1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 1037 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands= [" + |
Joachim Bingel | cd7b725 | 2014-02-13 08:49:14 +0000 | [diff] [blame] | 1038 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 1039 | "{@type=korap:span, key=s}," + |
| 1040 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1041 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" + |
| 1042 | "]}" + |
| 1043 | "]}" + |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 1044 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1045 | ct = new CosmasTree(query); |
| 1046 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 1047 | assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1048 | |
| 1049 | query = "#BED(der Mann , +pe)"; |
| 1050 | String bed2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 1051 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands= [" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1052 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 1053 | "{@type=korap:span, key=p}," + |
| 1054 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1055 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1056 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 1057 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1058 | "]}" + |
| 1059 | "]}" + |
| 1060 | "]}" + |
| 1061 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1062 | ct = new CosmasTree(query); |
| 1063 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1064 | assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 1065 | |
| 1066 | query = "#BED(der Mann , sa,-pa)"; |
| 1067 | String bed3 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 1068 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1069 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1070 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 1071 | "{@type=korap:span, key=s}," + |
| 1072 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1073 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1074 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 1075 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1076 | "]}" + |
| 1077 | "]}" + |
| 1078 | "]}," + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1079 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1080 | "{@type=korap:span, key=p}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 1081 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1082 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 1083 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 1084 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1085 | "]}" + |
| 1086 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1087 | "], exclude=true}" + |
| 1088 | "], distances=[" + |
| 1089 | "{@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] | 1090 | "]}" + |
| 1091 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 1092 | ct = new CosmasTree(query); |
| 1093 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 1094 | assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 1095 | } |
| 1096 | |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1097 | @Test |
| 1098 | public void testColonSeparatedConditions() throws QueryException { |
| 1099 | |
| 1100 | query = "Der:sa"; |
| 1101 | String col1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 1102 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1103 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 1104 | "{@type=korap:span, key=s}," + |
| 1105 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1106 | "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" + |
| 1107 | "]}" + |
| 1108 | "]}" + |
| 1109 | "]}"; |
| 1110 | ct = new CosmasTree(query); |
| 1111 | map = ct.getRequestMap().get("query").toString(); |
| 1112 | assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1113 | |
| 1114 | query = "Mann:sa,-pa,+te)"; |
| 1115 | String col2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 1116 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1117 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1118 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 1119 | "{@type=korap:span, key=s}," + |
| 1120 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 1121 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1122 | "]}" + |
| 1123 | "]}," + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1124 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1125 | "{@type=korap:span, key=p}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 1126 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1127 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1128 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1129 | "], exclude=true}," + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1130 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 1131 | "{@type=korap:span, key=t}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 1132 | "{@type=korap:group, operation=operation:class, class=3, operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 1133 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 1134 | "]}" + |
| 1135 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 1136 | "], distances=[" + |
| 1137 | "{@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] | 1138 | "]}" + |
| 1139 | "]}"; |
| 1140 | ct = new CosmasTree(query); |
| 1141 | map = ct.getRequestMap().get("query").toString(); |
| 1142 | assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 1143 | } |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 1144 | } |
| 1145 | |