updates
diff --git a/pom.xml b/pom.xml
index e4b88f2..b03027c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,11 +11,8 @@
<artifactId>KorAP-querySerialization</artifactId>
<version>0.0.2</version>
<packaging>jar</packaging>
-
-
<name>KorAP-querySerialization</name>
<url>http://maven.apache.org</url>
-
<dependencies>
<dependency>
<groupId>org.antlr</groupId>
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuery.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuery.java
index caf7154..f7f0ec6 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuery.java
@@ -3,7 +3,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -19,17 +19,17 @@
public MetaQuery() {
this.serialier = new ObjectMapper();
- meta = new HashMap();
+ this.meta = new LinkedHashMap();
}
- public MetaQuery addContext(Object left, Object right, String type) {
- Map map = new HashMap();
+ public MetaQuery addContext(Integer left, String leftType, Integer right, String rightType) {
+ Map map = new LinkedHashMap();
List l = new LinkedList();
List r = new LinkedList();
- l.add(type);
+ l.add(leftType);
l.add(left);
map.put("left", l);
- r.add(type);
+ r.add(rightType);
r.add(right);
map.put("right", r);
meta.put("context", map);
@@ -41,7 +41,11 @@
return this;
}
- public String toMeta() {
+ public Map raw() {
+ return meta;
+ }
+
+ public String toMetaString() {
try {
return serialier.writeValueAsString(meta);
} catch (JsonProcessingException e) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
index 21e0852..636888d 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
@@ -4,7 +4,6 @@
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
-
import de.ids_mannheim.korap.util.QueryException;
import org.slf4j.LoggerFactory;
@@ -49,28 +48,28 @@
* & field_group
*/
"Buch",
- "das Buch",
- "das /+w1:3 Buch",
- "das /+w1:3,s1 Buch",
- "(das /+w1:3,s1 Buch) /+w5 Tisch",
- "(das /+w1:3,s1 Buch) /-w5 Tisch",
- "(das /+w1:3,s1 Buch) /+w5 (auf dem Tisch)",
-
-
- "Institut für Deutsche Sprache",
- "Institut für deutsche Sprache",
- "Institut für $deutsche Sprache",
- "Institut für &deutsch Sprache",
- "Institut für /+w2 Sprache",
- "Institut für %+w1 deutsche Sprache",
- "Institut für MORPH(A) Sprache",
-
- "wegen #IN(L) <s>",
- "$wegen #IN(L) <s>",
- "#BED($wegen , +sa)",
- "#BEG(#ELEM(S))",
- "MORPH(V) #IN(L) #ELEM(S)",
- "MORPH(V) #IN(R) #ELEM(S)",
+ "das Buch",
+ "das /+w1:3 Buch",
+ "das /+w1:3,s1 Buch",
+ "(das /+w1:3,s1 Buch) /+w5 Tisch",
+ "(das /+w1:3,s1 Buch) /-w5 Tisch",
+ "(das /+w1:3,s1 Buch) /+w5 (auf dem Tisch)",
+
+
+ "Institut für Deutsche Sprache",
+ "Institut für deutsche Sprache",
+ "Institut für $deutsche Sprache",
+ "Institut für &deutsch Sprache",
+ "Institut für /+w2 Sprache",
+ "Institut für %+w1 deutsche Sprache",
+ "Institut für MORPH(A) Sprache",
+
+ "wegen #IN(L) <s>",
+ "$wegen #IN(L) <s>",
+ "#BED($wegen , +sa)",
+ "#BEG(#ELEM(S))",
+ "MORPH(V) #IN(L) #ELEM(S)",
+ "MORPH(V) #IN(R) #ELEM(S)",
};
} else {
@@ -115,9 +114,9 @@
throws JsonGenerationException, JsonMappingException, IOException, QueryException {
if (queryLanguage.equals("poliqarp")) {
ast = new PoliqarpPlusTree(query);
- } else if (queryLanguage.equals("cosmas")) {
- ast = new CosmasTree(query);
- } else if (queryLanguage.equals("poliqarpplus")) {
+ } else if (queryLanguage.toLowerCase().equals("cosmas2")) {
+ ast = new CosmasTree(query);
+ } else if (queryLanguage.toLowerCase().equals("poliqarpplus")) {
ast = new PoliqarpPlusTree(query);
} else {
throw new QueryException(queryLanguage + " is not a supported query language!");
@@ -132,26 +131,30 @@
throws QueryException {
if (ql.toLowerCase().equals("poliqarp")) {
ast = new PoliqarpPlusTree(query);
- } else if (ql.toLowerCase().equals("cosmas")) {
- ast = new CosmasTree(query);
+ } else if (ql.toLowerCase().equals("cosmas2")) {
+ ast = new CosmasTree(query);
} else if (ql.toLowerCase().equals("poliqarpplus")) {
ast = new PoliqarpPlusTree(query);
} else {
throw new QueryException(ql + " is not a supported query language!");
}
+
Map<String, Object> requestMap = ast.getRequestMap();
CollectionQuery collectionQuery = new CollectionQuery();
collectionQuery.addResources(parents);
+ MetaQuery meta = new MetaQuery();
+ meta.addContext(cls, cli, crs, cri);
+ meta.addEntry("cutOff", cutoff);
+ meta.addEntry("startPage", page);
+ meta.addEntry("count", num);
+
try {
- requestMap.put("meta", collectionQuery.raw());
- requestMap = QueryUtils.addParameters(requestMap, page, num,
- cli, cri, cls, crs, cutoff);
- String res = mapper.writeValueAsString(requestMap);
- return res;
+ requestMap.put("collections", collectionQuery.raw());
+ requestMap.put("meta", meta.raw());
+ return mapper.writeValueAsString(requestMap);
} catch (IOException e) {
- e.printStackTrace();
- return null;
+ return "";
}
}