Handled other edge types in dominance & updated relation serialization.

Change-Id: I646d8684bfb2fe0524c9c1a81ec3bb971f311d03
diff --git a/Changes b/Changes
index 0d4ef61..0483509 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,11 @@
+0.25 2017-05-10
+	- Altered dominance and relation serialization (margaretha)
+	 
 0.24 2017-05-03
-	- Fixed serialization of regexes for VCs (diewald)
-
+	- Fixed serialization of regexes for VCs (diewald)	
+	- Implemented exclusion in Cosmas2 IN operation (margaretha)
+	- Restructured test suite (margaretha)
+	
 0.23 2016-10-27
 	- Added tests and comments for FCSQL (margaretha)
 	- Added quantifier for FCSQL QueryGroup (margaretha)
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java
index 0573fd4..ee56fac 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java
@@ -698,6 +698,7 @@
                 catch (ClassCastException | NullPointerException n) {
                     groupType = "relation";
                 }
+
                 if (groupType.equals("relation")
                 //                        || groupType.equals("treeRelation")
                 ) {
@@ -713,17 +714,44 @@
                     putAllBut(group, operatorGroup, "groupType");
                 }
                 else if (groupType.equals("hierarchy")) {
-                    group = KoralObjectGenerator
-                            .makeGroup(KoralOperation.HIERARCHY);
+                    Map<String, Object> attribute = null;
                     if (operatorGroup.containsKey("edgeValue")) {
                         String edgeValue = (String) operatorGroup
                                 .get("edgeValue");
-                        inheritFoundryAndLayer(edgeValue, operand1, operand2);
+                        attribute = inheritFoundryAndLayer(edgeValue, operand1,
+                                operand2);
                     }
-                    if (operatorGroup.containsKey("boundary")) {
-                        checkBoundary((Map<String, Object>) operatorGroup
-                                .get("boundary"), operand1, operand2);
+
+                    if (operatorGroup.containsKey("edgeType") && !operatorGroup
+                            .get("edgeType").toString().equals("edgetype")) {
+                        group = KoralObjectGenerator
+                                .makeGroup(KoralOperation.RELATION);
+                        Map<String, Object> relation = KoralObjectGenerator
+                                .makeRelation();
+                        // EM: for relations between arbitrary nodes e.g. secedge, rst without a label 
+                        // need layer and foundry rewrite default in Kustvakt 
+                        if (attribute != null) {
+                            relation.put("wrap", attribute);
+                        }
+                        group.put("relType", relation);
                     }
+                    else {
+                        group = KoralObjectGenerator
+                                .makeGroup(KoralOperation.HIERARCHY);
+                        if (!operatorGroup.containsKey("edgeType")) {
+                            group.put("edgeType", "edgetype");
+                        }
+                        if (attribute != null) {
+                            operand1.put("attr", attribute);
+                        }
+                        if (operatorGroup.containsKey("boundary")) {
+                            checkBoundary(
+                                    (Map<String, Object>) operatorGroup
+                                            .get("boundary"),
+                                    operand1, operand2);
+                        }
+                    }
+
                     putAllBut(group, operatorGroup, "groupType", "edgeValue");
                 }
                 else if (groupType.equals("position")) {
@@ -866,10 +894,10 @@
     }
 
 
+    @SuppressWarnings("unchecked")
     private String searchMap (Map<String, Object> operand, String key) {
 
         String type = (String) operand.get("@type");
-        Map<String, Object> child;
         if (type.equals("koral:token") && operand.containsKey("wrap")) {
             return searchMap((Map<String, Object>) operand.get("wrap"), key);
         }
@@ -889,6 +917,7 @@
             }
         }
         else {
+            // EM: (Annis) operand should not be of koral:group
             addError(StatusCodes.MALFORMED_QUERY,
                     "Cannot determine the " + key + ".");
         }
@@ -897,13 +926,12 @@
     }
 
 
