Fixed FCSQL tests.
Change-Id: If275d89653cffbe6d6f0f4e56581566ca0fc0f93
diff --git a/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/ExpressionParser.java b/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/ExpressionParser.java
index 4c1e340..1c42d5e 100644
--- a/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/ExpressionParser.java
+++ b/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/ExpressionParser.java
@@ -6,14 +6,12 @@
import java.util.List;
import java.util.Set;
-import org.omg.CosNaming.IstringHelper;
-
import de.ids_mannheim.korap.query.object.KoralMatchOperator;
import de.ids_mannheim.korap.query.object.KoralObject;
-import de.ids_mannheim.korap.query.object.KoralTermGroupRelation;
import de.ids_mannheim.korap.query.object.KoralTerm;
import de.ids_mannheim.korap.query.object.KoralTerm.KoralTermType;
import de.ids_mannheim.korap.query.object.KoralTermGroup;
+import de.ids_mannheim.korap.query.object.KoralTermGroupRelation;
import de.ids_mannheim.korap.query.object.KoralToken;
import de.ids_mannheim.korap.query.serialize.util.KoralException;
import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLComplexTest.java b/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLComplexTest.java
index 7417644..35305c1 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLComplexTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLComplexTest.java
@@ -41,8 +41,8 @@
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
// group and disjunction
- query = "([pos=\"NN\"]|[cnx:pos=\"N\"]|[text=\"Mann\"])";
- jsonLd = "{@type:koral:token,wrap:{@type:koral:term,key:N,foundry:cnx,layer:p,type:type:regex,match:match:eq}}";
+ query = "([pos=\"NN\"]|[corenlp:pos=\"N\"]|[text=\"Mann\"])";
+ jsonLd = "{@type:koral:token,wrap:{@type:koral:term,key:N,foundry:corenlp,layer:p,type:type:regex,match:match:eq}}";
FCSQLQueryProcessorTest
.validateNode(query, "/query/operands/1", jsonLd);
@@ -111,31 +111,31 @@
.validateNode(query, "/query/operands/1", jsonLd);
// sequence and disjunction
- query = "([pos=\"NN\"]|[cnx:pos=\"N\"])[text=\"Mann\"]";
+ query = "([pos=\"NN\"]|[corenlp:pos=\"N\"])[text=\"Mann\"]";
jsonLd = "{@type:koral:group,"
+ "operation:operation:sequence,"
+ "operands:["
+ "{@type:koral:group,"
+ "operation:operation:disjunction,"
+ "operands:[{@type:koral:token,wrap:{@type:koral:term,key:NN,foundry:tt,layer:p,type:type:regex,match:match:eq}},"
- + "{@type:koral:token,wrap:{@type:koral:term,key:N,foundry:cnx,layer:p,type:type:regex,match:match:eq}}"
+ + "{@type:koral:token,wrap:{@type:koral:term,key:N,foundry:corenlp,layer:p,type:type:regex,match:match:eq}}"
+ "]},"
+ "{@type:koral:token,wrap:{@type:koral:term,key:Mann,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}"
+ "]}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
- query = "[text=\"Mann\"]([pos=\"NN\"]|[cnx:pos=\"N\"])";
+ query = "[text=\"Mann\"]([pos=\"NN\"]|[corenlp:pos=\"N\"])";
jsonLd = "{@type:koral:group,"
+ "operation:operation:disjunction,"
+ "operands:[{@type:koral:token,wrap:{@type:koral:term,key:NN,foundry:tt,layer:p,type:type:regex,match:match:eq}},"
- + "{@type:koral:token,wrap:{@type:koral:term,key:N,foundry:cnx,layer:p,type:type:regex,match:match:eq}}"
+ + "{@type:koral:token,wrap:{@type:koral:term,key:N,foundry:corenlp,layer:p,type:type:regex,match:match:eq}}"
+ "]}";
FCSQLQueryProcessorTest.validateNode(query, "/query/operands/1", jsonLd);
}
@Test
public void testSequenceOfQueryGroups() throws IOException {
- query = "(\"blaue\"|\"grüne\")([pos=\"NN\"]|[cnx:pos=\"N\"])";
+ query = "(\"blaue\"|\"grüne\")([pos=\"NN\"]|[corenlp:pos=\"N\"])";
FCSQLQueryProcessorTest.validateNode(query, "/query/@type",
"koral:group");
FCSQLQueryProcessorTest.validateNode(query, "/query/operation",
@@ -153,7 +153,7 @@
jsonLd = "{@type:koral:group,operation:operation:disjunction,"
+ "operands:["
+ "{@type:koral:token,wrap:{@type:koral:term,key:NN,foundry:tt,layer:p,type:type:regex,match:match:eq}},"
- + "{@type:koral:token,wrap:{@type:koral:term,key:N,foundry:cnx,layer:p,type:type:regex,match:match:eq}}"
+ + "{@type:koral:token,wrap:{@type:koral:term,key:N,foundry:corenlp,layer:p,type:type:regex,match:match:eq}}"
+ "]}";
FCSQLQueryProcessorTest
.validateNode(query, "/query/operands/1", jsonLd);
@@ -200,10 +200,10 @@
FCSQLQueryProcessorTest.validateNode(query, "/query/boundary", jsonLd);
// segment query with quantifier
- query = "[cnx:pos=\"A\"]*";
+ query = "[corenlp:pos=\"A\"]*";
jsonLd = "{@type:koral:group,"
+ "operation:operation:repetition,"
- + "operands:[{@type:koral:token,wrap:{@type:koral:term,key:A,foundry:cnx,layer:p,type:type:regex,match:match:eq}}],"
+ + "operands:[{@type:koral:token,wrap:{@type:koral:term,key:A,foundry:corenlp,layer:p,type:type:regex,match:match:eq}}],"
+ "boundary:{@type:koral:boundary,min:0}}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
}
@@ -254,9 +254,9 @@
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
// sequence with extension
- query = "[cnx:pos=\"A\"] \"Hund\"[]{2}";
+ query = "[corenlp:pos=\"A\"] \"Hund\"[]{2}";
jsonLd = "["
- + "{@type:koral:token,wrap:{@type:koral:term,key:A,foundry:cnx,layer:p,type:type:regex,match:match:eq}},"
+ + "{@type:koral:token,wrap:{@type:koral:term,key:A,foundry:corenlp,layer:p,type:type:regex,match:match:eq}},"
+ "{@type:koral:token,wrap:{@type:koral:term,key:Hund,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}},"
+ "{@type:koral:group,operation:operation:repetition,operands:["
+ "{@type:koral:token}],boundary:{@type:koral:boundary,min:2,max:2}}"
@@ -320,7 +320,7 @@
jsonLd);
// multiple occurrences of wildcards
- query = "\"Katze\" []{3} \"Hund\" []{1,2} [cnx:pos=\"V\"]";
+ query = "\"Katze\" []{3} \"Hund\" []{1,2} [corenlp:pos=\"V\"]";
jsonLd = "{@type:koral:group,"
+ "operation:operation:sequence,"
+ "inOrder:true,"
@@ -337,7 +337,7 @@
+ "],"
+ "operands:["
+ "{@type:koral:token,wrap:{@type:koral:term,key:Hund,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}},"
- + "{@type:koral:token,wrap:{@type:koral:term,key:V,foundry:cnx,layer:p,type:type:regex,match:match:eq}}]}"
+ + "{@type:koral:token,wrap:{@type:koral:term,key:V,foundry:corenlp,layer:p,type:type:regex,match:match:eq}}]}"
+ "]}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
}
@@ -359,29 +359,29 @@
+ "]}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
- query = "[cnx:pos=\"VVFIN\"] within s";
+ query = "[corenlp:pos=\"VVFIN\"] within s";
jsonLd = "{@type:koral:group,"
+ "operation:operation:position,"
+ "operands:["
+ "{@type:koral:span,wrap:{@type:koral:term,key:s,foundry:base,layer:s}},"
- + "{@type:koral:token,wrap:{@type:koral:term,key:VVFIN,foundry:cnx,layer:p,type:type:regex,match:match:eq}}"
+ + "{@type:koral:token,wrap:{@type:koral:term,key:VVFIN,foundry:corenlp,layer:p,type:type:regex,match:match:eq}}"
+ "]}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
- query = "[cnx:pos=\"VVFIN\"] within sentence";
+ query = "[corenlp:pos=\"VVFIN\"] within sentence";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
- query = "[cnx:pos=\"VVFIN\"] within p";
+ query = "[corenlp:pos=\"VVFIN\"] within p";
jsonLd = "{@type:koral:span,wrap:{@type:koral:term,key:p,foundry:base,layer:s}}";
FCSQLQueryProcessorTest
.validateNode(query, "/query/operands/0", jsonLd);
- query = "[cnx:pos=\"VVFIN\"] within text";
+ query = "[corenlp:pos=\"VVFIN\"] within text";
jsonLd = "{@type:koral:span,wrap:{@type:koral:term,key:t,foundry:base,layer:s}}";
FCSQLQueryProcessorTest
.validateNode(query, "/query/operands/0", jsonLd);
- query = "[cnx:pos=\"VVFIN\"] within u";
+ query = "[corenlp:pos=\"VVFIN\"] within u";
error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query));
assertEquals(311, error.get(0));
assertEquals(
@@ -433,12 +433,12 @@
String errorMessage = "Query cannot be parsed, an unexpcected occured exception while parsing";
// expression should always be within a segment
- query = "!(mate:lemma=\"sein\" | mate:pos=\"PPOSS\")";
+ query = "!(tt:lemma=\"sein\" | tt:pos=\"PPOSS\")";
error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query));
assertEquals(399, error.get(0));
assertEquals(errorMessage, error.get(1).toString());
- query = "![mate:lemma=\"sein\" | mate:pos=\"PPOSS\"]";
+ query = "![tt:lemma=\"sein\" | tt:pos=\"PPOSS\"]";
error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query));
assertEquals(errorMessage, error.get(1).toString());
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLQueryProcessorTest.java
index 3d8bfaa..01881ee 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLQueryProcessorTest.java
@@ -120,9 +120,9 @@
// | "!=" /* non-equals */
@Test
public void testOperator() throws IOException {
- query = "[cnx:pos != \"N\"]";
+ query = "[corenlp:pos != \"N\"]";
jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:N, "
- + "foundry:cnx, layer:p, type:type:regex, match:match:ne}}";
+ + "foundry:corenlp, layer:p, type:type:regex, match:match:ne}}";
runAndValidate(query, jsonLd);
}
@@ -153,14 +153,14 @@
// qualified-attribute ::= identifier ":" identifier
@Test
public void testTermQueryWithQualifier() throws JsonProcessingException {
- query = "[mate:lemma = \"sein\"]";
+ query = "[tt:lemma = \"sein\"]";
jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:sein, "
- + "foundry:mate, layer:l, type:type:regex, match:match:eq}}";
+ + "foundry:tt, layer:l, type:type:regex, match:match:eq}}";
runAndValidate(query, jsonLd);
- query = "[cnx:pos = \"N\"]";
+ query = "[corenlp:pos = \"N\"]";
jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:N, "
- + "foundry:cnx, layer:p, type:type:regex, match:match:eq}}";
+ + "foundry:corenlp, layer:p, type:type:regex, match:match:eq}}";
runAndValidate(query, jsonLd);
}
@@ -174,17 +174,17 @@
// | expression "|" expression /* or */
@Test
public void testExpressionOr() throws IOException {
- query = "[mate:lemma=\"sein\" | mate:pos=\"PPOSS\"]";
+ query = "[tt:lemma=\"sein\" | tt:pos=\"PPOSS\"]";
jsonLd = "{@type: koral:token,"
+ " wrap: { @type: koral:termGroup,"
+ "relation: relation:or,"
+ " operands:["
- + "{@type: koral:term, key: sein, foundry: mate, layer: l, type:type:regex, match: match:eq},"
- + "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:eq}]}}";
+ + "{@type: koral:term, key: sein, foundry: tt, layer: l, type:type:regex, match: match:eq},"
+ + "{@type: koral:term, key: PPOSS, foundry: tt, layer: p, type:type:regex, match: match:eq}]}}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
- query = "[cnx:lemma=\"sein\" | mate:lemma=\"sein\" | mate:pos=\"PPOSS\"]";
- jsonLd = "{@type: koral:term, key: sein, foundry: cnx, layer: l, type:type:regex, match: match:eq}";
+ query = "[corenlp:lemma=\"sein\" | tt:lemma=\"sein\" | tt:pos=\"PPOSS\"]";
+ jsonLd = "{@type: koral:term, key: sein, foundry: corenlp, layer: l, type:type:regex, match: match:eq}";
FCSQLQueryProcessorTest.validateNode(query, "/query/wrap/operands/0",
jsonLd);
}
@@ -192,13 +192,13 @@
// | expression "&" expression /* and */
@Test
public void testExpressionAnd() throws IOException {
- query = "[mate:lemma=\"sein\" & mate:pos=\"PPOSS\"]";
+ query = "[tt:lemma=\"sein\" & tt:pos=\"PPOSS\"]";
jsonLd = "{@type: koral:token,"
+ " wrap: { @type: koral:termGroup,"
+ "relation: relation:and,"
+ " operands:["
- + "{@type: koral:term, key: sein, foundry: mate, layer: l, type:type:regex, match: match:eq},"
- + "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:eq}]}}";
+ + "{@type: koral:term, key: sein, foundry: tt, layer: l, type:type:regex, match: match:eq},"
+ + "{@type: koral:term, key: PPOSS, foundry: tt, layer: p, type:type:regex, match: match:eq}]}}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
}
@@ -224,27 +224,27 @@
@Test
public void testMultipleBooleanExpressions() throws IOException {
- query = "[mate:lemma=\"sein\" & (mate:pos=\"PPOSS\"|mate:pos=\"VAFIN\")]";
+ query = "[tt:lemma=\"sein\" & (tt:pos=\"PPOSS\"|tt:pos=\"VAFIN\")]";
jsonLd = "{@type: koral:termGroup,"
+ "relation: relation:or,"
+ " operands:["
- + "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:eq},"
- + "{@type: koral:term, key: VAFIN, foundry: mate, layer: p, type:type:regex, match: match:eq}]}";
+ + "{@type: koral:term, key: PPOSS, foundry: tt, layer: p, type:type:regex, match: match:eq},"
+ + "{@type: koral:term, key: VAFIN, foundry: tt, layer: p, type:type:regex, match: match:eq}]}";
FCSQLQueryProcessorTest.validateNode(query, "/query/wrap/operands/1",
jsonLd);
FCSQLQueryProcessorTest.validateNode(query, "/query/wrap/relation",
"relation:and");
- query = "[(cnx:lemma=\"sein\" | mate:pos=\"PPOSS\") | mate:pos=\"VAFIN\"]";
+ query = "[(corenlp:lemma=\"sein\" | tt:pos=\"PPOSS\") | tt:pos=\"VAFIN\"]";
jsonLd = "{@type: koral:termGroup,"
+ "relation: relation:or,"
+ " operands:["
- + "{@type: koral:term, key: sein, foundry: cnx, layer: l, type:type:regex, match: match:eq},"
- + "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:eq}]}";
+ + "{@type: koral:term, key: sein, foundry: corenlp, layer: l, type:type:regex, match: match:eq},"
+ + "{@type: koral:term, key: PPOSS, foundry: tt, layer: p, type:type:regex, match: match:eq}]}";
FCSQLQueryProcessorTest.validateNode(query, "/query/wrap/operands/0",
jsonLd);
- query = "[(cnx:lemma=\"sein\" | mate:pos=\"PPOSS\") & text=\"ist\"]";
+ query = "[(corenlp:lemma=\"sein\" | tt:pos=\"PPOSS\") & text=\"ist\"]";
jsonLd = "{@type: koral:term, key: ist, foundry: opennlp, layer: orth, type:type:regex, match: match:eq}";
FCSQLQueryProcessorTest.validateNode(query, "/query/wrap/operands/1",
jsonLd);
@@ -262,27 +262,27 @@
query = "[!!!pos != \"NN\"]";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
- query = "[mate:lemma=\"sein\" & !mate:pos=\"PPOSS\"]";
+ query = "[tt:lemma=\"sein\" & !tt:pos=\"PPOSS\"]";
jsonLd = "{@type: koral:token,"
+ " wrap: { "
+ "@type: koral:termGroup,"
+ "relation: relation:and,"
+ " operands:["
- + "{@type: koral:term, key: sein, foundry: mate, layer: l, type:type:regex, match: match:eq},"
- + "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:ne}]}}";
+ + "{@type: koral:term, key: sein, foundry: tt, layer: l, type:type:regex, match: match:eq},"
+ + "{@type: koral:term, key: PPOSS, foundry: tt, layer: p, type:type:regex, match: match:ne}]}}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
}
@Test
public void testNotExpressionGroup() throws JsonProcessingException {
- query = "[!(mate:lemma=\"sein\" & mate:pos=\"PPOSS\")]";
+ query = "[!(tt:lemma=\"sein\" & tt:pos=\"PPOSS\")]";
jsonLd = "{@type: koral:token,"
+ " wrap: { "
+ "@type: koral:termGroup,"
+ "relation: relation:or,"
+ " operands:["
- + "{@type: koral:term, key: sein, foundry: mate, layer: l, type:type:regex, match: match:ne},"
- + "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:ne}]}}";
+ + "{@type: koral:term, key: sein, foundry: tt, layer: l, type:type:regex, match: match:ne},"
+ + "{@type: koral:term, key: PPOSS, foundry: tt, layer: p, type:type:regex, match: match:ne}]}}";
//FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
error = getError(new FCSQLQueryProcessor(query));
@@ -316,17 +316,17 @@
error.get(1));
// unsupported layer
- query = "[cnx:morph = \"heit\"]";
+ query = "[corenlp:morph = \"heit\"]";
error = getError(new FCSQLQueryProcessor(query));
assertEquals(306, error.get(0));
assertEquals("Layer morph is unsupported.",
error.get(1));
// missing layer
- query = "[cnx=\"V\"]";
+ query = "[corenlp=\"V\"]";
error = getError(new FCSQLQueryProcessor(query));
assertEquals(306, error.get(0));
- assertEquals("Layer cnx is unsupported.",
+ assertEquals("Layer corenlp is unsupported.",
error.get(1));
}
}