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