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