added '@' for context, rewriting query X:sa as #BEG(X , sa), updated examples
diff --git a/examples/cosmas17.json b/examples/cosmas17.json
deleted file mode 100644
index 61333fd..0000000
--- a/examples/cosmas17.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
- "query" : {
- "@type" : "korap:group",
- "operation" : "operation:submatch",
- "classRef" : [ 1 ],
- "operands" : [ {
- "@type" : "korap:group",
- "operation" : "operation:position",
- "frame" : "frame:startswith",
- "operands" : [ {
- "@type" : "korap:span",
- "key" : "s"
- }, {
- "@type" : "korap:group",
- "operation" : "operation:class",
- "class" : 1,
- "operands" : [ {
- "@type" : "korap:token",
- "wrap" : {
- "@type" : "korap:term",
- "caseInsensitive" : true,
- "key" : "wegen",
- "layer" : "orth",
- "match" : "match:eq"
- }
- } ]
- } ]
- } ]
- }
-}
\ No newline at end of file
diff --git a/examples/cosmas1.json b/examples/cosmas2_1.json
similarity index 69%
rename from examples/cosmas1.json
rename to examples/cosmas2_1.json
index 871fce1..42cf066 100644
--- a/examples/cosmas1.json
+++ b/examples/cosmas2_1.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:token",
"wrap" : {
diff --git a/examples/cosmas10.json b/examples/cosmas2_10.json
similarity index 91%
rename from examples/cosmas10.json
rename to examples/cosmas2_10.json
index d958810..ae4dd0a 100644
--- a/examples/cosmas10.json
+++ b/examples/cosmas2_10.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:sequence",
diff --git a/examples/cosmas11.json b/examples/cosmas2_11.json
similarity index 91%
rename from examples/cosmas11.json
rename to examples/cosmas2_11.json
index 6cd164f..43d37d1 100644
--- a/examples/cosmas11.json
+++ b/examples/cosmas2_11.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:sequence",
diff --git a/examples/cosmas12.json b/examples/cosmas2_12.json
similarity index 91%
rename from examples/cosmas12.json
rename to examples/cosmas2_12.json
index e6d8895..4031774 100644
--- a/examples/cosmas12.json
+++ b/examples/cosmas2_12.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:sequence",
diff --git a/examples/cosmas13.json b/examples/cosmas2_13.json
similarity index 93%
rename from examples/cosmas13.json
rename to examples/cosmas2_13.json
index ea83cba..52bf24a 100644
--- a/examples/cosmas13.json
+++ b/examples/cosmas2_13.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:sequence",
diff --git a/examples/cosmas14.json b/examples/cosmas2_14.json
similarity index 91%
rename from examples/cosmas14.json
rename to examples/cosmas2_14.json
index f7fd874..bb80964 100644
--- a/examples/cosmas14.json
+++ b/examples/cosmas2_14.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:sequence",
diff --git a/examples/cosmas15.json b/examples/cosmas2_15.json
similarity index 89%
rename from examples/cosmas15.json
rename to examples/cosmas2_15.json
index f5aabc0..1980eba 100644
--- a/examples/cosmas15.json
+++ b/examples/cosmas2_15.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:submatch",
diff --git a/examples/cosmas16.json b/examples/cosmas2_16.json
similarity index 89%
rename from examples/cosmas16.json
rename to examples/cosmas2_16.json
index 61333fd..15303f4 100644
--- a/examples/cosmas16.json
+++ b/examples/cosmas2_16.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:submatch",
diff --git a/examples/cosmas16.json b/examples/cosmas2_17.json
similarity index 89%
copy from examples/cosmas16.json
copy to examples/cosmas2_17.json
index 61333fd..15303f4 100644
--- a/examples/cosmas16.json
+++ b/examples/cosmas2_17.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:submatch",
diff --git a/examples/cosmas18.json b/examples/cosmas2_18.json
similarity index 71%
rename from examples/cosmas18.json
rename to examples/cosmas2_18.json
index c27404e..944a465 100644
--- a/examples/cosmas18.json
+++ b/examples/cosmas2_18.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:submatch",
diff --git a/examples/cosmas19.json b/examples/cosmas2_19.json
similarity index 89%
rename from examples/cosmas19.json
rename to examples/cosmas2_19.json
index b31d80b..3f8fc30 100644
--- a/examples/cosmas19.json
+++ b/examples/cosmas2_19.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:submatch",
diff --git a/examples/cosmas2.json b/examples/cosmas2_2.json
similarity index 85%
rename from examples/cosmas2.json
rename to examples/cosmas2_2.json
index fdcb2d3..b8d6267 100644
--- a/examples/cosmas2.json
+++ b/examples/cosmas2_2.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:sequence",
diff --git a/examples/cosmas20.json b/examples/cosmas2_20.json
similarity index 89%
rename from examples/cosmas20.json
rename to examples/cosmas2_20.json
index 32887c7..991689f 100644
--- a/examples/cosmas20.json
+++ b/examples/cosmas2_20.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:submatch",
diff --git a/examples/cosmas3.json b/examples/cosmas2_3.json
similarity index 88%
rename from examples/cosmas3.json
rename to examples/cosmas2_3.json
index 2c77f42..f43b829 100644
--- a/examples/cosmas3.json
+++ b/examples/cosmas2_3.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:sequence",
diff --git a/examples/cosmas4.json b/examples/cosmas2_4.json
similarity index 89%
rename from examples/cosmas4.json
rename to examples/cosmas2_4.json
index 55eab65..9e010c5 100644
--- a/examples/cosmas4.json
+++ b/examples/cosmas2_4.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:sequence",
diff --git a/examples/cosmas5.json b/examples/cosmas2_5.json
similarity index 93%
copy from examples/cosmas5.json
copy to examples/cosmas2_5.json
index ec1cdbf..a96845d 100644
--- a/examples/cosmas5.json
+++ b/examples/cosmas2_5.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:sequence",
diff --git a/examples/cosmas5.json b/examples/cosmas2_6.json
similarity index 93%
rename from examples/cosmas5.json
rename to examples/cosmas2_6.json
index ec1cdbf..06a9726 100644
--- a/examples/cosmas5.json
+++ b/examples/cosmas2_6.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:sequence",
@@ -11,6 +11,14 @@
"max" : 5
} ],
"operands" : [ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "key" : "Tisch",
+ "layer" : "orth",
+ "match" : "match:eq"
+ }
+ }, {
"@type" : "korap:group",
"operation" : "operation:sequence",
"inOrder" : true,
@@ -42,14 +50,6 @@
"match" : "match:eq"
}
} ]
- }, {
- "@type" : "korap:token",
- "wrap" : {
- "@type" : "korap:term",
- "key" : "Tisch",
- "layer" : "orth",
- "match" : "match:eq"
- }
} ]
}
}
\ No newline at end of file
diff --git a/examples/cosmas7.json b/examples/cosmas2_7.json
similarity index 95%
rename from examples/cosmas7.json
rename to examples/cosmas2_7.json
index 0bf2ba3..f4b8f2a 100644
--- a/examples/cosmas7.json
+++ b/examples/cosmas2_7.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:sequence",
diff --git a/examples/cosmas8.json b/examples/cosmas2_8.json
similarity index 91%
rename from examples/cosmas8.json
rename to examples/cosmas2_8.json
index a8f4a3f..c9d2f85 100644
--- a/examples/cosmas8.json
+++ b/examples/cosmas2_8.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:sequence",
diff --git a/examples/cosmas9.json b/examples/cosmas2_9.json
similarity index 91%
rename from examples/cosmas9.json
rename to examples/cosmas2_9.json
index 865226c..b42eefc 100644
--- a/examples/cosmas9.json
+++ b/examples/cosmas2_9.json
@@ -1,5 +1,5 @@
{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
"query" : {
"@type" : "korap:group",
"operation" : "operation:sequence",
diff --git a/examples/cosmas6.json b/examples/cosmas6.json
deleted file mode 100644
index d52d5c7..0000000
--- a/examples/cosmas6.json
+++ /dev/null
@@ -1,55 +0,0 @@
-{
- "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
- "query" : {
- "@type" : "korap:group",
- "operation" : "operation:sequence",
- "inOrder" : true,
- "distances" : [ {
- "@type" : "korap:distance",
- "key" : "w",
- "min" : 0,
- "max" : 5
- } ],
- "operands" : [ {
- "@type" : "korap:token",
- "wrap" : {
- "@type" : "korap:term",
- "key" : "Tisch",
- "layer" : "orth",
- "match" : "match:eq"
- }
- }, {
- "@type" : "korap:group",
- "operation" : "operation:sequence",
- "inOrder" : true,
- "distances" : [ {
- "@type" : "korap:distance",
- "key" : "w",
- "min" : 1,
- "max" : 3
- }, {
- "@type" : "korap:distance",
- "key" : "s",
- "min" : 0,
- "max" : 1
- } ],
- "operands" : [ {
- "@type" : "korap:token",
- "wrap" : {
- "@type" : "korap:term",
- "key" : "das",
- "layer" : "orth",
- "match" : "match:eq"
- }
- }, {
- "@type" : "korap:token",
- "wrap" : {
- "@type" : "korap:term",
- "key" : "Buch",
- "layer" : "orth",
- "match" : "match:eq"
- }
- } ]
- } ]
- }
-}
\ No newline at end of file
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
index f97cc77..777d06a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
@@ -6,6 +6,8 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.RecognitionException;
@@ -85,7 +87,7 @@
/**
* A list of node categories that can be sequenced (i.e. which can be in a sequence with any number of other nodes in this list)
*/
- private final List<String> sequentiableCats = Arrays.asList(new String[] {"OPWF", "OPLEM", "OPMORPH", "OPBEG", "OPEND", "OPIN"});
+ private final List<String> sequentiableCats = Arrays.asList(new String[] {"OPWF", "OPLEM", "OPMORPH", "OPBEG", "OPEND", "OPIN", "OPBED"});
/**
* Keeps track of sequenced nodes, i.e. nodes that implicitly govern a sequence, as in (C2PQ (OPWF der) (OPWF Mann)).
* This is necessary in order to know when to take the sequence off the object stack, as the sequence is introduced by the
@@ -133,7 +135,7 @@
}
System.out.println("Processing Cosmas");
- requestMap.put("context", "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld");
+ requestMap.put("@context", "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld");
// QueryUtils.prepareContext(requestMap);
processNode(tree);
}
@@ -164,6 +166,7 @@
// Check for potential implicit sequences as in (C2PQ (OPWF der) (OPWF Mann)). The sequence is introduced
// by the first child if it (and its siblings) is sequentiable.
if (sequentiableCats.contains(nodeCat)) {
+ System.err.println(nodeCat);
// for each node, check if parent has more than one child (-> could be implicit sequence)
Tree parent = node.getParent();
if (parent.getChildCount()>1) {
@@ -173,13 +176,14 @@
for (int i=1; i<parent.getChildCount() ;i++) {
if (sequentiableCats.contains(QueryUtils.getNodeCat(parent.getChild(i)))) {
hasSequentiableSiblings = true;
+ continue;
}
}
if (hasSequentiableSiblings) {
// Step I: create sequence
LinkedHashMap<String, Object> sequence = new LinkedHashMap<String, Object>();
sequence.put("@type", "korap:group");
- sequence.put("operation", "operation:"+ "sequence");
+ sequence.put("operation", "operation:sequence");
sequence.put("operands", new ArrayList<Object>());
// push sequence on object stack but don't increment stackedObjects counter since
// we've got to wait until the parent node is processed - therefore, add the parent
@@ -223,7 +227,12 @@
fieldMap.put("match", "match:eq");
}
//Step II: decide where to put
- putIntoSuperObject(token, 1);
+ if (! QueryUtils.hasChild(node, "TPOS")) {
+ putIntoSuperObject(token, 1);
+ } else {
+
+ }
+
}
if (nodeCat.equals("OPMORPH")) {
@@ -505,7 +514,7 @@
submatchgroup.put("classRef", spanRef);
ArrayList<Object> submatchoperands = new ArrayList<Object>();
submatchgroup.put("operands", submatchoperands);
- putIntoSuperObject(submatchgroup, 1);
+ putIntoSuperObject(submatchgroup, 0);
// Distinguish two cases. Normal case: query has just one condition, like #BED(X, sa) ...
if (conditions.getChildCount()==1) {
@@ -767,9 +776,27 @@
}
- private static Tree parseCosmasQuery(String p) throws RecognitionException {
+ private static Tree parseCosmasQuery(String q) throws RecognitionException {
+ Pattern p = Pattern.compile("(\\w+):((\\+|-)?(sa|se|pa|pe|ta|te),?)+");
+ Matcher m = p.matcher(q);
+
+ String rewrittenQuery = q;
+ while (m.find()) {
+ String match = m.group();
+ String conditionsString = match.split(":")[1];
+ Pattern conditionPattern = Pattern.compile("(\\+|-)?(sa|se|pa|pe|ta|te)");
+ Matcher conditionMatcher = conditionPattern.matcher(conditionsString);
+ String replacement = "#BED("+m.group(1)+" , ";
+ while (conditionMatcher.find()) {
+ replacement = replacement+conditionMatcher.group()+",";
+ }
+ replacement = replacement.substring(0, replacement.length()-1)+")"; //remove trailing comma and close parenthesis
+ System.out.println(replacement);
+ rewrittenQuery = rewrittenQuery.replace(match, replacement);
+ }
+ q = rewrittenQuery;
Tree tree = null;
- ANTLRStringStream ss = new ANTLRStringStream(p);
+ ANTLRStringStream ss = new ANTLRStringStream(q);
c2psLexer lex = new c2psLexer(ss);
org.antlr.runtime.CommonTokenStream tokens = new org.antlr.runtime.CommonTokenStream(lex); //v3
cosmasParser = new c2psParser(tokens);
@@ -800,9 +827,11 @@
// "(Mann oder Frau) #IN <s>",
// "#BEG(der /w3:5 Mann) /+w10 kommt",
// "&würde /w0 MORPH(V)",
- "#NHIT(gehen /w1:10 voran)",
- "#BED(der Mann , sa,-pa)",
- "Mann /t0 Frau"
+// "#NHIT(gehen /w1:10 voran)",
+// "#BED(der Mann , sa,-pa)",
+// "Mann /t0 Frau",
+ "sagt der:sa Bundeskanzler",
+// "Der:sa,-pe,+te ",
};
// CosmasTree.debug=true;
for (String q : queries) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
index ec62578..161aa18 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
@@ -179,7 +179,7 @@
}
}
System.out.println("Processing PoliqarpPlus");
- requestMap.put("context", "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld");
+ requestMap.put("@context", "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld");
// QueryUtils.prepareContext(requestMap);
processNode(tree);
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/QueryUtils.java b/src/main/java/de/ids_mannheim/korap/query/serialize/QueryUtils.java
index 4495c01..e0f0c0d 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/QueryUtils.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/QueryUtils.java
@@ -58,6 +58,22 @@
* @param childCat The category of the potential child.
* @return true iff one or more children belong to the specified category
*/
+ public static boolean hasChild(Tree node, String childCat) {
+ for (int i = 0; i < node.getChildCount(); i++) {
+ if (getNodeCat(node.getChild(i)).equals(childCat)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Tests whether a certain node has a child by a certain name
+ *
+ * @param node The parent node.
+ * @param childCat The category of the potential child.
+ * @return true iff one or more children belong to the specified category
+ */
public static boolean hasChild(ParseTree node, String childCat) {
for (int i = 0; i < node.getChildCount(); i++) {
if (getNodeCat(node.getChild(i)).equals(childCat)) {
@@ -335,4 +351,5 @@
}
+
}
diff --git a/src/test/java/CosmasTreeTest.java b/src/test/java/CosmasTreeTest.java
index 1cfb8bb..b084bb4 100644
--- a/src/test/java/CosmasTreeTest.java
+++ b/src/test/java/CosmasTreeTest.java
@@ -24,24 +24,9 @@
return res.equals(queryMap);
}
-// @Test
+ @Test
public void testContext() throws QueryException {
- String contextString = "{korap = http://korap.ids-mannheim.de/ns/KorAP/json-ld/v0.1/, " +
- "boundary = korap:boundary/,"+
- "group = korap:group/,"+
- "operation = {@id = group:operation/, @type = @id},"+
- "class = {@id = group:class, @type = xsd:integer},"+
- "operands = {@id = group:operands, @container = @list},"+
- "frame = {@id = group:frame/, @type = @id},"+
- "classRef = {@id = group:classRef, @type = xsd:integer},"+
- "spanRef = {@id = group:spanRef, @type = xsd:integer},"+
- "classRefOp = {@id = group:classRefOp, @type = @id},"+
- "min = {@id = boundary:min, @type = xsd:integer},"+
- "max = {@id = boundary:max, @type = xsd:integer},"+
- "exclude = {@id = group:exclude, @type = xsd:boolean},"+
- "distances = {@id = group:distances, @container = @list},"+
- "inOrder = {@id = group:inOrder, @type = xsd:boolean}"+
- "}";
+ String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld";
ct = new CosmasTree("Test");
assertEquals(contextString.replaceAll(" ", ""), ct.getRequestMap().get("@context").toString().replaceAll(" ", ""));
}
@@ -599,5 +584,52 @@
assertEquals(bed3.replaceAll(" ", ""), map.replaceAll(" ", ""));
}
+ @Test
+ public void testColonSeparatedConditions() throws QueryException {
+
+ query = "Der:sa";
+ String col1 =
+ "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
+ "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
+ "{@type=korap:span, key=s}," +
+ "{@type=korap:group, operation=operation:class, class=1, operands=[" +
+ "{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}" +
+ "]}" +
+ "]}" +
+ "]}";
+ ct = new CosmasTree(query);
+ map = ct.getRequestMap().get("query").toString();
+ assertEquals(col1.replaceAll(" ", ""), map.replaceAll(" ", ""));
+
+ query = "Mann:sa,-pa,+te)";
+ String col2 =
+ "{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
+ "{@type=korap:group, operation=operation:sequence, distances=[" +
+ "{@type=korap:distance, key=w, min=0, max=0}" +
+ "], operands=[" +
+ "{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
+ "{@type=korap:span, key=s}," +
+ "{@type=korap:group, operation=operation:class, class=1, operands=[" +
+ "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
+ "]}" +
+ "]}," +
+ "{@type=korap:group, operation=operation:position, frame=frame:startswith, exclude=true, operands=[" +
+ "{@type=korap:span, key=p}," +
+ "{@type=korap:group, operation=operation:class, class=1, operands=[" +
+ "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
+ "]}" +
+ "]}," +
+ "{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
+ "{@type=korap:span, key=t}," +
+ "{@type=korap:group, operation=operation:class, class=1, operands=[" +
+ "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
+ "]}" +
+ "]}" +
+ "]}" +
+ "]}";
+ ct = new CosmasTree(query);
+ map = ct.getRequestMap().get("query").toString();
+ assertEquals(col2.replaceAll(" ", ""), map.replaceAll(" ", ""));
+ }
}
diff --git a/src/test/java/PoliqarpPlusTreeTest.java b/src/test/java/PoliqarpPlusTreeTest.java
index b7c48be..ad293eb 100644
--- a/src/test/java/PoliqarpPlusTreeTest.java
+++ b/src/test/java/PoliqarpPlusTreeTest.java
@@ -24,24 +24,9 @@
return res.equals(queryMap);
}
-// @Test
+ @Test
public void testContext() throws QueryException {
- String contextString = "{korap = http://korap.ids-mannheim.de/ns/KorAP/json-ld/v0.1/, " +
- "boundary = korap:boundary/,"+
- "group = korap:group/,"+
- "operation = {@id = group:operation/, @type = @id},"+
- "class = {@id = group:class, @type = xsd:integer},"+
- "operands = {@id = group:operands, @container = @list},"+
- "frame = {@id = group:frame/, @type = @id},"+
- "classRef = {@id = group:classRef, @type = xsd:integer},"+
- "spanRef = {@id = group:spanRef, @type = xsd:integer},"+
- "classRefOp = {@id = group:classRefOp, @type = @id},"+
- "min = {@id = boundary:min, @type = xsd:integer},"+
- "max = {@id = boundary:max, @type = xsd:integer},"+
- "exclude = {@id = group:exclude, @type = xsd:boolean},"+
- "distances = {@id = group:distances, @container = @list},"+
- "inOrder = {@id = group:inOrder, @type = xsd:boolean}"+
- "}";
+ String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld";
ppt = new PoliqarpPlusTree("Test");
assertEquals(contextString.replaceAll(" ", ""), ppt.getRequestMap().get("@context").toString().replaceAll(" ", ""));
}