Added character offsets for elements in relation payloads.

Change-Id: I717372329181a6641c8e40c6ff8025e866e14f58
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java
index d62216b..61ec3db 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java
@@ -23,7 +23,7 @@
  * prefix "<" or
  * ">". The direction of the angle bracket represents the direction of
  * the
- * corresponding relation. <br/><br/>
+ * corresponding relation. By default, the relation is set ">". <br/><br/>
  * 
  * This class provides two types of query:
  * <ol>
@@ -56,7 +56,7 @@
  * */
 public class SpanRelationQuery extends SimpleSpanQuery {
 
-    private int direction = 0;
+    private int direction = 0; // >
     private byte tempSourceNum = 1;
     private byte tempTargetNum = 2;
     private byte sourceClass;
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java
index 9049ddb..25d1f76 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java
@@ -91,15 +91,13 @@
         currentDoc = firstSpans.doc();
 
         this.query = query;
-        if (getSpanId() > 0) {
-            hasSpanId = true;
-        }
     }
 
 
     @Override
     public boolean next () throws IOException {
         matchPayload.clear();
+        spanId = 0;
         CandidateSpan cs;
         while (hasMoreSpans || candidateSpans.size() > 0) {
             if (isSorted) {
@@ -148,7 +146,37 @@
         matchEndPosition = cs.getEnd();
         matchDocNumber = cs.getDoc();
         matchPayload.addAll(cs.getPayloads());
-        setSpanId(cs.getSpanId());
+
+        if (firstSpans instanceof RelationSpans && classNumbers.size() == 1) {
+            RelationSpans relationSpans = (RelationSpans) firstSpans;
+            int direction = relationSpans.getDirection();
+
+            if (classNumbers.get(0) == relationSpans.getTempSourceNum()) {
+                if (direction == 0) {
+                    setSpanId(relationSpans.getLeftId());
+                }
+                else {
+                    setSpanId(relationSpans.getRightId());
+                }
+            }
+            else if (classNumbers.get(0) == relationSpans.getTempTargetNum()) {
+                if (direction == 0) {
+                    setSpanId(relationSpans.getRightId());
+                }
+                else {
+                    setSpanId(relationSpans.getLeftId());
+                }
+            }
+            // else {
+            // throw new
+            // IllegalArgumentException("Classnumber is not found.");
+            // }
+            if (spanId > 0) hasSpanId = true;
+         }
+         else if (cs.getSpanId() > 0) {
+             hasSpanId = true;
+             setSpanId(cs.getSpanId());
+         }
     }
 
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java
index 572528e..42d391b 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java
@@ -194,46 +194,56 @@
             cs.setLeftEnd(cs.start + 1);
             cs.setRightStart(i);
             cs.setRightEnd(i + 1);
-            cs.setLeftId(bb.getShort(5)); // left id
-            cs.setRightId(bb.getShort(7)); // right id
-            if (length > 9) {
+            if (length > 5) {
+                cs.setLeftId(bb.getShort(5)); // left id
+                cs.setRightId(bb.getShort(7)); // right id
                 cs.setSpanId(bb.getShort(9)); // relation id
             }
         }
         else if (payloadTypeIdentifier == PayloadTypeIdentifier.TERM_TO_ELEMENT.value) { // length
             // 15
             cs.setLeftEnd(cs.start + 1);
-            cs.setRightStart(bb.getInt(1));
-            cs.setRightEnd(bb.getInt(5));
-            cs.setLeftId(bb.getShort(9)); // left id
-            cs.setRightId(bb.getShort(11)); // right id
-            if (length > 13) {
-                cs.setSpanId(bb.getShort(13)); // relation id
+            // 1-4 start element offset
+            // 5-8 end element offset
+            cs.setRightStart(bb.getInt(9));
+            cs.setRightEnd(bb.getInt(13));
+            if (length > 17) {
+                cs.setLeftId(bb.getShort(17)); // left id
+                cs.setRightId(bb.getShort(19)); // right id
+                cs.setSpanId(bb.getShort(21)); // relation id
             }
         }
         else if (payloadTypeIdentifier == PayloadTypeIdentifier.ELEMENT_TO_TERM.value) { // length
             // 15
-            cs.setEnd(bb.getInt(1));
+            // 1-4 start element offset
+            // 5-8 end element offset
+            cs.setEnd(bb.getInt(9));
             cs.setLeftEnd(cs.end);
-            i = bb.getInt(5);
+            i = bb.getInt(13);
             cs.setRightStart(i);
             cs.setRightEnd(i + 1);
-            cs.setLeftId(bb.getShort(9)); // left id
-            cs.setRightId(bb.getShort(11)); // right id
             if (length > 13) {
-                cs.setSpanId(bb.getShort(13)); // relation id
+                cs.setLeftId(bb.getShort(17)); // left id
+                cs.setRightId(bb.getShort(19)); // right id
+                cs.setSpanId(bb.getShort(21)); // relation id
             }
         }
         else if (payloadTypeIdentifier == PayloadTypeIdentifier.ELEMENT_TO_ELEMENT.value) {
             // length 19
-            cs.setEnd(bb.getInt(1));
+
+            // 1-4 start left-element offset
+            // 5-8 end left-element offset
+            // 9-12 start right-element offset
+            // 13-16 end right-element offset
+
+            cs.setEnd(bb.getInt(17));
             cs.setLeftEnd(cs.end);
-            cs.setRightStart(bb.getInt(5));
-            cs.setRightEnd(bb.getInt(9));
-            cs.setLeftId(bb.getShort(13)); // left id
-            cs.setRightId(bb.getShort(15)); // right id
+            cs.setRightStart(bb.getInt(21));
+            cs.setRightEnd(bb.getInt(25));
             if (length > 17) {
-                cs.setSpanId(bb.getShort(17)); // relation id
+                cs.setLeftId(bb.getShort(29)); // left id
+                cs.setRightId(bb.getShort(31)); // right id
+                cs.setSpanId(bb.getShort(33)); // relation id
             }
         }
 
@@ -362,4 +372,28 @@
         this.rightEnd = rightEnd;
     }
 
+    public byte getTempSourceNum() {
+        return tempSourceNum;
+    }
+
+    public void setTempSourceNum(byte tempSourceNum) {
+        this.tempSourceNum = tempSourceNum;
+    }
+
+    public byte getTempTargetNum() {
+        return tempTargetNum;
+    }
+
+    public void setTempTargetNum(byte tempTargetNum) {
+        this.tempTargetNum = tempTargetNum;
+    }
+
+    public int getDirection() {
+        return direction;
+    }
+
+    public void setDirection(int direction) {
+        this.direction = direction;
+    }
+
 }
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestReferenceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestReferenceIndex.java
index a9d5534..73d77f5 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestReferenceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestReferenceIndex.java
@@ -247,14 +247,14 @@
                         + "<>:nn$<b>64<i>0<i>12<i>1<b>0<s>3|"
                         + "<>:np$<b>64<i>0<i>13<i>1<b>0<s>2|"
                         + "<>:s$<b>64<i>0<i>37<i>4<b>0<s>1|"
-                        + "<:stanford/d:tag$<b>32<i>1<s>3<s>1]"
+                        + "<:stanford/d:tag$<b>32<i>1<s>3<s>1<s>0]"
 
                         + "[(14-19)s:treat|_1$<i>14<i>19|"
                         + "<>:vb$<b>64<i>14<i>19<i>2<b>0<s>1|"
                         + "<>:vp$<b>64<i>14<i>36<i>4<b>0<s>2|"
-                        + ">:stanford/d:tag$<b>32<i>0<s>1<s>3|"
-                        + ">:stanford/d:tag$<b>32<i>3<s>1<s>1|"
-                        + ">:stanford/d:tag$<b>32<i>4<s>1<s>1]"
+                        + ">:stanford/d:tag$<b>32<i>0<s>1<s>3<s>0|"
+                        + ">:stanford/d:tag$<b>32<i>3<s>1<s>1<s>0|"
+                        + ">:stanford/d:tag$<b>32<i>4<s>1<s>1<s>0]"
 
                         + "[(20-22)s:my|_2$<i>20<i>22|"
                         + "<>:prp$<b>64<i>20<i>22<i>3<b>0<s>1|"
@@ -262,7 +262,7 @@
 
                         + "[(23-31)s:daughter|_3$<i>23<i>31|"
                         + "<>:nn$<b>64<i>23<i>31<i>4<b>0<s>1|"
-                        + ">:stanford/d:tag$<b>32<i>2<s>1<s>1]"
+                        + ">:stanford/d:tag$<b>32<i>2<s>1<s>1<s>0]"
 
                         + "[(32-36)s:well|_4$<i>32<i>36|"
                         + "<>:rb$<b>64<i>32<i>36<i>5<b>0<s>1|"
@@ -282,14 +282,14 @@
                         + "<>:nn$<b>64<i>0<i>12<i>1<b>0<s>3|"
                         + "<>:np$<b>64<i>0<i>13<i>1<b>0<s>2|"
                         + "<>:s$<b>64<i>0<i>37<i>5<b>0<s>1|"
-                        + "<:stanford/d:tag$<b>32<i>1<s>3<s>1]"
+                        + "<:stanford/d:tag$<b>32<i>1<s>3<s>1<s>0]"
 
                         + "[(14-19)s:treat|_1$<i>14<i>19|"
                         + "<>:vb$<b>64<i>14<i>19<i>2<b>0<s>1|"
                         + "<>:vp$<b>64<i>14<i>36<i>5<b>0<s>2|"
-                        + ">:stanford/d:tag$<b>32<i>0<s>1<s>2|"
-                        + ">:stanford/d:tag$<b>32<i>3<s>1<s>1|"
-                        + ">:stanford/d:tag$<b>32<i>4<s>1<s>1]"
+                        + ">:stanford/d:tag$<b>32<i>0<s>1<s>2<s>0|"
+                        + ">:stanford/d:tag$<b>32<i>3<s>1<s>1<s>0|"
+                        + ">:stanford/d:tag$<b>32<i>4<s>1<s>1<s>0]"
 
                         + "[(20-22)s:my|_2$<i>20<i>22|"
                         + "<>:prp$<b>64<i>20<i>22<i>3<b>0<s>1|"
@@ -297,7 +297,7 @@
 
                         + "[(23-31)s:daughter|_3$<i>23<i>31|"
                         + "<>:nn$<b>64<i>23<i>31<i>4<b>0<s>1|"
-                        + ">:stanford/d:tag$<b>32<i>2<s>21<s>1]"
+                        + ">:stanford/d:tag$<b>32<i>2<s>21<s>1<s>0]"
 
                         + "[(32-36)s:well|_4$<i>32<i>36|"
                         + "<>:rb$<b>64<i>32<i>36<i>5<b>0<s>1|"
@@ -319,10 +319,10 @@
 
                         + "[(49-52)s:one|_8$<i>49<i>52|"
                         + "<>:nn$<b>64<i>49<i>52<i>9<b>0<s>1|"
-                        + ">:stanford/d:tag$<b>32<i>5<s>1<s>3|"
-                        + ">:stanford/d:tag$<b>32<i>6<s>1<s>1|"
-                        + ">:stanford/d:tag$<b>32<i>7<s>1<s>3|"
-                        + ">:stanford/d:tag$<b>32<i>10<s>1<s>1]"
+                        + ">:stanford/d:tag$<b>32<i>5<s>1<s>3<s>0|"
+                        + ">:stanford/d:tag$<b>32<i>6<s>1<s>1<s>0|"
+                        + ">:stanford/d:tag$<b>32<i>7<s>1<s>3<s>0|"
+                        + ">:stanford/d:tag$<b>32<i>10<s>1<s>1<s>0]"
 
                         + "[(53-57)s:that|_9$<i>53<i>57|"
                         + "<>:rp$<b>64<i>53<i>57<i>10<b>0<s>1|"
@@ -332,9 +332,9 @@
                         + "<>:vb$<b>64<i>58<i>63<i>11<b>0<s>1|"
                         + "<>:s$<b>64<i>58<i>96<i>18<b>0<s>2|"
                         + "<>:vp$<b>64<i>58<i>96<i>18<b>0<s>3|"
-                        + ">:stanford/d:tag$<b>32<i>9<s>1<s>1|"
-                        + ">:stanford/d:tag$<b>32<i>12<s>1<s>1|"
-                        + ">:stanford/d:tag$<b>32<i>15<s>1<s>33]"
+                        + ">:stanford/d:tag$<b>32<i>9<s>1<s>1<s>0|"
+                        + ">:stanford/d:tag$<b>32<i>12<s>1<s>1<s>0|"
+                        + ">:stanford/d:tag$<b>32<i>15<s>1<s>33<s>0]"
 
                         + "[(64-68)s:your|_11$<i>64<i>68|"
                         + "<>:prp$<b>64<i>64<i>68<i>12<b>0<s>1|"
@@ -342,7 +342,7 @@
 
                         + "[(69-75)s:master|_12$<i>69<i>75|"
                         + "<>:nn$<b>64<i>69<i>75<i>13<b>0<s>1|"
-                        + ">:stanford/d:tag$<b>32<i>11<s>1<s>1]"
+                        + ">:stanford/d:tag$<b>32<i>11<s>1<s>1<s>0]"
 
                         + "[(76-79)s:who|_13$<i>76<i>79|"
                         + "<>:rp$<b>64<i>76<i>79<i>14<b>0<s>1|"
@@ -356,9 +356,9 @@
                         + "[(84-88)s:hold|_15$<i>84<i>88|"
                         + "<>:vb$<b>64<i>84<i>88<i>16<b>0<s>2|"
                         + "<>:vp$<b>64<i>84<i>96<i>18<b>0<s>1|"
-                        + ">:stanford/d:tag$<b>32<i>13<s>2<s>1|"
-                        + ">:stanford/d:tag$<b>32<i>14<s>2<s>3|"
-                        + ">:stanford/d:tag$<b>32<i>17<s>2<s>1]"
+                        + ">:stanford/d:tag$<b>32<i>13<s>2<s>1<s>0|"
+                        + ">:stanford/d:tag$<b>32<i>14<s>2<s>3<s>0|"
+                        + ">:stanford/d:tag$<b>32<i>17<s>2<s>1<s>0]"
 
                         + "[(89-91)s:so|_16$<i>89<i>91|"
                         + "<>:rb$<b>64<i>89<i>91<i>17<b>0<s>1|"
@@ -366,7 +366,7 @@
 
                         + "[(92-96)s:dear|_17$<i>92<i>96|"
                         + "<>:jj$<b>64<i>92<i>96<i>18<b>0<s>1|"
-                        + ">:stanford/d:tag$<b>32<i>16<s>1<s>1]");
+                        + ">:stanford/d:tag$<b>32<i>16<s>1<s>1<s>0]");
 
         return fd;
     }
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
index c63ac56..6db76be 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
@@ -18,6 +18,7 @@
 import de.ids_mannheim.korap.query.SpanRelationQuery;
 import de.ids_mannheim.korap.query.SpanTermWithIdQuery;
 import de.ids_mannheim.korap.query.SpanWithAttributeQuery;
