support empty tokens
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/AqlTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/AqlTree.java
index b20bfee..747b52f 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/AqlTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/AqlTree.java
@@ -198,9 +198,11 @@
object = makeSpan();
} else if (firstChildNodeCat.equals("tok")) {
object = makeToken();
- LinkedHashMap<String, Object> term = makeTerm();
- term.put("layer", "orth");
- object.put("wrap", term);
+ if (node.getChildCount() > 1) { // empty tokens do not wrap a term
+ LinkedHashMap<String, Object> term = makeTerm();
+ term.put("layer", "orth");
+ object.put("wrap", term);
+ }
} else if (firstChildNodeCat.equals("qName")) { // only (foundry/)?layer specified
// may be token or span, depending on indicated layer! (e.g. cnx/cat=NP or mate/pos=NN)
HashMap<String, Object> qNameParse = parseQNameNode(node.getChild(0));
@@ -729,6 +731,7 @@
// "cat=\"NP\" > cat=\"VP\" & #1 _l_ #2",
// "cat=\"NP\" > cat=\"VP\" & #1 . tok=\"foo\"",
"cat=\"NP\" & cat=\"VP\" & #1 > #2 & #1 _l_ #2",
+ "tok"
};
// AqlTree.verbose=true;
for (String q : queries) {
diff --git a/src/test/java/AqlTreeTest.java b/src/test/java/AqlTreeTest.java
index 0cf0564..b3ad0fc 100644
--- a/src/test/java/AqlTreeTest.java
+++ b/src/test/java/AqlTreeTest.java
@@ -41,6 +41,11 @@
query = "Mann";
String token4 = "{@type=korap:span, layer=Mann}";
assertTrue(equalsQueryContent(token4, query));
+
+ // tok
+ query = "tok";
+ String token5 = "{@type=korap:token}";
+ assertTrue(equalsQueryContent(token5, query));
}
@Test