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 | 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 | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 262 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 263 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, 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 | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 266 | "]}," + |
| 267 | "{@type=korap:group, operation=operation:sequence, " + |
| 268 | "operands=[" + |
| 269 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 270 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 271 | "], inOrder=true, " + |
| 272 | "distances=[" + |
| 273 | "{@type=korap:distance, key=w, min=1, max=4}" + |
| 274 | "]" + |
| 275 | "}" + |
| 276 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 277 | ct = new CosmasTree(query); |
| 278 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 279 | assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 280 | |
| 281 | query="Sonne /-w4 Mond"; |
| 282 | String prox5 = |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 283 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 284 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 285 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," + |
| 286 | "{@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] | 287 | "]}," + |
| 288 | "{@type=korap:group, operation=operation:sequence, " + |
| 289 | "operands=[" + |
| 290 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," + |
| 291 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 292 | "], inOrder=true, " + |
| 293 | "distances=[" + |
| 294 | "{@type=korap:distance, key=w, min=1, max=4}" + |
| 295 | "]" + |
| 296 | "}" + |
| 297 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 298 | ct = new CosmasTree(query); |
| 299 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 300 | assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 301 | |
| 302 | query="Sonne /w4 Mond"; |
| 303 | String prox6 = |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 304 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 305 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
| 306 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 307 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 308 | "]}," + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 309 | "{@type=korap:group, operation=operation:sequence, " + |
| 310 | "operands=[" + |
| 311 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 312 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 313 | "], inOrder=false, " + |
| 314 | "distances=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 315 | "{@type=korap:distance, key=w, min=1, max=4}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 316 | "]" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 317 | "}" + |
| 318 | "]}"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 319 | ct = new CosmasTree(query); |
| 320 | map = ct.getRequestMap().get("query").toString(); |
| 321 | assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | @Test |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 325 | public void testOPPROXNested() throws QueryException { |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 326 | query="Sonne /-w4 Mond /+w2 Sterne"; |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 327 | |
| 328 | String mondsterne = |
| 329 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," + |
| 330 | "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" ; |
| 331 | String mondsterneSeq = |
| 332 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 333 | mondsterne + |
| 334 | "], inOrder=true, distances=[" + |
| 335 | "{@type=korap:distance, key=w, min=1, max=2}" + |
| 336 | "]}" ; |
| 337 | String mondsterneOv = |
| 338 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
| 339 | mondsterne + |
| 340 | "]}"; |
| 341 | String mondsterneAll = |
| 342 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 343 | mondsterneOv + "," + mondsterneSeq + |
| 344 | "]}"; |
| 345 | |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 346 | String prox6 = |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 347 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 348 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
| 349 | mondsterneAll + "," + |
| 350 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 351 | "]}," + |
| 352 | "{@type=korap:group, operation=operation:sequence, " + |
| 353 | "operands=[" + |
| 354 | mondsterneAll + "," + |
| 355 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 356 | "], inOrder=true, " + |
| 357 | "distances=[" + |
| 358 | "{@type=korap:distance, key=w, min=1, max=4}" + |
| 359 | "]" + |
| 360 | "}" + |
| 361 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 362 | ct = new CosmasTree(query); |
| 363 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 364 | assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 368 | public void testOPIN() throws QueryException { |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 369 | query="wegen #IN <s>"; |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 370 | String opin1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 371 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 372 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 373 | "{@type=korap:span, key=s}," + |
| 374 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 375 | "{@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] | 376 | "]}" + |
| 377 | "]}" + |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 378 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 379 | ct = new CosmasTree(query); |
| 380 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 381 | assertEquals(opin1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 382 | |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 383 | 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] | 384 | String opin2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 385 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 386 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 387 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 388 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 389 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 390 | "{@type=korap:span, key=s}" + |
| 391 | "]}," + |
| 392 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 393 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 394 | "]}" + |
| 395 | "]}" + |
| 396 | "]}," + |
| 397 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 398 | "], exclude=true}" + |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 399 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 400 | ct = new CosmasTree(query); |
| 401 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 402 | assertEquals(opin2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 403 | |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 404 | |
| 405 | query="wegen #IN(F) <s>"; |
| 406 | String opin3= |
| 407 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 408 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 409 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 410 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 411 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 412 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 413 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 414 | "{@type=korap:span, key=s}" + |
| 415 | "]}," + |
| 416 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 417 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 418 | "]}" + |
| 419 | "]}" + |
| 420 | "]}," + |
| 421 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 422 | "]}" + |
| 423 | "]}," + |
| 424 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 425 | "]}" + |
| 426 | "]}" + |
| 427 | ""; |
| 428 | ct = new CosmasTree(query); |
| 429 | map = ct.getRequestMap().get("query").toString(); |
| 430 | assertEquals(opin3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 431 | |
| 432 | query="wegen #IN(FI) <s>"; |
| 433 | String opin4= |
| 434 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 435 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 436 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 437 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 438 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 439 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 440 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 441 | "{@type=korap:span, key=s}" + |
| 442 | "]}," + |
| 443 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 444 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 445 | "]}" + |
| 446 | "]}" + |
| 447 | "]}," + |
| 448 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 449 | "]}" + |
| 450 | "]}," + |
| 451 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 452 | "], exclude=true}" + |
| 453 | "]}" + |
| 454 | ""; |
| 455 | ct = new CosmasTree(query); |
| 456 | map = ct.getRequestMap().get("query").toString(); |
| 457 | assertEquals(opin4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 458 | |
| 459 | query="wegen #IN(FE) <s>"; |
| 460 | String opin5= |
| 461 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 462 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 463 | "{@type=korap:span, key=s}," + |
| 464 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 465 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 466 | "]}" + |
| 467 | "]}" + |
| 468 | "]}" + |
| 469 | ""; |
| 470 | ct = new CosmasTree(query); |
| 471 | map = ct.getRequestMap().get("query").toString(); |
| 472 | assertEquals(opin5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 473 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 474 | query="wegen #IN(%, L) <s>"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 475 | String opin6 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 476 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 477 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 478 | "{@type=korap:span, key=s}," + |
| 479 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 480 | "{@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] | 481 | "]}" + |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 482 | "], exclude=true}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 483 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 484 | ct = new CosmasTree(query); |
| 485 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 486 | assertEquals(opin6.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 487 | |
| 488 | query="wegen #IN('FE,ALL,%,MIN') <s>"; |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 489 | String opin7 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 490 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 491 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 492 | "{@type=korap:span, key=s}," + |
| 493 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 494 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 495 | "]}" + |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 496 | "], range=all, exclude=true, grouping=false}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 497 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 498 | ct = new CosmasTree(query); |
| 499 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 500 | assertEquals(opin7.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 504 | public void testOPOV() throws QueryException { |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 505 | query="wegen #OV <s>"; |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 506 | String opov1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 507 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 508 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
| 509 | "{@type=korap:span, key=s}," + |
| 510 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 511 | "{@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] | 512 | "]}" + |
| 513 | "]}" + |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 514 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 515 | ct = new CosmasTree(query); |
| 516 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 517 | assertEquals(opov1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 518 | |
| 519 | query="wegen #OV(L) <s>"; |
| 520 | String opov2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 521 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 522 | "{@type=korap:group, operation=operation:position, frame=frame:overlapsLeft, operands=[" + |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 523 | "{@type=korap:span, key=s}," + |
| 524 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 525 | "{@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] | 526 | "]}" + |
| 527 | "]}" + |
| 528 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 529 | ct = new CosmasTree(query); |
| 530 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | cc1dc24 | 2014-01-15 09:32:38 +0000 | [diff] [blame] | 531 | assertEquals(opov2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 532 | |
| 533 | query="wegen #OV(F) <s>"; |
| 534 | String opov3= |
| 535 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 536 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 537 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 538 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 539 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 540 | "{@type=korap:span, key=s}" + |
| 541 | "]}," + |
| 542 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 543 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 544 | "]}" + |
| 545 | "]}" + |
| 546 | "]}," + |
| 547 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 548 | "]}" + |
| 549 | "]}" + |
| 550 | ""; |
| 551 | ct = new CosmasTree(query); |
| 552 | map = ct.getRequestMap().get("query").toString(); |
| 553 | assertEquals(opov3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 554 | |
| 555 | query="wegen #OV(FI) <s>"; |
| 556 | String opov4= |
| 557 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 558 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 559 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 560 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 561 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 562 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 563 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 564 | "{@type=korap:span, key=s}" + |
| 565 | "]}," + |
| 566 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 567 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 568 | "]}" + |
| 569 | "]}" + |
| 570 | "]}," + |
| 571 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 572 | "]}" + |
| 573 | "]}," + |
| 574 | "{@type=korap:reference, operation=operation:focus, classRef=[2]}" + |
| 575 | "], exclude=true}" + |
| 576 | "]}" + |
| 577 | ""; |
| 578 | ct = new CosmasTree(query); |
| 579 | map = ct.getRequestMap().get("query").toString(); |
| 580 | assertEquals(opov4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 581 | |
| 582 | query="wegen #OV(FE) <s>"; |
| 583 | String opov5= |
| 584 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
| 585 | "{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" + |
| 586 | "{@type=korap:span, key=s}," + |
| 587 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 588 | "{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" + |
| 589 | "]}" + |
| 590 | "]}" + |
| 591 | "]}" + |
| 592 | ""; |
| 593 | ct = new CosmasTree(query); |
| 594 | map = ct.getRequestMap().get("query").toString(); |
| 595 | assertEquals(opov5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 599 | public void testOPNOT() throws QueryException { |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 600 | query="Sonne nicht Mond"; |
| 601 | String opnot1 = |
Joachim Bingel | b7a5979 | 2014-02-14 13:52:29 +0000 | [diff] [blame] | 602 | "{@type=korap:group, operation=operation:sequence, distances=[" + |
| 603 | "{@type=korap:distance, key=t, min=0, max=0, exclude=true}" + |
| 604 | "], operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 605 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," + |
| 606 | "{@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] | 607 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 608 | ct = new CosmasTree(query); |
| 609 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 610 | assertEquals(opnot1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 611 | } |
| 612 | |
| 613 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 614 | public void testBEG_END() throws QueryException { |
Joachim Bingel | 3a9f793 | 2014-01-07 17:11:31 +0000 | [diff] [blame] | 615 | // BEG and END operators |
| 616 | // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/links.html |
| 617 | // http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/rechts.html |
| 618 | // 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] | 619 | query="#BEG(der /w3:5 Mann)"; |
| 620 | String beg1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 621 | "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 622 | "{@type=korap:group, operation=operation:sequence," + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 623 | "operands = [" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 624 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 625 | "{@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] | 626 | "], inOrder=false, distances=[" + |
| 627 | "{@type=korap:distance, key=w, min=3, max=5}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 628 | "]}" + |
| 629 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 630 | ct = new CosmasTree(query); |
| 631 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 632 | assertEquals(beg1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 633 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 634 | |
| 635 | String dermannSeq = "{@type=korap:group, operation=operation:sequence," + |
| 636 | "operands = [" + |
| 637 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 638 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 639 | "], inOrder=false, distances=[" + |
| 640 | "{@type=korap:distance, key=w, min=3, max=5}" + |
| 641 | "]}"; |
| 642 | String begDermannSeq = "{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" + |
| 643 | dermannSeq + |
| 644 | "]}"; |
| 645 | String kommt = "{@type=korap:token, wrap={@type=korap:term, key=kommt, layer=orth, match=match:eq}}"; |
| 646 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 647 | query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group |
| 648 | String beg2 = |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 649 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 650 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
| 651 | begDermannSeq + "," + |
| 652 | kommt + |
| 653 | "]}," + |
| 654 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 655 | begDermannSeq + "," + |
| 656 | kommt + |
| 657 | "], inOrder=true, distances=[" + |
| 658 | "{@type=korap:distance, key=w, min=1, max=10}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 659 | "]}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 660 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 661 | ct = new CosmasTree(query); |
| 662 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 663 | assertEquals(beg2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 664 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 665 | query="kommt /+w10 #BEG(der /w3:5 Mann)"; |
| 666 | String beg3 = |
| 667 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 668 | "{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" + |
| 669 | kommt + "," + |
| 670 | begDermannSeq + |
| 671 | "]}," + |
| 672 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 673 | kommt + "," + |
| 674 | begDermannSeq + |
| 675 | "], inOrder=true, distances=[" + |
| 676 | "{@type=korap:distance, key=w, min=1, max=10}" + |
| 677 | "]}" + |
| 678 | "]}"; |
| 679 | ct = new CosmasTree(query); |
| 680 | map = ct.getRequestMap().get("query").toString(); |
| 681 | assertEquals(beg3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 682 | |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 683 | query="#END(der /w3:5 Mann)"; |
| 684 | String end1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 685 | "{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 686 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 687 | "operands = [" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 688 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 689 | "{@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] | 690 | "], inOrder=false, distances=[" + |
| 691 | "{@type=korap:distance, key=w, min=3, max=5}" + |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 692 | "]}" + |
| 693 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 694 | ct = new CosmasTree(query); |
| 695 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 696 | assertEquals(end1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 697 | } |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 698 | |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 699 | @Test |
| 700 | public void testSentenceDistance() throws QueryException { |
| 701 | query="Sonne /s0 Mond"; // contains(focus(contains({<s>},Sonne)),Mond) |
| 702 | expected = |
| 703 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 704 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 705 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 706 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 707 | "{@type=korap:span, key=s}" + |
| 708 | "]}," + |
| 709 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 710 | "]}" + |
| 711 | "]}," + |
| 712 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 713 | "]}"; |
| 714 | ct = new CosmasTree(query); |
| 715 | map = ct.getRequestMap().get("query").toString(); |
| 716 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 717 | |
| 718 | query="Sonne /s2:2 Mond"; // contains(<s>,Sonne)<s>contains(<s>,Mond) |
| 719 | expected = |
| 720 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 721 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 722 | "{@type=korap:span, key=s}," + |
| 723 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 724 | "]}," + |
| 725 | "{@type=korap:span, key=s}," + |
| 726 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 727 | "{@type=korap:span, key=s}," + |
| 728 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 729 | "]}," + |
| 730 | "]}"; |
| 731 | ct = new CosmasTree(query); |
| 732 | map = ct.getRequestMap().get("query").toString(); |
| 733 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 734 | |
| 735 | query="Sonne /s2 Mond"; // contains(focus(contains({<s>},Sonne)),Mond) | contains(<s>,Sonne)<s>?contains(<s>,Mond) |
| 736 | expected = |
| 737 | "{@type=korap:group, operation=operation:or, operands=[" + |
| 738 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 739 | "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" + |
| 740 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 741 | "{@type=korap:group, operation=operation:class, class=0, operands=[" + |
| 742 | "{@type=korap:span, key=s}" + |
| 743 | "]}," + |
| 744 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 745 | "]}" + |
| 746 | "]}," + |
| 747 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 748 | "]}," + |
| 749 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 750 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 751 | "{@type=korap:span, key=s}," + |
| 752 | "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" + |
| 753 | "]}," + |
| 754 | "{@type=korap:group, operation=operation:repetition, repetition={@type=korap:boundary, min=0, max=1}, min=0, max=1, operands=[" + |
| 755 | "{@type=korap:span, key=s}," + |
| 756 | "]}," + |
| 757 | "{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" + |
| 758 | "{@type=korap:span, key=s}," + |
| 759 | "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" + |
| 760 | "]}," + |
| 761 | "]}" + |
| 762 | "]}"; |
| 763 | ct = new CosmasTree(query); |
| 764 | map = ct.getRequestMap().get("query").toString(); |
| 765 | assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 766 | } |
| 767 | |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 768 | |
| 769 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 770 | public void testELEM() throws QueryException { |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 771 | // 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] | 772 | query="#ELEM(S)"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 773 | String elem1 = "{@type=korap:span, key=s}"; |
| 774 | ct = new CosmasTree(query); |
| 775 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 776 | assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 777 | |
| 778 | query="#ELEM(W ANA=N)"; |
| 779 | String elem2 = |
| 780 | "{@type=korap:span, key=w, attr=" + |
| 781 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 782 | "{@type=korap:term, layer=pos, key=N, match=match:eq}" + |
| 783 | "]}" + |
| 784 | "}"; |
| 785 | ct = new CosmasTree(query); |
| 786 | map = ct.getRequestMap().get("query").toString(); |
| 787 | assertEquals(elem2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 788 | |
| 789 | query="#ELEM(W ANA != 'N V')"; |
| 790 | String elem3 = |
| 791 | "{@type=korap:span, key=w, attr=" + |
| 792 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 793 | "{@type=korap:term, layer=pos, key=N, match=match:ne}," + |
| 794 | "{@type=korap:term, layer=pos, key=V, match=match:ne}" + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 795 | "]}" + |
| 796 | "}"; |
| 797 | ct = new CosmasTree(query); |
| 798 | map = ct.getRequestMap().get("query").toString(); |
| 799 | assertEquals(elem3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 800 | |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 801 | query="#ELEM(W ANA != 'N A V' Genre = Sport)"; |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 802 | String elem4 = |
| 803 | "{@type=korap:span, key=w, attr=" + |
| 804 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 805 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 806 | "{@type=korap:term, layer=pos, key=N, match=match:ne}," + |
| 807 | "{@type=korap:term, layer=pos, key=A, match=match:ne}," + |
| 808 | "{@type=korap:term, layer=pos, key=V, match=match:ne}" + |
| 809 | "]}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 810 | "{@type=korap:term, layer=Genre, key=Sport, match=match:eq}" + |
| 811 | "]}" + |
| 812 | "}"; |
| 813 | ct = new CosmasTree(query); |
| 814 | map = ct.getRequestMap().get("query").toString(); |
| 815 | assertEquals(elem4.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | b674cca | 2014-05-09 14:00:58 +0000 | [diff] [blame] | 816 | |
| 817 | query="#ELEM(W ANA != 'N V' Genre != 'Sport Politik')"; |
| 818 | String elem5 = |
| 819 | "{@type=korap:span, key=w, attr=" + |
| 820 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 821 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 822 | "{@type=korap:term, layer=pos, key=N, match=match:ne}," + |
| 823 | "{@type=korap:term, layer=pos, key=V, match=match:ne}" + |
| 824 | "]}," + |
| 825 | "{@type=korap:termGroup, relation=relation:and, operands=[" + |
| 826 | "{@type=korap:term, layer=Genre, key=Sport, match=match:ne}," + |
| 827 | "{@type=korap:term, layer=Genre, key=Politik, match=match:ne}" + |
| 828 | "]}" + |
| 829 | "]}" + |
| 830 | "}"; |
| 831 | ct = new CosmasTree(query); |
| 832 | map = ct.getRequestMap().get("query").toString(); |
| 833 | assertEquals(elem5.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 834 | } |
| 835 | |
| 836 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 837 | public void testOPALL() throws QueryException { |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 838 | query="#ALL(gehen /w1:10 voran)"; |
Joachim Bingel | e98d088 | 2014-01-21 12:58:54 +0000 | [diff] [blame] | 839 | String all1 = |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 840 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 11d5b15 | 2014-02-11 21:33:47 +0000 | [diff] [blame] | 841 | "operands=[" + |
Joachim Bingel | ee3b21d | 2014-02-12 12:34:59 +0000 | [diff] [blame] | 842 | "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}," + |
| 843 | "{@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] | 844 | "], inOrder=false, " + |
| 845 | "distances=[" + |
| 846 | "{@type=korap:distance, key=w, min=1, max=10}" + |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 847 | "]" + |
| 848 | "}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 849 | ct = new CosmasTree(query); |
| 850 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 851 | assertEquals(all1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 852 | } |
| 853 | |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 854 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 855 | public void testOPNHIT() throws QueryException { |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 856 | query="#NHIT(gehen /w1:10 voran)"; |
| 857 | String nhit1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 858 | "{@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] | 859 | "{@type=korap:group, operation=operation:sequence, " + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 860 | "operands=[" + |
| 861 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 862 | "{@type=korap:token, wrap={@type=korap:term, key=gehen, layer=orth, match=match:eq}}" + |
| 863 | "]}," + |
| 864 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
| 865 | "{@type=korap:token, wrap={@type=korap:term, key=voran, layer=orth, match=match:eq}}" + |
| 866 | "]}" + |
Joachim Bingel | 097c1eb | 2014-07-11 14:57:25 +0000 | [diff] [blame] | 867 | "], inOrder=false, " + |
| 868 | "distances=[" + |
| 869 | "{@type=korap:distance, key=w, min=1, max=10}" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 870 | "]" + |
| 871 | "}" + |
| 872 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 873 | ct = new CosmasTree(query); |
| 874 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 89cceac | 2014-01-08 15:51:08 +0000 | [diff] [blame] | 875 | assertEquals(nhit1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 876 | } |
| 877 | |
| 878 | @Test |
Joachim Bingel | 87480d0 | 2014-01-17 14:07:46 +0000 | [diff] [blame] | 879 | public void testOPBED() throws QueryException { |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 880 | query = "#BED(der , sa)"; |
| 881 | String bed1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 882 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands= [" + |
Joachim Bingel | cd7b725 | 2014-02-13 08:49:14 +0000 | [diff] [blame] | 883 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 884 | "{@type=korap:span, key=s}," + |
| 885 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 886 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}" + |
| 887 | "]}" + |
| 888 | "]}" + |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 889 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 890 | ct = new CosmasTree(query); |
| 891 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | eecc765 | 2014-01-11 17:21:07 +0000 | [diff] [blame] | 892 | assertEquals(bed1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 893 | |
| 894 | query = "#BED(der Mann , +pe)"; |
| 895 | String bed2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 896 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands= [" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 897 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 898 | "{@type=korap:span, key=p}," + |
| 899 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 900 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 901 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 902 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 903 | "]}" + |
| 904 | "]}" + |
| 905 | "]}" + |
| 906 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 907 | ct = new CosmasTree(query); |
| 908 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 909 | assertEquals(bed2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | 3f0850c | 2014-01-17 16:50:10 +0000 | [diff] [blame] | 910 | |
| 911 | query = "#BED(der Mann , sa,-pa)"; |
| 912 | String bed3 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 913 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 914 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 915 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 916 | "{@type=korap:span, key=s}," + |
| 917 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 918 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 919 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 920 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 921 | "]}" + |
| 922 | "]}" + |
| 923 | "]}," + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 924 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 925 | "{@type=korap:span, key=p}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 926 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 927 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
| 928 | "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," + |
| 929 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 930 | "]}" + |
| 931 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 932 | "], exclude=true}" + |
| 933 | "], distances=[" + |
| 934 | "{@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] | 935 | "]}" + |
| 936 | "]}"; |
Joachim Bingel | 2daf986 | 2014-02-12 10:18:54 +0000 | [diff] [blame] | 937 | ct = new CosmasTree(query); |
| 938 | map = ct.getRequestMap().get("query").toString(); |
Joachim Bingel | 36233b5 | 2014-02-13 10:48:24 +0000 | [diff] [blame] | 939 | assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", "")); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 940 | } |
| 941 | |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 942 | @Test |
| 943 | public void testColonSeparatedConditions() throws QueryException { |
| 944 | |
| 945 | query = "Der:sa"; |
| 946 | String col1 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 947 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 948 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 949 | "{@type=korap:span, key=s}," + |
| 950 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 951 | "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" + |
| 952 | "]}" + |
| 953 | "]}" + |
| 954 | "]}"; |
| 955 | ct = new CosmasTree(query); |
| 956 | map = ct.getRequestMap().get("query").toString(); |
| 957 | assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 958 | |
| 959 | query = "Mann:sa,-pa,+te)"; |
| 960 | String col2 = |
Joachim Bingel | 0de1b41 | 2014-07-02 14:51:48 +0000 | [diff] [blame] | 961 | "{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 962 | "{@type=korap:group, operation=operation:sequence, operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 963 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
| 964 | "{@type=korap:span, key=s}," + |
| 965 | "{@type=korap:group, operation=operation:class, class=1, operands=[" + |
| 966 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 967 | "]}" + |
| 968 | "]}," + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 969 | "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 970 | "{@type=korap:span, key=p}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 971 | "{@type=korap:group, operation=operation:class, class=2, operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 972 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 973 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 974 | "], exclude=true}," + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 975 | "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" + |
| 976 | "{@type=korap:span, key=t}," + |
Joachim Bingel | 402c6e1 | 2014-05-08 17:09:06 +0000 | [diff] [blame] | 977 | "{@type=korap:group, operation=operation:class, class=3, operands=[" + |
Joachim Bingel | 8181263 | 2014-02-18 08:55:22 +0000 | [diff] [blame] | 978 | "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" + |
| 979 | "]}" + |
| 980 | "]}" + |
Joachim Bingel | 37a803f | 2014-07-28 14:21:44 +0000 | [diff] [blame] | 981 | "], distances=[" + |
| 982 | "{@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] | 983 | "]}" + |
| 984 | "]}"; |
| 985 | ct = new CosmasTree(query); |
| 986 | map = ct.getRequestMap().get("query").toString(); |
| 987 | assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", "")); |
| 988 | } |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 989 | } |
| 990 | |