Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 1 | import static org.junit.Assert.*; |
| 2 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 3 | import java.io.IOException; |
| 4 | import java.util.ArrayList; |
| 5 | |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 6 | import org.junit.Test; |
| 7 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 8 | import de.ids_mannheim.korap.query.serialize.QuerySerializer; |
Joachim Bingel | 6003b85 | 2014-12-18 14:20:55 +0000 | [diff] [blame^] | 9 | import de.ids_mannheim.korap.query.serialize.util.QueryException; |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 10 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 11 | import com.fasterxml.jackson.core.JsonProcessingException; |
| 12 | import com.fasterxml.jackson.databind.JsonNode; |
| 13 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 14 | |
| 15 | /** |
| 16 | * Tests for JSON-LD serialization of Cosmas II queries. |
| 17 | * @author Joachim Bingel (bingel@ids-mannheim.de) |
| 18 | * @version 1.0 |
| 19 | */ |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 20 | public class CosmasTreeTest { |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 21 | |
Michael Hanl | baf1a5e | 2014-05-15 19:51:40 +0000 | [diff] [blame] | 22 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 23 | String query; |
| 24 | ArrayList<JsonNode> operands; |
| 25 | |
| 26 | QuerySerializer qs = new QuerySerializer(); |
| 27 | ObjectMapper mapper = new ObjectMapper(); |
| 28 | JsonNode res; |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 29 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 30 | @Test |
| 31 | public void testContext() throws QueryException, JsonProcessingException, IOException { |
| 32 | String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld"; |
| 33 | query = "foo"; |
| 34 | qs.setQuery(query, "cosmas2"); |
| 35 | res = mapper.readTree(qs.toJSON()); |
| 36 | assertEquals(contextString, res.get("@context").asText()); |
| 37 | } |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 38 | |
| 39 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 40 | @Test |
| 41 | public void testSingleToken() throws QueryException, JsonProcessingException, IOException { |
| 42 | query = "der"; |
| 43 | qs.setQuery(query, "cosmas2"); |
| 44 | res = mapper.readTree(qs.toJSON()); |
| 45 | assertEquals("korap:token", res.at("/query/@type").asText()); |
| 46 | assertEquals("korap:term", res.at("/query/wrap/@type").asText()); |
| 47 | assertEquals("der", res.at("/query/wrap/key").asText()); |
| 48 | assertEquals("orth", res.at("/query/wrap/layer").asText()); |
| 49 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 50 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 51 | query = "&Mann"; |
| 52 | qs.setQuery(query, "cosmas2"); |
| 53 | res = mapper.readTree(qs.toJSON()); |
| 54 | assertEquals("korap:token", res.at("/query/@type").asText()); |
| 55 | assertEquals("korap:term", res.at("/query/wrap/@type").asText()); |
| 56 | assertEquals("Mann", res.at("/query/wrap/key").asText()); |
| 57 | assertEquals("lemma", res.at("/query/wrap/layer").asText()); |
| 58 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
| 59 | } |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 60 | |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 61 | |
| 62 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 63 | @Test |
| 64 | public void testWildcardToken() throws QueryException, JsonProcessingException, IOException { |
| 65 | query = "*der"; |
| 66 | qs.setQuery(query, "cosmas2"); |
| 67 | res = mapper.readTree(qs.toJSON()); |
| 68 | assertEquals("korap:term", res.at("/query/wrap/@type").asText()); |
| 69 | assertEquals("type:wildcard", res.at("/query/wrap/type").asText()); |
| 70 | assertEquals("*der", res.at("/query/wrap/key").asText()); |
| 71 | assertEquals("orth", res.at("/query/wrap/layer").asText()); |
| 72 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 73 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 74 | query = "*de*?r"; |
| 75 | qs.setQuery(query, "cosmas2"); |
| 76 | res = mapper.readTree(qs.toJSON()); |
| 77 | assertEquals("*de*?r", res.at("/query/wrap/key").asText()); |
| 78 | } |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 79 | // |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 80 | @Test |
| 81 | public void testCaseSensitivityFlag() throws QueryException, JsonProcessingException, IOException { |
| 82 | query = "$deutscher"; |
| 83 | qs.setQuery(query, "cosmas2"); |
| 84 | res = mapper.readTree(qs.toJSON()); |
| 85 | assertEquals("korap:term", res.at("/query/wrap/@type").asText()); |
| 86 | assertEquals("deutscher", res.at("/query/wrap/key").asText()); |
| 87 | assertEquals(true, res.at("/query/wrap/caseInsensitive").asBoolean()); |
| 88 | assertEquals("orth", res.at("/query/wrap/layer").asText()); |
| 89 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 90 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 91 | query = "$deutscher Bundestag"; |
| 92 | qs.setQuery(query, "cosmas2"); |
| 93 | res = mapper.readTree(qs.toJSON()); |
| 94 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 95 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 96 | assertEquals("korap:term", res.at("/query/operands/0/wrap/@type").asText()); |
| 97 | assertEquals("deutscher", res.at("/query/operands/0/wrap/key").asText()); |
| 98 | assertEquals(true, res.at("/query/operands/0/wrap/caseInsensitive").asBoolean()); |
| 99 | assertEquals("orth", res.at("/query/operands/0/wrap/layer").asText()); |
| 100 | assertEquals("match:eq", res.at("/query/operands/0/wrap/match").asText()); |
| 101 | assertEquals("Bundestag", res.at("/query/operands/1/wrap/key").asText()); |
| 102 | assertEquals(true, res.at("/query/operands/1/wrap/caseInsensitive").isMissingNode()); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 103 | } |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 104 | |
Joachim Bingel | ba9a0ab | 2014-01-29 10:12:25 +0000 | [diff] [blame] | 105 | @Test |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 106 | public void testMORPH() throws QueryException, JsonProcessingException, IOException { |
| 107 | query = "MORPH(p=V)"; |
| 108 | qs.setQuery(query, "cosmas2"); |
| 109 | res = mapper.readTree(qs.toJSON()); |
| 110 | assertEquals("korap:token", res.at("/query/@type").asText()); |
| 111 | assertEquals("korap:term", res.at("/query/wrap/@type").asText()); |
| 112 | assertEquals("V", res.at("/query/wrap/key").asText()); |
| 113 | assertEquals("p", res.at("/query/wrap/layer").asText()); |
| 114 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 115 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 116 | query = "MORPH(V)"; |
| 117 | qs.setQuery(query, "cosmas2"); |
| 118 | res = mapper.readTree(qs.toJSON()); |
| 119 | assertEquals("korap:token", res.at("/query/@type").asText()); |
| 120 | assertEquals("korap:term", res.at("/query/wrap/@type").asText()); |
| 121 | assertEquals("V", res.at("/query/wrap/key").asText()); |
| 122 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 123 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 124 | query = "MORPH(tt/p=V)"; |
| 125 | qs.setQuery(query, "cosmas2"); |
| 126 | res = mapper.readTree(qs.toJSON()); |
| 127 | assertEquals("korap:token", res.at("/query/@type").asText()); |
| 128 | assertEquals("korap:term", res.at("/query/wrap/@type").asText()); |
| 129 | assertEquals("V", res.at("/query/wrap/key").asText()); |
| 130 | assertEquals("p", res.at("/query/wrap/layer").asText()); |
| 131 | assertEquals("tt", res.at("/query/wrap/foundry").asText()); |
| 132 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 133 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 134 | query = "MORPH(mate/m=temp:pres)"; |
| 135 | qs.setQuery(query, "cosmas2"); |
| 136 | res = mapper.readTree(qs.toJSON()); |
| 137 | assertEquals("korap:token", res.at("/query/@type").asText()); |
| 138 | assertEquals("korap:term", res.at("/query/wrap/@type").asText()); |
| 139 | assertEquals("temp", res.at("/query/wrap/key").asText()); |
| 140 | assertEquals("pres", res.at("/query/wrap/value").asText()); |
| 141 | assertEquals("m", res.at("/query/wrap/layer").asText()); |
| 142 | assertEquals("mate", res.at("/query/wrap/foundry").asText()); |
| 143 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 144 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 145 | query = "MORPH(tt/p=V & mate/m!=temp:pres)"; |
| 146 | qs.setQuery(query, "cosmas2"); |
| 147 | res = mapper.readTree(qs.toJSON()); |
| 148 | assertEquals("korap:token", res.at("/query/@type").asText()); |
| 149 | assertEquals("korap:termGroup", res.at("/query/wrap/@type").asText()); |
| 150 | assertEquals("V", res.at("/query/wrap/operands/0/key").asText()); |
| 151 | assertEquals("p", res.at("/query/wrap/operands/0/layer").asText()); |
| 152 | assertEquals("tt", res.at("/query/wrap/operands/0/foundry").asText()); |
| 153 | assertEquals("match:eq", res.at("/query/wrap/operands/0/match").asText()); |
| 154 | assertEquals("temp", res.at("/query/wrap/operands/1/key").asText()); |
| 155 | assertEquals("pres", res.at("/query/wrap/operands/1/value").asText()); |
| 156 | assertEquals("m", res.at("/query/wrap/operands/1/layer").asText()); |
| 157 | assertEquals("mate", res.at("/query/wrap/operands/1/foundry").asText()); |
| 158 | assertEquals("match:ne", res.at("/query/wrap/operands/1/match").asText()); |
Joachim Bingel | 9a202ab | 2014-10-07 12:35:17 +0000 | [diff] [blame] | 159 | } |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 160 | |
Joachim Bingel | 9a202ab | 2014-10-07 12:35:17 +0000 | [diff] [blame] | 161 | @Test |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 162 | public void testSequence() throws QueryException, JsonProcessingException, IOException { |
| 163 | query = "der Mann"; |
| 164 | qs.setQuery(query, "cosmas2"); |
| 165 | res = mapper.readTree(qs.toJSON()); |
| 166 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 167 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 168 | assertEquals("der", res.at("/query/operands/0/wrap/key").asText()); |
| 169 | assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText()); |
| 170 | assertEquals(true, res.at("/query/operands/2").isMissingNode()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 171 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 172 | query = "der Mann schläft"; |
| 173 | qs.setQuery(query, "cosmas2"); |
| 174 | res = mapper.readTree(qs.toJSON()); |
| 175 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 176 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 177 | assertEquals("der", res.at("/query/operands/0/wrap/key").asText()); |
| 178 | assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText()); |
| 179 | assertEquals("schläft", res.at("/query/operands/2/wrap/key").asText()); |
| 180 | assertEquals(true, res.at("/query/operands/3").isMissingNode()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 181 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 182 | query = "der Mann schläft lang"; |
| 183 | qs.setQuery(query, "cosmas2"); |
| 184 | res = mapper.readTree(qs.toJSON()); |
| 185 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 186 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 187 | assertEquals("der", res.at("/query/operands/0/wrap/key").asText()); |
| 188 | assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText()); |
| 189 | assertEquals("schläft", res.at("/query/operands/2/wrap/key").asText()); |
| 190 | assertEquals("lang", res.at("/query/operands/3/wrap/key").asText()); |
| 191 | assertEquals(true, res.at("/query/operands/4").isMissingNode()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 192 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 193 | query = "der #ELEM(W)"; |
| 194 | qs.setQuery(query, "cosmas2"); |
| 195 | res = mapper.readTree(qs.toJSON()); |
| 196 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 197 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 198 | assertEquals("der", res.at("/query/operands/0/wrap/key").asText()); |
| 199 | assertEquals("w", res.at("/query/operands/1/key").asText()); |
| 200 | assertEquals("korap:span", res.at("/query/operands/1/@type").asText()); |
| 201 | assertEquals(true, res.at("/query/operands/2").isMissingNode()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 202 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 203 | query = "der #ELEM(W) Mann"; |
| 204 | qs.setQuery(query, "cosmas2"); |
| 205 | res = mapper.readTree(qs.toJSON()); |
| 206 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 207 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 208 | assertEquals("der", res.at("/query/operands/0/wrap/key").asText()); |
| 209 | assertEquals("w", res.at("/query/operands/1/key").asText()); |
| 210 | assertEquals("korap:span", res.at("/query/operands/1/@type").asText()); |
| 211 | assertEquals("Mann", res.at("/query/operands/2/wrap/key").asText()); |
| 212 | assertEquals(true, res.at("/query/operands/3").isMissingNode()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 213 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 214 | query = "der MORPH(p=ADJA) Mann"; |
| 215 | qs.setQuery(query, "cosmas2"); |
| 216 | res = mapper.readTree(qs.toJSON()); |
| 217 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 218 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 219 | assertEquals("der", res.at("/query/operands/0/wrap/key").asText()); |
| 220 | assertEquals("ADJA", res.at("/query/operands/1/wrap/key").asText()); |
| 221 | assertEquals("p", res.at("/query/operands/1/wrap/layer").asText()); |
| 222 | assertEquals("Mann", res.at("/query/operands/2/wrap/key").asText()); |
| 223 | assertEquals(true, res.at("/query/operands/3").isMissingNode()); |
| 224 | } |
| 225 | |
| 226 | @Test |
| 227 | public void testOPOR() throws QueryException, JsonProcessingException, IOException { |
| 228 | query = "Sonne oder Mond"; |
| 229 | qs.setQuery(query, "cosmas2"); |
| 230 | res = mapper.readTree(qs.toJSON()); |
| 231 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 232 | assertEquals("operation:or", res.at("/query/operation").asText()); |
| 233 | assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText()); |
| 234 | assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText()); |
| 235 | assertEquals(true, res.at("/query/operands/2").isMissingNode()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 236 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 237 | query = "(Sonne scheint) oder Mond"; |
| 238 | qs.setQuery(query, "cosmas2"); |
| 239 | res = mapper.readTree(qs.toJSON()); |
| 240 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 241 | assertEquals("operation:or", res.at("/query/operation").asText()); |
| 242 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 243 | assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText()); |
| 244 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key").asText()); |
| 245 | assertEquals("scheint", res.at("/query/operands/0/operands/1/wrap/key").asText()); |
| 246 | assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText()); |
| 247 | assertEquals(true, res.at("/query/operands/2").isMissingNode()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 248 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 249 | query = "(Sonne scheint) oder (Mond scheint)"; |
| 250 | qs.setQuery(query, "cosmas2"); |
| 251 | res = mapper.readTree(qs.toJSON()); |
| 252 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 253 | assertEquals("operation:or", res.at("/query/operation").asText()); |
| 254 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 255 | assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText()); |
| 256 | assertEquals("korap:group", res.at("/query/operands/1/@type").asText()); |
| 257 | assertEquals("operation:sequence", res.at("/query/operands/1/operation").asText()); |
| 258 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key").asText()); |
| 259 | assertEquals("scheint", res.at("/query/operands/0/operands/1/wrap/key").asText()); |
| 260 | assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key").asText()); |
| 261 | assertEquals("scheint", res.at("/query/operands/1/operands/1/wrap/key").asText()); |
| 262 | assertEquals(true, res.at("/query/operands/2").isMissingNode()); |
| 263 | } |
| 264 | |
| 265 | @Test |
| 266 | public void testOPORAND() throws QueryException, JsonProcessingException, IOException { |
| 267 | query = "(Sonne oder Mond) und scheint"; |
| 268 | qs.setQuery(query, "cosmas2"); |
| 269 | res = mapper.readTree(qs.toJSON()); |
| 270 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 271 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 272 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText()); |
| 273 | assertEquals("t", res.at("/query/distances/0/key").asText()); |
| 274 | assertEquals(0, res.at("/query/distances/0/min").asInt()); |
| 275 | assertEquals(0, res.at("/query/distances/0/max").asInt()); |
| 276 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 277 | assertEquals("operation:or", res.at("/query/operands/0/operation").asText()); |
| 278 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key").asText()); |
| 279 | assertEquals("Mond", res.at("/query/operands/0/operands/1/wrap/key").asText()); |
| 280 | assertEquals("korap:token", res.at("/query/operands/1/@type").asText()); |
| 281 | assertEquals("scheint", res.at("/query/operands/1/wrap/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 282 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 283 | query = "scheint und (Sonne oder Mond)"; |
| 284 | qs.setQuery(query, "cosmas2"); |
| 285 | res = mapper.readTree(qs.toJSON()); |
| 286 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 287 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 288 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText()); |
| 289 | assertEquals("t", res.at("/query/distances/0/key").asText()); |
| 290 | assertEquals(0, res.at("/query/distances/0/min").asInt()); |
| 291 | assertEquals(0, res.at("/query/distances/0/max").asInt()); |
| 292 | assertEquals("korap:token", res.at("/query/operands/0/@type").asText()); |
| 293 | assertEquals("scheint", res.at("/query/operands/0/wrap/key").asText()); |
| 294 | assertEquals("korap:group", res.at("/query/operands/1/@type").asText()); |
| 295 | assertEquals("operation:or", res.at("/query/operands/1/operation").asText()); |
| 296 | assertEquals("Sonne", res.at("/query/operands/1/operands/0/wrap/key").asText()); |
| 297 | assertEquals("Mond", res.at("/query/operands/1/operands/1/wrap/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 298 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 299 | query = "Regen und scheint und (Sonne oder Mond)"; |
| 300 | qs.setQuery(query, "cosmas2"); |
| 301 | res = mapper.readTree(qs.toJSON()); |
| 302 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 303 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 304 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText()); |
| 305 | assertEquals("t", res.at("/query/distances/0/key").asText()); |
| 306 | assertEquals(0, res.at("/query/distances/0/min").asInt()); |
| 307 | assertEquals(0, res.at("/query/distances/0/max").asInt()); |
| 308 | assertEquals("korap:token", res.at("/query/operands/0/@type").asText()); |
| 309 | assertEquals("Regen", res.at("/query/operands/0/wrap/key").asText()); |
| 310 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 311 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 312 | assertEquals("cosmas:distance", res.at("/query/operands/1/distances/0/@type").asText()); |
| 313 | assertEquals("t", res.at("/query/operands/1/distances/0/key").asText()); |
| 314 | assertEquals(0, res.at("/query/operands/1/distances/0/min").asInt()); |
| 315 | assertEquals(0, res.at("/query/operands/1/distances/0/max").asInt()); |
| 316 | assertEquals("scheint", res.at("/query/operands/1/operands/0/wrap/key").asText()); |
| 317 | assertEquals("korap:group", res.at("/query/operands/1/operands/1/@type").asText()); |
| 318 | assertEquals("operation:or", res.at("/query/operands/1/operands/1/operation").asText()); |
| 319 | assertEquals("Sonne", res.at("/query/operands/1/operands/1/operands/0/wrap/key").asText()); |
| 320 | assertEquals("Mond", res.at("/query/operands/1/operands/1/operands/1/wrap/key").asText()); |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 321 | } |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 322 | |
Joachim Bingel | 8c640e4 | 2014-02-07 16:20:47 +0000 | [diff] [blame] | 323 | @Test |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 324 | public void testOPNOT() throws QueryException, JsonProcessingException, IOException { |
| 325 | query = "Sonne nicht Mond"; |
| 326 | qs.setQuery(query, "cosmas2"); |
| 327 | res = mapper.readTree(qs.toJSON()); |
| 328 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 329 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 330 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText()); |
| 331 | assertEquals("t", res.at("/query/distances/0/key").asText()); |
| 332 | assertEquals(0, res.at("/query/distances/0/min").asInt()); |
| 333 | assertEquals(0, res.at("/query/distances/0/max").asInt()); |
| 334 | assertEquals(true, res.at("/query/distances/0/exclude").asBoolean()); |
| 335 | assertEquals("korap:token", res.at("/query/operands/0/@type").asText()); |
| 336 | assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText()); |
| 337 | assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 338 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 339 | query = "Sonne nicht Mond nicht Sterne"; |
| 340 | qs.setQuery(query, "cosmas2"); |
| 341 | res = mapper.readTree(qs.toJSON()); |
| 342 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 343 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 344 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText()); |
| 345 | assertEquals("t", res.at("/query/distances/0/key").asText()); |
| 346 | assertEquals(0, res.at("/query/distances/0/min").asInt()); |
| 347 | assertEquals(0, res.at("/query/distances/0/max").asInt()); |
| 348 | assertEquals(true, res.at("/query/distances/0/exclude").asBoolean()); |
| 349 | assertEquals("korap:token", res.at("/query/operands/0/@type").asText()); |
| 350 | assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText()); |
| 351 | assertEquals("korap:group", res.at("/query/operands/1/@type").asText()); |
| 352 | assertEquals("operation:sequence", res.at("/query/operands/1/operation").asText()); |
| 353 | assertEquals("cosmas:distance", res.at("/query/operands/1/distances/0/@type").asText()); |
| 354 | assertEquals("t", res.at("/query/operands/1/distances/0/key").asText()); |
| 355 | assertEquals(0, res.at("/query/operands/1/distances/0/min").asInt()); |
| 356 | assertEquals(0, res.at("/query/operands/1/distances/0/max").asInt()); |
| 357 | assertEquals(true, res.at("/query/operands/1/distances/0/exclude").asBoolean()); |
| 358 | assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key").asText()); |
| 359 | assertEquals("Sterne", res.at("/query/operands/1/operands/1/wrap/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 360 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 361 | query = "(Sonne nicht Mond) nicht Sterne"; |
| 362 | qs.setQuery(query, "cosmas2"); |
| 363 | res = mapper.readTree(qs.toJSON()); |
| 364 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 365 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 366 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type").asText()); |
| 367 | assertEquals("t", res.at("/query/distances/0/key").asText()); |
| 368 | assertEquals(0, res.at("/query/distances/0/min").asInt()); |
| 369 | assertEquals(0, res.at("/query/distances/0/max").asInt()); |
| 370 | assertEquals(true, res.at("/query/distances/0/exclude").asBoolean()); |
| 371 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 372 | assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText()); |
| 373 | assertEquals("cosmas:distance", res.at("/query/operands/0/distances/0/@type").asText()); |
| 374 | assertEquals("t", res.at("/query/operands/0/distances/0/key").asText()); |
| 375 | assertEquals(0, res.at("/query/operands/0/distances/0/min").asInt()); |
| 376 | assertEquals(0, res.at("/query/operands/0/distances/0/max").asInt()); |
| 377 | assertEquals(true, res.at("/query/operands/0/distances/0/exclude").asBoolean()); |
| 378 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key").asText()); |
| 379 | assertEquals("Mond", res.at("/query/operands/0/operands/1/wrap/key").asText()); |
| 380 | assertEquals("korap:token", res.at("/query/operands/1/@type").asText()); |
| 381 | assertEquals("Sterne", res.at("/query/operands/1/wrap/key").asText()); |
Joachim Bingel | ffd65e3 | 2014-01-22 14:22:57 +0000 | [diff] [blame] | 382 | } |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 383 | |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 384 | @Test |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 385 | public void testOPPROX() throws QueryException, JsonProcessingException, IOException { |
| 386 | query = "Sonne /+w1:4 Mond"; |
| 387 | qs.setQuery(query, "cosmas2"); |
| 388 | res = mapper.readTree(qs.toJSON()); |
| 389 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 390 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 391 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 392 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 393 | assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText()); |
| 394 | assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText()); |
| 395 | assertEquals("w", res.at("/query/operands/0/distances/0/key").asText()); |
| 396 | assertEquals(1, res.at("/query/operands/0/distances/0/boundary/min").asInt()); |
| 397 | assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt()); |
| 398 | assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean()); |
| 399 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText()); |
| 400 | assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText()); |
| 401 | assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt()); |
| 402 | assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt()); |
| 403 | assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText()); |
| 404 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 405 | assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 406 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 407 | query = "Sonne /+w1:4,s0,p1:3 Mond"; |
| 408 | qs.setQuery(query, "cosmas2"); |
| 409 | res = mapper.readTree(qs.toJSON()); |
| 410 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 411 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 412 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 413 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 414 | assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText()); |
| 415 | assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText()); |
| 416 | assertEquals("w", res.at("/query/operands/0/distances/0/key").asText()); |
| 417 | assertEquals(1, res.at("/query/operands/0/distances/0/boundary/min").asInt()); |
| 418 | assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt()); |
| 419 | assertEquals("s", res.at("/query/operands/0/distances/1/key").asText()); |
| 420 | assertEquals(0, res.at("/query/operands/0/distances/1/boundary/min").asInt()); |
| 421 | assertEquals("p", res.at("/query/operands/0/distances/2/key").asText()); |
| 422 | assertEquals(1, res.at("/query/operands/0/distances/2/boundary/min").asInt()); |
| 423 | assertEquals(3, res.at("/query/operands/0/distances/2/boundary/max").asInt()); |
| 424 | assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean()); |
| 425 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText()); |
| 426 | assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText()); |
| 427 | assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt()); |
| 428 | assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt()); |
| 429 | assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText()); |
| 430 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 431 | assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 432 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 433 | query = "Sonne /+w4 Mond"; |
| 434 | qs.setQuery(query, "cosmas2"); |
| 435 | res = mapper.readTree(qs.toJSON()); |
| 436 | assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText()); |
| 437 | assertEquals("w", res.at("/query/operands/0/distances/0/key").asText()); |
| 438 | assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt()); |
| 439 | assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 440 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 441 | query = "Sonne /-w4 Mond"; |
| 442 | qs.setQuery(query, "cosmas2"); |
| 443 | res = mapper.readTree(qs.toJSON()); |
| 444 | assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText()); |
| 445 | assertEquals("w", res.at("/query/operands/0/distances/0/key").asText()); |
| 446 | assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt()); |
| 447 | assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt()); |
| 448 | assertEquals("Mond", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 449 | assertEquals("Sonne", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 450 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 451 | query = "Sonne /w4 Mond"; |
| 452 | qs.setQuery(query, "cosmas2"); |
| 453 | res = mapper.readTree(qs.toJSON()); |
| 454 | assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText()); |
| 455 | assertEquals("w", res.at("/query/operands/0/distances/0/key").asText()); |
| 456 | assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt()); |
| 457 | assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt()); |
| 458 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 459 | assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText()); |
| 460 | assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean()); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 461 | } |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 462 | |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 463 | @Test |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 464 | public void testOPPROXNested() throws QueryException, JsonProcessingException, IOException { |
| 465 | query = "Sonne /+w1:4 Mond /+w1:7 Sterne"; |
| 466 | qs.setQuery(query, "cosmas2"); |
| 467 | res = mapper.readTree(qs.toJSON()); |
| 468 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 469 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 470 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 471 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 472 | assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText()); |
| 473 | assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText()); |
| 474 | assertEquals("w", res.at("/query/operands/0/distances/0/key").asText()); |
| 475 | assertEquals(1, res.at("/query/operands/0/distances/0/boundary/min").asInt()); |
| 476 | assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt()); |
| 477 | assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean()); |
| 478 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText()); |
| 479 | assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText()); |
| 480 | assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt()); |
| 481 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 482 | assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt()); |
| 483 | assertEquals("korap:reference", res.at("/query/operands/0/operands/1/operands/0/@type").asText()); |
| 484 | assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/classRef/0").asInt()); |
| 485 | assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operands/0/operation").asText()); |
| 486 | assertEquals("operation:sequence", res.at("/query/operands/0/operands/1/operands/0/operands/0/operation").asText()); |
| 487 | assertEquals("w", res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/key").asText()); |
| 488 | assertEquals(1, res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/boundary/min").asInt()); |
| 489 | assertEquals(7, res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/boundary/max").asInt()); |
| 490 | assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/classOut").asInt()); |
| 491 | assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 492 | assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/classOut").asInt()); |
| 493 | assertEquals("Sterne", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 494 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 495 | query = "Sonne /+w1:4 Mond /-w1:7 Sterne"; |
| 496 | qs.setQuery(query, "cosmas2"); |
| 497 | res = mapper.readTree(qs.toJSON()); |
| 498 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 499 | assertEquals("Sterne", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 500 | assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 501 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 502 | query = "Sonne /-w4 Mond /+w2 Sterne"; |
| 503 | qs.setQuery(query, "cosmas2"); |
| 504 | res = mapper.readTree(qs.toJSON()); |
| 505 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 506 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 507 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 508 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 509 | assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText()); |
| 510 | assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText()); |
| 511 | assertEquals("w", res.at("/query/operands/0/distances/0/key").asText()); |
| 512 | assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt()); |
| 513 | assertEquals(4, res.at("/query/operands/0/distances/0/boundary/max").asInt()); |
| 514 | assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean()); |
| 515 | assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText()); |
| 516 | assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText()); |
| 517 | assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt()); |
| 518 | assertEquals("Sonne", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText()); |
| 519 | assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt()); |
| 520 | assertEquals("korap:reference", res.at("/query/operands/0/operands/0/operands/0/@type").asText()); |
| 521 | assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/classRef/0").asInt()); |
| 522 | assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operands/0/operation").asText()); |
| 523 | assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operands/0/operands/0/operation").asText()); |
| 524 | assertEquals("w", res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/key").asText()); |
| 525 | assertEquals(0, res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/boundary/min").asInt()); |
| 526 | assertEquals(2, res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/boundary/max").asInt()); |
| 527 | assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/classOut").asInt()); |
| 528 | assertEquals("Mond", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 529 | assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/classOut").asInt()); |
| 530 | assertEquals("Sterne", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/operands/0/wrap/key").asText()); |
| 531 | |
| 532 | } |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 533 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 534 | @Test |
| 535 | public void testOPIN() throws QueryException, JsonProcessingException, IOException { |
| 536 | query = "wegen #IN <s>"; |
| 537 | qs.setQuery(query, "cosmas2"); |
| 538 | res = mapper.readTree(qs.toJSON()); |
| 539 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 540 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 541 | assertEquals(130, res.at("/query/classRef/0").asInt()); |
| 542 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 543 | assertEquals("operation:class", res.at("/query/operands/0/operation").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 544 | assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck/0").asText()); |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 545 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText()); |
| 546 | assertEquals("operation:position", res.at("/query/operands/0/operands/0/operation").asText()); |
| 547 | assertEquals(true, res.at("/query/operands/0/operands/0/frames/0").isMissingNode()); |
| 548 | assertEquals(129, res.at("/query/operands/0/classIn/0").asInt()); |
| 549 | assertEquals(130, res.at("/query/operands/0/classIn/1").asInt()); |
| 550 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText()); |
| 551 | assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText()); |
| 552 | assertEquals(129, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt()); |
| 553 | assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText()); |
| 554 | assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/operands/0/key").asText()); |
| 555 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText()); |
| 556 | assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText()); |
| 557 | assertEquals(130, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt()); |
| 558 | assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/1/operands/0/@type").asText()); |
| 559 | assertEquals("wegen", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 560 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 561 | query = "wegen #IN(L) <s>"; |
| 562 | qs.setQuery(query, "cosmas2"); |
| 563 | res = mapper.readTree(qs.toJSON()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 564 | assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck/0").asText()); |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 565 | assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 566 | assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 567 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 568 | query = "wegen #IN(F) <s>"; |
| 569 | qs.setQuery(query, "cosmas2"); |
| 570 | res = mapper.readTree(qs.toJSON()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 571 | assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck/0").asText()); |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 572 | assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 573 | assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 574 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 575 | query = "wegen #IN(FI) <s>"; |
| 576 | qs.setQuery(query, "cosmas2"); |
| 577 | res = mapper.readTree(qs.toJSON()); |
| 578 | assertEquals("classRefCheck:unequals", res.at("/query/operands/0/classRefCheck/0").asText()); |
| 579 | assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck/1").asText()); |
| 580 | assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 581 | assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 582 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 583 | query = "wegen #IN(FE) <s>"; |
| 584 | qs.setQuery(query, "cosmas2"); |
| 585 | res = mapper.readTree(qs.toJSON()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 586 | assertEquals("classRefCheck:equals", res.at("/query/operands/0/classRefCheck/0").asText()); |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 587 | assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 588 | assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 589 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 590 | query = "wegen #IN(%, L) <s>"; |
| 591 | qs.setQuery(query, "cosmas2"); |
| 592 | res = mapper.readTree(qs.toJSON()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 593 | assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck/0").asText()); |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 594 | assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 595 | assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode()); |
| 596 | assertEquals(true, res.at("/query/operands/0/operands/0/exclude").asBoolean()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 597 | |
Joachim Bingel | e3fe367 | 2014-12-17 18:35:58 +0000 | [diff] [blame] | 598 | query = "wegen #IN(FE,%,MIN) <s>"; |
| 599 | qs.setQuery(query, "cosmas2"); |
| 600 | res = mapper.readTree(qs.toJSON()); |
| 601 | assertEquals(true, res.at("/query/reset").isMissingNode()); |
| 602 | assertEquals("classRefCheck:equals", res.at("/query/operands/0/classRefCheck/0").asText()); |
| 603 | assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 604 | assertEquals(true, res.at("/query/operands/0/operands/0/exclude").asBoolean()); |
| 605 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 606 | query = "wegen #IN(FE,ALL,%,MIN) <s>"; |
| 607 | qs.setQuery(query, "cosmas2"); |
| 608 | res = mapper.readTree(qs.toJSON()); |
| 609 | assertEquals(true, res.at("/query/reset").asBoolean()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 610 | assertEquals("classRefCheck:equals", res.at("/query/operands/0/classRefCheck/0").asText()); |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 611 | assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 612 | assertEquals(true, res.at("/query/operands/0/operands/0/exclude").asBoolean()); |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 613 | } |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 614 | |
Joachim Bingel | d5161a1 | 2014-01-08 11:15:49 +0000 | [diff] [blame] | 615 | @Test |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 616 | public void testOPOV() throws QueryException, JsonProcessingException, IOException { |
| 617 | query = "wegen #OV <s>"; |
| 618 | qs.setQuery(query, "cosmas2"); |
| 619 | res = mapper.readTree(qs.toJSON()); |
| 620 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 621 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 622 | assertEquals(130, res.at("/query/classRef/0").asInt()); |
| 623 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 624 | assertEquals("operation:class", res.at("/query/operands/0/operation").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 625 | assertEquals("classRefCheck:intersects", res.at("/query/operands/0/classRefCheck/0").asText()); |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 626 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText()); |
| 627 | assertEquals("operation:position", res.at("/query/operands/0/operands/0/operation").asText()); |
| 628 | assertEquals(true, res.at("/query/operands/0/operands/0/frames/0").isMissingNode()); |
| 629 | assertEquals(129, res.at("/query/operands/0/classIn/0").asInt()); |
| 630 | assertEquals(130, res.at("/query/operands/0/classIn/1").asInt()); |
| 631 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText()); |
| 632 | assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText()); |
| 633 | assertEquals(129, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt()); |
| 634 | assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText()); |
| 635 | assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/operands/0/key").asText()); |
| 636 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText()); |
| 637 | assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText()); |
| 638 | assertEquals(130, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt()); |
| 639 | assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/1/operands/0/@type").asText()); |
| 640 | assertEquals("wegen", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 641 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 642 | query = "wegen #OV(L) <s>"; |
| 643 | qs.setQuery(query, "cosmas2"); |
| 644 | res = mapper.readTree(qs.toJSON()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 645 | assertEquals("classRefCheck:intersects", res.at("/query/operands/0/classRefCheck/0").asText()); |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 646 | assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 647 | assertEquals("frames:overlapsLeft", res.at("/query/operands/0/operands/0/frames/1").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 648 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 649 | query = "wegen #OV(F) <s>"; |
| 650 | qs.setQuery(query, "cosmas2"); |
| 651 | res = mapper.readTree(qs.toJSON()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 652 | assertEquals("classRefCheck:intersects", res.at("/query/operands/0/classRefCheck/0").asText()); |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 653 | assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 654 | assertEquals(true, res.at("/query/operands/0/operands/0/frames/1").isMissingNode()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 655 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 656 | query = "wegen #OV(FI) <s>"; |
| 657 | qs.setQuery(query, "cosmas2"); |
| 658 | res = mapper.readTree(qs.toJSON()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 659 | assertEquals("classRefCheck:unequals", res.at("/query/operands/0/classRefCheck/0").asText()); |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 660 | assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 661 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 662 | query = "wegen #OV(FE) <s>"; |
| 663 | qs.setQuery(query, "cosmas2"); |
| 664 | res = mapper.readTree(qs.toJSON()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 665 | assertEquals("classRefCheck:equals", res.at("/query/operands/0/classRefCheck/0").asText()); |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 666 | assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 667 | } |
| 668 | |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 669 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 670 | @Test |
| 671 | public void testBEG_END() throws QueryException, JsonProcessingException, IOException { |
| 672 | query = "#BEG(der /w3:5 Mann)"; |
| 673 | qs.setQuery(query, "cosmas2"); |
| 674 | res = mapper.readTree(qs.toJSON()); |
| 675 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 676 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 677 | assertEquals(0, res.at("/query/spanRef/0").asInt()); |
| 678 | assertEquals(1, res.at("/query/spanRef/1").asInt()); |
| 679 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 680 | assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText()); |
| 681 | assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText()); |
| 682 | assertEquals("w", res.at("/query/operands/0/distances/0/key").asText()); |
| 683 | assertEquals(3, res.at("/query/operands/0/distances/0/boundary/min").asInt()); |
| 684 | assertEquals(5, res.at("/query/operands/0/distances/0/boundary/max").asInt()); |
| 685 | assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean()); |
| 686 | assertEquals("korap:token", res.at("/query/operands/0/operands/0/@type").asText()); |
| 687 | assertEquals("der", res.at("/query/operands/0/operands/0/wrap/key").asText()); |
| 688 | assertEquals("Mann", res.at("/query/operands/0/operands/1/wrap/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 689 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 690 | query = "#BEG(der /w3:5 Mann) /+w10 kommt"; |
| 691 | qs.setQuery(query, "cosmas2"); |
| 692 | res = mapper.readTree(qs.toJSON()); |
| 693 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 694 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 695 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 696 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 697 | assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText()); |
| 698 | assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText()); |
| 699 | assertEquals("w", res.at("/query/operands/0/distances/0/key").asText()); |
| 700 | assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt()); |
| 701 | assertEquals(10, res.at("/query/operands/0/distances/0/boundary/max").asInt()); |
| 702 | assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean()); |
| 703 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText()); |
| 704 | assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText()); |
| 705 | assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt()); |
| 706 | assertEquals("korap:reference", res.at("/query/operands/0/operands/0/operands/0/@type").asText()); |
| 707 | assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operands/0/operation").asText()); |
| 708 | assertEquals(0, res.at("/query/operands/0/operands/0/operands/0/spanRef/0").asInt()); |
| 709 | assertEquals(1, res.at("/query/operands/0/operands/0/operands/0/spanRef/1").asInt()); |
| 710 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText()); |
| 711 | assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operands/0/operands/0/operation").asText()); |
| 712 | assertEquals("korap:distance", res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/@type").asText()); |
| 713 | assertEquals("w", res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/key").asText()); |
| 714 | assertEquals(3, res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/boundary/min").asInt()); |
| 715 | assertEquals(5, res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/boundary/max").asInt()); |
| 716 | assertEquals(false, res.at("/query/operands/0/operands/0/operands/0/operands/0/inOrder").asBoolean()); |
| 717 | assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/@type").asText()); |
| 718 | assertEquals("der", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 719 | assertEquals("Mann", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/wrap/key").asText()); |
| 720 | assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText()); |
| 721 | assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt()); |
| 722 | assertEquals("korap:token", res.at("/query/operands/0/operands/1/operands/0/@type").asText()); |
| 723 | assertEquals("kommt", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 724 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 725 | query = "kommt /+w10 #BEG(der /w3:5 Mann)"; |
| 726 | qs.setQuery(query, "cosmas2"); |
| 727 | res = mapper.readTree(qs.toJSON()); |
| 728 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 729 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 730 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 731 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 732 | assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText()); |
| 733 | assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText()); |
| 734 | assertEquals("w", res.at("/query/operands/0/distances/0/key").asText()); |
| 735 | assertEquals(0, res.at("/query/operands/0/distances/0/boundary/min").asInt()); |
| 736 | assertEquals(10, res.at("/query/operands/0/distances/0/boundary/max").asInt()); |
| 737 | assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean()); |
| 738 | assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText()); |
| 739 | assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText()); |
| 740 | assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt()); |
| 741 | assertEquals("korap:reference", res.at("/query/operands/0/operands/1/operands/0/@type").asText()); |
| 742 | assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operands/0/operation").asText()); |
| 743 | assertEquals(0, res.at("/query/operands/0/operands/1/operands/0/spanRef/0").asInt()); |
| 744 | assertEquals(1, res.at("/query/operands/0/operands/1/operands/0/spanRef/1").asInt()); |
| 745 | assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/operands/0/@type").asText()); |
| 746 | assertEquals("operation:sequence", res.at("/query/operands/0/operands/1/operands/0/operands/0/operation").asText()); |
| 747 | assertEquals("korap:distance", res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/@type").asText()); |
| 748 | assertEquals("w", res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/key").asText()); |
| 749 | assertEquals(3, res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/boundary/min").asInt()); |
| 750 | assertEquals(5, res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/boundary/max").asInt()); |
| 751 | assertEquals(false, res.at("/query/operands/0/operands/1/operands/0/operands/0/inOrder").asBoolean()); |
| 752 | assertEquals("korap:token", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/@type").asText()); |
| 753 | assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 754 | assertEquals("Mann", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/wrap/key").asText()); |
| 755 | assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText()); |
| 756 | assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt()); |
| 757 | assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText()); |
| 758 | assertEquals("kommt", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 759 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 760 | query = "#END(der /w3:5 Mann)"; |
| 761 | qs.setQuery(query, "cosmas2"); |
| 762 | res = mapper.readTree(qs.toJSON()); |
| 763 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 764 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 765 | assertEquals(-1, res.at("/query/spanRef/0").asInt()); |
| 766 | assertEquals(1, res.at("/query/spanRef/1").asInt()); |
| 767 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 768 | assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText()); |
| 769 | assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText()); |
| 770 | assertEquals("w", res.at("/query/operands/0/distances/0/key").asText()); |
| 771 | assertEquals(3, res.at("/query/operands/0/distances/0/boundary/min").asInt()); |
| 772 | assertEquals(5, res.at("/query/operands/0/distances/0/boundary/max").asInt()); |
| 773 | assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean()); |
| 774 | assertEquals("korap:token", res.at("/query/operands/0/operands/0/@type").asText()); |
| 775 | assertEquals("der", res.at("/query/operands/0/operands/0/wrap/key").asText()); |
| 776 | assertEquals("Mann", res.at("/query/operands/0/operands/1/wrap/key").asText()); |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 777 | } |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 778 | |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 779 | @Test |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 780 | public void testELEM() throws QueryException, JsonProcessingException, IOException { |
| 781 | query = "#ELEM(S)"; |
| 782 | qs.setQuery(query, "cosmas2"); |
| 783 | res = mapper.readTree(qs.toJSON()); |
| 784 | assertEquals("korap:span", res.at("/query/@type").asText()); |
| 785 | assertEquals("s", res.at("/query/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 786 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 787 | query = "#ELEM(W ANA=N)"; |
| 788 | qs.setQuery(query, "cosmas2"); |
| 789 | res = mapper.readTree(qs.toJSON()); |
| 790 | assertEquals("korap:span", res.at("/query/@type").asText()); |
| 791 | assertEquals("w", res.at("/query/key").asText()); |
| 792 | assertEquals("korap:term", res.at("/query/attr/@type").asText()); |
| 793 | assertEquals("N", res.at("/query/attr/key").asText()); |
| 794 | assertEquals("p", res.at("/query/attr/layer").asText()); |
| 795 | assertEquals("match:eq", res.at("/query/attr/match").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 796 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 797 | query = "#ELEM(W ANA != 'N V')"; |
| 798 | qs.setQuery(query, "cosmas2"); |
| 799 | res = mapper.readTree(qs.toJSON()); |
| 800 | assertEquals("korap:span", res.at("/query/@type").asText()); |
| 801 | assertEquals("w", res.at("/query/key").asText()); |
| 802 | assertEquals("korap:termGroup", res.at("/query/attr/@type").asText()); |
| 803 | assertEquals("relation:and", res.at("/query/attr/relation").asText()); |
| 804 | assertEquals("korap:term", res.at("/query/attr/operands/0/@type").asText()); |
| 805 | assertEquals("N", res.at("/query/attr/operands/0/key").asText()); |
| 806 | assertEquals("p", res.at("/query/attr/operands/0/layer").asText()); |
| 807 | assertEquals("match:ne", res.at("/query/attr/operands/0/match").asText()); |
| 808 | assertEquals("korap:term", res.at("/query/attr/operands/1/@type").asText()); |
| 809 | assertEquals("V", res.at("/query/attr/operands/1/key").asText()); |
| 810 | assertEquals("p", res.at("/query/attr/operands/1/layer").asText()); |
| 811 | assertEquals("match:ne", res.at("/query/attr/operands/1/match").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 812 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 813 | query = "#ELEM(W ANA != 'N A V' Genre = Sport)"; |
| 814 | qs.setQuery(query, "cosmas2"); |
| 815 | res = mapper.readTree(qs.toJSON()); |
| 816 | assertEquals("korap:span", res.at("/query/@type").asText()); |
| 817 | assertEquals("w", res.at("/query/key").asText()); |
| 818 | assertEquals("korap:termGroup", res.at("/query/attr/@type").asText()); |
| 819 | assertEquals("relation:and", res.at("/query/attr/relation").asText()); |
| 820 | assertEquals("korap:termGroup", res.at("/query/attr/operands/0/@type").asText()); |
| 821 | assertEquals("relation:and", res.at("/query/attr/operands/0/relation").asText()); |
| 822 | assertEquals("N", res.at("/query/attr/operands/0/operands/0/key").asText()); |
| 823 | assertEquals("A", res.at("/query/attr/operands/0/operands/1/key").asText()); |
| 824 | assertEquals("V", res.at("/query/attr/operands/0/operands/2/key").asText()); |
| 825 | assertEquals("Genre", res.at("/query/attr/operands/1/layer").asText()); |
| 826 | assertEquals("Sport", res.at("/query/attr/operands/1/key").asText()); |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 827 | |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 828 | query = "#ELEM(W ANA != 'N A V' Genre != 'Sport Politik')"; |
| 829 | qs.setQuery(query, "cosmas2"); |
| 830 | res = mapper.readTree(qs.toJSON()); |
| 831 | assertEquals("korap:span", res.at("/query/@type").asText()); |
| 832 | assertEquals("w", res.at("/query/key").asText()); |
| 833 | assertEquals("korap:termGroup", res.at("/query/attr/@type").asText()); |
| 834 | assertEquals("relation:and", res.at("/query/attr/relation").asText()); |
| 835 | assertEquals("korap:termGroup", res.at("/query/attr/operands/0/@type").asText()); |
| 836 | assertEquals("relation:and", res.at("/query/attr/operands/0/relation").asText()); |
| 837 | assertEquals("korap:termGroup", res.at("/query/attr/operands/1/@type").asText()); |
| 838 | assertEquals("relation:and", res.at("/query/attr/operands/1/relation").asText()); |
| 839 | assertEquals("N", res.at("/query/attr/operands/0/operands/0/key").asText()); |
| 840 | assertEquals("A", res.at("/query/attr/operands/0/operands/1/key").asText()); |
| 841 | assertEquals("V", res.at("/query/attr/operands/0/operands/2/key").asText()); |
| 842 | assertEquals("match:ne", res.at("/query/attr/operands/0/operands/2/match").asText()); |
| 843 | assertEquals("Genre", res.at("/query/attr/operands/1/operands/0/layer").asText()); |
| 844 | assertEquals("Sport", res.at("/query/attr/operands/1/operands/0/key").asText()); |
| 845 | assertEquals("Genre", res.at("/query/attr/operands/1/operands/1/layer").asText()); |
| 846 | assertEquals("Politik", res.at("/query/attr/operands/1/operands/1/key").asText()); |
| 847 | assertEquals("match:ne", res.at("/query/attr/operands/1/operands/1/match").asText()); |
| 848 | } |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 849 | @Test |
| 850 | public void testOPALL() throws QueryException, JsonProcessingException, IOException { |
| 851 | query = "#ALL(gehen /w1:10 voran)"; |
| 852 | qs.setQuery(query, "cosmas2"); |
| 853 | res = mapper.readTree(qs.toJSON()); |
| 854 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 855 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 856 | assertEquals("gehen", res.at("/query/operands/0/wrap/key").asText()); |
| 857 | assertEquals("voran", res.at("/query/operands/1/wrap/key").asText()); |
| 858 | assertEquals("korap:distance", res.at("/query/distances/0/@type").asText()); |
| 859 | assertEquals("w", res.at("/query/distances/0/key").asText()); |
| 860 | assertEquals(1, res.at("/query/distances/0/boundary/min").asInt()); |
| 861 | assertEquals(10, res.at("/query/distances/0/boundary/max").asInt()); |
| 862 | |
| 863 | query = "#ALL(gehen /w1:10 (voran /w1:4 schnell))"; |
| 864 | qs.setQuery(query, "cosmas2"); |
| 865 | res = mapper.readTree(qs.toJSON()); |
| 866 | assertEquals("korap:group", res.at("/query/@type").asText()); |
| 867 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 868 | assertEquals("korap:distance", res.at("/query/distances/0/@type").asText()); |
| 869 | assertEquals("w", res.at("/query/distances/0/key").asText()); |
| 870 | assertEquals(1, res.at("/query/distances/0/boundary/min").asInt()); |
| 871 | assertEquals(10, res.at("/query/distances/0/boundary/max").asInt()); |
| 872 | assertEquals("gehen", res.at("/query/operands/0/wrap/key").asText()); |
| 873 | assertEquals("korap:group", res.at("/query/operands/1/@type").asText()); |
| 874 | assertEquals("operation:sequence", res.at("/query/operands/1/operation").asText()); |
| 875 | assertEquals("korap:distance", res.at("/query/operands/1/distances/0/@type").asText()); |
| 876 | assertEquals("w", res.at("/query/operands/1/distances/0/key").asText()); |
| 877 | assertEquals(1, res.at("/query/operands/1/distances/0/boundary/min").asInt()); |
| 878 | assertEquals(4, res.at("/query/operands/1/distances/0/boundary/max").asInt()); |
| 879 | assertEquals("voran", res.at("/query/operands/1/operands/0/wrap/key").asText()); |
| 880 | assertEquals("schnell", res.at("/query/operands/1/operands/1/wrap/key").asText()); |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 881 | |
| 882 | |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 883 | } |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 884 | |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 885 | @Test |
| 886 | public void testOPNHIT() throws QueryException, JsonProcessingException, IOException { |
| 887 | query = "#NHIT(gehen /w1:10 voran)"; |
| 888 | qs.setQuery(query, "cosmas2"); |
| 889 | res = mapper.readTree(qs.toJSON()); |
| 890 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 891 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 892 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 893 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 894 | assertEquals("operation:class", res.at("/query/operands/0/operation").asText()); |
| 895 | assertEquals("classRefOp:inversion",res.at("/query/operands/0/classRefOp").asText()); |
| 896 | assertEquals(130, res.at("/query/operands/0/classIn/0").asInt()); |
| 897 | assertEquals(131, res.at("/query/operands/0/classIn/1").asInt()); |
| 898 | assertEquals(129, res.at("/query/operands/0/classOut").asInt()); |
| 899 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText()); |
| 900 | assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operation").asText()); |
| 901 | assertEquals("korap:distance", res.at("/query/operands/0/operands/0/distances/0/@type").asText()); |
| 902 | assertEquals("w", res.at("/query/operands/0/operands/0/distances/0/key").asText()); |
| 903 | assertEquals(1, res.at("/query/operands/0/operands/0/distances/0/boundary/min").asInt()); |
| 904 | assertEquals(10, res.at("/query/operands/0/operands/0/distances/0/boundary/max").asInt()); |
| 905 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/0/@type").asText()); |
| 906 | assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText()); |
| 907 | assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt()); |
| 908 | assertEquals(131, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt()); |
| 909 | assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText()); |
| 910 | assertEquals("gehen", res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 911 | assertEquals("voran", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText()); |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 912 | |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 913 | query = "#NHIT(gehen /w1:10 voran /w1:10 Beispiel)"; |
| 914 | qs.setQuery(query, "cosmas2"); |
| 915 | res = mapper.readTree(qs.toJSON()); |
| 916 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 917 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 918 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 919 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 920 | assertEquals("operation:class", res.at("/query/operands/0/operation").asText()); |
| 921 | assertEquals("classRefOp:inversion",res.at("/query/operands/0/classRefOp").asText()); |
| 922 | assertEquals(130, res.at("/query/operands/0/classIn/0").asInt()); |
| 923 | assertEquals(131, res.at("/query/operands/0/classIn/1").asInt()); |
| 924 | assertEquals(129, res.at("/query/operands/0/classOut").asInt()); |
| 925 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText()); |
| 926 | assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operation").asText()); |
| 927 | assertEquals("korap:distance", res.at("/query/operands/0/operands/0/distances/0/@type").asText()); |
| 928 | assertEquals("w", res.at("/query/operands/0/operands/0/distances/0/key").asText()); |
| 929 | assertEquals(1, res.at("/query/operands/0/operands/0/distances/0/boundary/min").asInt()); |
| 930 | assertEquals(10, res.at("/query/operands/0/operands/0/distances/0/boundary/max").asInt()); |
| 931 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/0/@type").asText()); |
| 932 | assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText()); |
| 933 | assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt()); |
| 934 | assertEquals(131, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt()); |
| 935 | assertEquals("gehen", res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 936 | assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operands/1/operands/0/operation").asText()); |
| 937 | assertEquals(132, res.at("/query/operands/0/operands/0/operands/1/operands/0/classRef/0").asInt()); |
| 938 | assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operation").asText()); |
| 939 | assertEquals(132, res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/0/classOut").asInt()); |
| 940 | assertEquals("voran", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 941 | assertEquals(132, res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/1/classOut").asInt()); |
| 942 | assertEquals("Beispiel", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key").asText()); |
Joachim Bingel | cd30ed1 | 2014-12-03 16:14:13 +0000 | [diff] [blame] | 943 | |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 944 | } |
Joachim Bingel | b5f7bf0 | 2014-01-07 16:36:54 +0000 | [diff] [blame] | 945 | |
Joachim Bingel | 8fbdfa7 | 2014-12-04 10:33:34 +0000 | [diff] [blame] | 946 | @Test |
| 947 | public void testOPBED() throws QueryException, JsonProcessingException, IOException { |
| 948 | query = "#BED(der , sa)"; |
| 949 | qs.setQuery(query, "cosmas2"); |
| 950 | res = mapper.readTree(qs.toJSON()); |
| 951 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 952 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 953 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 954 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 955 | assertEquals("operation:position", res.at("/query/operands/0/operation").asText()); |
| 956 | assertEquals("frames:startswith", res.at("/query/operands/0/frames/0").asText()); |
| 957 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 958 | assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText()); |
| 959 | assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt()); |
| 960 | assertEquals("korap:token", res.at("/query/operands/0/operands/1/operands/0/@type").asText()); |
| 961 | assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText()); |
| 962 | assertEquals("korap:span", res.at("/query/operands/0/operands/0/@type").asText()); |
| 963 | assertEquals("s", res.at("/query/operands/0/operands/0/key").asText()); |
| 964 | |
| 965 | query = "#BED(der Mann , +pe)"; |
| 966 | qs.setQuery(query, "cosmas2"); |
| 967 | res = mapper.readTree(qs.toJSON()); |
| 968 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 969 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 970 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 971 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 972 | assertEquals("operation:position", res.at("/query/operands/0/operation").asText()); |
| 973 | assertEquals("frames:matches", res.at("/query/operands/0/frames/0").asText()); |
| 974 | assertEquals("korap:reference", res.at("/query/operands/0/operands/0/@type").asText()); |
| 975 | assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operation").asText()); |
| 976 | assertEquals(-1, res.at("/query/operands/0/operands/0/spanRef/0").asInt()); |
| 977 | assertEquals(1, res.at("/query/operands/0/operands/0/spanRef/1").asInt()); |
| 978 | assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/@type").asText()); |
| 979 | assertEquals("p", res.at("/query/operands/0/operands/0/operands/0/key").asText()); |
| 980 | assertEquals("korap:reference", res.at("/query/operands/0/operands/1/@type").asText()); |
| 981 | assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operation").asText()); |
| 982 | assertEquals(0, res.at("/query/operands/0/operands/1/spanRef/0").asInt()); |
| 983 | assertEquals(1, res.at("/query/operands/0/operands/1/spanRef/1").asInt()); |
| 984 | assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/@type").asText()); |
| 985 | assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/0/operation").asText()); |
| 986 | assertEquals(129, res.at("/query/operands/0/operands/1/operands/0/classOut").asInt()); |
| 987 | assertEquals("operation:sequence", res.at("/query/operands/0/operands/1/operands/0/operands/0/operation").asText()); |
| 988 | assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/wrap/key").asText()); |
| 989 | assertEquals("Mann", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/wrap/key").asText()); |
| 990 | |
| 991 | query = "#BED(der Mann , sa,-pa)"; |
| 992 | qs.setQuery(query, "cosmas2"); |
| 993 | res = mapper.readTree(qs.toJSON()); |
| 994 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 995 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 996 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 997 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 998 | assertEquals("operation:position", res.at("/query/operands/0/operation").asText()); |
| 999 | assertEquals("frames:matches", res.at("/query/operands/0/frames/0").asText()); |
| 1000 | |
| 1001 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText()); |
| 1002 | assertEquals("operation:position", res.at("/query/operands/0/operands/0/operation").asText()); |
| 1003 | assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 1004 | assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/@type").asText()); |
| 1005 | assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/key").asText()); |
| 1006 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText()); |
| 1007 | assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText()); |
| 1008 | assertEquals(129, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt()); |
| 1009 | assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operands/1/operands/0/operation").asText()); |
| 1010 | assertEquals("der", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/wrap/key").asText()); |
| 1011 | assertEquals("Mann", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/1/wrap/key").asText()); |
| 1012 | |
| 1013 | assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText()); |
| 1014 | assertEquals("operation:position", res.at("/query/operands/0/operands/1/operation").asText()); |
| 1015 | assertEquals("frames:startswith", res.at("/query/operands/0/operands/1/frames/0").asText()); |
| 1016 | assertEquals(true, res.at("/query/operands/0/operands/1/exclude").asBoolean()); |
| 1017 | assertEquals("korap:span", res.at("/query/operands/0/operands/1/operands/0/@type").asText()); |
| 1018 | assertEquals("p", res.at("/query/operands/0/operands/1/operands/0/key").asText()); |
| 1019 | assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/1/@type").asText()); |
| 1020 | assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/1/operation").asText()); |
| 1021 | assertEquals(130, res.at("/query/operands/0/operands/1/operands/1/classOut").asInt()); |
| 1022 | assertEquals("operation:sequence", res.at("/query/operands/0/operands/1/operands/1/operands/0/operation").asText()); |
| 1023 | assertEquals("der", res.at("/query/operands/0/operands/1/operands/1/operands/0/operands/0/wrap/key").asText()); |
| 1024 | assertEquals("Mann", res.at("/query/operands/0/operands/1/operands/1/operands/0/operands/1/wrap/key").asText()); |
| 1025 | |
| 1026 | } |
| 1027 | |
| 1028 | @Test |
| 1029 | public void testColonSeparatedConditions() throws QueryException, JsonProcessingException, IOException { |
| 1030 | query = "der:sa"; |
| 1031 | qs.setQuery(query, "cosmas2"); |
| 1032 | res = mapper.readTree(qs.toJSON()); |
| 1033 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 1034 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 1035 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 1036 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 1037 | assertEquals("operation:position", res.at("/query/operands/0/operation").asText()); |
| 1038 | assertEquals("frames:startswith", res.at("/query/operands/0/frames/0").asText()); |
| 1039 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 1040 | assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText()); |
| 1041 | assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt()); |
| 1042 | assertEquals("korap:token", res.at("/query/operands/0/operands/1/operands/0/@type").asText()); |
| 1043 | assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText()); |
| 1044 | assertEquals("korap:span", res.at("/query/operands/0/operands/0/@type").asText()); |
| 1045 | assertEquals("s", res.at("/query/operands/0/operands/0/key").asText()); |
| 1046 | |
| 1047 | query = "der:sa,-pa"; |
| 1048 | qs.setQuery(query, "cosmas2"); |
| 1049 | res = mapper.readTree(qs.toJSON()); |
| 1050 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 1051 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 1052 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 1053 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 1054 | assertEquals("operation:position", res.at("/query/operands/0/operation").asText()); |
| 1055 | assertEquals("frames:matches", res.at("/query/operands/0/frames/0").asText()); |
| 1056 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText()); |
| 1057 | assertEquals("operation:position", res.at("/query/operands/0/operands/0/operation").asText()); |
| 1058 | assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 1059 | assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/@type").asText()); |
| 1060 | assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/key").asText()); |
| 1061 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText()); |
| 1062 | assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText()); |
| 1063 | assertEquals(129, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt()); |
| 1064 | assertEquals("der", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText()); |
| 1065 | assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText()); |
| 1066 | assertEquals("operation:position", res.at("/query/operands/0/operands/1/operation").asText()); |
| 1067 | assertEquals("frames:startswith", res.at("/query/operands/0/operands/1/frames/0").asText()); |
| 1068 | assertEquals(true, res.at("/query/operands/0/operands/1/exclude").asBoolean()); |
| 1069 | assertEquals("korap:span", res.at("/query/operands/0/operands/1/operands/0/@type").asText()); |
| 1070 | assertEquals("p", res.at("/query/operands/0/operands/1/operands/0/key").asText()); |
| 1071 | assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/1/@type").asText()); |
| 1072 | assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/1/operation").asText()); |
| 1073 | assertEquals(130, res.at("/query/operands/0/operands/1/operands/1/classOut").asInt()); |
| 1074 | assertEquals("der", res.at("/query/operands/0/operands/1/operands/1/operands/0/wrap/key").asText()); |
| 1075 | |
| 1076 | query = "der:sa,-pa,+te"; |
| 1077 | qs.setQuery(query, "cosmas2"); |
| 1078 | res = mapper.readTree(qs.toJSON()); |
| 1079 | assertEquals("korap:reference", res.at("/query/@type").asText()); |
| 1080 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 1081 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 1082 | assertEquals("korap:group", res.at("/query/operands/0/@type").asText()); |
| 1083 | assertEquals("operation:position", res.at("/query/operands/0/operation").asText()); |
| 1084 | assertEquals("frames:matches", res.at("/query/operands/0/frames/0").asText()); |
| 1085 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText()); |
| 1086 | assertEquals("operation:position", res.at("/query/operands/0/operands/0/operation").asText()); |
| 1087 | assertEquals("frames:startswith", res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 1088 | assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/@type").asText()); |
| 1089 | assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/key").asText()); |
| 1090 | assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText()); |
| 1091 | assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText()); |
| 1092 | assertEquals(129, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt()); |
| 1093 | assertEquals("der", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText()); |
| 1094 | assertEquals("korap:reference", res.at("/query/operands/0/operands/1/@type").asText()); |
| 1095 | assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operation").asText()); |
| 1096 | assertEquals(130, res.at("/query/operands/0/operands/1/classRef/0").asInt()); |
| 1097 | assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/@type").asText()); |
| 1098 | assertEquals("operation:position", res.at("/query/operands/0/operands/1/operands/0/operation").asText()); |
| 1099 | assertEquals("frames:matches", res.at("/query/operands/0/operands/1/operands/0/frames/0").asText()); |
| 1100 | assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/operands/0/@type").asText()); |
| 1101 | assertEquals("operation:position", res.at("/query/operands/0/operands/1/operands/0/operands/0/operation").asText()); |
| 1102 | assertEquals("frames:startswith", res.at("/query/operands/0/operands/1/operands/0/operands/0/frames/0").asText()); |
| 1103 | assertEquals(true, res.at("/query/operands/0/operands/1/operands/0/operands/0/exclude").asBoolean()); |
| 1104 | assertEquals("korap:span", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/@type").asText()); |
| 1105 | assertEquals("p", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/key").asText()); |
| 1106 | assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/@type").asText()); |
| 1107 | assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operation").asText()); |
| 1108 | assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/classOut").asInt()); |
| 1109 | assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key").asText()); |
| 1110 | assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/operands/1/@type").asText()); |
| 1111 | assertEquals("operation:position", res.at("/query/operands/0/operands/1/operands/0/operands/1/operation").asText()); |
| 1112 | assertEquals("frames:matches", res.at("/query/operands/0/operands/1/operands/0/operands/1/frames/0").asText()); |
| 1113 | assertEquals("korap:reference", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/@type").asText()); |
| 1114 | assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/operation").asText()); |
| 1115 | assertEquals(-1, res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/spanRef/0").asInt()); |
| 1116 | assertEquals(1, res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/spanRef/1").asInt()); |
| 1117 | assertEquals("korap:span", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/operands/0/@type").asText()); |
| 1118 | assertEquals("t", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/operands/0/key").asText()); |
| 1119 | assertEquals("korap:reference", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/@type").asText()); |
| 1120 | assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operation").asText()); |
| 1121 | assertEquals(0, res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/spanRef/0").asInt()); |
| 1122 | assertEquals(1, res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/spanRef/1").asInt()); |
| 1123 | assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/@type").asText()); |
| 1124 | assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/operation").asText()); |
| 1125 | assertEquals(131, res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/classOut").asInt()); |
| 1126 | assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/operands/0/wrap/key").asText()); |
| 1127 | } |
| 1128 | } |