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; |
| 13 | |
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 | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 213 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 214 | "operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 215 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 216 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 217 | "], inOrder=true, " + |
| 218 | "distances=[" + |
| 219 | "{@type=korap:distance, key=w, min=1, max=4}" + |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 220 | "]" + |
| 221 | "}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 222 | ct = new CosmasTree(query); |
| 223 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 224 | assertEquals(prox1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 225 | |
| 226 | query="Sonne /+w1:4,s0,p1:3 Mond"; |
| 227 | String prox2 = |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 228 | "{@type=korap:group, operation=operation:sequence, " + |
| 229 | "operands=[" + |
| 230 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 231 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 232 | "], inOrder=true, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 233 | "distances=[" + |
Joachim Bingel | cd7b725 | 2014-02-13 08:49:14 +0000 | [diff] [blame] | 234 | "{@type=korap:distance, key=w, min=1, max=4}," + |
| 235 | "{@type=korap:distance, key=s, min=0, max=0}," + |
| 236 | "{@type=korap:distance, key=p, min=1, max=3}" + |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 237 | "]" + |
| 238 | "}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 239 | ct = new CosmasTree(query); |
| 240 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 241 | assertEquals(prox2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 242 | |
| 243 | query="Sonne %+w1:4,s0,p1:3 Mond"; |
| 244 | String prox3 = |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 245 | "{@type=korap:group, operation=operation:sequence, " + |
| 246 | "operands=[" + |
| 247 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 248 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 249 | "], inOrder=true, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 250 | "distances=[" + |
Joachim Bingel | cd7b725 | 2014-02-13 08:49:14 +0000 | [diff] [blame] | 251 | "{@type=korap:distance, key=w, min=1, max=4, exclude=true}," + |
| 252 | "{@type=korap:distance, key=s, min=0, max=0, exclude=true}," + |
| 253 | "{@type=korap:distance, key=p, min=1, max=3, exclude=true}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 254 | "]" + |
| 255 | "}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 256 | ct = new CosmasTree(query); |
| 257 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 258 | assertEquals(prox3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 259 | |
| 260 | query="Sonne /+w4 Mond"; |
| 261 | String prox4 = |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 262 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 263 | "operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 264 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 265 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 266 | "], inOrder=true, " + |
| 267 | "distances=[" + |
| 268 | "{@type=korap:distance, key=w, min=0, max=4}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 269 | "]" + |
| 270 | "}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 271 | ct = new CosmasTree(query); |
| 272 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 273 | assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 274 | |
| 275 | query="Sonne /-w4 Mond"; |
| 276 | String prox5 = |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 277 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 278 | "operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 279 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," + |
| 280 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 281 | "], inOrder=true, " + |
| 282 | "distances=[" + |
| 283 | "{@type=korap:distance, key=w, min=0, max=4}" + |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 284 | "]" + |
| 285 | "}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 286 | ct = new CosmasTree(query); |
| 287 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 288 | assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 289 | |
| 290 | query="Sonne /w4 Mond"; |
| 291 | String prox6 = |
| 292 | "{@type=korap:group, operation=operation:sequence, " + |
| 293 | "operands=[" + |
| 294 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 295 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 296 | "], inOrder=false, " + |
| 297 | "distances=[" + |
| 298 | "{@type=korap:distance, key=w, min=0, max=4}" + |
| 299 | "]" + |
| 300 | "}"; |
| 301 | ct = new CosmasTree(query); |
| 302 | map = ct.getRequestMap().get("query").toString(); |
| 303 | assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | @Test |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 307 | public void testOPPROXNested() throws QueryException { |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 308 | query="Sonne /-w4 Mond /+w2 Sterne"; |
| 309 | String prox6 = |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 310 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 311 | "operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 312 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 313 | "operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 314 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," + |
| 315 | "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 316 | "], inOrder=true, " + |
| 317 | "distances=[" + |
| 318 | "{@type=korap:distance, key=w, min=0, max=2}" + |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 319 | "]}," + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 320 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 321 | "], inOrder=true, " + |
| 322 | "distances=[" + |
| 323 | "{@type=korap:distance, key=w, min=0, max=4}" + |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 324 | "]" + |
| 325 | "}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 326 | ct = new CosmasTree(query); |
| 327 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 328 | assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 332 | public void testOPIN() throws QueryException { |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 333 | query="wegen #IN <s>"; |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 334 | String opin1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 335 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 336 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 337 | "{@type=korap:span, key=s}," + |
| 338 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 339 | "{@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] | 340 | "]}" + |
| 341 | "]}" + |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 342 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 343 | ct = new CosmasTree(query); |
| 344 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 345 | assertEquals(opin1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 346 | |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 347 | 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] | 348 | String opin2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 349 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 350 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 351 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 352 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 353 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 354 | "{@type=korap:span, key=s}" + |
| 355 | "]}," + |
| 356 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 357 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 358 | "]}" + |
| 359 | "]}" + |
| 360 | "]}," + |
| 361 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 362 | "], exclude=true}" + |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 363 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 364 | ct = new CosmasTree(query); |
| 365 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 366 | assertEquals(opin2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 367 | |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 368 | |
| 369 | query="wegen #IN(F) <s>"; |
| 370 | String opin3= |
| 371 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 372 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 373 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 374 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 375 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 376 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 377 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 378 | "{@type=korap:span, key=s}" + |
| 379 | "]}," + |
| 380 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 381 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 382 | "]}" + |
| 383 | "]}" + |
| 384 | "]}," + |
| 385 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 386 | "]}" + |
| 387 | "]}," + |
| 388 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 389 | "]}" + |
| 390 | "]}" + |
| 391 | ""; |
| 392 | ct = new CosmasTree(query); |
| 393 | map = ct.getRequestMap().get("query").toString(); |
| 394 | assertEquals(opin3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 395 | |
| 396 | query="wegen #IN(FI) <s>"; |
| 397 | String opin4= |
| 398 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 399 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 400 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 401 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 402 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 403 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 404 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 405 | "{@type=korap:span, key=s}" + |
| 406 | "]}," + |
| 407 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 408 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 409 | "]}" + |
| 410 | "]}" + |
| 411 | "]}," + |
| 412 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 413 | "]}" + |
| 414 | "]}," + |
| 415 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 416 | "], exclude=true}" + |
| 417 | "]}" + |
| 418 | ""; |
| 419 | ct = new CosmasTree(query); |
| 420 | map = ct.getRequestMap().get("query").toString(); |
| 421 | assertEquals(opin4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 422 | |
| 423 | query="wegen #IN(FE) <s>"; |
| 424 | String opin5= |
| 425 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 426 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 427 | "{@type=korap:span, key=s}," + |
| 428 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 429 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 430 | "]}" + |
| 431 | "]}" + |
| 432 | "]}" + |
| 433 | ""; |
| 434 | ct = new CosmasTree(query); |
| 435 | map = ct.getRequestMap().get("query").toString(); |
| 436 | assertEquals(opin5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 437 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 438 | query="wegen #IN(%, L) <s>"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 439 | String opin6 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 440 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 441 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 442 | "{@type=korap:span, key=s}," + |
| 443 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 444 | "{@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] | 445 | "]}" + |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 446 | "], exclude=true}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 447 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 448 | ct = new CosmasTree(query); |
| 449 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 450 | assertEquals(opin6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 451 | |
| 452 | query="wegen #IN('FE,ALL,%,MIN') <s>"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 453 | String opin7 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 454 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 455 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 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 | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 459 | "]}" + |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 460 | "], range=all, exclude=true, grouping=false}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +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 | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 464 | assertEquals(opin7.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 468 | public void testOPOV() throws QueryException { |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 469 | query="wegen #OV <s>"; |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 470 | String opov1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 471 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 472 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
| 473 | "{@type=korap:span, key=s}," + |
| 474 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 475 | "{@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] | 476 | "]}" + |
| 477 | "]}" + |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 478 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 479 | ct = new CosmasTree(query); |
| 480 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 481 | assertEquals(opov1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 482 | |
| 483 | query="wegen #OV(L) <s>"; |
| 484 | String opov2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 485 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 486 | "{@type=korap:group, operation=operation:position, frame=frame:overlapsLeft, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 487 | "{@type=korap:span, key=s}," + |
| 488 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 489 | "{@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] | 490 | "]}" + |
| 491 | "]}" + |
| 492 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 493 | ct = new CosmasTree(query); |
| 494 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 495 | assertEquals(opov2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 496 | |
| 497 | query="wegen #OV(F) <s>"; |
| 498 | String opov3= |
| 499 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 500 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 501 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 502 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 503 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 504 | "{@type=korap:span, key=s}" + |
| 505 | "]}," + |
| 506 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 507 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 508 | "]}" + |
| 509 | "]}" + |
| 510 | "]}," + |
| 511 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 512 | "]}" + |
| 513 | "]}" + |
| 514 | ""; |
| 515 | ct = new CosmasTree(query); |
| 516 | map = ct.getRequestMap().get("query").toString(); |
| 517 | assertEquals(opov3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 518 | |
| 519 | query="wegen #OV(FI) <s>"; |
| 520 | String opov4= |
| 521 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 522 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 523 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 524 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 525 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 526 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 527 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 528 | "{@type=korap:span, key=s}" + |
| 529 | "]}," + |
| 530 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 531 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 532 | "]}" + |
| 533 | "]}" + |
| 534 | "]}," + |
| 535 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 536 | "]}" + |
| 537 | "]}," + |
| 538 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 539 | "], exclude=true}" + |
| 540 | "]}" + |
| 541 | ""; |
| 542 | ct = new CosmasTree(query); |
| 543 | map = ct.getRequestMap().get("query").toString(); |
| 544 | assertEquals(opov4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 545 | |
| 546 | query="wegen #OV(FE) <s>"; |
| 547 | String opov5= |
| 548 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 549 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 550 | "{@type=korap:span, key=s}," + |
| 551 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 552 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 553 | "]}" + |
| 554 | "]}" + |
| 555 | "]}" + |
| 556 | ""; |
| 557 | ct = new CosmasTree(query); |
| 558 | map = ct.getRequestMap().get("query").toString(); |
| 559 | assertEquals(opov5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 563 | public void testOPNOT() throws QueryException { |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 564 | query="Sonne nicht Mond"; |
| 565 | String opnot1 = |
Joachim Bingel | b7a5979 | 2014-02-14 13:52:29 +0000 | [diff] [blame] | 566 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
| 567 | "{@type=korap:distance, key=t, min=0, max=0, exclude=true}" + |
| 568 | "], operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 569 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 570 | "{@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] | 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 | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 574 | assertEquals(opnot1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 575 | } |
| 576 | |
| 577 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 578 | public void testBEG_END() throws QueryException { |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 579 | // BEG and END operators |
| 580 | // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/links.html |
| 581 | // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/rechts.html |
| 582 | // 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] | 583 | query="#BEG(der /w3:5 Mann)"; |
| 584 | String beg1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 585 | "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 586 | "{@type=korap:group, operation=operation:sequence," + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 587 | "operands = [" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 588 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 589 | "{@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] | 590 | "], inOrder=false, distances=[" + |
| 591 | "{@type=korap:distance, key=w, min=3, max=5}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 592 | "]}" + |
| 593 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 594 | ct = new CosmasTree(query); |
| 595 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 596 | assertEquals(beg1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 597 | |
| 598 | query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group |
| 599 | String beg2 = |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 600 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 601 | "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 602 | "{@type=korap:group, operation=operation:sequence," + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 603 | "operands = [" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 604 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 605 | "{@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] | 606 | "], inOrder=false, distances=[" + |
| 607 | "{@type=korap:distance, key=w, min=3, max=5}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 608 | "]}" + |
| 609 | "]}," + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 610 | "{@type=korap:token, wrap={@type=korap:term, key=kommt, layer=orth, match=match:eq}}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 611 | "], inOrder=true, distances=[" + |
| 612 | "{@type=korap:distance, key=w, min=0, max=10}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 613 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 614 | ct = new CosmasTree(query); |
| 615 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 616 | assertEquals(beg2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 617 | |
| 618 | query="#END(der /w3:5 Mann)"; |
| 619 | String end1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 620 | "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 621 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 622 | "operands = [" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 623 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 624 | "{@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] | 625 | "], inOrder=false, distances=[" + |
| 626 | "{@type=korap:distance, key=w, min=3, max=5}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 627 | "]}" + |
| 628 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 629 | ct = new CosmasTree(query); |
| 630 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 631 | assertEquals(end1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 632 | } |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 633 | |
| 634 | |
| 635 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 636 | public void testELEM() throws QueryException { |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 637 | // 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] | 638 | query="#ELEM(S)"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 639 | String elem1 = "{@type=korap:span, key=s}"; |
| 640 | ct = new CosmasTree(query); |
| 641 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 642 | assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 643 | |
| 644 | query="#ELEM(W ANA=N)"; |
| 645 | String elem2 = |
| 646 | "{@type=korap:span, key=w, attr=" + |
| 647 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 648 | "{@type=korap:term, layer=pos, key=N, match=match:eq}" + |
| 649 | "]}" + |
| 650 | "}"; |
| 651 | ct = new CosmasTree(query); |
| 652 | map = ct.getRequestMap().get("query").toString(); |
| 653 | assertEquals(elem2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 654 | |
| 655 | query="#ELEM(W ANA != 'N V')"; |
| 656 | String elem3 = |
| 657 | "{@type=korap:span, key=w, attr=" + |
| 658 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 659 | "{@type=korap:term, layer=pos, key=N, match=match:ne}," + |
| 660 | "{@type=korap:term, layer=pos, key=V, match=match:ne}" + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 661 | "]}" + |
| 662 | "}"; |
| 663 | ct = new CosmasTree(query); |
| 664 | map = ct.getRequestMap().get("query").toString(); |
| 665 | assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 666 | |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 667 | query="#ELEM(W ANA != 'N A V' Genre = Sport)"; |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 668 | String elem4 = |
| 669 | "{@type=korap:span, key=w, attr=" + |
| 670 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 671 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 672 | "{@type=korap:term, layer=pos, key=N, match=match:ne}," + |
| 673 | "{@type=korap:term, layer=pos, key=A, match=match:ne}," + |
| 674 | "{@type=korap:term, layer=pos, key=V, match=match:ne}" + |
| 675 | "]}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 676 | "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" + |
| 677 | "]}" + |
| 678 | "}"; |
| 679 | ct = new CosmasTree(query); |
| 680 | map = ct.getRequestMap().get("query").toString(); |
| 681 | assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 682 | |
| 683 | query="#ELEM(W ANA != 'N V' Genre != 'Sport Politik')"; |
| 684 | String elem5 = |
| 685 | "{@type=korap:span, key=w, attr=" + |
| 686 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 687 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 688 | "{@type=korap:term, layer=pos, key=N, match=match:ne}," + |
| 689 | "{@type=korap:term, layer=pos, key=V, match=match:ne}" + |
| 690 | "]}," + |
| 691 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 692 | "{@type=korap:term, layer=Genre, key=Sport, match=match:ne}," + |
| 693 | "{@type=korap:term, layer=Genre, key=Politik, match=match:ne}" + |
| 694 | "]}" + |
| 695 | "]}" + |
| 696 | "}"; |
| 697 | ct = new CosmasTree(query); |
| 698 | map = ct.getRequestMap().get("query").toString(); |
| 699 | assertEquals(elem5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 700 | } |
| 701 | |
| 702 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 703 | public void testOPALL() throws QueryException { |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 704 | query="#ALL(gehen /w1:10 voran)"; |
Joachim Bingel | e98d088 | 2014-01-21 12:58:54 +0000 | [diff] [blame] | 705 | String all1 = |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 706 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 707 | "operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 708 | "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," + |
| 709 | "{@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] | 710 | "], inOrder=false, " + |
| 711 | "distances=[" + |
| 712 | "{@type=korap:distance, key=w, min=1, max=10}" + |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 713 | "]" + |
| 714 | "}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 715 | ct = new CosmasTree(query); |
| 716 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 717 | assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 718 | } |
| 719 | |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 720 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 721 | public void testOPNHIT() throws QueryException { |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 722 | query="#NHIT(gehen /w1:10 voran)"; |
| 723 | String nhit1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 724 | "{@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] | 725 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 726 | "operands=[" + |
| 727 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 728 | "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" + |
| 729 | "]}," + |
| 730 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 731 | "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" + |
| 732 | "]}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 733 | "], inOrder=false, " + |
| 734 | "distances=[" + |
| 735 | "{@type=korap:distance, key=w, min=1, max=10}" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 736 | "]" + |
| 737 | "}" + |
| 738 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 739 | ct = new CosmasTree(query); |
| 740 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 741 | assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 745 | public void testOPBED() throws QueryException { |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 746 | query = "#BED(der , sa)"; |
| 747 | String bed1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 748 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands= [" + |
Joachim Bingel | cd7b725 | 2014-02-13 08:49:14 +0000 | [diff] [blame] | 749 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 750 | "{@type=korap:span, key=s}," + |
| 751 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 752 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" + |
| 753 | "]}" + |
| 754 | "]}" + |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 755 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 756 | ct = new CosmasTree(query); |
| 757 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 758 | assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 759 | |
| 760 | query = "#BED(der Mann , +pe)"; |
| 761 | String bed2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 762 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands= [" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 763 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 764 | "{@type=korap:span, key=p}," + |
| 765 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 766 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 767 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 768 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 769 | "]}" + |
| 770 | "]}" + |
| 771 | "]}" + |
| 772 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 773 | ct = new CosmasTree(query); |
| 774 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 775 | assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 776 | |
| 777 | query = "#BED(der Mann , sa,-pa)"; |
| 778 | String bed3 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 779 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 780 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
| 781 | "{@type=korap:distance, key=w, min=0, max=0}" + |
| 782 | "], operands=[" + |
| 783 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 784 | "{@type=korap:span, key=s}," + |
| 785 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 786 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 787 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 788 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 789 | "]}" + |
| 790 | "]}" + |
| 791 | "]}," + |
| 792 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, exclude=true, operands=[" + |
| 793 | "{@type=korap:span, key=p}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 794 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 795 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 796 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 797 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 798 | "]}" + |
| 799 | "]}" + |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 800 | "]}" + |
| 801 | "]}" + |
| 802 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 803 | ct = new CosmasTree(query); |
| 804 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 805 | assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 806 | } |
| 807 | |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 808 | @Test |
| 809 | public void testColonSeparatedConditions() throws QueryException { |
| 810 | |
| 811 | query = "Der:sa"; |
| 812 | String col1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 813 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 814 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 815 | "{@type=korap:span, key=s}," + |
| 816 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 817 | "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" + |
| 818 | "]}" + |
| 819 | "]}" + |
| 820 | "]}"; |
| 821 | ct = new CosmasTree(query); |
| 822 | map = ct.getRequestMap().get("query").toString(); |
| 823 | assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 824 | |
| 825 | query = "Mann:sa,-pa,+te)"; |
| 826 | String col2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 827 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 828 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
| 829 | "{@type=korap:distance, key=w, min=0, max=0}" + |
| 830 | "], operands=[" + |
| 831 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 832 | "{@type=korap:span, key=s}," + |
| 833 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 834 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 835 | "]}" + |
| 836 | "]}," + |
| 837 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, exclude=true, operands=[" + |
| 838 | "{@type=korap:span, key=p}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 839 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 840 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 841 | "]}" + |
| 842 | "]}," + |
| 843 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 844 | "{@type=korap:span, key=t}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 845 | "{@type=korap:group, operation=operation:class, class=3, operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 846 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 847 | "]}" + |
| 848 | "]}" + |
| 849 | "]}" + |
| 850 | "]}"; |
| 851 | ct = new CosmasTree(query); |
| 852 | map = ct.getRequestMap().get("query").toString(); |
| 853 | assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 854 | } |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 855 | } |
| 856 | |