| Eliza Margaretha | cef8427 | 2016-10-26 15:40:36 +0200 | [diff] [blame^] | 1 | package de.ids_mannheim.korap.query.test; |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 2 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 3 | import static org.junit.Assert.*; |
| 4 | |
| 5 | import java.io.IOException; |
| 6 | import java.util.ArrayList; |
| 7 | |
| 8 | import org.junit.Test; |
| 9 | |
| 10 | import de.ids_mannheim.korap.query.serialize.QuerySerializer; |
| 11 | import de.ids_mannheim.korap.query.serialize.util.StatusCodes; |
| 12 | |
| 13 | import com.fasterxml.jackson.core.JsonProcessingException; |
| 14 | import com.fasterxml.jackson.databind.JsonNode; |
| 15 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 16 | |
| 17 | /** |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 18 | * Tests for JSON-LD serialization of Cosmas II queries. |
| 19 | * |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 20 | * @author Joachim Bingel (bingel@ids-mannheim.de) |
| Akron | 79cd736 | 2016-06-03 17:05:05 +0200 | [diff] [blame] | 21 | * @author Nils Diewald |
| 22 | * @version 1.1 |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 23 | */ |
| 24 | public class Cosmas2QueryProcessorTest { |
| 25 | |
| 26 | |
| 27 | String query; |
| 28 | ArrayList<JsonNode> operands; |
| 29 | |
| 30 | QuerySerializer qs = new QuerySerializer(); |
| 31 | ObjectMapper mapper = new ObjectMapper(); |
| 32 | JsonNode res; |
| 33 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 34 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 35 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 36 | public void testContext () throws JsonProcessingException, IOException { |
| Joachim Bingel | 7cb346e | 2015-03-09 10:56:20 +0100 | [diff] [blame] | 37 | String contextString = "http://korap.ids-mannheim.de/ns/koral/0.3/context.jsonld"; |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 38 | query = "foo"; |
| 39 | qs.setQuery(query, "cosmas2"); |
| 40 | res = mapper.readTree(qs.toJSON()); |
| 41 | assertEquals(contextString, res.get("@context").asText()); |
| 42 | } |
| 43 | |
| 44 | |
| 45 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 46 | public void testSingleToken () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 47 | query = "der"; |
| 48 | qs.setQuery(query, "cosmas2"); |
| 49 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 50 | assertEquals("koral:token", res.at("/query/@type").asText()); |
| 51 | assertEquals("koral:term", res.at("/query/wrap/@type").asText()); |
| 52 | assertEquals("der", res.at("/query/wrap/key").asText()); |
| 53 | assertEquals("orth", res.at("/query/wrap/layer").asText()); |
| 54 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 55 | |
| 56 | query = "&Mann"; |
| 57 | qs.setQuery(query, "cosmas2"); |
| 58 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 59 | assertEquals("koral:token", res.at("/query/@type").asText()); |
| 60 | assertEquals("koral:term", res.at("/query/wrap/@type").asText()); |
| 61 | assertEquals("Mann", res.at("/query/wrap/key").asText()); |
| 62 | assertEquals("lemma", res.at("/query/wrap/layer").asText()); |
| 63 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | |
| 67 | |
| 68 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 69 | public void testWildcardToken () throws JsonProcessingException, |
| 70 | IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 71 | query = "*der"; |
| 72 | qs.setQuery(query, "cosmas2"); |
| 73 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 74 | assertEquals("koral:term", res.at("/query/wrap/@type").asText()); |
| 75 | assertEquals("type:wildcard", res.at("/query/wrap/type").asText()); |
| 76 | assertEquals("*der", res.at("/query/wrap/key").asText()); |
| 77 | assertEquals("orth", res.at("/query/wrap/layer").asText()); |
| 78 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 79 | |
| 80 | query = "*de*?r"; |
| 81 | qs.setQuery(query, "cosmas2"); |
| 82 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 83 | assertEquals("*de*?r", res.at("/query/wrap/key").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 84 | } |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 85 | |
| 86 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 87 | // |
| 88 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 89 | public void testCaseSensitivityFlag () throws JsonProcessingException, |
| 90 | IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 91 | query = "$deutscher"; |
| 92 | qs.setQuery(query, "cosmas2"); |
| 93 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 94 | assertEquals("koral:term", res.at("/query/wrap/@type").asText()); |
| 95 | assertEquals("deutscher", res.at("/query/wrap/key").asText()); |
| 96 | assertEquals("flags:caseInsensitive", res.at("/query/wrap/flags/0") |
| 97 | .asText()); |
| 98 | assertEquals("orth", res.at("/query/wrap/layer").asText()); |
| 99 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 100 | |
| 101 | query = "$deutscher Bundestag"; |
| 102 | qs.setQuery(query, "cosmas2"); |
| 103 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 104 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 105 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 106 | assertEquals("koral:term", res.at("/query/operands/0/wrap/@type") |
| 107 | .asText()); |
| 108 | assertEquals("deutscher", res.at("/query/operands/0/wrap/key").asText()); |
| 109 | assertEquals("flags:caseInsensitive", |
| 110 | res.at("/query/operands/0/wrap/flags/0").asText()); |
| 111 | assertEquals("orth", res.at("/query/operands/0/wrap/layer").asText()); |
| 112 | assertEquals("match:eq", res.at("/query/operands/0/wrap/match") |
| 113 | .asText()); |
| 114 | assertEquals("Bundestag", res.at("/query/operands/1/wrap/key").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 117 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 118 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 119 | public void testMORPH () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 120 | query = "MORPH(p=V)"; |
| 121 | qs.setQuery(query, "cosmas2"); |
| 122 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 123 | assertEquals("koral:token", res.at("/query/@type").asText()); |
| 124 | assertEquals("koral:term", res.at("/query/wrap/@type").asText()); |
| 125 | assertEquals("V", res.at("/query/wrap/key").asText()); |
| 126 | assertEquals("p", res.at("/query/wrap/layer").asText()); |
| 127 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 128 | |
| 129 | query = "MORPH(V)"; |
| 130 | qs.setQuery(query, "cosmas2"); |
| 131 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 132 | assertEquals("koral:token", res.at("/query/@type").asText()); |
| 133 | assertEquals("koral:term", res.at("/query/wrap/@type").asText()); |
| 134 | assertEquals("V", res.at("/query/wrap/key").asText()); |
| 135 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 136 | |
| 137 | query = "MORPH(tt/p=V)"; |
| 138 | qs.setQuery(query, "cosmas2"); |
| 139 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 140 | assertEquals("koral:token", res.at("/query/@type").asText()); |
| 141 | assertEquals("koral:term", res.at("/query/wrap/@type").asText()); |
| 142 | assertEquals("V", res.at("/query/wrap/key").asText()); |
| 143 | assertEquals("p", res.at("/query/wrap/layer").asText()); |
| 144 | assertEquals("tt", res.at("/query/wrap/foundry").asText()); |
| 145 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 146 | |
| 147 | query = "MORPH(tt/p=\"V.*\")"; |
| 148 | qs.setQuery(query, "cosmas2"); |
| 149 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 150 | assertEquals("koral:token", res.at("/query/@type").asText()); |
| 151 | assertEquals("koral:term", res.at("/query/wrap/@type").asText()); |
| 152 | assertEquals("type:regex", res.at("/query/wrap/type").asText()); |
| 153 | assertEquals("V.*", res.at("/query/wrap/key").asText()); |
| 154 | assertEquals("p", res.at("/query/wrap/layer").asText()); |
| 155 | assertEquals("tt", res.at("/query/wrap/foundry").asText()); |
| 156 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 157 | |
| 158 | query = "MORPH(mate/m=temp:pres)"; |
| 159 | qs.setQuery(query, "cosmas2"); |
| 160 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 161 | assertEquals("koral:token", res.at("/query/@type").asText()); |
| 162 | assertEquals("koral:term", res.at("/query/wrap/@type").asText()); |
| 163 | assertEquals("temp", res.at("/query/wrap/key").asText()); |
| 164 | assertEquals("pres", res.at("/query/wrap/value").asText()); |
| 165 | assertEquals("m", res.at("/query/wrap/layer").asText()); |
| 166 | assertEquals("mate", res.at("/query/wrap/foundry").asText()); |
| 167 | assertEquals("match:eq", res.at("/query/wrap/match").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 168 | |
| 169 | query = "MORPH(tt/p=V & mate/m!=temp:pres)"; |
| 170 | qs.setQuery(query, "cosmas2"); |
| 171 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 172 | assertEquals("koral:token", res.at("/query/@type").asText()); |
| 173 | assertEquals("koral:termGroup", res.at("/query/wrap/@type").asText()); |
| 174 | assertEquals("V", res.at("/query/wrap/operands/0/key").asText()); |
| 175 | assertEquals("p", res.at("/query/wrap/operands/0/layer").asText()); |
| 176 | assertEquals("tt", res.at("/query/wrap/operands/0/foundry").asText()); |
| 177 | assertEquals("match:eq", res.at("/query/wrap/operands/0/match") |
| 178 | .asText()); |
| 179 | assertEquals("temp", res.at("/query/wrap/operands/1/key").asText()); |
| 180 | assertEquals("pres", res.at("/query/wrap/operands/1/value").asText()); |
| 181 | assertEquals("m", res.at("/query/wrap/operands/1/layer").asText()); |
| 182 | assertEquals("mate", res.at("/query/wrap/operands/1/foundry").asText()); |
| 183 | assertEquals("match:ne", res.at("/query/wrap/operands/1/match") |
| 184 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 185 | } |
| 186 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 187 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 188 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 189 | public void testSequence () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 190 | query = "der Mann"; |
| 191 | qs.setQuery(query, "cosmas2"); |
| 192 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 193 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 194 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 195 | assertEquals("der", res.at("/query/operands/0/wrap/key").asText()); |
| 196 | assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText()); |
| 197 | assertEquals(true, res.at("/query/operands/2").isMissingNode()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 198 | |
| 199 | query = "der Mann schläft"; |
| 200 | qs.setQuery(query, "cosmas2"); |
| 201 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 202 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 203 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 204 | assertEquals("der", res.at("/query/operands/0/wrap/key").asText()); |
| 205 | assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText()); |
| 206 | assertEquals("schläft", res.at("/query/operands/2/wrap/key").asText()); |
| 207 | assertEquals(true, res.at("/query/operands/3").isMissingNode()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 208 | |
| 209 | query = "der Mann schläft lang"; |
| 210 | qs.setQuery(query, "cosmas2"); |
| 211 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 212 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 213 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 214 | assertEquals("der", res.at("/query/operands/0/wrap/key").asText()); |
| 215 | assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText()); |
| 216 | assertEquals("schläft", res.at("/query/operands/2/wrap/key").asText()); |
| 217 | assertEquals("lang", res.at("/query/operands/3/wrap/key").asText()); |
| 218 | assertEquals(true, res.at("/query/operands/4").isMissingNode()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 219 | |
| 220 | query = "der #ELEM(W)"; |
| 221 | qs.setQuery(query, "cosmas2"); |
| 222 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 223 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 224 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 225 | assertEquals("der", res.at("/query/operands/0/wrap/key").asText()); |
| 226 | assertEquals("w", res.at("/query/operands/1/key").asText()); |
| 227 | assertEquals("koral:span", res.at("/query/operands/1/@type").asText()); |
| 228 | assertEquals(true, res.at("/query/operands/2").isMissingNode()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 229 | |
| 230 | query = "der #ELEM(W) Mann"; |
| 231 | qs.setQuery(query, "cosmas2"); |
| 232 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 233 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 234 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 235 | assertEquals("der", res.at("/query/operands/0/wrap/key").asText()); |
| 236 | assertEquals("w", res.at("/query/operands/1/key").asText()); |
| 237 | assertEquals("koral:span", res.at("/query/operands/1/@type").asText()); |
| 238 | assertEquals("Mann", res.at("/query/operands/2/wrap/key").asText()); |
| 239 | assertEquals(true, res.at("/query/operands/3").isMissingNode()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 240 | |
| 241 | query = "der MORPH(p=ADJA) Mann"; |
| 242 | qs.setQuery(query, "cosmas2"); |
| 243 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 244 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 245 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 246 | assertEquals("der", res.at("/query/operands/0/wrap/key").asText()); |
| 247 | assertEquals("ADJA", res.at("/query/operands/1/wrap/key").asText()); |
| 248 | assertEquals("p", res.at("/query/operands/1/wrap/layer").asText()); |
| 249 | assertEquals("Mann", res.at("/query/operands/2/wrap/key").asText()); |
| 250 | assertEquals(true, res.at("/query/operands/3").isMissingNode()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 251 | } |
| 252 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 253 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 254 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 255 | public void testOPOR () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 256 | query = "Sonne oder Mond"; |
| 257 | qs.setQuery(query, "cosmas2"); |
| 258 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 259 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 260 | assertEquals("operation:disjunction", res.at("/query/operation") |
| 261 | .asText()); |
| 262 | assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText()); |
| 263 | assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText()); |
| 264 | assertEquals(true, res.at("/query/operands/2").isMissingNode()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 265 | |
| 266 | query = "(Sonne scheint) oder Mond"; |
| 267 | qs.setQuery(query, "cosmas2"); |
| 268 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 269 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 270 | assertEquals("operation:disjunction", res.at("/query/operation") |
| 271 | .asText()); |
| 272 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 273 | assertEquals("operation:sequence", res |
| 274 | .at("/query/operands/0/operation").asText()); |
| 275 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key") |
| 276 | .asText()); |
| 277 | assertEquals("scheint", res.at("/query/operands/0/operands/1/wrap/key") |
| 278 | .asText()); |
| 279 | assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText()); |
| 280 | assertEquals(true, res.at("/query/operands/2").isMissingNode()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 281 | |
| 282 | query = "(Sonne scheint) oder (Mond scheint)"; |
| 283 | qs.setQuery(query, "cosmas2"); |
| 284 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 285 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 286 | assertEquals("operation:disjunction", res.at("/query/operation") |
| 287 | .asText()); |
| 288 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 289 | assertEquals("operation:sequence", res |
| 290 | .at("/query/operands/0/operation").asText()); |
| 291 | assertEquals("koral:group", res.at("/query/operands/1/@type").asText()); |
| 292 | assertEquals("operation:sequence", res |
| 293 | .at("/query/operands/1/operation").asText()); |
| 294 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key") |
| 295 | .asText()); |
| 296 | assertEquals("scheint", res.at("/query/operands/0/operands/1/wrap/key") |
| 297 | .asText()); |
| 298 | assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key") |
| 299 | .asText()); |
| 300 | assertEquals("scheint", res.at("/query/operands/1/operands/1/wrap/key") |
| 301 | .asText()); |
| 302 | assertEquals(true, res.at("/query/operands/2").isMissingNode()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 303 | } |
| 304 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 305 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 306 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 307 | public void testOPORAND () throws JsonProcessingException, IOException { |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 308 | |
| 309 | // Query |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 310 | query = "(Sonne oder Mond) und scheint"; |
| 311 | qs.setQuery(query, "cosmas2"); |
| 312 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 313 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 314 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 315 | |
| 316 | assertEquals(false, res.at("/query/inOrder").isMissingNode()); |
| 317 | assertEquals(false, res.at("/query/inOrder").asBoolean()); |
| 318 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 319 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 320 | .asText()); |
| 321 | assertEquals("t", res.at("/query/distances/0/key").asText()); |
| 322 | assertEquals(0, res.at("/query/distances/0/min").asInt()); |
| 323 | assertEquals(0, res.at("/query/distances/0/max").asInt()); |
| 324 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 325 | assertEquals("operation:disjunction", |
| 326 | res.at("/query/operands/0/operation").asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 327 | |
| 328 | assertEquals(false, res.at("/query/operands/0/inOrder").isMissingNode()); |
| 329 | assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean()); |
| 330 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 331 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key") |
| 332 | .asText()); |
| 333 | assertEquals("Mond", res.at("/query/operands/0/operands/1/wrap/key") |
| 334 | .asText()); |
| 335 | assertEquals("koral:token", res.at("/query/operands/1/@type").asText()); |
| 336 | assertEquals("scheint", res.at("/query/operands/1/wrap/key").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 337 | |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 338 | // Query |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 339 | query = "scheint und (Sonne oder Mond)"; |
| 340 | qs.setQuery(query, "cosmas2"); |
| 341 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 342 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 343 | |
| 344 | assertEquals(false, res.at("/query/inOrder").isMissingNode()); |
| 345 | assertEquals(false, res.at("/query/inOrder").asBoolean()); |
| 346 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 347 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 348 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 349 | .asText()); |
| 350 | assertEquals("t", res.at("/query/distances/0/key").asText()); |
| 351 | assertEquals(0, res.at("/query/distances/0/min").asInt()); |
| 352 | assertEquals(0, res.at("/query/distances/0/max").asInt()); |
| 353 | assertEquals("koral:token", res.at("/query/operands/0/@type").asText()); |
| 354 | assertEquals("scheint", res.at("/query/operands/0/wrap/key").asText()); |
| 355 | assertEquals("koral:group", res.at("/query/operands/1/@type").asText()); |
| 356 | assertEquals("operation:disjunction", |
| 357 | res.at("/query/operands/1/operation").asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 358 | |
| 359 | assertEquals(false, res.at("/query/operands/1/inOrder").isMissingNode()); |
| 360 | assertEquals(false, res.at("/query/operands/1/inOrder").asBoolean()); |
| 361 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 362 | assertEquals("Sonne", res.at("/query/operands/1/operands/0/wrap/key") |
| 363 | .asText()); |
| 364 | assertEquals("Mond", res.at("/query/operands/1/operands/1/wrap/key") |
| 365 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 366 | |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 367 | // Query |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 368 | query = "Regen und scheint und (Sonne oder Mond)"; |
| 369 | qs.setQuery(query, "cosmas2"); |
| 370 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 371 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 372 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 373 | |
| 374 | assertEquals(false, res.at("/query/inOrder").isMissingNode()); |
| 375 | assertEquals(false, res.at("/query/inOrder").asBoolean()); |
| 376 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 377 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 378 | .asText()); |
| 379 | assertEquals("t", res.at("/query/distances/0/key").asText()); |
| 380 | assertEquals(0, res.at("/query/distances/0/min").asInt()); |
| 381 | assertEquals(0, res.at("/query/distances/0/max").asInt()); |
| 382 | assertEquals("koral:token", res.at("/query/operands/0/@type").asText()); |
| 383 | assertEquals("Regen", res.at("/query/operands/0/wrap/key").asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 384 | |
| 385 | assertEquals("koral:group", res.at("/query/operands/1/@type").asText()); |
| 386 | assertEquals("operation:sequence", res |
| 387 | .at("/query/operands/1/operation").asText()); |
| 388 | |
| 389 | assertEquals(false, res.at("/query/operands/1/inOrder").isMissingNode()); |
| 390 | assertEquals(false, res.at("/query/operands/1/inOrder").asBoolean()); |
| 391 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 392 | assertEquals("cosmas:distance", |
| 393 | res.at("/query/operands/1/distances/0/@type").asText()); |
| 394 | assertEquals("t", res.at("/query/operands/1/distances/0/key").asText()); |
| 395 | assertEquals(0, res.at("/query/operands/1/distances/0/min").asInt()); |
| 396 | assertEquals(0, res.at("/query/operands/1/distances/0/max").asInt()); |
| 397 | assertEquals("scheint", res.at("/query/operands/1/operands/0/wrap/key") |
| 398 | .asText()); |
| 399 | assertEquals("koral:group", res |
| 400 | .at("/query/operands/1/operands/1/@type").asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 401 | |
| 402 | assertEquals(false, res.at("/query/operands/1/operands/1/inOrder") |
| 403 | .isMissingNode()); |
| 404 | assertEquals(false, res.at("/query/operands/1/operands/1/inOrder") |
| 405 | .asBoolean()); |
| 406 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 407 | assertEquals("operation:disjunction", |
| 408 | res.at("/query/operands/1/operands/1/operation").asText()); |
| 409 | assertEquals("Sonne", |
| 410 | res.at("/query/operands/1/operands/1/operands/0/wrap/key") |
| 411 | .asText()); |
| 412 | assertEquals("Mond", |
| 413 | res.at("/query/operands/1/operands/1/operands/1/wrap/key") |
| 414 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 415 | } |
| 416 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 417 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 418 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 419 | public void testOPNOT () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 420 | query = "Sonne nicht Mond"; |
| 421 | qs.setQuery(query, "cosmas2"); |
| 422 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 423 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 424 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 425 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 426 | .asText()); |
| 427 | assertEquals("t", res.at("/query/distances/0/key").asText()); |
| 428 | assertEquals(0, res.at("/query/distances/0/min").asInt()); |
| 429 | assertEquals(0, res.at("/query/distances/0/max").asInt()); |
| 430 | assertEquals(true, res.at("/query/distances/0/exclude").asBoolean()); |
| 431 | assertEquals("koral:token", res.at("/query/operands/0/@type").asText()); |
| 432 | assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText()); |
| 433 | assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 434 | |
| 435 | query = "Sonne nicht Mond nicht Sterne"; |
| 436 | qs.setQuery(query, "cosmas2"); |
| 437 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 438 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 439 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 440 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 441 | .asText()); |
| 442 | assertEquals("t", res.at("/query/distances/0/key").asText()); |
| 443 | assertEquals(0, res.at("/query/distances/0/min").asInt()); |
| 444 | assertEquals(0, res.at("/query/distances/0/max").asInt()); |
| 445 | assertEquals(true, res.at("/query/distances/0/exclude").asBoolean()); |
| 446 | assertEquals("koral:token", res.at("/query/operands/0/@type").asText()); |
| 447 | assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText()); |
| 448 | assertEquals("koral:group", res.at("/query/operands/1/@type").asText()); |
| 449 | assertEquals("operation:sequence", res |
| 450 | .at("/query/operands/1/operation").asText()); |
| 451 | assertEquals("cosmas:distance", |
| 452 | res.at("/query/operands/1/distances/0/@type").asText()); |
| 453 | assertEquals("t", res.at("/query/operands/1/distances/0/key").asText()); |
| 454 | assertEquals(0, res.at("/query/operands/1/distances/0/min").asInt()); |
| 455 | assertEquals(0, res.at("/query/operands/1/distances/0/max").asInt()); |
| 456 | assertEquals(true, res.at("/query/operands/1/distances/0/exclude") |
| 457 | .asBoolean()); |
| 458 | assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key") |
| 459 | .asText()); |
| 460 | assertEquals("Sterne", res.at("/query/operands/1/operands/1/wrap/key") |
| 461 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 462 | |
| 463 | query = "(Sonne nicht Mond) nicht Sterne"; |
| 464 | qs.setQuery(query, "cosmas2"); |
| 465 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 466 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 467 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 468 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 469 | .asText()); |
| 470 | assertEquals("t", res.at("/query/distances/0/key").asText()); |
| 471 | assertEquals(0, res.at("/query/distances/0/min").asInt()); |
| 472 | assertEquals(0, res.at("/query/distances/0/max").asInt()); |
| 473 | assertEquals(true, res.at("/query/distances/0/exclude").asBoolean()); |
| 474 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 475 | assertEquals("operation:sequence", res |
| 476 | .at("/query/operands/0/operation").asText()); |
| 477 | assertEquals("cosmas:distance", |
| 478 | res.at("/query/operands/0/distances/0/@type").asText()); |
| 479 | assertEquals("t", res.at("/query/operands/0/distances/0/key").asText()); |
| 480 | assertEquals(0, res.at("/query/operands/0/distances/0/min").asInt()); |
| 481 | assertEquals(0, res.at("/query/operands/0/distances/0/max").asInt()); |
| 482 | assertEquals(true, res.at("/query/operands/0/distances/0/exclude") |
| 483 | .asBoolean()); |
| 484 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key") |
| 485 | .asText()); |
| 486 | assertEquals("Mond", res.at("/query/operands/0/operands/1/wrap/key") |
| 487 | .asText()); |
| 488 | assertEquals("koral:token", res.at("/query/operands/1/@type").asText()); |
| 489 | assertEquals("Sterne", res.at("/query/operands/1/wrap/key").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 490 | } |
| 491 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 492 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 493 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 494 | public void testOPPROX () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 495 | query = "Sonne /+w1:4 Mond"; |
| 496 | qs.setQuery(query, "cosmas2"); |
| 497 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 498 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 499 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 500 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 501 | .asText()); |
| 502 | assertEquals("w", res.at("/query/distances/0/key").asText()); |
| 503 | assertEquals(1, res.at("/query/distances/0/boundary/min").asInt()); |
| 504 | assertEquals(4, res.at("/query/distances/0/boundary/max").asInt()); |
| 505 | assertEquals(true, res.at("/query/inOrder").asBoolean()); |
| 506 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 507 | assertEquals("operation:class", res.at("/query/operands/0/operation") |
| 508 | .asText()); |
| 509 | assertEquals(129, res.at("/query/operands/0/classOut").asInt()); |
| 510 | assertEquals(129, res.at("/query/operands/1/classOut").asInt()); |
| 511 | assertEquals("koral:token", res |
| 512 | .at("/query/operands/0/operands/0/@type").asText()); |
| 513 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key") |
| 514 | .asText()); |
| 515 | assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key") |
| 516 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 517 | |
| 518 | query = "Sonne /+w1:4,s0,p1:3 Mond"; |
| 519 | qs.setQuery(query, "cosmas2"); |
| 520 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 521 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 522 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 523 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 524 | .asText()); |
| 525 | assertEquals("w", res.at("/query/distances/0/key").asText()); |
| 526 | assertEquals(1, res.at("/query/distances/0/boundary/min").asInt()); |
| 527 | assertEquals(4, res.at("/query/distances/0/boundary/max").asInt()); |
| 528 | assertEquals("s", res.at("/query/distances/1/key").asText()); |
| 529 | assertEquals(0, res.at("/query/distances/1/boundary/min").asInt()); |
| 530 | assertEquals("p", res.at("/query/distances/2/key").asText()); |
| 531 | assertEquals(1, res.at("/query/distances/2/boundary/min").asInt()); |
| 532 | assertEquals(3, res.at("/query/distances/2/boundary/max").asInt()); |
| 533 | assertEquals(true, res.at("/query/inOrder").asBoolean()); |
| 534 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 535 | assertEquals("operation:class", res.at("/query/operands/0/operation") |
| 536 | .asText()); |
| 537 | assertEquals(129, res.at("/query/operands/0/classOut").asInt()); |
| 538 | assertEquals(129, res.at("/query/operands/1/classOut").asInt()); |
| 539 | assertEquals("koral:token", res |
| 540 | .at("/query/operands/0/operands/0/@type").asText()); |
| 541 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key") |
| 542 | .asText()); |
| 543 | assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key") |
| 544 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 545 | |
| 546 | query = "Sonne /+w4 Mond"; |
| 547 | qs.setQuery(query, "cosmas2"); |
| 548 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 549 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 550 | .asText()); |
| 551 | assertEquals("w", res.at("/query/distances/0/key").asText()); |
| 552 | assertEquals(0, res.at("/query/distances/0/boundary/min").asInt()); |
| 553 | assertEquals(4, res.at("/query/distances/0/boundary/max").asInt()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 554 | |
| 555 | query = "Sonne /-w4 Mond"; |
| 556 | qs.setQuery(query, "cosmas2"); |
| 557 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 558 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 559 | .asText()); |
| 560 | assertEquals("w", res.at("/query/distances/0/key").asText()); |
| 561 | assertEquals(0, res.at("/query/distances/0/boundary/min").asInt()); |
| 562 | assertEquals(4, res.at("/query/distances/0/boundary/max").asInt()); |
| 563 | assertEquals("Mond", res.at("/query/operands/0/operands/0/wrap/key") |
| 564 | .asText()); |
| 565 | assertEquals("Sonne", res.at("/query/operands/1/operands/0/wrap/key") |
| 566 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 567 | |
| 568 | query = "Sonne /w4 Mond"; |
| 569 | qs.setQuery(query, "cosmas2"); |
| 570 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 571 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 572 | .asText()); |
| 573 | assertEquals("w", res.at("/query/distances/0/key").asText()); |
| 574 | assertEquals(0, res.at("/query/distances/0/boundary/min").asInt()); |
| 575 | assertEquals(4, res.at("/query/distances/0/boundary/max").asInt()); |
| 576 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key") |
| 577 | .asText()); |
| 578 | assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key") |
| 579 | .asText()); |
| 580 | assertEquals(false, res.at("/query/inOrder").asBoolean()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 581 | } |
| 582 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 583 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 584 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 585 | public void testOPPROXNested () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 586 | query = "Sonne /+w1:4 Mond /+w1:7 Sterne"; |
| 587 | qs.setQuery(query, "cosmas2"); |
| 588 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 589 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 590 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 591 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 592 | .asText()); |
| 593 | assertEquals("w", res.at("/query/distances/0/key").asText()); |
| 594 | assertEquals(1, res.at("/query/distances/0/boundary/min").asInt()); |
| 595 | assertEquals(4, res.at("/query/distances/0/boundary/max").asInt()); |
| 596 | assertEquals(true, res.at("/query/inOrder").asBoolean()); |
| 597 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 598 | assertEquals("operation:class", res.at("/query/operands/0/operation") |
| 599 | .asText()); |
| 600 | assertEquals(129, res.at("/query/operands/0/classOut").asInt()); |
| 601 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key") |
| 602 | .asText()); |
| 603 | assertEquals(129, res.at("/query/operands/1/classOut").asInt()); |
| 604 | assertEquals("operation:sequence", |
| 605 | res.at("/query/operands/1/operands/0/operation").asText()); |
| 606 | assertEquals("w", res |
| 607 | .at("/query/operands/1/operands/0/distances/0/key").asText()); |
| 608 | assertEquals(1, |
| 609 | res.at("/query/operands/1/operands/0/distances/0/boundary/min") |
| 610 | .asInt()); |
| 611 | assertEquals(7, |
| 612 | res.at("/query/operands/1/operands/0/distances/0/boundary/max") |
| 613 | .asInt()); |
| 614 | assertEquals(130, |
| 615 | res.at("/query/operands/1/operands/0/operands/0/classOut") |
| 616 | .asInt()); |
| 617 | assertEquals( |
| 618 | "Mond", |
| 619 | res.at("/query/operands/1/operands/0/operands/0/operands/0/wrap/key") |
| 620 | .asText()); |
| 621 | assertEquals(130, |
| 622 | res.at("/query/operands/1/operands/0/operands/1/classOut") |
| 623 | .asInt()); |
| 624 | assertEquals( |
| 625 | "Sterne", |
| 626 | res.at("/query/operands/1/operands/0/operands/1/operands/0/wrap/key") |
| 627 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 628 | |
| 629 | query = "Sonne /+w1:4 Mond /-w1:7 Sterne"; |
| 630 | qs.setQuery(query, "cosmas2"); |
| 631 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 632 | assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key") |
| 633 | .asText()); |
| 634 | assertEquals( |
| 635 | "Sterne", |
| 636 | res.at("/query/operands/1/operands/0/operands/0/operands/0/wrap/key") |
| 637 | .asText()); |
| 638 | assertEquals( |
| 639 | "Mond", |
| 640 | res.at("/query/operands/1/operands/0/operands/1/operands/0/wrap/key") |
| 641 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 642 | |
| 643 | query = "Sonne /-w4 Mond /+w2 Sterne"; |
| 644 | qs.setQuery(query, "cosmas2"); |
| 645 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 646 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 647 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 648 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 649 | .asText()); |
| 650 | assertEquals("w", res.at("/query/distances/0/key").asText()); |
| 651 | assertEquals(0, res.at("/query/distances/0/boundary/min").asInt()); |
| 652 | assertEquals(4, res.at("/query/distances/0/boundary/max").asInt()); |
| 653 | assertEquals(true, res.at("/query/inOrder").asBoolean()); |
| 654 | assertEquals("koral:group", res.at("/query/operands/1/@type").asText()); |
| 655 | assertEquals("operation:class", res.at("/query/operands/1/operation") |
| 656 | .asText()); |
| 657 | assertEquals(129, res.at("/query/operands/1/classOut").asInt()); |
| 658 | assertEquals("Sonne", res.at("/query/operands/1/operands/0/wrap/key") |
| 659 | .asText()); |
| 660 | assertEquals(129, res.at("/query/operands/0/classOut").asInt()); |
| 661 | assertEquals("operation:sequence", |
| 662 | res.at("/query/operands/0/operands/0/operation").asText()); |
| 663 | assertEquals("w", res |
| 664 | .at("/query/operands/0/operands/0/distances/0/key").asText()); |
| 665 | assertEquals(0, |
| 666 | res.at("/query/operands/0/operands/0/distances/0/boundary/min") |
| 667 | .asInt()); |
| 668 | assertEquals(2, |
| 669 | res.at("/query/operands/0/operands/0/distances/0/boundary/max") |
| 670 | .asInt()); |
| 671 | assertEquals(130, |
| 672 | res.at("/query/operands/0/operands/0/operands/0/classOut") |
| 673 | .asInt()); |
| 674 | assertEquals( |
| 675 | "Mond", |
| 676 | res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key") |
| 677 | .asText()); |
| 678 | assertEquals(130, |
| 679 | res.at("/query/operands/0/operands/0/operands/1/classOut") |
| 680 | .asInt()); |
| 681 | assertEquals( |
| 682 | "Sterne", |
| 683 | res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key") |
| 684 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 685 | |
| 686 | } |
| 687 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 688 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 689 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 690 | public void testOPIN () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 691 | query = "wegen #IN <s>"; |
| 692 | qs.setQuery(query, "cosmas2"); |
| 693 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 694 | assertEquals("koral:reference", res.at("/query/@type").asText()); |
| 695 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 696 | assertEquals(130, res.at("/query/classRef/0").asInt()); |
| 697 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 698 | assertEquals("operation:class", res.at("/query/operands/0/operation") |
| 699 | .asText()); |
| 700 | assertEquals("classRefCheck:includes", |
| 701 | res.at("/query/operands/0/classRefCheck/0").asText()); |
| 702 | assertEquals("koral:group", res |
| 703 | .at("/query/operands/0/operands/0/@type").asText()); |
| 704 | assertEquals("operation:position", |
| 705 | res.at("/query/operands/0/operands/0/operation").asText()); |
| 706 | assertEquals(true, res.at("/query/operands/0/operands/0/frames/0") |
| 707 | .isMissingNode()); |
| 708 | assertEquals(129, res.at("/query/operands/0/classIn/0").asInt()); |
| 709 | assertEquals(130, res.at("/query/operands/0/classIn/1").asInt()); |
| 710 | assertEquals(131, res.at("/query/operands/0/classOut").asInt()); |
| 711 | assertEquals("koral:group", res |
| 712 | .at("/query/operands/0/operands/0/@type").asText()); |
| 713 | assertEquals("operation:class", |
| 714 | res.at("/query/operands/0/operands/0/operands/0/operation") |
| 715 | .asText()); |
| 716 | assertEquals(129, |
| 717 | res.at("/query/operands/0/operands/0/operands/0/classOut") |
| 718 | .asInt()); |
| 719 | assertEquals( |
| 720 | "koral:span", |
| 721 | res.at("/query/operands/0/operands/0/operands/0/operands/0/@type") |
| 722 | .asText()); |
| 723 | assertEquals( |
| 724 | "s", |
| Akron | 79cd736 | 2016-06-03 17:05:05 +0200 | [diff] [blame] | 725 | res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key") |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 726 | .asText()); |
| 727 | assertEquals("koral:group", |
| 728 | res.at("/query/operands/0/operands/0/operands/1/@type") |
| 729 | .asText()); |
| 730 | assertEquals("operation:class", |
| 731 | res.at("/query/operands/0/operands/0/operands/1/operation") |
| 732 | .asText()); |
| 733 | assertEquals(130, |
| 734 | res.at("/query/operands/0/operands/0/operands/1/classOut") |
| 735 | .asInt()); |
| 736 | assertEquals( |
| 737 | "koral:token", |
| 738 | res.at("/query/operands/0/operands/0/operands/1/operands/0/@type") |
| 739 | .asText()); |
| 740 | assertEquals( |
| 741 | "wegen", |
| 742 | res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key") |
| 743 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 744 | |
| 745 | query = "wegen #IN(L) <s>"; |
| 746 | qs.setQuery(query, "cosmas2"); |
| 747 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 748 | assertEquals("koral:reference", res.at("/query/@type").asText()); |
| 749 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 750 | assertEquals(130, res.at("/query/classRef/0").asInt()); |
| 751 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 752 | assertEquals("operation:position", res |
| 753 | .at("/query/operands/0/operation").asText()); |
| 754 | assertEquals("frames:startsWith", res.at("/query/operands/0/frames/0") |
| 755 | .asText()); |
| 756 | assertEquals("frames:matches", res.at("/query/operands/0/frames/1") |
| 757 | .asText()); |
| 758 | assertEquals(true, res.at("/query/operands/0/frames/2").isMissingNode()); |
| 759 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 760 | assertEquals("operation:class", |
| 761 | res.at("/query/operands/0/operands/0/operation").asText()); |
| 762 | assertEquals(129, res.at("/query/operands/0/operands/0/classOut") |
| 763 | .asInt()); |
| 764 | assertEquals("koral:span", |
| 765 | res.at("/query/operands/0/operands/0/operands/0/@type") |
| 766 | .asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 767 | assertEquals("s", |
| 768 | res.at("/query/operands/0/operands/0/operands/0/wrap/key") |
| 769 | .asText()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 770 | assertEquals("koral:group", res |
| 771 | .at("/query/operands/0/operands/1/@type").asText()); |
| 772 | assertEquals("operation:class", |
| 773 | res.at("/query/operands/0/operands/1/operation").asText()); |
| 774 | assertEquals(130, res.at("/query/operands/0/operands/1/classOut") |
| 775 | .asInt()); |
| 776 | assertEquals("koral:token", |
| 777 | res.at("/query/operands/0/operands/1/operands/0/@type") |
| 778 | .asText()); |
| 779 | assertEquals("wegen", |
| 780 | res.at("/query/operands/0/operands/1/operands/0/wrap/key") |
| 781 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 782 | |
| 783 | query = "wegen #IN(F) <s>"; |
| 784 | qs.setQuery(query, "cosmas2"); |
| 785 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 786 | assertEquals(true, res.at("/query/operands/0/classRefCheck") |
| 787 | .isMissingNode()); |
| 788 | assertEquals("frames:matches", res.at("/query/operands/0/frames/0") |
| 789 | .asText()); |
| 790 | assertEquals(true, res.at("/query/operands/0/frames/1").isMissingNode()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 791 | |
| 792 | query = "wegen #IN(FI) <s>"; |
| 793 | qs.setQuery(query, "cosmas2"); |
| 794 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 795 | assertEquals("classRefCheck:unequals", |
| 796 | res.at("/query/operands/0/classRefCheck/0").asText()); |
| 797 | assertEquals("frames:matches", |
| 798 | res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 799 | assertEquals(true, res.at("/query/operands/0/operands/0/frames/1") |
| 800 | .isMissingNode()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 801 | |
| 802 | query = "wegen #IN(FE) <s>"; |
| 803 | qs.setQuery(query, "cosmas2"); |
| 804 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 805 | assertEquals("classRefCheck:equals", |
| 806 | res.at("/query/operands/0/classRefCheck/0").asText()); |
| 807 | assertEquals("frames:matches", |
| 808 | res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 809 | assertEquals(true, res.at("/query/operands/0/operands/0/frames/1") |
| 810 | .isMissingNode()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 811 | |
| 812 | query = "wegen #IN(%, L) <s>"; |
| 813 | qs.setQuery(query, "cosmas2"); |
| 814 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 815 | assertEquals("frames:startsWith", res.at("/query/operands/0/frames/0") |
| 816 | .asText()); |
| 817 | assertEquals("frames:matches", res.at("/query/operands/0/frames/1") |
| 818 | .asText()); |
| Joachim Bingel | 1d79104 | 2015-02-03 10:19:47 +0000 | [diff] [blame] | 819 | // assertEquals(true, res.at("/query/operands/0/operands/0/exclude").isMissingNode()); |
| 820 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 821 | query = "wegen #IN(FE,%,MIN) <s>"; |
| 822 | qs.setQuery(query, "cosmas2"); |
| 823 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 824 | assertEquals("classRefCheck:equals", |
| 825 | res.at("/query/operands/0/classRefCheck/0").asText()); |
| 826 | assertEquals("frames:matches", |
| 827 | res.at("/query/operands/0/operands/0/frames/0").asText()); |
| Joachim Bingel | 1d79104 | 2015-02-03 10:19:47 +0000 | [diff] [blame] | 828 | // assertEquals(true, res.at("/query/operands/0/operands/0/exclude").isMissingNode()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 829 | |
| 830 | query = "wegen #IN(FE,ALL,%,MIN) <s>"; |
| 831 | qs.setQuery(query, "cosmas2"); |
| 832 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 833 | assertEquals("operation:class", res.at("/query/operation").asText()); |
| 834 | assertEquals("classRefOp:delete", res.at("/query/classRefOp").asText()); |
| 835 | assertEquals(131, res.at("/query/classIn/0").asInt()); |
| 836 | assertEquals("classRefCheck:equals", |
| 837 | res.at("/query/operands/0/classRefCheck/0").asText()); |
| 838 | assertEquals("frames:matches", |
| 839 | res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 840 | assertEquals(true, res.at("/query/operands/0/operands/0/exclude") |
| 841 | .asBoolean()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 842 | |
| 843 | query = "wegen #IN(FE,ALL,%,MAX) <s>"; |
| 844 | qs.setQuery(query, "cosmas2"); |
| 845 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 846 | assertEquals("operation:merge", res.at("/query/operation").asText()); |
| 847 | assertEquals("operation:class", res.at("/query/operands/0/operation") |
| 848 | .asText()); |
| 849 | assertEquals("classRefOp:delete", res |
| 850 | .at("/query/operands/0/classRefOp").asText()); |
| 851 | assertEquals(131, res.at("/query/operands/0/classIn/0").asInt()); |
| 852 | assertEquals("classRefCheck:equals", |
| 853 | res.at("/query/operands/0/operands/0/classRefCheck/0").asText()); |
| 854 | assertEquals("frames:matches", |
| 855 | res.at("/query/operands/0/operands/0/operands/0/frames/0") |
| 856 | .asText()); |
| 857 | assertEquals(true, |
| 858 | res.at("/query/operands/0/operands/0/operands/0/exclude") |
| 859 | .asBoolean()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 860 | } |
| 861 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 862 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 863 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 864 | public void testOPOV () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 865 | query = "wegen #OV <s>"; |
| 866 | qs.setQuery(query, "cosmas2"); |
| 867 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 868 | assertEquals("koral:reference", res.at("/query/@type").asText()); |
| 869 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 870 | assertEquals(130, res.at("/query/classRef/0").asInt()); |
| 871 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 872 | assertEquals("operation:class", res.at("/query/operands/0/operation") |
| 873 | .asText()); |
| 874 | assertEquals("classRefCheck:intersects", |
| 875 | res.at("/query/operands/0/classRefCheck/0").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 876 | // assertEquals("classRefOp:merge", res.at("/query/operands/0/classRefOp").asText()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 877 | assertEquals(131, res.at("/query/operands/0/classOut").asInt()); |
| 878 | assertEquals(129, res.at("/query/operands/0/classIn/0").asInt()); |
| 879 | assertEquals(130, res.at("/query/operands/0/classIn/1").asInt()); |
| 880 | assertEquals("koral:group", res |
| 881 | .at("/query/operands/0/operands/0/@type").asText()); |
| 882 | assertEquals("operation:position", |
| 883 | res.at("/query/operands/0/operands/0/operation").asText()); |
| 884 | assertEquals(true, res.at("/query/operands/0/operands/0/frames/0") |
| 885 | .isMissingNode()); |
| 886 | assertEquals("koral:group", res |
| 887 | .at("/query/operands/0/operands/0/@type").asText()); |
| 888 | assertEquals("operation:class", |
| 889 | res.at("/query/operands/0/operands/0/operands/0/operation") |
| 890 | .asText()); |
| 891 | assertEquals(129, |
| 892 | res.at("/query/operands/0/operands/0/operands/0/classOut") |
| 893 | .asInt()); |
| 894 | assertEquals( |
| 895 | "koral:span", |
| 896 | res.at("/query/operands/0/operands/0/operands/0/operands/0/@type") |
| 897 | .asText()); |
| 898 | assertEquals( |
| 899 | "s", |
| Akron | 79cd736 | 2016-06-03 17:05:05 +0200 | [diff] [blame] | 900 | res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key") |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 901 | .asText()); |
| 902 | assertEquals("koral:group", |
| 903 | res.at("/query/operands/0/operands/0/operands/1/@type") |
| 904 | .asText()); |
| 905 | assertEquals("operation:class", |
| 906 | res.at("/query/operands/0/operands/0/operands/1/operation") |
| 907 | .asText()); |
| 908 | assertEquals(130, |
| 909 | res.at("/query/operands/0/operands/0/operands/1/classOut") |
| 910 | .asInt()); |
| 911 | assertEquals( |
| 912 | "koral:token", |
| 913 | res.at("/query/operands/0/operands/0/operands/1/operands/0/@type") |
| 914 | .asText()); |
| 915 | assertEquals( |
| 916 | "wegen", |
| 917 | res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key") |
| 918 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 919 | |
| 920 | query = "wegen #OV(L) <s>"; |
| 921 | qs.setQuery(query, "cosmas2"); |
| 922 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 923 | assertEquals("classRefCheck:intersects", |
| 924 | res.at("/query/operands/0/classRefCheck/0").asText()); |
| 925 | assertEquals("frames:startsWith", |
| 926 | res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 927 | assertEquals("frames:overlapsLeft", |
| 928 | res.at("/query/operands/0/operands/0/frames/1").asText()); |
| 929 | assertEquals("frames:matches", |
| 930 | res.at("/query/operands/0/operands/0/frames/2").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 931 | |
| 932 | query = "wegen #OV(F) <s>"; |
| 933 | qs.setQuery(query, "cosmas2"); |
| 934 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 935 | assertEquals("classRefCheck:intersects", |
| 936 | res.at("/query/operands/0/classRefCheck/0").asText()); |
| 937 | assertEquals("frames:matches", |
| 938 | res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 939 | assertEquals(true, res.at("/query/operands/0/operands/0/frames/1") |
| 940 | .isMissingNode()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 941 | |
| 942 | query = "wegen #OV(FI) <s>"; |
| 943 | qs.setQuery(query, "cosmas2"); |
| 944 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 945 | assertEquals("classRefCheck:unequals", |
| 946 | res.at("/query/operands/0/classRefCheck/0").asText()); |
| 947 | assertEquals("frames:matches", |
| 948 | res.at("/query/operands/0/operands/0/frames/0").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 949 | |
| 950 | query = "wegen #OV(FE) <s>"; |
| 951 | qs.setQuery(query, "cosmas2"); |
| 952 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 953 | assertEquals("classRefCheck:equals", |
| 954 | res.at("/query/operands/0/classRefCheck/0").asText()); |
| 955 | assertEquals("frames:matches", |
| 956 | res.at("/query/operands/0/operands/0/frames/0").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 957 | } |
| 958 | |
| 959 | |
| 960 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 961 | public void testBEG_END () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 962 | query = "#BEG(der /w3:5 Mann)"; |
| 963 | qs.setQuery(query, "cosmas2"); |
| 964 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 965 | assertEquals("koral:reference", res.at("/query/@type").asText()); |
| 966 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 967 | assertEquals(0, res.at("/query/spanRef/0").asInt()); |
| 968 | assertEquals(1, res.at("/query/spanRef/1").asInt()); |
| 969 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 970 | assertEquals("operation:sequence", res |
| 971 | .at("/query/operands/0/operation").asText()); |
| 972 | assertEquals("cosmas:distance", |
| 973 | res.at("/query/operands/0/distances/0/@type").asText()); |
| 974 | assertEquals("w", res.at("/query/operands/0/distances/0/key").asText()); |
| 975 | assertEquals(3, res.at("/query/operands/0/distances/0/boundary/min") |
| 976 | .asInt()); |
| 977 | assertEquals(5, res.at("/query/operands/0/distances/0/boundary/max") |
| 978 | .asInt()); |
| 979 | assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean()); |
| 980 | assertEquals("koral:token", res |
| 981 | .at("/query/operands/0/operands/0/@type").asText()); |
| 982 | assertEquals("der", res.at("/query/operands/0/operands/0/wrap/key") |
| 983 | .asText()); |
| 984 | assertEquals("Mann", res.at("/query/operands/0/operands/1/wrap/key") |
| 985 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 986 | |
| 987 | query = "#BEG(der /w3:5 Mann) /+w10 kommt"; |
| 988 | qs.setQuery(query, "cosmas2"); |
| 989 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 990 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 991 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 992 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 993 | .asText()); |
| 994 | assertEquals("w", res.at("/query/distances/0/key").asText()); |
| 995 | assertEquals(0, res.at("/query/distances/0/boundary/min").asInt()); |
| 996 | assertEquals(10, res.at("/query/distances/0/boundary/max").asInt()); |
| 997 | assertEquals(true, res.at("/query/inOrder").asBoolean()); |
| 998 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 999 | assertEquals("operation:class", res.at("/query/operands/0/operation") |
| 1000 | .asText()); |
| 1001 | assertEquals(129, res.at("/query/operands/0/classOut").asInt()); |
| 1002 | assertEquals("koral:reference", |
| 1003 | res.at("/query/operands/0/operands/0/@type").asText()); |
| 1004 | assertEquals("operation:focus", |
| 1005 | res.at("/query/operands/0/operands/0/operation").asText()); |
| 1006 | assertEquals(0, res.at("/query/operands/0/operands/0/spanRef/0") |
| 1007 | .asInt()); |
| 1008 | assertEquals(1, res.at("/query/operands/0/operands/0/spanRef/1") |
| 1009 | .asInt()); |
| 1010 | assertEquals("koral:group", |
| 1011 | res.at("/query/operands/0/operands/0/operands/0/@type") |
| 1012 | .asText()); |
| 1013 | assertEquals("operation:sequence", |
| 1014 | res.at("/query/operands/0/operands/0/operands/0/operation") |
| 1015 | .asText()); |
| 1016 | assertEquals( |
| 1017 | "cosmas:distance", |
| 1018 | res.at("/query/operands/0/operands/0/operands/0/distances/0/@type") |
| 1019 | .asText()); |
| 1020 | assertEquals( |
| 1021 | "w", |
| 1022 | res.at("/query/operands/0/operands/0/operands/0/distances/0/key") |
| 1023 | .asText()); |
| 1024 | assertEquals( |
| 1025 | 3, |
| 1026 | res.at("/query/operands/0/operands/0/operands/0/distances/0/boundary/min") |
| 1027 | .asInt()); |
| 1028 | assertEquals( |
| 1029 | 5, |
| 1030 | res.at("/query/operands/0/operands/0/operands/0/distances/0/boundary/max") |
| 1031 | .asInt()); |
| 1032 | assertEquals(false, |
| 1033 | res.at("/query/operands/0/operands/0/operands/0/inOrder") |
| 1034 | .asBoolean()); |
| 1035 | assertEquals( |
| 1036 | "koral:token", |
| 1037 | res.at("/query/operands/0/operands/0/operands/0/operands/0/@type") |
| 1038 | .asText()); |
| 1039 | assertEquals( |
| 1040 | "der", |
| 1041 | res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key") |
| 1042 | .asText()); |
| 1043 | assertEquals( |
| 1044 | "Mann", |
| 1045 | res.at("/query/operands/0/operands/0/operands/0/operands/1/wrap/key") |
| 1046 | .asText()); |
| 1047 | assertEquals("operation:class", res.at("/query/operands/1/operation") |
| 1048 | .asText()); |
| 1049 | assertEquals(129, res.at("/query/operands/1/classOut").asInt()); |
| 1050 | assertEquals("koral:token", res |
| 1051 | .at("/query/operands/1/operands/0/@type").asText()); |
| 1052 | assertEquals("kommt", res.at("/query/operands/1/operands/0/wrap/key") |
| 1053 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1054 | |
| 1055 | query = "kommt /+w10 #BEG(der /w3:5 Mann)"; |
| 1056 | qs.setQuery(query, "cosmas2"); |
| 1057 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1058 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 1059 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 1060 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 1061 | .asText()); |
| 1062 | assertEquals("w", res.at("/query/distances/0/key").asText()); |
| 1063 | assertEquals(0, res.at("/query/distances/0/boundary/min").asInt()); |
| 1064 | assertEquals(10, res.at("/query/distances/0/boundary/max").asInt()); |
| 1065 | assertEquals(true, res.at("/query/inOrder").asBoolean()); |
| 1066 | assertEquals("koral:group", res.at("/query/operands/1/@type").asText()); |
| 1067 | assertEquals("operation:class", res.at("/query/operands/1/operation") |
| 1068 | .asText()); |
| 1069 | assertEquals(129, res.at("/query/operands/1/classOut").asInt()); |
| 1070 | assertEquals("koral:reference", |
| 1071 | res.at("/query/operands/1/operands/0/@type").asText()); |
| 1072 | assertEquals("operation:focus", |
| 1073 | res.at("/query/operands/1/operands/0/operation").asText()); |
| 1074 | assertEquals(0, res.at("/query/operands/1/operands/0/spanRef/0") |
| 1075 | .asInt()); |
| 1076 | assertEquals(1, res.at("/query/operands/1/operands/0/spanRef/1") |
| 1077 | .asInt()); |
| 1078 | assertEquals("koral:group", |
| 1079 | res.at("/query/operands/1/operands/0/operands/0/@type") |
| 1080 | .asText()); |
| 1081 | assertEquals("operation:sequence", |
| 1082 | res.at("/query/operands/1/operands/0/operands/0/operation") |
| 1083 | .asText()); |
| 1084 | assertEquals( |
| 1085 | "cosmas:distance", |
| 1086 | res.at("/query/operands/1/operands/0/operands/0/distances/0/@type") |
| 1087 | .asText()); |
| 1088 | assertEquals( |
| 1089 | "w", |
| 1090 | res.at("/query/operands/1/operands/0/operands/0/distances/0/key") |
| 1091 | .asText()); |
| 1092 | assertEquals( |
| 1093 | 3, |
| 1094 | res.at("/query/operands/1/operands/0/operands/0/distances/0/boundary/min") |
| 1095 | .asInt()); |
| 1096 | assertEquals( |
| 1097 | 5, |
| 1098 | res.at("/query/operands/1/operands/0/operands/0/distances/0/boundary/max") |
| 1099 | .asInt()); |
| 1100 | assertEquals(false, |
| 1101 | res.at("/query/operands/1/operands/0/operands/0/inOrder") |
| 1102 | .asBoolean()); |
| 1103 | assertEquals( |
| 1104 | "koral:token", |
| 1105 | res.at("/query/operands/1/operands/0/operands/0/operands/0/@type") |
| 1106 | .asText()); |
| 1107 | assertEquals( |
| 1108 | "der", |
| 1109 | res.at("/query/operands/1/operands/0/operands/0/operands/0/wrap/key") |
| 1110 | .asText()); |
| 1111 | assertEquals( |
| 1112 | "Mann", |
| 1113 | res.at("/query/operands/1/operands/0/operands/0/operands/1/wrap/key") |
| 1114 | .asText()); |
| 1115 | assertEquals("operation:class", res.at("/query/operands/0/operation") |
| 1116 | .asText()); |
| 1117 | assertEquals(129, res.at("/query/operands/0/classOut").asInt()); |
| 1118 | assertEquals("koral:token", res |
| 1119 | .at("/query/operands/0/operands/0/@type").asText()); |
| 1120 | assertEquals("kommt", res.at("/query/operands/0/operands/0/wrap/key") |
| 1121 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1122 | |
| 1123 | query = "#END(der /w3:5 Mann)"; |
| 1124 | qs.setQuery(query, "cosmas2"); |
| 1125 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1126 | assertEquals("koral:reference", res.at("/query/@type").asText()); |
| 1127 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 1128 | assertEquals(-1, res.at("/query/spanRef/0").asInt()); |
| 1129 | assertEquals(1, res.at("/query/spanRef/1").asInt()); |
| 1130 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 1131 | assertEquals("operation:sequence", res |
| 1132 | .at("/query/operands/0/operation").asText()); |
| 1133 | assertEquals("cosmas:distance", |
| 1134 | res.at("/query/operands/0/distances/0/@type").asText()); |
| 1135 | assertEquals("w", res.at("/query/operands/0/distances/0/key").asText()); |
| 1136 | assertEquals(3, res.at("/query/operands/0/distances/0/boundary/min") |
| 1137 | .asInt()); |
| 1138 | assertEquals(5, res.at("/query/operands/0/distances/0/boundary/max") |
| 1139 | .asInt()); |
| 1140 | assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean()); |
| 1141 | assertEquals("koral:token", res |
| 1142 | .at("/query/operands/0/operands/0/@type").asText()); |
| 1143 | assertEquals("der", res.at("/query/operands/0/operands/0/wrap/key") |
| 1144 | .asText()); |
| 1145 | assertEquals("Mann", res.at("/query/operands/0/operands/1/wrap/key") |
| 1146 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1147 | } |
| 1148 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1149 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1150 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1151 | public void testELEM () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1152 | query = "#ELEM(S)"; |
| 1153 | qs.setQuery(query, "cosmas2"); |
| 1154 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1155 | assertEquals("koral:span", res.at("/query/@type").asText()); |
| 1156 | assertEquals("s", res.at("/query/key").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1157 | |
| 1158 | query = "#ELEM(W ANA=N)"; |
| 1159 | qs.setQuery(query, "cosmas2"); |
| 1160 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1161 | assertEquals("koral:span", res.at("/query/@type").asText()); |
| 1162 | assertEquals("w", res.at("/query/key").asText()); |
| 1163 | assertEquals("koral:term", res.at("/query/attr/@type").asText()); |
| 1164 | assertEquals("N", res.at("/query/attr/key").asText()); |
| 1165 | assertEquals("p", res.at("/query/attr/layer").asText()); |
| 1166 | assertEquals("match:eq", res.at("/query/attr/match").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1167 | |
| 1168 | query = "#ELEM(W ANA != 'N V')"; |
| 1169 | qs.setQuery(query, "cosmas2"); |
| 1170 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1171 | assertEquals("koral:span", res.at("/query/@type").asText()); |
| 1172 | assertEquals("w", res.at("/query/key").asText()); |
| 1173 | assertEquals("koral:termGroup", res.at("/query/attr/@type").asText()); |
| 1174 | assertEquals("relation:and", res.at("/query/attr/relation").asText()); |
| 1175 | assertEquals("koral:term", res.at("/query/attr/operands/0/@type") |
| 1176 | .asText()); |
| 1177 | assertEquals("N", res.at("/query/attr/operands/0/key").asText()); |
| 1178 | assertEquals("p", res.at("/query/attr/operands/0/layer").asText()); |
| 1179 | assertEquals("match:ne", res.at("/query/attr/operands/0/match") |
| 1180 | .asText()); |
| 1181 | assertEquals("koral:term", res.at("/query/attr/operands/1/@type") |
| 1182 | .asText()); |
| 1183 | assertEquals("V", res.at("/query/attr/operands/1/key").asText()); |
| 1184 | assertEquals("p", res.at("/query/attr/operands/1/layer").asText()); |
| 1185 | assertEquals("match:ne", res.at("/query/attr/operands/1/match") |
| 1186 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1187 | |
| 1188 | query = "#ELEM(W ANA != 'N A V' Genre = Sport)"; |
| 1189 | qs.setQuery(query, "cosmas2"); |
| 1190 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1191 | assertEquals("koral:span", res.at("/query/@type").asText()); |
| 1192 | assertEquals("w", res.at("/query/key").asText()); |
| 1193 | assertEquals("koral:termGroup", res.at("/query/attr/@type").asText()); |
| 1194 | assertEquals("relation:and", res.at("/query/attr/relation").asText()); |
| 1195 | assertEquals("koral:termGroup", res.at("/query/attr/operands/0/@type") |
| 1196 | .asText()); |
| 1197 | assertEquals("relation:and", res.at("/query/attr/operands/0/relation") |
| 1198 | .asText()); |
| 1199 | assertEquals("N", res.at("/query/attr/operands/0/operands/0/key") |
| 1200 | .asText()); |
| 1201 | assertEquals("A", res.at("/query/attr/operands/0/operands/1/key") |
| 1202 | .asText()); |
| 1203 | assertEquals("V", res.at("/query/attr/operands/0/operands/2/key") |
| 1204 | .asText()); |
| 1205 | assertEquals("Genre", res.at("/query/attr/operands/1/layer").asText()); |
| 1206 | assertEquals("Sport", res.at("/query/attr/operands/1/key").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1207 | |
| 1208 | query = "#ELEM(W ANA != 'N A V' Genre != 'Sport Politik')"; |
| 1209 | qs.setQuery(query, "cosmas2"); |
| 1210 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1211 | assertEquals("koral:span", res.at("/query/@type").asText()); |
| 1212 | assertEquals("w", res.at("/query/key").asText()); |
| 1213 | assertEquals("koral:termGroup", res.at("/query/attr/@type").asText()); |
| 1214 | assertEquals("relation:and", res.at("/query/attr/relation").asText()); |
| 1215 | assertEquals("koral:termGroup", res.at("/query/attr/operands/0/@type") |
| 1216 | .asText()); |
| 1217 | assertEquals("relation:and", res.at("/query/attr/operands/0/relation") |
| 1218 | .asText()); |
| 1219 | assertEquals("koral:termGroup", res.at("/query/attr/operands/1/@type") |
| 1220 | .asText()); |
| 1221 | assertEquals("relation:and", res.at("/query/attr/operands/1/relation") |
| 1222 | .asText()); |
| 1223 | assertEquals("N", res.at("/query/attr/operands/0/operands/0/key") |
| 1224 | .asText()); |
| 1225 | assertEquals("A", res.at("/query/attr/operands/0/operands/1/key") |
| 1226 | .asText()); |
| 1227 | assertEquals("V", res.at("/query/attr/operands/0/operands/2/key") |
| 1228 | .asText()); |
| 1229 | assertEquals("match:ne", |
| 1230 | res.at("/query/attr/operands/0/operands/2/match").asText()); |
| 1231 | assertEquals("Genre", res.at("/query/attr/operands/1/operands/0/layer") |
| 1232 | .asText()); |
| 1233 | assertEquals("Sport", res.at("/query/attr/operands/1/operands/0/key") |
| 1234 | .asText()); |
| 1235 | assertEquals("Genre", res.at("/query/attr/operands/1/operands/1/layer") |
| 1236 | .asText()); |
| 1237 | assertEquals("Politik", res.at("/query/attr/operands/1/operands/1/key") |
| 1238 | .asText()); |
| 1239 | assertEquals("match:ne", |
| 1240 | res.at("/query/attr/operands/1/operands/1/match").asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1241 | } |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1242 | |
| 1243 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1244 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1245 | public void testOPALL () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1246 | query = "#ALL(gehen /w1:10 voran)"; |
| 1247 | qs.setQuery(query, "cosmas2"); |
| 1248 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1249 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 1250 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 1251 | assertEquals("gehen", res.at("/query/operands/0/wrap/key").asText()); |
| 1252 | assertEquals("voran", res.at("/query/operands/1/wrap/key").asText()); |
| 1253 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 1254 | .asText()); |
| 1255 | assertEquals("w", res.at("/query/distances/0/key").asText()); |
| 1256 | assertEquals(1, res.at("/query/distances/0/boundary/min").asInt()); |
| 1257 | assertEquals(10, res.at("/query/distances/0/boundary/max").asInt()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1258 | |
| 1259 | query = "#ALL(gehen /w1:10 (voran /w1:4 schnell))"; |
| 1260 | qs.setQuery(query, "cosmas2"); |
| 1261 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1262 | assertEquals("koral:group", res.at("/query/@type").asText()); |
| 1263 | assertEquals("operation:sequence", res.at("/query/operation").asText()); |
| 1264 | assertEquals("cosmas:distance", res.at("/query/distances/0/@type") |
| 1265 | .asText()); |
| 1266 | assertEquals("w", res.at("/query/distances/0/key").asText()); |
| 1267 | assertEquals(1, res.at("/query/distances/0/boundary/min").asInt()); |
| 1268 | assertEquals(10, res.at("/query/distances/0/boundary/max").asInt()); |
| 1269 | assertEquals("gehen", res.at("/query/operands/0/wrap/key").asText()); |
| 1270 | assertEquals("koral:group", res.at("/query/operands/1/@type").asText()); |
| 1271 | assertEquals("operation:sequence", res |
| 1272 | .at("/query/operands/1/operation").asText()); |
| 1273 | assertEquals("cosmas:distance", |
| 1274 | res.at("/query/operands/1/distances/0/@type").asText()); |
| 1275 | assertEquals("w", res.at("/query/operands/1/distances/0/key").asText()); |
| 1276 | assertEquals(1, res.at("/query/operands/1/distances/0/boundary/min") |
| 1277 | .asInt()); |
| 1278 | assertEquals(4, res.at("/query/operands/1/distances/0/boundary/max") |
| 1279 | .asInt()); |
| 1280 | assertEquals("voran", res.at("/query/operands/1/operands/0/wrap/key") |
| 1281 | .asText()); |
| 1282 | assertEquals("schnell", res.at("/query/operands/1/operands/1/wrap/key") |
| 1283 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1284 | |
| 1285 | |
| 1286 | } |
| 1287 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1288 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1289 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1290 | public void testOPNHIT () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1291 | query = "#NHIT(gehen /w1:10 voran)"; |
| 1292 | qs.setQuery(query, "cosmas2"); |
| 1293 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1294 | assertEquals("koral:reference", res.at("/query/@type").asText()); |
| 1295 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 1296 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 1297 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 1298 | assertEquals("operation:class", res.at("/query/operands/0/operation") |
| 1299 | .asText()); |
| 1300 | assertEquals("classRefOp:inversion", |
| 1301 | res.at("/query/operands/0/classRefOp").asText()); |
| 1302 | assertEquals(130, res.at("/query/operands/0/classIn/0").asInt()); |
| 1303 | assertEquals(131, res.at("/query/operands/0/classIn/1").asInt()); |
| 1304 | assertEquals(129, res.at("/query/operands/0/classOut").asInt()); |
| 1305 | assertEquals("koral:group", res |
| 1306 | .at("/query/operands/0/operands/0/@type").asText()); |
| 1307 | assertEquals("operation:sequence", |
| 1308 | res.at("/query/operands/0/operands/0/operation").asText()); |
| 1309 | assertEquals("cosmas:distance", |
| 1310 | res.at("/query/operands/0/operands/0/distances/0/@type") |
| 1311 | .asText()); |
| 1312 | assertEquals("w", res |
| 1313 | .at("/query/operands/0/operands/0/distances/0/key").asText()); |
| 1314 | assertEquals(1, |
| 1315 | res.at("/query/operands/0/operands/0/distances/0/boundary/min") |
| 1316 | .asInt()); |
| 1317 | assertEquals(10, |
| 1318 | res.at("/query/operands/0/operands/0/distances/0/boundary/max") |
| 1319 | .asInt()); |
| 1320 | assertEquals("koral:group", |
| 1321 | res.at("/query/operands/0/operands/0/operands/0/@type") |
| 1322 | .asText()); |
| 1323 | assertEquals("operation:class", |
| 1324 | res.at("/query/operands/0/operands/0/operands/0/operation") |
| 1325 | .asText()); |
| 1326 | assertEquals(130, |
| 1327 | res.at("/query/operands/0/operands/0/operands/0/classOut") |
| 1328 | .asInt()); |
| 1329 | assertEquals(131, |
| 1330 | res.at("/query/operands/0/operands/0/operands/1/classOut") |
| 1331 | .asInt()); |
| 1332 | assertEquals( |
| 1333 | "koral:token", |
| 1334 | res.at("/query/operands/0/operands/0/operands/0/operands/0/@type") |
| 1335 | .asText()); |
| 1336 | assertEquals( |
| 1337 | "gehen", |
| 1338 | res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key") |
| 1339 | .asText()); |
| 1340 | assertEquals( |
| 1341 | "voran", |
| 1342 | res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key") |
| 1343 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1344 | |
| 1345 | query = "#NHIT(gehen /w1:10 voran /w1:10 Beispiel)"; |
| 1346 | qs.setQuery(query, "cosmas2"); |
| 1347 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1348 | assertEquals("koral:reference", res.at("/query/@type").asText()); |
| 1349 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 1350 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 1351 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 1352 | assertEquals("operation:class", res.at("/query/operands/0/operation") |
| 1353 | .asText()); |
| 1354 | assertEquals("classRefOp:inversion", |
| 1355 | res.at("/query/operands/0/classRefOp").asText()); |
| 1356 | assertEquals(130, res.at("/query/operands/0/classIn/0").asInt()); |
| 1357 | assertEquals(131, res.at("/query/operands/0/classIn/1").asInt()); |
| 1358 | assertEquals(129, res.at("/query/operands/0/classOut").asInt()); |
| 1359 | assertEquals("koral:group", res |
| 1360 | .at("/query/operands/0/operands/0/@type").asText()); |
| 1361 | assertEquals("operation:sequence", |
| 1362 | res.at("/query/operands/0/operands/0/operation").asText()); |
| 1363 | assertEquals("cosmas:distance", |
| 1364 | res.at("/query/operands/0/operands/0/distances/0/@type") |
| 1365 | .asText()); |
| 1366 | assertEquals("w", res |
| 1367 | .at("/query/operands/0/operands/0/distances/0/key").asText()); |
| 1368 | assertEquals(1, |
| 1369 | res.at("/query/operands/0/operands/0/distances/0/boundary/min") |
| 1370 | .asInt()); |
| 1371 | assertEquals(10, |
| 1372 | res.at("/query/operands/0/operands/0/distances/0/boundary/max") |
| 1373 | .asInt()); |
| 1374 | assertEquals("koral:group", |
| 1375 | res.at("/query/operands/0/operands/0/operands/0/@type") |
| 1376 | .asText()); |
| 1377 | assertEquals("operation:class", |
| 1378 | res.at("/query/operands/0/operands/0/operands/0/operation") |
| 1379 | .asText()); |
| 1380 | assertEquals(130, |
| 1381 | res.at("/query/operands/0/operands/0/operands/0/classOut") |
| 1382 | .asInt()); |
| 1383 | assertEquals( |
| 1384 | "gehen", |
| 1385 | res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key") |
| 1386 | .asText()); |
| 1387 | assertEquals(131, |
| 1388 | res.at("/query/operands/0/operands/0/operands/1/classOut") |
| 1389 | .asInt()); |
| Joachim Bingel | 1d79104 | 2015-02-03 10:19:47 +0000 | [diff] [blame] | 1390 | // assertEquals("classRefOp:merge", res.at("/query/operands/0/operands/0/operands/1/classRefOp").asText()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1391 | assertEquals( |
| 1392 | "operation:sequence", |
| 1393 | res.at("/query/operands/0/operands/0/operands/1/operands/0/operation") |
| 1394 | .asText()); |
| 1395 | assertEquals( |
| 1396 | 132, |
| 1397 | res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/classOut") |
| 1398 | .asInt()); |
| 1399 | assertEquals( |
| 1400 | "voran", |
| 1401 | res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/0/wrap/key") |
| 1402 | .asText()); |
| 1403 | assertEquals( |
| 1404 | 132, |
| 1405 | res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/1/classOut") |
| 1406 | .asInt()); |
| 1407 | assertEquals( |
| 1408 | "Beispiel", |
| 1409 | res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/1/operands/0/wrap/key") |
| 1410 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1411 | |
| 1412 | } |
| 1413 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1414 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1415 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1416 | public void testOPBED () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1417 | query = "#BED(der , sa)"; |
| 1418 | qs.setQuery(query, "cosmas2"); |
| 1419 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1420 | assertEquals("koral:reference", res.at("/query/@type").asText()); |
| 1421 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 1422 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 1423 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 1424 | assertEquals("operation:position", res |
| 1425 | .at("/query/operands/0/operation").asText()); |
| 1426 | assertEquals("frames:startsWith", res.at("/query/operands/0/frames/0") |
| 1427 | .asText()); |
| 1428 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 1429 | assertEquals("operation:class", |
| 1430 | res.at("/query/operands/0/operands/1/operation").asText()); |
| 1431 | assertEquals(129, res.at("/query/operands/0/operands/1/classOut") |
| 1432 | .asInt()); |
| 1433 | assertEquals("koral:token", |
| 1434 | res.at("/query/operands/0/operands/1/operands/0/@type") |
| 1435 | .asText()); |
| 1436 | assertEquals("der", |
| 1437 | res.at("/query/operands/0/operands/1/operands/0/wrap/key") |
| 1438 | .asText()); |
| 1439 | assertEquals("koral:span", res.at("/query/operands/0/operands/0/@type") |
| 1440 | .asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 1441 | assertEquals("s", res.at("/query/operands/0/operands/0/wrap/key") |
| 1442 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1443 | |
| 1444 | query = "#BED(der Mann , +pe)"; |
| 1445 | qs.setQuery(query, "cosmas2"); |
| 1446 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1447 | assertEquals("koral:reference", res.at("/query/@type").asText()); |
| 1448 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 1449 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 1450 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 1451 | assertEquals("operation:position", res |
| 1452 | .at("/query/operands/0/operation").asText()); |
| 1453 | assertEquals("frames:matches", res.at("/query/operands/0/frames/0") |
| 1454 | .asText()); |
| 1455 | assertEquals("koral:reference", |
| 1456 | res.at("/query/operands/0/operands/0/@type").asText()); |
| 1457 | assertEquals("operation:focus", |
| 1458 | res.at("/query/operands/0/operands/0/operation").asText()); |
| 1459 | assertEquals(-1, res.at("/query/operands/0/operands/0/spanRef/0") |
| 1460 | .asInt()); |
| 1461 | assertEquals(1, res.at("/query/operands/0/operands/0/spanRef/1") |
| 1462 | .asInt()); |
| 1463 | assertEquals("koral:span", |
| 1464 | res.at("/query/operands/0/operands/0/operands/0/@type") |
| 1465 | .asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 1466 | assertEquals("p", |
| 1467 | res.at("/query/operands/0/operands/0/operands/0/wrap/key") |
| 1468 | .asText()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1469 | assertEquals("koral:reference", |
| 1470 | res.at("/query/operands/0/operands/1/@type").asText()); |
| 1471 | assertEquals("operation:focus", |
| 1472 | res.at("/query/operands/0/operands/1/operation").asText()); |
| 1473 | assertEquals(0, res.at("/query/operands/0/operands/1/spanRef/0") |
| 1474 | .asInt()); |
| 1475 | assertEquals(1, res.at("/query/operands/0/operands/1/spanRef/1") |
| 1476 | .asInt()); |
| 1477 | assertEquals("koral:group", |
| 1478 | res.at("/query/operands/0/operands/1/operands/0/@type") |
| 1479 | .asText()); |
| 1480 | assertEquals("operation:class", |
| 1481 | res.at("/query/operands/0/operands/1/operands/0/operation") |
| 1482 | .asText()); |
| 1483 | assertEquals(129, |
| 1484 | res.at("/query/operands/0/operands/1/operands/0/classOut") |
| 1485 | .asInt()); |
| 1486 | assertEquals( |
| 1487 | "operation:sequence", |
| 1488 | res.at("/query/operands/0/operands/1/operands/0/operands/0/operation") |
| 1489 | .asText()); |
| 1490 | assertEquals( |
| 1491 | "der", |
| 1492 | res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/wrap/key") |
| 1493 | .asText()); |
| 1494 | assertEquals( |
| 1495 | "Mann", |
| 1496 | res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/wrap/key") |
| 1497 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1498 | |
| 1499 | query = "#BED(der Mann , sa,-pa)"; |
| 1500 | qs.setQuery(query, "cosmas2"); |
| 1501 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1502 | assertEquals("koral:reference", res.at("/query/@type").asText()); |
| 1503 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 1504 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 1505 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 1506 | assertEquals("operation:position", res |
| 1507 | .at("/query/operands/0/operation").asText()); |
| 1508 | assertEquals("frames:matches", res.at("/query/operands/0/frames/0") |
| 1509 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1510 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1511 | assertEquals("koral:group", res |
| 1512 | .at("/query/operands/0/operands/0/@type").asText()); |
| 1513 | assertEquals("operation:position", |
| 1514 | res.at("/query/operands/0/operands/0/operation").asText()); |
| 1515 | assertEquals("frames:startsWith", |
| 1516 | res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 1517 | assertEquals("koral:span", |
| 1518 | res.at("/query/operands/0/operands/0/operands/0/@type") |
| 1519 | .asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 1520 | assertEquals("s", |
| 1521 | res.at("/query/operands/0/operands/0/operands/0/wrap/key") |
| 1522 | .asText()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1523 | assertEquals("koral:group", |
| 1524 | res.at("/query/operands/0/operands/0/operands/1/@type") |
| 1525 | .asText()); |
| 1526 | assertEquals("operation:class", |
| 1527 | res.at("/query/operands/0/operands/0/operands/1/operation") |
| 1528 | .asText()); |
| 1529 | assertEquals(129, |
| 1530 | res.at("/query/operands/0/operands/0/operands/1/classOut") |
| 1531 | .asInt()); |
| 1532 | assertEquals( |
| 1533 | "operation:sequence", |
| 1534 | res.at("/query/operands/0/operands/0/operands/1/operands/0/operation") |
| 1535 | .asText()); |
| 1536 | assertEquals( |
| 1537 | "der", |
| 1538 | res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/wrap/key") |
| 1539 | .asText()); |
| 1540 | assertEquals( |
| 1541 | "Mann", |
| 1542 | res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/1/wrap/key") |
| 1543 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1544 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1545 | assertEquals("koral:group", res |
| 1546 | .at("/query/operands/0/operands/1/@type").asText()); |
| 1547 | assertEquals("operation:position", |
| 1548 | res.at("/query/operands/0/operands/1/operation").asText()); |
| 1549 | assertEquals("frames:startsWith", |
| 1550 | res.at("/query/operands/0/operands/1/frames/0").asText()); |
| 1551 | assertEquals(true, res.at("/query/operands/0/operands/1/exclude") |
| 1552 | .asBoolean()); |
| 1553 | assertEquals("koral:span", |
| 1554 | res.at("/query/operands/0/operands/1/operands/0/@type") |
| 1555 | .asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 1556 | assertEquals("p", |
| 1557 | res.at("/query/operands/0/operands/1/operands/0/wrap/key") |
| 1558 | .asText()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1559 | assertEquals("koral:group", |
| 1560 | res.at("/query/operands/0/operands/1/operands/1/@type") |
| 1561 | .asText()); |
| 1562 | assertEquals("operation:class", |
| 1563 | res.at("/query/operands/0/operands/1/operands/1/operation") |
| 1564 | .asText()); |
| 1565 | assertEquals(130, |
| 1566 | res.at("/query/operands/0/operands/1/operands/1/classOut") |
| 1567 | .asInt()); |
| 1568 | assertEquals( |
| 1569 | "operation:sequence", |
| 1570 | res.at("/query/operands/0/operands/1/operands/1/operands/0/operation") |
| 1571 | .asText()); |
| 1572 | assertEquals( |
| 1573 | "der", |
| 1574 | res.at("/query/operands/0/operands/1/operands/1/operands/0/operands/0/wrap/key") |
| 1575 | .asText()); |
| 1576 | assertEquals( |
| 1577 | "Mann", |
| 1578 | res.at("/query/operands/0/operands/1/operands/1/operands/0/operands/1/wrap/key") |
| 1579 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1580 | |
| 1581 | } |
| 1582 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1583 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1584 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1585 | public void testColonSeparatedConditions () throws JsonProcessingException, |
| 1586 | IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1587 | query = "der:sa"; |
| 1588 | qs.setQuery(query, "cosmas2"); |
| 1589 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1590 | assertEquals("koral:reference", res.at("/query/@type").asText()); |
| 1591 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 1592 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 1593 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 1594 | assertEquals("operation:position", res |
| 1595 | .at("/query/operands/0/operation").asText()); |
| 1596 | assertEquals("frames:startsWith", res.at("/query/operands/0/frames/0") |
| 1597 | .asText()); |
| 1598 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 1599 | assertEquals("operation:class", |
| 1600 | res.at("/query/operands/0/operands/1/operation").asText()); |
| 1601 | assertEquals(129, res.at("/query/operands/0/operands/1/classOut") |
| 1602 | .asInt()); |
| 1603 | assertEquals("koral:token", |
| 1604 | res.at("/query/operands/0/operands/1/operands/0/@type") |
| 1605 | .asText()); |
| 1606 | assertEquals("der", |
| 1607 | res.at("/query/operands/0/operands/1/operands/0/wrap/key") |
| 1608 | .asText()); |
| 1609 | assertEquals("koral:span", res.at("/query/operands/0/operands/0/@type") |
| 1610 | .asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 1611 | assertEquals("s", res.at("/query/operands/0/operands/0/wrap/key") |
| 1612 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1613 | |
| 1614 | query = "der:sa,-pa"; |
| 1615 | qs.setQuery(query, "cosmas2"); |
| 1616 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1617 | assertEquals("koral:reference", res.at("/query/@type").asText()); |
| 1618 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 1619 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 1620 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 1621 | assertEquals("operation:position", res |
| 1622 | .at("/query/operands/0/operation").asText()); |
| 1623 | assertEquals("frames:matches", res.at("/query/operands/0/frames/0") |
| 1624 | .asText()); |
| 1625 | assertEquals("koral:group", res |
| 1626 | .at("/query/operands/0/operands/0/@type").asText()); |
| 1627 | assertEquals("operation:position", |
| 1628 | res.at("/query/operands/0/operands/0/operation").asText()); |
| 1629 | assertEquals("frames:startsWith", |
| 1630 | res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 1631 | assertEquals("koral:span", |
| 1632 | res.at("/query/operands/0/operands/0/operands/0/@type") |
| 1633 | .asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 1634 | assertEquals("s", |
| 1635 | res.at("/query/operands/0/operands/0/operands/0/wrap/key") |
| 1636 | .asText()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1637 | assertEquals("koral:group", |
| 1638 | res.at("/query/operands/0/operands/0/operands/1/@type") |
| 1639 | .asText()); |
| 1640 | assertEquals("operation:class", |
| 1641 | res.at("/query/operands/0/operands/0/operands/1/operation") |
| 1642 | .asText()); |
| 1643 | assertEquals(129, |
| 1644 | res.at("/query/operands/0/operands/0/operands/1/classOut") |
| 1645 | .asInt()); |
| 1646 | assertEquals( |
| 1647 | "der", |
| 1648 | res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key") |
| 1649 | .asText()); |
| 1650 | assertEquals("koral:group", res |
| 1651 | .at("/query/operands/0/operands/1/@type").asText()); |
| 1652 | assertEquals("operation:position", |
| 1653 | res.at("/query/operands/0/operands/1/operation").asText()); |
| 1654 | assertEquals("frames:startsWith", |
| 1655 | res.at("/query/operands/0/operands/1/frames/0").asText()); |
| 1656 | assertEquals(true, res.at("/query/operands/0/operands/1/exclude") |
| 1657 | .asBoolean()); |
| 1658 | assertEquals("koral:span", |
| 1659 | res.at("/query/operands/0/operands/1/operands/0/@type") |
| 1660 | .asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 1661 | assertEquals("p", |
| 1662 | res.at("/query/operands/0/operands/1/operands/0/wrap/key") |
| 1663 | .asText()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1664 | assertEquals("koral:group", |
| 1665 | res.at("/query/operands/0/operands/1/operands/1/@type") |
| 1666 | .asText()); |
| 1667 | assertEquals("operation:class", |
| 1668 | res.at("/query/operands/0/operands/1/operands/1/operation") |
| 1669 | .asText()); |
| 1670 | assertEquals(130, |
| 1671 | res.at("/query/operands/0/operands/1/operands/1/classOut") |
| 1672 | .asInt()); |
| 1673 | assertEquals( |
| 1674 | "der", |
| 1675 | res.at("/query/operands/0/operands/1/operands/1/operands/0/wrap/key") |
| 1676 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1677 | |
| 1678 | query = "der:sa,-pa,+te"; |
| 1679 | qs.setQuery(query, "cosmas2"); |
| 1680 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1681 | assertEquals("koral:reference", res.at("/query/@type").asText()); |
| 1682 | assertEquals("operation:focus", res.at("/query/operation").asText()); |
| 1683 | assertEquals(129, res.at("/query/classRef/0").asInt()); |
| 1684 | assertEquals("koral:group", res.at("/query/operands/0/@type").asText()); |
| 1685 | assertEquals("operation:position", res |
| 1686 | .at("/query/operands/0/operation").asText()); |
| 1687 | assertEquals("frames:matches", res.at("/query/operands/0/frames/0") |
| 1688 | .asText()); |
| 1689 | assertEquals("koral:group", res |
| 1690 | .at("/query/operands/0/operands/0/@type").asText()); |
| 1691 | assertEquals("operation:position", |
| 1692 | res.at("/query/operands/0/operands/0/operation").asText()); |
| 1693 | assertEquals("frames:startsWith", |
| 1694 | res.at("/query/operands/0/operands/0/frames/0").asText()); |
| 1695 | assertEquals("koral:span", |
| 1696 | res.at("/query/operands/0/operands/0/operands/0/@type") |
| 1697 | .asText()); |
| Akron | 3ac85c9 | 2016-06-06 16:14:40 +0200 | [diff] [blame] | 1698 | assertEquals("s", |
| 1699 | res.at("/query/operands/0/operands/0/operands/0/wrap/key") |
| 1700 | .asText()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1701 | assertEquals("koral:group", |
| 1702 | res.at("/query/operands/0/operands/0/operands/1/@type") |
| 1703 | .asText()); |
| 1704 | assertEquals("operation:class", |
| 1705 | res.at("/query/operands/0/operands/0/operands/1/operation") |
| 1706 | .asText()); |
| 1707 | assertEquals(129, |
| 1708 | res.at("/query/operands/0/operands/0/operands/1/classOut") |
| 1709 | .asInt()); |
| 1710 | assertEquals( |
| 1711 | "der", |
| 1712 | res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key") |
| 1713 | .asText()); |
| 1714 | assertEquals("koral:reference", |
| 1715 | res.at("/query/operands/0/operands/1/@type").asText()); |
| 1716 | assertEquals("operation:focus", |
| 1717 | res.at("/query/operands/0/operands/1/operation").asText()); |
| 1718 | assertEquals(130, res.at("/query/operands/0/operands/1/classRef/0") |
| 1719 | .asInt()); |
| 1720 | assertEquals("koral:group", |
| 1721 | res.at("/query/operands/0/operands/1/operands/0/@type") |
| 1722 | .asText()); |
| 1723 | assertEquals("operation:position", |
| 1724 | res.at("/query/operands/0/operands/1/operands/0/operation") |
| 1725 | .asText()); |
| 1726 | assertEquals("frames:matches", |
| 1727 | res.at("/query/operands/0/operands/1/operands/0/frames/0") |
| 1728 | .asText()); |
| 1729 | assertEquals( |
| 1730 | "koral:group", |
| 1731 | res.at("/query/operands/0/operands/1/operands/0/operands/0/@type") |
| 1732 | .asText()); |
| 1733 | assertEquals( |
| 1734 | "operation:position", |
| 1735 | res.at("/query/operands/0/operands/1/operands/0/operands/0/operation") |
| 1736 | .asText()); |
| 1737 | assertEquals( |
| 1738 | "frames:startsWith", |
| 1739 | res.at("/query/operands/0/operands/1/operands/0/operands/0/frames/0") |
| 1740 | .asText()); |
| 1741 | assertEquals( |
| 1742 | true, |
| 1743 | res.at("/query/operands/0/operands/1/operands/0/operands/0/exclude") |
| 1744 | .asBoolean()); |
| 1745 | assertEquals( |
| 1746 | "koral:span", |
| 1747 | res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/@type") |
| 1748 | .asText()); |
| 1749 | assertEquals( |
| 1750 | "p", |
| Akron | 79cd736 | 2016-06-03 17:05:05 +0200 | [diff] [blame] | 1751 | res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/wrap/key") |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1752 | .asText()); |
| 1753 | assertEquals( |
| 1754 | "koral:group", |
| 1755 | res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/@type") |
| 1756 | .asText()); |
| 1757 | assertEquals( |
| 1758 | "operation:class", |
| 1759 | res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operation") |
| 1760 | .asText()); |
| 1761 | assertEquals( |
| 1762 | 130, |
| 1763 | res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/classOut") |
| 1764 | .asInt()); |
| 1765 | assertEquals( |
| 1766 | "der", |
| 1767 | res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key") |
| 1768 | .asText()); |
| 1769 | assertEquals( |
| 1770 | "koral:group", |
| 1771 | res.at("/query/operands/0/operands/1/operands/0/operands/1/@type") |
| 1772 | .asText()); |
| 1773 | assertEquals( |
| 1774 | "operation:position", |
| 1775 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operation") |
| 1776 | .asText()); |
| 1777 | assertEquals( |
| 1778 | "frames:matches", |
| 1779 | res.at("/query/operands/0/operands/1/operands/0/operands/1/frames/0") |
| 1780 | .asText()); |
| 1781 | assertEquals( |
| 1782 | "koral:reference", |
| 1783 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/@type") |
| 1784 | .asText()); |
| 1785 | assertEquals( |
| 1786 | "operation:focus", |
| 1787 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/operation") |
| 1788 | .asText()); |
| 1789 | assertEquals( |
| 1790 | -1, |
| 1791 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/spanRef/0") |
| 1792 | .asInt()); |
| 1793 | assertEquals( |
| 1794 | 1, |
| 1795 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/spanRef/1") |
| 1796 | .asInt()); |
| 1797 | assertEquals( |
| 1798 | "koral:span", |
| 1799 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/operands/0/@type") |
| 1800 | .asText()); |
| 1801 | assertEquals( |
| 1802 | "t", |
| Akron | 79cd736 | 2016-06-03 17:05:05 +0200 | [diff] [blame] | 1803 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/operands/0/wrap/key") |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1804 | .asText()); |
| 1805 | assertEquals( |
| 1806 | "koral:reference", |
| 1807 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/@type") |
| 1808 | .asText()); |
| 1809 | assertEquals( |
| 1810 | "operation:focus", |
| 1811 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operation") |
| 1812 | .asText()); |
| 1813 | assertEquals( |
| 1814 | 0, |
| 1815 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/spanRef/0") |
| 1816 | .asInt()); |
| 1817 | assertEquals( |
| 1818 | 1, |
| 1819 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/spanRef/1") |
| 1820 | .asInt()); |
| 1821 | assertEquals( |
| 1822 | "koral:group", |
| 1823 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/@type") |
| 1824 | .asText()); |
| 1825 | assertEquals( |
| 1826 | "operation:class", |
| 1827 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/operation") |
| 1828 | .asText()); |
| 1829 | assertEquals( |
| 1830 | 131, |
| 1831 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/classOut") |
| 1832 | .asInt()); |
| 1833 | assertEquals( |
| 1834 | "der", |
| 1835 | res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/operands/0/wrap/key") |
| 1836 | .asText()); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1837 | } |
| 1838 | |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1839 | |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1840 | @Test |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1841 | public void testErrors () throws JsonProcessingException, IOException { |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1842 | query = "MORPH(tt/p=\"\")"; |
| 1843 | qs.setQuery(query, "cosmas2"); |
| 1844 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1845 | assertEquals(true, res.at("/query/@type").isMissingNode()); |
| 1846 | assertEquals(StatusCodes.INCOMPATIBLE_OPERATOR_AND_OPERAND, |
| 1847 | res.at("/errors/0/0").asInt()); |
| 1848 | assertTrue(res |
| 1849 | .at("/errors/0/1") |
| 1850 | .asText() |
| 1851 | .startsWith( |
| 1852 | "Something went wrong parsing the argument in MORPH()")); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1853 | |
| 1854 | query = "MORPH(tt/p=\"foo)"; |
| 1855 | qs.setQuery(query, "cosmas2"); |
| 1856 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1857 | assertEquals(true, res.at("/query/@type").isMissingNode()); |
| 1858 | assertEquals(StatusCodes.MALFORMED_QUERY, res.at("/errors/0/0").asInt()); |
| 1859 | assertTrue(res.at("/errors/0/1").asText() |
| 1860 | .startsWith("Early closing parenthesis")); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1861 | |
| 1862 | query = "MORPH(tt/p=)"; |
| 1863 | qs.setQuery(query, "cosmas2"); |
| 1864 | res = mapper.readTree(qs.toJSON()); |
| Joachim Bingel | a6954de | 2015-03-20 16:37:37 +0100 | [diff] [blame] | 1865 | assertEquals(true, res.at("/query/@type").isMissingNode()); |
| 1866 | assertEquals(StatusCodes.MALFORMED_QUERY, res.at("/errors/0/0").asInt()); |
| 1867 | assertTrue(res.at("/errors/0/1").asText() |
| 1868 | .startsWith("Early closing parenthesis")); |
| Joachim Bingel | f05490a | 2015-01-23 11:43:52 +0000 | [diff] [blame] | 1869 | } |
| Joachim Bingel | 1c6c755 | 2015-02-05 17:55:31 +0100 | [diff] [blame] | 1870 | } |