Added payload type identifiers to relation spans.
Change-Id: I2392058aafdd17a139d7c06b0ce9080c577a01ad
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
index 1a93456..6ec374e 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
@@ -45,10 +45,10 @@
// ELEMENT_WITH_TUI_AND_CERTAINTY_VALUE (67),
MILESTONE(65);
- private int value;
+ private byte value;
- private PayloadTypeIdentifier(int value) {
- this.value = value;
+ private PayloadTypeIdentifier (int value) {
+ this.value = (byte) value;
}
}
@@ -125,8 +125,6 @@
return;
}
-
-
if (!payload.isEmpty()) {
// Get payload one by one
final int length = payload.get(0).length;
@@ -147,8 +145,8 @@
// FIX ME
// Copy the start and end character offsets
- b = Arrays.copyOfRange(bb.array(), 1, 9);
- this.matchPayload = Collections.singletonList(b);
+ b = Arrays.copyOfRange(bb.array(), 1, 9);
+ this.matchPayload = Collections.singletonList(b);
return;
}
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 fcc8645..02d9656 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
@@ -10,7 +10,6 @@
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermContext;
-import org.apache.lucene.search.spans.Spans;
import org.apache.lucene.search.spans.TermSpans;
import org.apache.lucene.util.Bits;
import org.slf4j.Logger;
@@ -57,10 +56,20 @@
private TermSpans relationTermSpan;
protected Logger logger = LoggerFactory.getLogger(RelationSpans.class);
- private List<CandidateRelationSpan> candidateList;
+ private List<CandidateSpan> candidateList;
private byte tempSourceNum, tempTargetNum;
private byte sourceClass, targetClass;
+ public static enum PayloadTypeIdentifier {
+ TERM_TO_TERM(32), TERM_TO_ELEMENT(33), ELEMENT_TO_TERM(34), ELEMENT_TO_ELEMENT(
+ 35);
+
+ private byte value;
+
+ private PayloadTypeIdentifier (int value) {
+ this.value = (byte) value;
+ }
+ }
/**
* Constructs RelationSpans from the given
@@ -112,7 +121,7 @@
private boolean advance () throws IOException {
while (hasMoreSpans || !candidateList.isEmpty()) {
if (!candidateList.isEmpty()) {
- CandidateRelationSpan cs = candidateList.get(0);
+ CandidateSpan cs = candidateList.get(0);
this.matchDocNumber = cs.getDoc();
this.matchStartPosition = cs.getStart();
this.matchEndPosition = cs.getEnd();
@@ -146,7 +155,8 @@
private void setCandidateList () throws IOException {
while (hasMoreSpans && relationTermSpan.doc() == currentDoc
&& relationTermSpan.start() == currentPosition) {
- CandidateRelationSpan cs = new CandidateRelationSpan(
+
+ CandidateSpan cs = new CandidateSpan(
relationTermSpan);
readPayload(cs);
setPayload(cs);
@@ -167,7 +177,7 @@
* @param cs
* a CandidateRelationSpan
*/
- private void readPayload (CandidateRelationSpan cs) {
+ private void readPayload(CandidateSpan cs) {
List<byte[]> payload = (List<byte[]>) cs.getPayloads();
int length = payload.get(0).length;
ByteBuffer bb = ByteBuffer.allocate(length);
@@ -176,34 +186,33 @@
cs.setLeftStart(cs.start);
int i;
- switch (length) {
- case 10: // Token to token
- i = bb.getInt(0);
- cs.setLeftEnd(cs.start + 1);
- cs.setRightStart(i);
- cs.setRightEnd(i + 1);
- break;
-
- case 14: // Token to span
- cs.setLeftEnd(cs.start + 1);
- cs.setRightStart(bb.getInt(0));
- cs.setRightEnd(bb.getInt(4));
- break;
-
- case 15: // Span to token
- cs.setEnd(bb.getInt(0));
- cs.setLeftEnd(cs.end);
- i = bb.getInt(5);
- cs.setRightStart(i);
- cs.setRightEnd(i + 1);
- break;
-
- case 18: // Span to span
- cs.setEnd(bb.getInt(0));
- cs.setLeftEnd(cs.end);
- cs.setRightStart(bb.getInt(4));
- cs.setRightEnd(bb.getInt(8));
- break;
+ this.payloadTypeIdentifier = bb.get(0);
+
+ if (payloadTypeIdentifier == PayloadTypeIdentifier.TERM_TO_TERM.value){ // length 11
+ i = bb.getInt(1);
+ cs.setLeftEnd(cs.start + 1);
+ cs.setRightStart(i);
+ cs.setRightEnd(i + 1);
+ }
+ 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));
+ }
+ else if (payloadTypeIdentifier == PayloadTypeIdentifier.ELEMENT_TO_TERM.value) { // length
+ // 15
+ cs.setEnd(bb.getInt(1));
+ cs.setLeftEnd(cs.end);
+ i = bb.getInt(5);
+ cs.setRightStart(i);
+ cs.setRightEnd(i + 1);
+ }
+ else if (payloadTypeIdentifier == PayloadTypeIdentifier.ELEMENT_TO_ELEMENT.value) {
+ cs.setEnd(bb.getInt(1));
+ cs.setLeftEnd(cs.end);
+ cs.setRightStart(bb.getInt(5));
+ cs.setRightEnd(bb.getInt(9));
}
cs.setRightId(bb.getShort(length - 2)); //right id
@@ -213,7 +222,7 @@
}
- private void setPayload (CandidateRelationSpan cs) throws IOException {
+ private void setPayload(CandidateSpan cs) throws IOException {
ArrayList<byte[]> payload = new ArrayList<byte[]>();
if (relationTermSpan.isPayloadAvailable()) {
payload.addAll(relationTermSpan.getPayload());
@@ -331,63 +340,4 @@
this.rightEnd = rightEnd;
}
- /**
- * CandidateRelationSpan stores a state of RelationSpans. In a
- * list,
- * CandidateRelationSpans are ordered first by the position of the
- * relation
- * left side.
- */
- class CandidateRelationSpan extends CandidateSpan {
-
- private int rightStart, rightEnd;
- private short leftId, rightId;
-
-
- public CandidateRelationSpan (Spans span) throws IOException {
- super(span);
- }
-
-
- public int getRightEnd () {
- return rightEnd;
- }
-
-
- public void setRightEnd (int rightEnd) {
- this.rightEnd = rightEnd;
- }
-
-
- public int getRightStart () {
- return rightStart;
- }
-
-
- public void setRightStart (int rightStart) {
- this.rightStart = rightStart;
- }
-
-
- public short getLeftId () {
- return leftId;
- }
-
-
- public void setLeftId (short leftId) {
- this.leftId = leftId;
- }
-
-
- public short getRightId () {
- return rightId;
- }
-
-
- public void setRightId (short rightId) {
- this.rightId = rightId;
- }
-
- }
-
}
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 995f32d..687ef5f 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestReferenceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestReferenceIndex.java
@@ -245,20 +245,22 @@
"[(0-12)s:Frankenstein|_0$<i>0<i>12|<>:nn$<b>64<i>0<i>12<i>1<b>0<s>18|"
+ "<>:s$<b>64<i>0<i>37<i>4<b>0<s>1|"
+ "<>:np$<b>64<i>0<i>13<i>1<b>0<s>2|"
- + "<:stanford/d:tag$<i>1<s>1<s>18<s>19]"
+ + "<:stanford/d:tag$<b>32<i>1<s>1<s>18<s>19]"
+ "[(14-19)s:treat|_1$<i>14<i>19|<>:vb$<b>64<i>14<i>19<i>2<b>0<s>19|"
+ "<>:vp$<b>64<i>14<i>36<i>4<b>0<s>3|"
- + ">:stanford/d:tag$<i>0<s>2<s>19<s>18|"
- + ">:stanford/d:tag$<i>3<s>3<s>19<s>21|"
- + ">:stanford/d:tag$<i>4<s>4<s>19<s>22]"
+ + ">:stanford/d:tag$<b>32<i>0<s>2<s>19<s>18|"
+ + ">:stanford/d:tag$<b>32<i>3<s>3<s>19<s>21|"
+ + ">:stanford/d:tag$<b>32<i>4<s>4<s>19<s>22]"
- + "[(20-22)s:my|_2$<i>20<i>22|<>:prp$<b>64<i>20<i>22<i>3<s>20|<>:np$<b>64<i>20<i>31<i>3<s>4]"
+ + "[(20-22)s:my|_2$<i>20<i>22|<>:prp$<b>64<i>20<i>22<i>3<b>0<s>20|"
+ + "<>:np$<b>64<i>20<i>31<i>3<b>0<s>4]"
- + "[(23-31)s:daughter|_3$<i>23<i>31|<>:nn$<b>64<i>23<i>31<i>4<s>21|"
- + ">:stanford/d:tag$<i>2<s>5<s>21<s>20]"
+ + "[(23-31)s:daughter|_3$<i>23<i>31|<>:nn$<b>64<i>23<i>31<i>4<b>0<s>21|"
+ + ">:stanford/d:tag$<b>32<i>2<s>5<s>21<s>20]"
- + "[(32-36)s:well|_4$<i>32<i>36|<>:rb$<b>64<i>32<i>36<i>5<s>22|<>:advp$<b>64<i>32<i>36<i>4<s>5]");
+ + "[(32-36)s:well|_4$<i>32<i>36|<>:rb$<b>64<i>32<i>36<i>5<b>0<s>22|"
+ + "<>:advp$<b>64<i>32<i>36<i>4<b>0<s>5]");
return fd;
}
@@ -273,20 +275,24 @@
"[(0-12)s:Frankenstein|_0$<i>0<i>12|<>:nn$<b>64<i>0<i>12<i>1<b>0<s>18|"
+ "<>:s$<b>64<i>0<i>37<i>5<b>0<s>1|"
+ "<>:np$<b>64<i>0<i>13<i>1<b>0<s>2|"
- + "<:stanford/d:tag$<i>1<s>1<s>18<s>19]"
+ + "<:stanford/d:tag$<b>32<i>1<s>1<s>18<s>19]"
+ "[(14-19)s:treat|_1$<i>14<i>19|<>:vb$<b>64<i>14<i>19<i>2<b>0<s>19|"
+ "<>:vp$<b>64<i>14<i>36<i>5<b>0<s>3|"
- + ">:stanford/d:tag$<i>0<s>2<s>19<s>18|"
- + ">:stanford/d:tag$<i>3<s>3<s>19<s>21|"
- + ">:stanford/d:tag$<i>4<s>4<s>19<s>22]"
+ + ">:stanford/d:tag$<b>32<i>0<s>2<s>19<s>18|"
+ + ">:stanford/d:tag$<b>32<i>3<s>3<s>19<s>21|"
+ + ">:stanford/d:tag$<b>32<i>4<s>4<s>19<s>22]"
- + "[(20-22)s:my|_2$<i>20<i>22|<>:prp$<b>64<i>20<i>22<i>3<b>0<s>20|<>:np$<b>64<i>20<i>31<i>4<b>0<s>4]"
+ + "[(20-22)s:my|_2$<i>20<i>22|"
+ + "<>:prp$<b>64<i>20<i>22<i>3<b>0<s>20|"
+ + "<>:np$<b>64<i>20<i>31<i>4<b>0<s>4]"
+ "[(23-31)s:daughter|_3$<i>23<i>31|<>:nn$<b>64<i>23<i>31<i>4<b>0<s>21|"
- + ">:stanford/d:tag$<i>2<s>5<s>21<s>20]"
+ + ">:stanford/d:tag$<b>32<i>2<s>5<s>21<s>20]"
- + "[(32-36)s:well|_4$<i>32<i>36|<>:rb$<b>64<i>32<i>36<i>5<b>0<s>22|<>:advp$<b>64<i>32<i>36<i>5<b>0<s>5]"
+ + "[(32-36)s:well|_4$<i>32<i>36|"
+ + "<>:rb$<b>64<i>32<i>36<i>5<b>0<s>22|"
+ + "<>:advp$<b>64<i>32<i>36<i>5<b>0<s>5]"
+ "[(38-41)s:She|_5$<i>38<i>41|<>:prp$<b>64<i>38<i>41<i>6<b>0<s>23|"
+ "<>:np$<b>64<i>38<i>41<i>6<b>0<s>36|"
@@ -299,10 +305,10 @@
+ "<>:np$<b>64<i>45<i>96<i>18<b>0<s>9]"
+ "[(49-52)s:one|_8$<i>49<i>52|<>:nn$<b>64<i>49<i>52<i>9<b>0<s>26|"
- + ">:stanford/d:tag$<i>5<s>6<s>26<s>23|"
- + ">:stanford/d:tag$<i>6<s>7<s>26<s>24|"
- + ">:stanford/d:tag$<i>7<s>8<s>26<s>25|"
- + ">:stanford/d:tag$<i>10<s>9<s>26<s>28]"
+ + ">:stanford/d:tag$<b>32<i>5<s>6<s>26<s>23|"
+ + ">:stanford/d:tag$<b>32<i>6<s>7<s>26<s>24|"
+ + ">:stanford/d:tag$<b>32<i>7<s>8<s>26<s>25|"
+ + ">:stanford/d:tag$<b>32<i>10<s>9<s>26<s>28]"
+ "[(53-57)s:that|_9$<i>53<i>57|<>:rp$<b>64<i>53<i>57<i>10<b>0<s>27|"
+ "<>:sb$<b>64<i>53<i>96<i>18<b>0<s>10]"
@@ -310,15 +316,15 @@
+ "[(58-63)s:saved|_10$<i>58<i>63|<>:vb$<b>64<i>58<i>63<i>11<b>0<s>28|"
+ "<>:s$<b>64<i>58<i>96<i>18<b>0<s>11|"
+ "<>:vp$<b>64<i>58<i>96<i>18<b>0<s>12|"
- + ">:stanford/d:tag$<i>9<s>10<s>28<s>27|"
- + ">:stanford/d:tag$<i>12<s>11<s>28<s>30|"
- + ">:stanford/d:tag$<i>15<s>12<s>28<s>33]"
+ + ">:stanford/d:tag$<b>32<i>9<s>10<s>28<s>27|"
+ + ">:stanford/d:tag$<b>32<i>12<s>11<s>28<s>30|"
+ + ">:stanford/d:tag$<b>32<i>15<s>12<s>28<s>33]"
+ "[(64-68)s:your|_11$<i>64<i>68|<>:prp$<b>64<i>64<i>68<i>12<b>0<s>29|"
+ "<>:np$<b>64<i>64<i>75<i>13<b>0<s>13]"
+ "[(69-75)s:master|_12$<i>69<i>75|<>:nn$<b>64<i>69<i>75<i>13<b>0<s>30|"
- + ">:stanford/d:tag$<i>11<s>13<s>30<s>29]"
+ + ">:stanford/d:tag$<b>32<i>11<s>13<s>30<s>29]"
+ "[(76-79)s:who|_13$<i>76<i>79|<>:rp$<b>64<i>76<i>79<i>14<b>0<s>31|"
+ "<>:sb$<b>64<i>76<i>96<i>18<b>0<s>14]"
@@ -329,15 +335,15 @@
+ "[(84-88)s:hold|_15$<i>84<i>88|<>:vb$<b>64<i>84<i>88<i>16<b>0<s>33|"
+ "<>:vp$<b>64<i>84<i>96<i>18<b>0<s>16|"
- + ">:stanford/d:tag$<i>13<s>14<s>33<s>31|"
- + ">:stanford/d:tag$<i>14<s>15<s>33<s>32|"
- + ">:stanford/d:tag$<i>17<s>16<s>33<s>35]"
+ + ">:stanford/d:tag$<b>32<i>13<s>14<s>33<s>31|"
+ + ">:stanford/d:tag$<b>32<i>14<s>15<s>33<s>32|"
+ + ">:stanford/d:tag$<b>32<i>17<s>16<s>33<s>35]"
+ "[(89-91)s:so|_16$<i>89<i>91|<>:rb$<b>64<i>89<i>91<i>17<b>0<s>341|"
+ "<>:adjp$<b>64<i>89<i>96<i>18<b>0<s>17]"
+ "[(92-96)s:dear|_17$<i>92<i>96|<>:jj$<b>64<i>92<i>96<i>18<b>0<s>35|"
- + ">:stanford/d:tag$<i>16<s>17<s>35<s>34]");
+ + ">:stanford/d:tag$<b>32<i>16<s>17<s>35<s>34]");
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 22cbc67..07b8e50 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
@@ -75,16 +75,19 @@
fd.addTV(
"base",
"ceccecdeed",
- "[(0-1)s:c$<s>1|_0#0-1|>:xip/syntax-dep_rel$<i>6<s>1<s>1<s>1]"
- + "[(1-2)s:e$<s>1|_1#1-2|<:xip/syntax-dep_rel$<i>9<s>1<s>1<s>1|>:xip/syntax-dep_rel$<i>4<s>1<s>1<s>1]"
- + "[(2-3)s:c|_2#2-3]"
- + "[(3-4)s:c$<s>1|s:b$<s>2|_3#3-4|<:xip/syntax-dep_rel$<i>9<s>1<s>1<s>1]"
- + "[(4-5)s:e$<s>1|s:d$<s>2|_4#4-5|<:xip/syntax-dep_rel$<i>1<s>1<s>1<s>1]"
- + "[(5-6)s:c|_5#5-6]"
- + "[(6-7)s:d$<s>1|_6#6-7|<:xip/syntax-dep_rel$<i>1<s>1<s>1<s>1]"
- + "[(7-8)s:e|_7#7-8]"
- + "[(8-9)s:e|s:b|_8#8-9]"
- + "[(9-10)s:d$<s>1|_9#9-10|>:xip/syntax-dep_rel$<i>1<s>2<s>1<s>1|>:xip/syntax-dep_rel$<i>3<s>1<s>1<s>1]");
+ "[(0-1)s:c$<s>1|_0$<i>0<i>1"
+ + "|>:xip/syntax-dep_rel$<b>32<i>6<s>1<s>1<s>1]"
+ + "[(1-2)s:e$<s>1|_1$<i>1<i>2|"
+ + "<:xip/syntax-dep_rel$<b>32<i>9<s>1<s>1<s>1|"
+ + ">:xip/syntax-dep_rel$<b>32<i>4<s>1<s>1<s>1]"
+ + "[(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<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<s>1]"
+ + "[(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<s>1]"
+ + "[(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>2<s>1<s>1|>:xip/syntax-dep_rel$<b>32<i>3<s>1<s>1<s>1]");
return fd;
}
@@ -95,23 +98,23 @@
fd.addTV(
"base",
"ceccecdeed",
- "[(0-1)s:c$<s>2|<>:p#0-3$<i>3<s>1|_0#0-1|"
- + ">:xip/syntax-dep_rel$<i>3<i>6<i>9<s>2<s>1<s>1|"
- + ">:xip/syntax-dep_rel$<i>6<i>9<s>1<s>2<s>1|"
- + "r@:func=subj$<s>2]"
- + "[(1-2)s:e|_1#1-2|<>:p#1-3$<i>3<s>1]"
- + "[(2-3)s:c|_2#2-3]"
- + "[(3-4)s:c|s:b|_3#3-4]"
- + "[(4-5)s:e|s:d|_4#4-5]"
- + "[(5-6)s:c|_5#5-6]"
- + "[(6-7)s:d$<s>2|<>:p#6-9$<i>9<s>1|_6#6-7|"
- + "<:xip/syntax-dep_rel$<i>9<b>0<i>1<s>1<s>1<s>2|"
- + ">:xip/syntax-dep_rel$<i>9<b>0<i>9<s>3<s>1<s>1|"
- + "<:xip/syntax-dep_rel$<i>9<i>1<i>3<s>2<s>1<s>1|"
- + "r@:func=obj$<s>2]"
- + "[(7-8)s:e|_7#7-8]"
- + "[(8-9)s:e|s:b|_8#8-9]"
- + "[(9-10)s:d$<s>1|_9#9-10|<:xip/syntax-dep_rel$<i>6<i>9<s>2<s>1<s>1]");
+ "[(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>2<s>1<s>1|"
+ + ">:xip/syntax-dep_rel$<b>33<i>6<i>9<s>1<s>2<s>1|"
+ + "@: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]"
+ + "[(3-4)s:c|s:b|_3$<i>3<i>4]"
+ + "[(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>1<s>1<s>1<s>2|"
+ + ">:xip/syntax-dep_rel$<b>34<i>9<i>9<s>3<s>1<s>1|"
+ + "<:xip/syntax-dep_rel$<b>35<i>9<i>1<i>3<s>2<s>1<s>1|"
+ + "@: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<s>1]");
return fd;
}
@@ -122,62 +125,67 @@
fd.addTV(
"base",
"Ich kaufe die Blümen für meine Mutter.",
- "[(0-3)s:Ich|_0#0-3|pos:NN$<s>1|<>:s#0-38$<i>7<s>2|<>:np#0-3$<i>1<s>3|"
- + ">:child-of$<i>0<i>7<s>1<s>3<s>2|"
- + ">:child-of$<i>0<i>1<s>2<s>1<s>3|"
- + "<:child-of$<i>0<s>3<s>3<s>1|"
- + "<:child-of$<i>7<i>0<i>1<s>4<s>2<s>3|"
- + "<:child-of$<i>7<i>1<i>7<s>5<s>2<s>2|"
- + "<:dep$<i>0<s>2<s>1<s>1|"
- + "r@:func=sbj$<i>0<i>7<s>1]"
+ "[(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>4<s>3<s>2|"
+ + ">:child-of$<b>33<i>0<i>1<s>5<s>1<s>3|"
+ + "<:child-of$<b>32<i>0<s>6<s>3<s>1|"
+ + "<:child-of$<b>35<i>7<i>0<i>1<s>7<s>2<s>3|"
+ + "<:child-of$<b>35<i>7<i>1<i>7<s>8<s>2<s>2|"
+ + "<:dep$<b>32<i>0<s>9<s>1<s>1|"
+ + "@:func=sbj$<b>18<i>7<s>4]"
+
- "[(1-2)s:kaufe|_1#4-9|pos:V$<s>1|<>:vp#4-38$<i>7<s>2|"
- + ">:child-of$<i>7<i>0<i>7<s>6<s>2<s>2|"
- + ">:child-of$<i>1<i>7<s>2<s>7<s>2|"
- + "<:child-of$<i>7<b>0<i>2<s>8<s>2<s>1|"
- + "<:child-of$<i>7<i>2<i>7<s>9<s>2<s>4|"
- + ">:dep$<i>0<s>3<s>1<s>1|"
- + ">:dep$<i>3<s>4<s>1<s>1]"
+ "[(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>6<s>2<s>2|"
+ + ">:child-of$<b>33<i>1<i>7<s>2<s>7<s>2|"
+ + "<:child-of$<b>34<i>7<i>2<s>8<s>2<s>1|"
+ + "<:child-of$<b>35<i>7<i>2<i>7<s>9<s>2<s>4|"
+ + ">:dep$<b>32<i>0<s>3<s>1<s>1|"
+ + ">:dep$<b>32<i>3<s>4<s>1<s>1]"
+
- "[(2-3)s:die|_2#10-13|pos:ART$<s>1|tt:DET$<s>2|<>:np#10-20$<i>4<s>3|<>:np#10-38$<i>7<s>4|"
- + ">:child-of$<i>4<i>2<i>7<s>10<s>3<s>4|"
- + ">:child-of$<i>2<i>4<s>11<s>1<s>3|"
- + ">:child-of$<i>7<i>1<i>7<s>12<s>4<s>2|"
- + "<:child-of$<i>4<b>0<i>2<s>13<s>3<s>1|"
- + "<:child-of$<i>4<b>0<i>3<s>14<s>3<s>1|"
- + "<:child-of$<i>7<i>2<i>4<s>15<s>4<s>3|"
- + "<:child-of$<i>7<i>4<i>7<s>16<s>4<s>2|"
- + ">:parent-of$<i>7<i>4<i>7<s>17<s>4<s>2|"
- + "<:dep$<i>3<s>3<s>1<s>1]" +
+ "[(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>10<s>3<s>4|"
+ + ">:child-of$<b>33<i>2<i>4<s>11<s>1<s>3|"
+ + ">:child-of$<b>35<i>7<i>1<i>7<s>12<s>4<s>2|"
+ + "<:child-of$<b>34<i>4<i>2<s>13<s>3<s>1|"
+ + "<:child-of$<b>34<i>4<i>3<s>14<s>3<s>1|"
+ + "<:child-of$<b>35<i>7<i>2<i>4<s>15<s>4<s>3|"
+ + "<:child-of$<b>35<i>7<i>4<i>7<s>16<s>4<s>2|"
+ + ">:parent-of$<b>35<i>7<i>4<i>7<s>17<s>4<s>2|"
+ + "<:dep$<b>32<i>3<s>3<s>1<s>1|"
+ + "@:func=head$<b>18<i>4<s>3]"
- "[(3-4)s:Blümen|_3#14-20|pos:NN$<s>1|"
- + ">:child-of$<i>2<i>4<s>17<s>1<s>3|"
- + "<:dep$<i>1<s>2<s>1<s>1|" + ">:dep$<i>2<s>3<s>1<s>1|"
- + ">:dep$<i>4<s>4<s>1<s>1|"
- + "r@:func=head$<i>2<i>4<s>3|"
- + "r@:func=obj$<i>2<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>17<s>1<s>3|"
+ + "<:dep$<b>32<i>1<s>2<s>1<s>1|"
+ + ">:dep$<b>32<i>2<s>3<s>1<s>1|"
+ + ">:dep$<b>32<i>4<s>4<s>1<s>1|"
+ + "@:func=obj$<b>18<i>4<s>3]"
- "[(4-5)s:für|_4#21-24|pos:PREP$<s>1|<>:pp#21-38$<i>7<s>2|"
- + ">:child-of$<i>4<i>7<s>18<s>1<s>2|"
- + ">:child-of$<i>7<i>2<i>7<s>19<s>2<s>4|"
- + "<:child-of$<i>7<b>0<i>5<s>20<s>2<s>1|"
- + "<:child-of$<i>7<i>5<i>7<s>21<s>2<s>2|"
- + "<:dep$<i>3<s>1<s>1<s>1|" + ">:dep$<i>6<s>3<s>1<s>1]"
+
+ + "[(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>18<s>1<s>2|"
+ + ">:child-of$<b>35<i>7<i>2<i>7<s>19<s>2<s>4|"
+ + "<:child-of$<b>34<i>7<i>5<s>20<s>2<s>1|"
+ + "<:child-of$<b>35<i>7<i>5<i>7<s>21<s>2<s>2|"
+ + "<:dep$<b>32<i>3<s>1<s>1<s>1|"
+ + ">:dep$<b>32<i>6<s>3<s>1<s>1]"
+
- "[(5-6)s:meine|_5#25-30|pos:ART$<s>1|<>:np#25-38$<i>7<s>2|"
- + ">:child-of$<i>5<i>7<s>22<s>1<s>2|"
- + ">:child-of$<i>7<i>4<i>7<s>23<s>2<s>2|"
- + "<:child-of$<i>7<b>0<i>5<s>24<s>2<s>1|"
- + "<:child-of$<i>7<b>0<i>6<s>25<s>2<s>1|"
- + "<:dep$<i>6<s>3<s>1<s>1]" +
-
- "[(6-7)s:Mutter.|_6#31-38|pos:NN$<s>1|"
- + ">:child-of$<i>5<i>7<s>26<s>1<s>2|"
- + ">:dep$<i>5<s>2<s>1<s>1|" + "<:dep$<i>4<s>3<s>1<s>1|"
- + "r@:func=head$<i>5<i>7<s>3]");
+ "[(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>22<s>1<s>2|"
+ + ">:child-of$<b>35<i>7<i>4<i>7<s>23<s>2<s>2|"
+ + "<:child-of$<b>34<i>7<i>5<s>24<s>2<s>1|"
+ + "<:child-of$<b>34<i>7<i>6<s>25<s>2<s>1|"
+ + "<:dep$<b>32<i>6<s>3<s>1<s>1|"
+ + "@: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>26<s>1<s>2|"
+ + ">:dep$<b>32<i>5<s>2<s>1<s>1|"
+ + "<:dep$<b>32<i>4<s>3<s>1<s>1]");
+
return fd;
}
@@ -197,6 +205,7 @@
kr = ki.search(sq, (short) 10);
assertEquals((long) 7, kr.getTotalResults());
+
// token to token
assertEquals(0, kr.getMatch(0).getLocalDocID());
assertEquals(0, kr.getMatch(0).getStartPos());
@@ -306,10 +315,13 @@
fq.setRemoveTemporaryClasses(true);
fq.setSorted(false);
+ SpanAttributeQuery saq = new SpanAttributeQuery(new SpanTermQuery(
+ new Term("base", "@:func=sbj")), true);
+
+ kr = ki.search(saq, (short) 20);
+
// child-of with attr func=sbj
- SpanWithAttributeQuery wq = new SpanWithAttributeQuery(fq,
- new SpanAttributeQuery(new SpanTermQuery(new Term("base",
- "r@:func=sbj")), true), true);
+ SpanWithAttributeQuery wq = new SpanWithAttributeQuery(fq, saq, true);
kr = ki.search(wq, (short) 20);
assertEquals((long) 1, kr.getTotalResults());
@@ -319,7 +331,8 @@
// child-of without attr func=sbj
wq = new SpanWithAttributeQuery(fq,
new SpanAttributeQuery(new SpanTermQuery(new Term("base",
- "r@:func=sbj")), true, true), true);
+ "@:func=sbj")), true, true),
+ true);
kr = ki.search(wq, (short) 20);
assertEquals((long) 12, kr.getTotalResults());
}
@@ -407,19 +420,13 @@
kr = ki.search(fq, (short) 10);
assertEquals((long) 6, kr.getTotalResults());
- // for (Match km : kr.getMatches()) {
- // System.out.println(km.getStartPos() + "," + km.getEndPos()
- // + " "
- // + km.getSnippetBrackets());
- // }
+
SpanAttributeQuery aq = new SpanAttributeQuery(new SpanTermQuery(
- new Term("base", "r@:func=head")), true);
+ new Term("base", "@:func=head")), true);
kr = ki.search(aq, (short) 10);
// dependency relation, which is also a head
- SpanWithAttributeQuery wq = new SpanWithAttributeQuery(fq,
- new SpanAttributeQuery(new SpanTermQuery(new Term("base",
- "r@:func=head")), true), true);
+ SpanWithAttributeQuery wq = new SpanWithAttributeQuery(fq, aq, true);
kr = ki.search(wq, (short) 20);