+import de.ids_mannheim.korap.response.Match;
 import de.ids_mannheim.korap.response.Result;
 
 /*
@@ -76,20 +77,20 @@
                 "base",
                 "ceccecdeed",
                 "[(0-1)s:c$<s>1|_0$<i>0<i>1"
-                        + "|>:xip/syntax-dep_rel$<b>32<i>6<s>1<s>1]"
+                        + "|>:xip/syntax-dep_rel$<b>32<i>6<s>1<s>1<s>0]"
                         + "[(1-2)s:e$<s>1|_1$<i>1<i>2|"
-                        + "<:xip/syntax-dep_rel$<b>32<i>9<s>1<s>1|"
-                        + ">:xip/syntax-dep_rel$<b>32<i>4<s>1<s>1]"
+                        + "<:xip/syntax-dep_rel$<b>32<i>9<s>1<s>1<s>0|"
+                        + ">:xip/syntax-dep_rel$<b>32<i>4<s>1<s>1<s>0]"
                         + "[(2-3)s:c|_2$<i>2<i>3]"
-                        + "[(3-4)s:c$<s>1|s:b$<s>2|_3$<i>3<i>4|<:xip/syntax-dep_rel$<b>32<i>9<s>1<s>1]"
-                        + "[(4-5)s:e$<s>1|s:d$<s>2|_4$<i>4<i>5|<:xip/syntax-dep_rel$<b>32<i>1<s>1<s>1]"
+                        + "[(3-4)s:c$<s>1|s:b$<s>2|_3$<i>3<i>4|<:xip/syntax-dep_rel$<b>32<i>9<s>1<s>1<s>0]"
+                        + "[(4-5)s:e$<s>1|s:d$<s>2|_4$<i>4<i>5|<:xip/syntax-dep_rel$<b>32<i>1<s>1<s>1<s>0]"
                         + "[(5-6)s:c|_5$<i>5<i>6]"
-                        + "[(6-7)s:d$<s>1|_6$<i>6<i>7|<:xip/syntax-dep_rel$<b>32<i>1<s>1<s>1]"
+                        + "[(6-7)s:d$<s>1|_6$<i>6<i>7|<:xip/syntax-dep_rel$<b>32<i>1<s>1<s>1<s>0]"
                         + "[(7-8)s:e|_7$<i>7<i>8]"
                         + "[(8-9)s:e|s:b|_8$<i>8<i>9]"
                         + "[(9-10)s:d$<s>1|_9$<i>9<i>10|"
-                        + ">:xip/syntax-dep_rel$<b>32<i>1<s>1<s>1|"
-                        + ">:xip/syntax-dep_rel$<b>32<i>3<s>1<s>1]");
+                        + ">:xip/syntax-dep_rel$<b>32<i>1<s>1<s>1<s>0|"
+                        + ">:xip/syntax-dep_rel$<b>32<i>3<s>1<s>1<s>0]");
         return fd;
     }
 
@@ -101,8 +102,8 @@
                 "base",
                 "ceccecdeed",
                 "[(0-1)s:c$<s>2|<>:p$<b>64<i>0<i>3<i>3<b>0<s>1|_0$<i>0<i>1|"
-                        + ">:xip/syntax-dep_rel$<b>35<i>3<i>6<i>9<s>1<s>1<s>2|"
-                        + ">:xip/syntax-dep_rel$<b>33<i>6<i>9<s>2<s>1|"
+                        + ">:xip/syntax-dep_rel$<b>35<i>0<i>1<i>1<i>2<i>3<i>6<i>9<s>1<s>1<s>2|"
+                        + ">:xip/syntax-dep_rel$<b>33<i>1<i>2<i>6<i>9<s>2<s>1<s>0|"
                         + "@:func=subj$<b>18<s>2]"
                         + "[(1-2)s:e|_1$<i>1<i>2|<>:p$<b>64<i>1<i>3<i>3<b>0<s>1]"
                         + "[(2-3)s:c|_2$<i>2<i>3]"
@@ -110,13 +111,13 @@
                         + "[(4-5)s:e|s:d|_4$<i>4<i>5]"
                         + "[(5-6)s:c|_5$<i>5<i>6]"
                         + "[(6-7)s:d$<s>2|<>:p$<b>64<i>6<i>9<i>9<b>0<s>1|_6$<i>6<i>7|"
-                        + ">:xip/syntax-dep_rel$<b>34<i>9<i>9<s>1<s>1|"
-                        + "<:xip/syntax-dep_rel$<b>35<i>9<i>1<i>3<s>1<s>1<s>2|"
-                        + "<:xip/syntax-dep_rel$<b>34<i>9<i>1<s>1<s>2|"
+                        + ">:xip/syntax-dep_rel$<b>34<i>3<i>4<i>9<i>9<s>1<s>1<s>0|"
+                        + "<:xip/syntax-dep_rel$<b>35<i>3<i>4<i>4<i>5<i>9<i>1<i>3<s>1<s>1<s>2|"
+                        + "<:xip/syntax-dep_rel$<b>34<i>5<i>6<i>9<i>1<s>1<s>2<s>0|"
                         + "@:func=obj$<b>18<s>2]" + "[(7-8)s:e|_7$<i>7<i>8]"
                         + "[(8-9)s:e|s:b|_8$<i>8<i>9]"
                         + "[(9-10)s:d$<s>1|_9$<i>9<i>10|<"
-                        + ":xip/syntax-dep_rel$<b>33<i>6<i>9<s>2<s>1]");
+                        + ":xip/syntax-dep_rel$<b>33<i>6<i>7<i>6<i>9<s>2<s>1<s>0]");
         return fd;
     }
 
@@ -128,66 +129,66 @@
                 "base",
                 "Ich kaufe die Blümen für meine Mutter.",
                 "[(0-3)s:Ich|_0$<i>0<i>3|pos:NN$<s>1|<>:s$<b>64<i>0<i>38<i>7<b>0<s>2|<>:np$<b>64<i>0<i>3<i>1<b>0<s>3|"
-                        + ">:child-of$<b>33<i>0<i>7<s>3<s>2<s>4|"
-                        + ">:child-of$<b>33<i>0<i>1<s>1<s>3|"
-                        + "<:child-of$<b>32<i>0<s>3<s>1|"
-                        + "<:child-of$<b>35<i>7<i>0<i>1<s>2<s>3|"
-                        + "<:child-of$<b>35<i>7<i>1<i>7<s>2<s>2|"
-                        + "<:dep$<b>32<i>0<s>1<s>1|"
-                        + "@:func=sbj$<b>18<i>7<s>4]"
+                        + ">:child-of$<b>33<i>0<i>38<i>0<i>7<s>3<s>2<s>4|"
+                        + ">:child-of$<b>33<i>0<i>3<i>0<i>1<s>1<s>3<s>0|"
+                        + "<:child-of$<b>32<i>0<s>3<s>1<s>0|"
+                        + "<:child-of$<b>35<i>0<i>38<i>0<i>3<i>7<i>0<i>1<s>2<s>3<s>0|"
+                        + "<:child-of$<b>35<i>0<i>38<i>4<i>9<i>7<i>1<i>7<s>2<s>2<s>0|"
+                        + "<:dep$<b>32<i>0<s>1<s>1<s>0|"
+                        + "@:func=sbj$<b>18<i>7<s>4]" // attribute belongs to a relation
                         +
 
                         "[(1-2)s:kaufe|_1$<i>4<i>9|pos:V$<s>1|<>:vp$<b>64<i>4<i>38<i>7<b>0<s>2|"
-                        + ">:child-of$<b>35<i>7<i>0<i>7<s>2<s>2|"
-                        + ">:child-of$<b>33<i>1<i>7<s>2<s>7|"
-                        + "<:child-of$<b>34<i>7<i>2<s>2<s>1|"
-                        + "<:child-of$<b>35<i>7<i>2<i>7<s>2<s>4|"
-                        + ">:dep$<b>32<i>0<s>1<s>1|"
-                        + ">:dep$<b>32<i>3<s>1<s>1]"
+                        + ">:child-of$<b>35<i>4<i>38<i>0<i>38<i>7<i>0<i>7<s>2<s>2<s>0|"
+                        + ">:child-of$<b>33<i>4<i>9<i>1<i>7<s>2<s>7<s>0|"
+                        + "<:child-of$<b>34<i>4<i>38<i>7<i>2<s>2<s>1<s>0|"
+                        + "<:child-of$<b>35<i>4<i>38<i>10<i>38<i>7<i>2<i>7<s>2<s>4<s>0|"
+                        + ">:dep$<b>32<i>0<s>1<s>1<s>0|"
+                        + ">:dep$<b>32<i>3<s>1<s>1<s>0]"
                         +
 
                         "[(2-3)s:die|_2$<i>10<i>13|pos:ART$<s>1|tt:DET$<s>2|"
                         + "<>:np$<b>64<i>10<i>20<i>4<b>0<s>3|<>:np$<b>64<i>10<i>38<i>7<b>0<s>4|"
-                        + ">:child-of$<b>35<i>4<i>2<i>7<s>3<s>4|"
-                        + ">:child-of$<b>33<i>2<i>4<s>1<s>3|"
-                        + ">:child-of$<b>35<i>7<i>1<i>7<s>4<s>2|"
-                        + "<:child-of$<b>34<i>4<i>2<s>3<s>1|"
-                        + "<:child-of$<b>34<i>4<i>3<s>3<s>1|"
-                        + "<:child-of$<b>35<i>7<i>2<i>4<s>4<s>3|"
-                        + "<:child-of$<b>35<i>7<i>4<i>7<s>4<s>2|"
-                        + ">:parent-of$<b>35<i>7<i>4<i>7<s>4<s>2|"
+                        + ">:child-of$<b>35<i>10<i>24<i>10<i>38<i>4<i>2<i>7<s>3<s>4<s>0|"
+                        + ">:child-of$<b>33<i>10<i>24<i>2<i>4<s>1<s>3<s>0|"
+                        + ">:child-of$<b>35<i>10<i>38<i>4<i>38<i>7<i>1<i>7<s>4<s>2<s>0|"
+                        + "<:child-of$<b>34<i>10<i>24<i>4<i>2<s>3<s>1<s>0|"
+                        + "<:child-of$<b>34<i>10<i>24<i>4<i>3<s>3<s>1<s>0|"
+                        + "<:child-of$<b>35<i>10<i>38<i>10<i>24<i>7<i>2<i>4<s>4<s>3<s>0|"
+                        + "<:child-of$<b>35<i>10<i>38<i>21<i>38<i>7<i>4<i>7<s>4<s>2<s>0|"
+                        + ">:parent-of$<b>35<i>10<i>38<i>21<i>38<i>7<i>4<i>7<s>4<s>2<s>0|"
                         + "<:dep$<b>32<i>3<s>1<s>1<s>3|"
                         + "@:func=head$<b>18<i>4<s>3]"
 
                         + "[(3-4)s:Blümen|_3$<i>14<i>20|pos:NN$<s>1|"
-                        + ">:child-of$<b>33<i>2<i>4<s>1<s>3|"
-                        + "<:dep$<b>32<i>1<s>1<s>1|"
+                        + ">:child-of$<b>33<i>10<i>24<i>2<i>4<s>1<s>3<s>0|"
+                        + "<:dep$<b>32<i>1<s>1<s>1<s>0|"
                         + ">:dep$<b>32<i>2<s>1<s>1<s>2|"
-                        + ">:dep$<b>32<i>4<s>1<s>1|"
+                        + ">:dep$<b>32<i>4<s>1<s>1<s>0|"
                         + "@:func=obj$<b>18<i>4<s>2]"
 
 
                         + "[(4-5)s:für|_4$<i>21<i>24|pos:PREP$<s>1|<>:pp$<b>64<i>21<i>38<i>7<b>0<s>2|"
-                        + ">:child-of$<b>33<i>4<i>7<s>1<s>2|"
-                        + ">:child-of$<b>35<i>7<i>2<i>7<s>2<s>4|"
-                        + "<:child-of$<b>34<i>7<i>5<s>2<s>1|"
-                        + "<:child-of$<b>35<i>7<i>5<i>7<s>2<s>2|"
-                        + "<:dep$<b>32<i>3<s>1<s>1|"
-                        + ">:dep$<b>32<i>6<s>1<s>1]"
+                        + ">:child-of$<b>33<i>21<i>38<i>4<i>7<s>1<s>2<s>0|"
+                        + ">:child-of$<b>35<i>21<i>38<i>10<i>38<i>7<i>2<i>7<s>2<s>4<s>0|"
+                        + "<:child-of$<b>34<i>21<i>38<i>7<i>5<s>2<s>1<s>0|"
+                        + "<:child-of$<b>35<i>21<i>38<i>25<i>38<i>7<i>5<i>7<s>2<s>2<s>0|"
+                        + "<:dep$<b>32<i>3<s>1<s>1<s>0|"
+                        + ">:dep$<b>32<i>6<s>1<s>1<s>0]"
                         +
 
                         "[(5-6)s:meine|_5$<i>25<i>30|pos:ART$<s>1|<>:np$<b>64<i>25<i>38<i>7<b>0<s>2|"
-                        + ">:child-of$<b>33<i>5<i>7<s>1<s>2|"
-                        + ">:child-of$<b>35<i>7<i>4<i>7<s>2<s>2|"
-                        + "<:child-of$<b>34<i>7<i>5<s>2<s>1|"
-                        + "<:child-of$<b>34<i>7<i>6<s>2<s>1|"
-                        + "<:dep$<b>32<i>6<s>1<s>1<s>3|"
+                        + ">:child-of$<b>33<i>25<i>38<i>5<i>7<s>1<s>2<s>0|"
+                        + ">:child-of$<b>35<i>25<i>38<i>21<i>38<i>7<i>4<i>7<s>2<s>2<s>0|"
+                        + "<:child-of$<b>34<i>25<i>38<i>7<i>5<s>2<s>1<s>0|"
+                        + "<:child-of$<b>34<i>25<i>38<i>7<i>6<s>2<s>1<s>0|"
+                        + "<:dep$<b>32<i>6<s>1<s>1<s>3<s>0|"
                         + "@:func=head$<b>18<i>7<s>3]"
 
                         + "[(6-7)s:Mutter.|_6$<i>31<i>38|pos:NN$<s>1|"
-                        + ">:child-of$<b>33<i>5<i>7<s>1<s>2|"
-                        + ">:dep$<b>32<i>5<s>1<s>1|"
-                        + "<:dep$<b>32<i>4<s>1<s>1]");
+                        + ">:child-of$<b>33<i>25<i>38<i>5<i>7<s>1<s>2<s>0|"
+                        + ">:dep$<b>32<i>5<s>1<s>1<s>0|"
+                        + "<:dep$<b>32<i>4<s>1<s>1<s>0]");
 
 
         return fd;
@@ -316,15 +317,18 @@
         fq.setMatchTemporaryClass(true);
         fq.setRemoveTemporaryClasses(true);
         fq.setSorted(false);
-
+        // kr = ki.search(fq, (short) 20);
+        // for (Match m : kr.getMatches()) {
+        // System.out.println(m.getStartPos() + " " + m.getEndPos());
+        // }
+        
         SpanAttributeQuery saq = new SpanAttributeQuery(new SpanTermQuery(
                 new Term("base", "@:func=sbj")), true);
-
-        kr = ki.search(saq, (short) 20);
+        // kr = ki.search(saq, (short) 20);
 
         // child-of with attr func=sbj
         SpanWithAttributeQuery wq;
-        // wq = new SpanWithAttributeQuery(fq, saq, true);
+        wq = new SpanWithAttributeQuery(fq, saq, true);
         // kr = ki.search(wq, (short) 20);
         // assertEquals((long) 1, kr.getTotalResults());
         // assertEquals(0, kr.getMatch(0).getStartPos()); // token