Skip to content

Commit

Permalink
opBED: some tests around #BED(Haus,sa) added.
Browse files Browse the repository at this point in the history
Change-Id: I159d252a25b6b2e526cea4d0d2d834258848d9b9
  • Loading branch information
Bodmo committed Nov 8, 2023
1 parent 44769cc commit d80a258
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/main/antlr/cosmas/c2ps.g
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// v0.8 - 06.11.23/FB
// - accepts #BED(searchword, sa) : comma attached to searchword.
// - more generally: comma at end of searchword, which is not enclosed by "..." is
// excluded from searchword.
// excluded from searchword now.
// - a comma inside a searchword is accepted if enclosed by "...".
//
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import org.junit.Test;

import com.fasterxml.jackson.core.JsonPointer;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -1197,7 +1198,9 @@ public void testOPNHIT () throws JsonProcessingException, IOException {

}


/* some tests added - 08.11.23/FB
*/

@Test
public void testOPBED () throws JsonProcessingException, IOException {
query = "#BED(der , sa)";
Expand Down Expand Up @@ -1227,6 +1230,95 @@ public void testOPBED () throws JsonProcessingException, IOException {
assertEquals("s", res.at("/query/operands/0/operands/0/wrap/key")
.asText());

// 08.11.23/FB
// treats now "der," as "der" + ",":
query = "#BED(der, sa)";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(129, res.at("/query/classRef/0").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:position", res
.at("/query/operands/0/operation").asText());
assertEquals("frames:startsWith", res.at("/query/operands/0/frames/0")
.asText());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/1/operation").asText());
assertEquals(129, res.at("/query/operands/0/operands/1/classOut")
.asInt());
assertEquals("koral:token",
res.at("/query/operands/0/operands/1/operands/0/@type")
.asText());
assertEquals("der",
res.at("/query/operands/0/operands/1/operands/0/wrap/key")
.asText());
assertEquals("koral:span", res.at("/query/operands/0/operands/0/@type")
.asText());
assertEquals("s", res.at("/query/operands/0/operands/0/wrap/key")
.asText());


// 08.11.23/FB
// treats now "der,sa" as "der" + "," + "sa":
query = "#BED(der,sa)";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(129, res.at("/query/classRef/0").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:position", res
.at("/query/operands/0/operation").asText());
assertEquals("frames:startsWith", res.at("/query/operands/0/frames/0")
.asText());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/1/operation").asText());
assertEquals(129, res.at("/query/operands/0/operands/1/classOut")
.asInt());
assertEquals("koral:token",
res.at("/query/operands/0/operands/1/operands/0/@type")
.asText());
assertEquals("der",
res.at("/query/operands/0/operands/1/operands/0/wrap/key")
.asText());
assertEquals("koral:span", res.at("/query/operands/0/operands/0/@type")
.asText());
assertEquals("s", res.at("/query/operands/0/operands/0/wrap/key")
.asText());

// 08.11.23/FB
// treats now "der,s0," as "der,s0" unchanged while written inside "...":
query = "#BED(\"der,so\", sa)";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());

assertEquals("koral:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(129, res.at("/query/classRef/0").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:position", res
.at("/query/operands/0/operation").asText());
assertEquals("frames:startsWith", res.at("/query/operands/0/frames/0")
.asText());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/1/operation").asText());
assertEquals(129, res.at("/query/operands/0/operands/1/classOut")
.asInt());
assertEquals("koral:token",
res.at("/query/operands/0/operands/1/operands/0/@type")
.asText());
assertEquals("der,so",
res.at("/query/operands/0/operands/1/operands/0/wrap/key")
.asText());
assertEquals("koral:span", res.at("/query/operands/0/operands/0/@type")
.asText());
assertEquals("s", res.at("/query/operands/0/operands/0/wrap/key")
.asText());

query = "#COND(der , sa)";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
Expand Down Expand Up @@ -1926,27 +2018,6 @@ public void testREGremoveBlanksAtBothSides () {
assertEquals("abc",sb.toString());
}

/* Testing #BED(expr,sa).
* 06.11.23/FB
*/

@Test
public void testBED () throws JsonProcessingException, IOException {

boolean
debug = true;
String
query = "#BED(Haus , se)";

qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
if( debug )
System.out.printf("testBED: query: >>%s<< -> key: >>%s<<.\n", query, res.at("/query/operands/0").asText());
/*
assertEquals("\"Abend\"-Ticket",res.at("/query/wrap/key").asText()); // key must be escaped, because converted to in "...".
assertEquals("type:regex", res.at("/query/wrap/type").asText());
assertEquals("orth", res.at("/query/wrap/layer").asText());
*/
}


}

0 comments on commit d80a258

Please sign in to comment.