Fix reference bug in Annis (Fixed #129)
Change-Id: I1c4aedf5bc97d062c0e8666cf94ed2c39103b54d
Reviewed-on: https://korap.ids-mannheim.de/gerrit/c/KorAP/Koral/+/6502
Reviewed-by: Nils Diewald <nils@diewald-online.de>
diff --git a/Changes b/Changes
index 3c37bd3..9bdcd93 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
-0.39 2022-11-16
+0.39 2023-01-12
- Updated to Java 11
- Dependencies updated
+ - Fix reference bug in Annis (resolved #129, diewald)
0.38.2 2022-10-05
- [feature] Improve regex treatment of negative
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 661a331..9d2ecb7 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
@@ -718,7 +718,8 @@
group = KoralObjectGenerator
.makeGroup(KoralOperation.RELATION);
Map<String, Object> relation = new HashMap<String, Object>();
- putAllBut(relation, operatorGroup, "groupType");
+ if (operatorGroup != null)
+ putAllBut(relation, operatorGroup, "groupType");
group.put("relType", relation);
}
else if (groupType.equals("sequence")) {
@@ -1347,4 +1348,5 @@
}
return tree;
}
-}
\ No newline at end of file
+}
+
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/annis/AnnisQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/test/annis/AnnisQueryProcessorTest.java
index 12da8b6..cd6baa9 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/annis/AnnisQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/annis/AnnisQueryProcessorTest.java
@@ -1176,4 +1176,14 @@
}
*/
+ @Test
+ public void testReferenceBug () throws Exception {
+ query = "tok & tok & #1 .1,11 #2 & #1 == #2";
+ qs.setQuery(query, "annis");
+ res = mapper.readTree(qs.toJSON());
+
+ // Not sure the serialization is correct, but it no longer throws a null pointer exception
+ assertEquals("koral:reference", res.at("/query/operands/1/@type").asText());
+ assertEquals("operation:relation", res.at("/query/operation").asText());
+ }
}