-    private void inheritFoundryAndLayer (String edgeValue,
+    private Map<String, Object> inheritFoundryAndLayer (String edgeValue,
             Map<String, Object> operand1, Map<String, Object> operand2) {
 
         Map<String, Object> attribute = KoralObjectGenerator.makeTerm();
         attribute.put("key", edgeValue);
         attribute.put("match", KoralMatchOperator.EQUALS.toString());
-        operand1.put("attr", attribute);
 
         if (operand1.containsKey("layer")) {
             attribute.put("layer", operand1.get("layer"));
@@ -923,6 +951,7 @@
         else if (operand2.containsKey("foundry")) {
             attribute.put("foundry", operand2.get("foundry"));
         }
+        return attribute;
     }
 
 
@@ -962,15 +991,18 @@
             //            relation = KoralObjectGenerator.makeRelation();
             relation = new HashMap<String, Object>();
             relation.put("groupType", "hierarchy");
-            // Ignored
-            // ParseTree edgeType = getFirstChildWithCat(operatorNode, "edgeType");
+            ParseTree edgeType = getFirstChildWithCat(operatorNode, "edgeType");
             ParseTree edgeSpecNode = getFirstChildWithCat(operatorNode,
                     "edgeSpec");
             ParseTree star = getFirstChildWithCat(operatorNode, "*");
             ParseTree rangeSpec = getFirstChildWithCat(operatorNode,
                     "rangeSpec");
 
-            //                term = parseQNameNode(qName);
+            if (edgeType != null) {
+                relation.put("edgeType",
+                        edgeType.getChild(0).toStringTree(parser));
+            }
+
             if (edgeSpecNode != null) {
                 Map<String, Object> edgeSpec = parseEdgeSpec(edgeSpecNode);
                 relation.put("edgeValue", edgeSpec.get("value"));
@@ -985,49 +1017,27 @@
             relation = KoralObjectGenerator.makeRelation();
             relation.put("groupType", "relation");
             ParseTree qName = getFirstChildWithCat(operatorNode, "qName");
-            ParseTree edgeType = getFirstChildWithCat(operatorNode, "edgeType");
             ParseTree edgeSpec = getFirstChildWithCat(operatorNode, "edgeSpec");
             ParseTree star = getFirstChildWithCat(operatorNode, "*");
             ParseTree rangeSpec = getFirstChildWithCat(operatorNode,
                     "rangeSpec");
+
             Map<String, Object> type = KoralObjectGenerator.makeTerm();
             if (qName != null) {
                 type.putAll(parseQNameNode(qName));
             }
-            else if (edgeType != null) {
-                type.putAll(parseEdgeAnno(edgeType, "key"));
-            }
-
-            Map<String, Object> label = KoralObjectGenerator.makeTerm();
             if (edgeSpec != null) {
-                label.putAll(parseEdgeSpec(edgeSpec));
-                relation.put("wrap", label);
+                type.putAll(parseEdgeSpec(edgeSpec));
             }
+            relation.put("wrap", type);
 
-            if (qName != null || edgeType != null) {
-                if (edgeSpec == null) {
-                    relation.put("wrap", type);
-                }
-                else {
-                    Map<String, Object> termgroup = KoralObjectGenerator
-                            .makeTermGroup(KoralTermGroupRelation.AND);
-                    ArrayList<Object> termGroupOperands = (ArrayList<Object>) termgroup
-                            .get("operands");
-                    termGroupOperands.add(type);
-                    termGroupOperands.add(label);
-                    relation.put("wrap", termgroup);
-                }
-            }
-            else if (!label.isEmpty()) {
-                relation.put("wrap", label);
-            }
-
-            if (star != null)
+            if (star != null) {
                 relation.put("boundary",
                         KoralObjectGenerator.makeBoundary(0, null));
-            if (rangeSpec != null)
+            }
+            if (rangeSpec != null) {
                 relation.put("boundary", boundaryFromRangeSpec(rangeSpec));
-
+            }
         }
         else if (operator.equals("precedence")) {
             relation = new HashMap<String, Object>();
@@ -1131,33 +1141,27 @@
     }
 
 
-    private Map<String, Object> parseEdgeAnno (ParseTree edgeAnnoSpec,
-            String name) {
+    private Map<String, Object> parseEdgeAnno (ParseTree edgeAnnoSpec) {
         Map<String, Object> edgeAnno = KoralObjectGenerator.makeTerm();
         ParseTree textSpecNode = getFirstChildWithCat(edgeAnnoSpec, "textSpec");
-        ParseTree keyNode = getFirstChildWithCat(edgeAnnoSpec, "key");
-        ParseTree layerNode = getFirstChildWithCat(edgeAnnoSpec, "layer");
-        ParseTree foundryNode = getFirstChildWithCat(edgeAnnoSpec, "foundry");
+//        ignored
+//        ParseTree keyNode = getFirstChildWithCat(edgeAnnoSpec, "key");
+//        ParseTree layerNode = getFirstChildWithCat(edgeAnnoSpec, "layer");
+//        ParseTree foundryNode = getFirstChildWithCat(edgeAnnoSpec, "foundry");
         ParseTree matchOperatorNode = getFirstChildWithCat(edgeAnnoSpec,
                 "eqOperator");
-        if (foundryNode != null)
-            edgeAnno.put("foundry",
-                    foundryNode.getChild(0).toStringTree(parser));
-        if (layerNode != null)
-            edgeAnno.put("layer", layerNode.getChild(0).toStringTree(parser));
-        if (keyNode != null)
-            edgeAnno.put("key", keyNode.getChild(0).toStringTree(parser));
-        edgeAnno.putAll(parseTextSpec(textSpecNode, name));
+//        if (foundryNode != null)
+//            edgeAnno.put("foundry",
+//                    foundryNode.getChild(0).toStringTree(parser));
+//        if (layerNode != null)
+//            edgeAnno.put("layer", layerNode.getChild(0).toStringTree(parser));
+//        if (keyNode != null)
+//            edgeAnno.put("key", keyNode.getChild(0).toStringTree(parser));
+        edgeAnno.putAll(parseTextSpec(textSpecNode, "key"));
         edgeAnno.put("match", parseMatchOperator(matchOperatorNode));
         return edgeAnno;
     }
 
-
-    private Map<String, Object> parseEdgeAnno (ParseTree edgeAnnoSpec) {
-        return parseEdgeAnno(edgeAnnoSpec, "value");
-    }
-
-
     private Map<String, Object> boundaryFromRangeSpec (ParseTree rangeSpec) {
         return boundaryFromRangeSpec(rangeSpec, true);
     }
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/annis/DominanceTests.java b/src/test/java/de/ids_mannheim/korap/query/test/annis/DominanceTests.java
index 66cbf84..6993424 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/annis/DominanceTests.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/annis/DominanceTests.java
@@ -33,6 +33,7 @@
         assertEquals("koral:group", res.at("/query/@type").asText());

         assertEquals("operation:hierarchy",

                 res.at("/query/operation").asText());

+        assertEquals("edgetype", res.at("/query/edgeType").asText());

         assertEquals("koral:span", res.at("/query/operands/0/@type").asText());

         assertEquals("koral:span", res.at("/query/operands/1/@type").asText());

     }

@@ -41,13 +42,14 @@
     @Test

     public void testDefaultTypedDominance ()

             throws JsonProcessingException, IOException {

-        query = "node & node & #1 >edgeType #2";

+        query = "node & node & #1 >edgetype #2";

         qs.setQuery(query, "annis");

         res = mapper.readTree(qs.toJSON());

 

         assertEquals("koral:group", res.at("/query/@type").asText());

         assertEquals("operation:hierarchy",

                 res.at("/query/operation").asText());

+        assertEquals("edgetype", res.at("/query/edgeType").asText());

         assertEquals("koral:span", res.at("/query/operands/0/@type").asText());

         assertEquals("koral:span", res.at("/query/operands/1/@type").asText());

     }

@@ -61,8 +63,8 @@
         res = mapper.readTree(qs.toJSON());

 

         assertEquals("koral:group", res.at("/query/@type").asText());

-        assertEquals("operation:hierarchy",

-                res.at("/query/operation").asText());

+        assertEquals("operation:relation", res.at("/query/operation").asText());

+        assertEquals("secedge", res.at("/query/edgeType").asText());

         assertEquals("koral:span", res.at("/query/operands/0/@type").asText());

         assertTrue(res.at("/query/operands/0/attr").isMissingNode());

         assertEquals("koral:span", res.at("/query/operands/1/@type").asText());

@@ -78,6 +80,7 @@
         assertEquals("koral:group", res.at("/query/@type").asText());

         assertEquals("operation:hierarchy",

                 res.at("/query/operation").asText());

+        assertEquals("edgetype", res.at("/query/edgeType").asText());

         assertEquals("koral:span", res.at("/query/operands/0/@type").asText());

         assertEquals("np", res.at("/query/operands/0/key").asText());

         assertEquals("c", res.at("/query/operands/0/layer").asText());

@@ -95,6 +98,7 @@
         assertEquals("koral:group", res.at("/query/@type").asText());

         assertEquals("operation:hierarchy",

                 res.at("/query/operation").asText());

+        assertEquals("edgetype", res.at("/query/edgeType").asText());

         assertEquals("koral:span", res.at("/query/operands/0/@type").asText());

         assertEquals("koral:span", res.at("/query/operands/1/@type").asText());

         assertEquals("np", res.at("/query/operands/1/key").asText());

@@ -113,6 +117,7 @@
         assertEquals("koral:group", res.at("/query/@type").asText());

         assertEquals("operation:hierarchy",

                 res.at("/query/operation").asText());

+        assertEquals("edgetype", res.at("/query/edgeType").asText());

         assertEquals("koral:span", res.at("/query/operands/0/@type").asText());

         assertEquals("PP", res.at("/query/operands/0/key").asText());

         assertEquals("c", res.at("/query/operands/0/layer").asText());

@@ -131,6 +136,7 @@
         assertEquals("koral:group", res.at("/query/@type").asText());

         assertEquals("operation:hierarchy",

                 res.at("/query/operation").asText());

+        assertEquals("edgetype", res.at("/query/edgeType").asText());

         assertEquals("koral:span", res.at("/query/operands/0/@type").asText());

         assertEquals("NP", res.at("/query/operands/0/key").asText());

         assertEquals("c", res.at("/query/operands/0/layer").asText());

@@ -149,6 +155,7 @@
         assertEquals("koral:group", res.at("/query/@type").asText());

         assertEquals("operation:hierarchy",

                 res.at("/query/operation").asText());

+        assertEquals("edgetype", res.at("/query/edgeType").asText());

         assertEquals("koral:span", res.at("/query/operands/0/@type").asText());

         assertEquals("koral:token", res.at("/query/operands/1/@type").asText());

         assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText());

@@ -197,12 +204,12 @@
         res = mapper.readTree(qs.toJSON());

         assertEquals(0, res.at("/query/boundary/min").asInt());

         assertTrue(res.at("/query/boundary/max").isMissingNode());

-        

+

         // same layers

         query = "cat=\"NP\" & cnx/c=\"PP\" & #1 >2,4 #2";

         qs.setQuery(query, "annis");

         res = mapper.readTree(qs.toJSON());

-        

+

         assertEquals("c", res.at("/query/operands/0/layer").asText());

         assertEquals("c", res.at("/query/operands/1/layer").asText());

         assertEquals(2, res.at("/query/boundary/min").asInt());

@@ -234,14 +241,15 @@
         assertEquals("p", res.at("/query/operands/1/wrap/layer").asText());

     }

 

