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