+

     @Test

     public void testIndirectDominanceWithFoundries ()

             throws JsonProcessingException, IOException {

-        

+

         query = "opennlp/c=\"NP\" & cnx/c=\"PP\" & #1 >2,4 #2";

         qs.setQuery(query, "annis");

         res = mapper.readTree(qs.toJSON());

-        

+

         assertEquals(305, res.at("/errors/0/0").asInt());

         assertEquals(

                 "Indirect dominance between operands of different foundries is not possible.",

@@ -268,6 +276,7 @@
         res = mapper.readTree(qs.toJSON());

         assertEquals("operation:hierarchy",

                 res.at("/query/operation").asText());

+        assertEquals("edgetype", res.at("/query/edgeType").asText());

         assertEquals("koral:span", res.at("/query/operands/0/@type").asText());

         assertEquals("koral:term",

                 res.at("/query/operands/0/attr/@type").asText());

@@ -291,6 +300,7 @@
         res = mapper.readTree(qs.toJSON());

         assertEquals("operation:hierarchy",

                 res.at("/query/operation").asText());

+        assertEquals("edgetype", res.at("/query/edgeType").asText());

         assertEquals("koral:span", res.at("/query/operands/0/@type").asText());

         assertEquals("koral:term",

                 res.at("/query/operands/0/attr/@type").asText());

@@ -305,24 +315,46 @@
 

 

     @Test

-    public void testDominanceWithTypeAndLabel ()

+    public void testDominanceWithEdgetypeAndLabel ()

             throws JsonProcessingException, IOException {

-        query = "node & node & #2 >rst[rst:name=\"evidence\"] #1";

+        query = "node & node & #2 >edgetype[func=\"SBJ\"] #1";

         //coordinates the func=SB term and requires a "c"-layer term (consituency relation/dominance)

         qs.setQuery(query, "annis");

         res = mapper.readTree(qs.toJSON());

         assertEquals("operation:hierarchy",

                 res.at("/query/operation").asText());

+        assertEquals("edgetype", res.at("/query/edgeType").asText());

         assertEquals("koral:span", res.at("/query/operands/0/@type").asText());

         assertEquals("koral:term",

                 res.at("/query/operands/0/attr/@type").asText());

         assertEquals("match:eq",

                 res.at("/query/operands/0/attr/match").asText());

-        assertEquals("evidence", res.at("/query/operands/0/attr/key").asText());

+        assertEquals("SBJ", res.at("/query/operands/0/attr/key").asText());

         assertEquals("koral:span", res.at("/query/operands/1/@type").asText());

     }

 

 

+    @Test

+    public void testDominanceWithTypeAndLabel ()

+            throws JsonProcessingException, IOException {

+        query = "rst & rst & #2 >rst[rst:name=\"evidence\"] #1";

+        //coordinates the func=SB term and requires a "c"-layer term (consituency relation/dominance)

+        qs.setQuery(query, "annis");

+        res = mapper.readTree(qs.toJSON());

+        assertEquals("operation:relation", res.at("/query/operation").asText());

+        assertEquals("rst", res.at("/query/edgeType").asText());

+        assertEquals("koral:span", res.at("/query/operands/0/@type").asText());

+        assertEquals("rst", res.at("/query/operands/0/layer").asText());

+        assertEquals("koral:span", res.at("/query/operands/1/@type").asText());

+        assertEquals("rst", res.at("/query/operands/1/layer").asText());

+

+        assertEquals("koral:term",

+                res.at("/query/relType/wrap/@type").asText());

+        assertEquals("evidence", res.at("/query/relType/wrap/key").asText());

+        assertEquals("rst", res.at("/query/relType/wrap/layer").asText());

+    }

+

+

 

     @Test

     public void testDominanceWithMultipleLabels ()

diff --git a/src/test/java/de/ids_mannheim/korap/query/test/annis/RelationTests.java b/src/test/java/de/ids_mannheim/korap/query/test/annis/RelationTests.java
index fb243d9..6da4f3d 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/annis/RelationTests.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/annis/RelationTests.java
@@ -13,6 +13,10 @@
 

 import de.ids_mannheim.korap.query.serialize.QuerySerializer;

 

+/**

+ * @author margaretha

+ *

+ */

 public class RelationTests {

     private String query;

 

@@ -24,10 +28,9 @@
     @Test

     public void testTypedRelationWithArbritraryNodes ()

             throws JsonProcessingException, IOException {

-        query = "node & node & #1 ->malt/d=\"PP\" #2";

+        query = "node & node & #1 ->malt/d[func=\"PP\"] #2";

         qs.setQuery(query, "annis");

         res = mapper.readTree(qs.toJSON());

-        //        System.out.println(res.asText());

 

         assertEquals("koral:group", res.at("/query/@type").asText());

         assertEquals("operation:relation", res.at("/query/operation").asText());

@@ -44,9 +47,30 @@
         assertTrue(res.at("/query/relType/wrap/value").isMissingNode());

     }

 

-

     @Test

-    public void testFoundryLayerTypedRelationWithArbritraryNodes ()

+    public void testTypedRelationWithLayerInLabel ()

+            throws JsonProcessingException, IOException {

+        query = "node & node & #1 ->malt/d[c:func!=\"PP\"] #2";

+        qs.setQuery(query, "annis");

+        res = mapper.readTree(qs.toJSON());

+

+        assertEquals("koral:group", res.at("/query/@type").asText());

+        assertEquals("operation:relation", res.at("/query/operation").asText());

+        assertEquals("koral:span", res.at("/query/operands/0/@type").asText());

+        assertEquals("koral:span", res.at("/query/operands/1/@type").asText());

+

+        assertEquals("koral:relation", res.at("/query/relType/@type").asText());

+        assertEquals("koral:term",

+                res.at("/query/relType/wrap/@type").asText());

+        assertEquals("malt", res.at("/query/relType/wrap/foundry").asText());

+        assertEquals("d", res.at("/query/relType/wrap/layer").asText());

+        assertEquals("match:ne", res.at("/query/relType/wrap/match").asText());

+        assertEquals("PP", res.at("/query/relType/wrap/key").asText());

+        assertTrue(res.at("/query/relType/wrap/value").isMissingNode());

+    }

+    

+    @Test

+    public void testTypedRelationWithoutLabel ()

             throws JsonProcessingException, IOException {

         query = "node & node & #1 ->malt/d #2";

         qs.setQuery(query, "annis");

@@ -63,12 +87,32 @@
         assertTrue(res.at("/query/relType/wrap/key").isMissingNode());

         assertTrue(res.at("/query/relType/wrap/value").isMissingNode());

     }

+    

+    //EM: needs rewrite default foundry in Kustvakt

+    @Test

+    public void testTypedRelationWithoutFoundry ()

+            throws JsonProcessingException, IOException {

+        query = "node & node & #1 ->d #2";

+        qs.setQuery(query, "annis");

+        res = mapper.readTree(qs.toJSON());

+

+        assertEquals("koral:group", res.at("/query/@type").asText());

+        assertEquals("operation:relation", res.at("/query/operation").asText());

+

+        assertEquals("koral:relation", res.at("/query/relType/@type").asText());

+        assertEquals("koral:term",

+                res.at("/query/relType/wrap/@type").asText());

+        assertEquals("d", res.at("/query/relType/wrap/layer").asText());

+        assertTrue(res.at("/query/relType/wrap/foundry").isMissingNode());

+        assertTrue(res.at("/query/relType/wrap/key").isMissingNode());

+        assertTrue(res.at("/query/relType/wrap/value").isMissingNode());

+    }

 

 

     @Test

-    public void testTypedRelation ()

+    public void testTypedRelationWithAnnotationNodes ()

             throws JsonProcessingException, IOException {

-        query = "corenlp/c=\"VP\" & corenlp/c=\"NP\" & #1 ->malt/d=\"PP\" #2";

+        query = "corenlp/c=\"VP\" & corenlp/c=\"NP\" & #1 ->malt/d[func=\"PP\"] #2";

         qs.setQuery(query, "annis");

         res = mapper.readTree(qs.toJSON());

 

@@ -94,7 +138,7 @@
     @Test

     public void testIndirectTypedRelation ()

             throws JsonProcessingException, IOException {

-        query = "corenlp/c=\"VP\" & corenlp/c=\"NP\" & #1 ->malt/d=\"PP\" * #2";

+        query = "corenlp/c=\"VP\" & corenlp/c=\"NP\" & #1 ->malt/d[func=\"PP\"] * #2";

         qs.setQuery(query, "annis");

         res = mapper.readTree(qs.toJSON());

         

@@ -115,7 +159,7 @@
     @Test

     public void testSpecificIndirectTypedRelation ()

             throws JsonProcessingException, IOException {

-        query = "corenlp/c=\"VP\" & corenlp/c=\"NP\" & #1 ->malt/d=\"PP\" 2,4 #2";

+        query = "corenlp/c=\"VP\" & corenlp/c=\"NP\" & #1 ->malt/d[func=\"PP\"] 2,4 #2";

         qs.setQuery(query, "annis");

         res = mapper.readTree(qs.toJSON());

         

@@ -124,79 +168,15 @@
         assertEquals(4, res.at("/query/relType/boundary/max").asInt());

     }

 

-    @Test

-    public void testTypedRelationWithLabel ()

-            throws JsonProcessingException, IOException {

-        query = "corenlp/c=\"VP\" & corenlp/c=\"NP\" & "

-                + "#1 ->malt/d=\"PP\"[func=\"SBJ\"] #2";

-        qs.setQuery(query, "annis");

-        res = mapper.readTree(qs.toJSON());

-        

-        assertEquals("koral:relation", res.at("/query/relType/@type").asText());

-        assertEquals("koral:termGroup",

-                res.at("/query/relType/wrap/@type").asText());

-        assertEquals("relation:and",

-                res.at("/query/relType/wrap/relation").asText());

-        assertEquals("malt", res.at("/query/relType/wrap/operands/0/foundry").asText());

-        assertEquals("d", res.at("/query/relType/wrap/operands/0/layer").asText());

-        assertEquals("PP", res.at("/query/relType/wrap/operands/0/key").asText());

-        assertTrue(res.at("/query/relType/wrap/operands/0/value").isMissingNode());

-        

-        assertEquals("match:eq", res.at("/query/relType/wrap/operands/1/match").asText());

-        assertTrue(res.at("/query/relType/wrap/operands/1/layer").isMissingNode());

-        assertEquals("func", res.at("/query/relType/wrap/operands/1/key").asText());

-        assertEquals("SBJ", res.at("/query/relType/wrap/operands/1/value").asText());

-    }

+    

 

-    // fix me

     @Test

     public void testTypedRelationWithMultipleLabels ()

             throws JsonProcessingException, IOException {

         query = "corenlp/c=\"VP\" & corenlp/c=\"NP\" & "

-                + "#1 ->malt/d=\"PP\"[func=\"SBJ\" func!=\"ADV\"] #2";

+                + "#1 ->malt/d[func=\"SBJ\" func!=\"ADV\"] #2";

         qs.setQuery(query, "annis");

         res = mapper.readTree(qs.toJSON());

-        

-//        assertEquals("koral:relation", res.at("/query/relType/@type").asText());

-//        assertEquals("koral:termGroup",

-//                res.at("/query/relType/wrap/@type").asText());

-//        assertEquals("relation:and",

-//                res.at("/query/relType/wrap/relation").asText());

-//        assertEquals("malt", res.at("/query/relType/wrap/operands/0/foundry").asText());

-//        assertEquals("d", res.at("/query/relType/wrap/operands/0/layer").asText());

-//        assertEquals("PP", res.at("/query/relType/wrap/operands/0/key").asText());

-//        assertTrue(res.at("/query/relType/wrap/operands/0/value").isMissingNode());

-//        

-//        assertEquals("match:eq", res.at("/query/relType/wrap/operands/1/match").asText());

-//        assertTrue(res.at("/query/relType/wrap/operands/1/layer").isMissingNode());

-//        assertEquals("func", res.at("/query/relType/wrap/operands/1/key").asText());

-//        assertEquals("SBJ", res.at("/query/relType/wrap/operands/1/value").asText());

+        assertEquals(302, res.at("/errors/0/0").asInt());

     }

-    

-    //  

-    //  @Test

-    //  public void testPointingRelations() throws Exception {

-    //      query = "node & node & #2 ->coref[val=\"true\"] #1";

-    //      String dom1 = 

-    //              "{@type=koral:group, operation=operation:relation, operands=[" +

-    //                      "{@type=koral:span}," +

-    //                      "{@type=koral:span}" +

-    //              "], relation={@type=koral:relation, wrap={@type=koral:term, layer=coref, key=true, match=match:eq}}" +

-    //              "}";

-    //      aqlt = new AqlTree(query);

-    //      map = aqlt.getRequestMap().get("query").toString();

-    //      assertEquals(dom1.replaceAll(" ", ""), map.replaceAll(" ", ""));

-    //      

-    //      query = "node & node & #2 ->mate/coref[val=\"true\"] #1";

-    //      String dom2 = 

-    //              "{@type=koral:group, operation=operation:relation, operands=[" +

-    //                      "{@type=koral:span}," +

-    //                      "{@type=koral:span}" +

-    //              "], relation={@type=koral:relation, wrap={@type=koral:term, foundry=mate, layer=coref, key=true, match=match:eq}}" +

-    //              "}";

-    //      aqlt = new AqlTree(query);

-    //      map = aqlt.getRequestMap().get("query").toString();

-    //      assertEquals(dom2.replaceAll(" ", ""), map.replaceAll(" ", ""));

-    //  }

-

 }