Formatted code.
Change-Id: I05497927c39fe6f868207e87cc9e99653d034f85
diff --git a/src/main/java/de/ids_mannheim/korap/query/object/KoralBoundary.java b/src/main/java/de/ids_mannheim/korap/query/object/KoralBoundary.java
index c28cece..b2b615a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/object/KoralBoundary.java
+++ b/src/main/java/de/ids_mannheim/korap/query/object/KoralBoundary.java
@@ -3,7 +3,8 @@
import java.util.LinkedHashMap;
import java.util.Map;
-/** Definition of koral:boundary in KoralQuery.
+/**
+ * Definition of koral:boundary in KoralQuery.
*
* @author margaretha
*
@@ -15,29 +16,35 @@
private int min;
private int max;
+
public KoralBoundary (int min, int max) {
this.min = min;
this.max = max;
}
- public int getMin() {
+
+ public int getMin () {
return min;
}
- public void setMin(int min) {
+
+ public void setMin (int min) {
this.min = min;
}
- public int getMax() {
+
+ public int getMax () {
return max;
}
- public void setMax(int max) {
+
+ public void setMax (int max) {
this.max = max;
}
+
@Override
- public Map<String, Object> buildMap() {
+ public Map<String, Object> buildMap () {
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("@type", type.toString());
if (min > -1) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/object/KoralContext.java b/src/main/java/de/ids_mannheim/korap/query/object/KoralContext.java
index 56f00a1..7ca7aa1 100644
--- a/src/main/java/de/ids_mannheim/korap/query/object/KoralContext.java
+++ b/src/main/java/de/ids_mannheim/korap/query/object/KoralContext.java
@@ -1,6 +1,7 @@
package de.ids_mannheim.korap.query.object;
-/** Context definition for the search scope in WithinQuery,
+/**
+ * Context definition for the search scope in WithinQuery,
* for instance, a withinquery in poliqarp is
* <code>"Bild" within s</code>.
*
@@ -8,18 +9,20 @@
*
*/
public enum KoralContext {
- SENTENCE("s"), PARAGRAPH("p"), TEXT("t");
-
- private final String key;
- public static final String FOUNDRY ="base";
- public static final String LAYER="s"; // surface
-
- KoralContext(String key){
- this.key = key;
- }
+ SENTENCE("s"), PARAGRAPH("p"), TEXT("t");
- public String getKey() {
- return key;
- }
+ private final String key;
+ public static final String FOUNDRY = "base";
+ public static final String LAYER = "s"; // surface
+
+
+ KoralContext (String key) {
+ this.key = key;
+ }
+
+
+ public String getKey () {
+ return key;
+ }
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/object/KoralDistance.java b/src/main/java/de/ids_mannheim/korap/query/object/KoralDistance.java
index 57e1b9a..f63471d 100644
--- a/src/main/java/de/ids_mannheim/korap/query/object/KoralDistance.java
+++ b/src/main/java/de/ids_mannheim/korap/query/object/KoralDistance.java
@@ -3,8 +3,9 @@
import java.util.LinkedHashMap;
import java.util.Map;
-/** Definition of koral:distance in KoralQuery.
- *
+/**
+ * Definition of koral:distance in KoralQuery.
+ *
* @author margaretha
*
*/
@@ -16,56 +17,67 @@
private String layer;
private KoralBoundary boundary;
+
public KoralDistance (KoralBoundary boundary) {
this.boundary = boundary;
}
-
- public KoralDistance (String key, KoralBoundary boundary) {
+
+
+ public KoralDistance (String key, KoralBoundary boundary) {
this(boundary);
this.key = key;
}
- public String getKey() {
+
+ public String getKey () {
return key;
}
- public void setKey(String key) {
+
+ public void setKey (String key) {
this.key = key;
}
- public String getFoundry() {
+
+ public String getFoundry () {
return foundry;
}
- public void setFoundry(String foundry) {
+
+ public void setFoundry (String foundry) {
this.foundry = foundry;
}
- public String getLayer() {
+
+ public String getLayer () {
return layer;
}
- public void setLayer(String layer) {
+
+ public void setLayer (String layer) {
this.layer = layer;
}
- public KoralBoundary getBoundary() {
+
+ public KoralBoundary getBoundary () {
return boundary;
}
- public void setBoundary(KoralBoundary boundary) {
+
+ public void setBoundary (KoralBoundary boundary) {
this.boundary = boundary;
}
+
@Override
- public Map<String, Object> buildMap() {
+ public Map<String, Object> buildMap () {
Map<String, Object> distanceMap = new LinkedHashMap<String, Object>();
distanceMap.put("@type", type.toString());
distanceMap.put("key", key);
- if (foundry != null){
+ if (foundry != null) {
distanceMap.put("foundry", foundry);
}
- if (layer!=null){
+ if (layer != null) {
distanceMap.put("layer", layer);
}
distanceMap.put("boundary", boundary.buildMap());
diff --git a/src/main/java/de/ids_mannheim/korap/query/object/KoralGroup.java b/src/main/java/de/ids_mannheim/korap/query/object/KoralGroup.java
index 87d98e8..757af61 100644
--- a/src/main/java/de/ids_mannheim/korap/query/object/KoralGroup.java
+++ b/src/main/java/de/ids_mannheim/korap/query/object/KoralGroup.java
@@ -10,7 +10,9 @@
import de.ids_mannheim.korap.query.object.KoralOperation;
import de.ids_mannheim.korap.query.object.KoralType;
-/** Definition of koral:group in KoralQuery.
+/**
+ * Definition of koral:group in KoralQuery.
+ *
* @author margaretha
*
*/
@@ -25,67 +27,81 @@
private List<KoralDistance> distances;
private List<Frame> frames;
private KoralBoundary boundary;
-
-// private int[] classIn;
-// private int classOut;
-// private int classRefCheck;
-// private int classRefOp;
-// private boolean exclude = false;
-
+
+
+ // private int[] classIn;
+ // private int classOut;
+ // private int classRefCheck;
+ // private int classRefOp;
+ // private boolean exclude = false;
+
public KoralGroup (KoralOperation operation) {
this.operation = operation;
}
- public boolean isInOrder() {
+
+ public boolean isInOrder () {
return inOrder;
}
- public void setInOrder(boolean inOrder) {
+
+ public void setInOrder (boolean inOrder) {
this.inOrder = inOrder;
}
- public List<KoralObject> getOperands() {
- return operands;
- }
-
- public void setOperands(List<KoralObject> operands) {
- this.operands = operands;
- }
- public KoralOperation getOperation() {
+ public List<KoralObject> getOperands () {
+ return operands;
+ }
+
+
+ public void setOperands (List<KoralObject> operands) {
+ this.operands = operands;
+ }
+
+
+ public KoralOperation getOperation () {
return operation;
}
- public void setOperation(KoralOperation operation) {
+
+ public void setOperation (KoralOperation operation) {
this.operation = operation;
}
- public List<KoralDistance> getDistances() {
+
+ public List<KoralDistance> getDistances () {
return distances;
}
- public void setDistances(List<KoralDistance> distances) {
+
+ public void setDistances (List<KoralDistance> distances) {
this.distances = distances;
}
-
- public List<Frame> getFrames() {
- return frames;
- }
- public void setFrames(List<Frame> frames) {
- this.frames = frames;
- }
- public KoralBoundary getBoundary() {
+ public List<Frame> getFrames () {
+ return frames;
+ }
+
+
+ public void setFrames (List<Frame> frames) {
+ this.frames = frames;
+ }
+
+
+ public KoralBoundary getBoundary () {
return boundary;
}
- public void setBoundary(KoralBoundary boundary) {
+
+ public void setBoundary (KoralBoundary boundary) {
this.boundary = boundary;
}
+
@Override
- public Map<String, Object> buildMap() {
+ public Map<String, Object> buildMap () {
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("@type", type.toString());
map.put("operation", operation.toString());
@@ -111,20 +127,32 @@
return map;
}
- public enum Frame{
- SUCCEDS("succeeds"), SUCCEDS_DIRECTLY("succeedsDirectly"), OVERLAPS_RIGHT("overlapsRight"),
- ALIGNS_RIGHT("alignsRight"), IS_WITHIN("isWithin"), STARTS_WITH("startsWith"),
- MATCHES("matches"), ALIGNS_LEFT("alignsLeft"), IS_AROUND("isAround"), ENDS_WITH("endsWith"),
- OVERLAPS_LEFT("overlapsLeft"), PRECEEDS_DIRECTLY("precedesDirectly"), PRECEDES("precedes");
-
- private String value;
- Frame(String value) {
- this.value = value;
- }
-
- @Override
- public String toString() {
- return "frame:"+value;
- }
- }
+ public enum Frame {
+ SUCCEDS("succeeds"), SUCCEDS_DIRECTLY(
+ "succeedsDirectly"), OVERLAPS_RIGHT(
+ "overlapsRight"), ALIGNS_RIGHT(
+ "alignsRight"), IS_WITHIN(
+ "isWithin"), STARTS_WITH(
+ "startsWith"), MATCHES(
+ "matches"), ALIGNS_LEFT(
+ "alignsLeft"), IS_AROUND(
+ "isAround"), ENDS_WITH(
+ "endsWith"), OVERLAPS_LEFT(
+ "overlapsLeft"), PRECEEDS_DIRECTLY(
+ "precedesDirectly"), PRECEDES(
+ "precedes");
+
+ private String value;
+
+
+ Frame (String value) {
+ this.value = value;
+ }
+
+
+ @Override
+ public String toString () {
+ return "frame:" + value;
+ }
+ }
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/object/KoralMatchOperator.java b/src/main/java/de/ids_mannheim/korap/query/object/KoralMatchOperator.java
index 2d8997b..13b31e6 100644
--- a/src/main/java/de/ids_mannheim/korap/query/object/KoralMatchOperator.java
+++ b/src/main/java/de/ids_mannheim/korap/query/object/KoralMatchOperator.java
@@ -1,6 +1,8 @@
package de.ids_mannheim.korap.query.object;
-/** Definition of the match operations used within koral:term.
+/**
+ * Definition of the match operations used within koral:term.
+ *
* @author margaretha
*
*/
@@ -9,12 +11,14 @@
String value;
+
KoralMatchOperator (String value) {
this.value = value;
}
+
@Override
- public String toString() {
+ public String toString () {
return "match:" + value;
};
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/object/KoralObject.java b/src/main/java/de/ids_mannheim/korap/query/object/KoralObject.java
index 2fd4563..a534407 100644
--- a/src/main/java/de/ids_mannheim/korap/query/object/KoralObject.java
+++ b/src/main/java/de/ids_mannheim/korap/query/object/KoralObject.java
@@ -8,9 +8,12 @@
*/
public interface KoralObject {
- /** Serializes the KoralObject into JSON-LD and structures it as a map.
+ /**
+ * Serializes the KoralObject into JSON-LD and structures it as a
+ * map.
*
- * @return a map containing parts of the JSON-LD serialization of the Koral object.
+ * @return a map containing parts of the JSON-LD serialization of
+ * the Koral object.
*/
- public Map<String, Object> buildMap();
+ public Map<String, Object> buildMap ();
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/object/KoralOperation.java b/src/main/java/de/ids_mannheim/korap/query/object/KoralOperation.java
index d81557f..30521bf 100644
--- a/src/main/java/de/ids_mannheim/korap/query/object/KoralOperation.java
+++ b/src/main/java/de/ids_mannheim/korap/query/object/KoralOperation.java
@@ -1,6 +1,8 @@
package de.ids_mannheim.korap.query.object;
-/** Definition of possible operations within koral:group.
+/**
+ * Definition of possible operations within koral:group.
+ *
* @author margaretha
*
*/
@@ -8,7 +10,7 @@
SEQUENCE, POSITION, DISJUNCTION, REPETITION, CLASS, MERGE, RELATION;
@Override
- public String toString() {
+ public String toString () {
return "operation:" + super.toString().toLowerCase();
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/object/KoralSpan.java b/src/main/java/de/ids_mannheim/korap/query/object/KoralSpan.java
index aa299ab..0540a21 100644
--- a/src/main/java/de/ids_mannheim/korap/query/object/KoralSpan.java
+++ b/src/main/java/de/ids_mannheim/korap/query/object/KoralSpan.java
@@ -6,58 +6,69 @@
import de.ids_mannheim.korap.query.serialize.util.KoralException;
import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
-/** Definition of koral:span in KoralQuery.
+/**
+ * Definition of koral:span in KoralQuery.
*
* @author margaretha
*
*/
-public class KoralSpan implements KoralObject{
-
- private static final KoralType type = KoralType.SPAN;
- private final KoralObject wrappedObject;
- private KoralObject attribute;
-
- public KoralSpan(KoralTerm term) throws KoralException {
- if (term == null){
- throw new KoralException(StatusCodes.MALFORMED_QUERY, "KoralSpan must not wrap null.");
- }
- this.wrappedObject = term;
- }
-
- public KoralSpan(KoralTermGroup termGroup) throws KoralException {
- if (termGroup == null){
- throw new KoralException(StatusCodes.MALFORMED_QUERY,"KoralSpan must not wrap null.");
- }
- this.wrappedObject = termGroup;
- }
+public class KoralSpan implements KoralObject {
- public KoralObject getWrappedObject() {
- return wrappedObject;
- }
-
- public KoralObject getAttribute() {
- return attribute;
- }
-
- public void setAttribute(KoralTerm attribute) {
- this.attribute = attribute;
- }
-
- public void setAttribute(KoralTermGroup attributes) {
- this.attribute = attributes;
- }
-
- @Override
- public Map<String, Object> buildMap() {
- Map<String, Object> map = new LinkedHashMap<String, Object>();
+ private static final KoralType type = KoralType.SPAN;
+ private final KoralObject wrappedObject;
+ private KoralObject attribute;
+
+
+ public KoralSpan (KoralTerm term) throws KoralException {
+ if (term == null) {
+ throw new KoralException(StatusCodes.MALFORMED_QUERY,
+ "KoralSpan must not wrap null.");
+ }
+ this.wrappedObject = term;
+ }
+
+
+ public KoralSpan (KoralTermGroup termGroup) throws KoralException {
+ if (termGroup == null) {
+ throw new KoralException(StatusCodes.MALFORMED_QUERY,
+ "KoralSpan must not wrap null.");
+ }
+ this.wrappedObject = termGroup;
+ }
+
+
+ public KoralObject getWrappedObject () {
+ return wrappedObject;
+ }
+
+
+ public KoralObject getAttribute () {
+ return attribute;
+ }
+
+
+ public void setAttribute (KoralTerm attribute) {
+ this.attribute = attribute;
+ }
+
+
+ public void setAttribute (KoralTermGroup attributes) {
+ this.attribute = attributes;
+ }
+
+
+ @Override
+ public Map<String, Object> buildMap () {
+ Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("@type", type.toString());
- if (wrappedObject == null){
- throw new NullPointerException("KoralSpan does not have a wrapped object.");
+ if (wrappedObject == null) {
+ throw new NullPointerException(
+ "KoralSpan does not have a wrapped object.");
}
map.put("wrap", wrappedObject.buildMap());
- if(attribute != null){
- map.put("wrap", attribute.buildMap());
+ if (attribute != null) {
+ map.put("wrap", attribute.buildMap());
}
- return map;
- }
+ return map;
+ }
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/object/KoralTerm.java b/src/main/java/de/ids_mannheim/korap/query/object/KoralTerm.java
index 9409ab7..b50f380 100644
--- a/src/main/java/de/ids_mannheim/korap/query/object/KoralTerm.java
+++ b/src/main/java/de/ids_mannheim/korap/query/object/KoralTerm.java
@@ -8,7 +8,8 @@
import de.ids_mannheim.korap.query.object.KoralMatchOperator;
import de.ids_mannheim.korap.query.object.KoralType;
-/** Definition of koral:term in KoralQuery.
+/**
+ * Definition of koral:term in KoralQuery.
*
* @author margaretha
*
@@ -16,143 +17,164 @@
public class KoralTerm implements KoralObject {
private static final KoralType koralType = KoralType.TERM;
-
+
private final String key;
private String value;
private String layer;
private String foundry;
private KoralMatchOperator operator; // match
-
- private KoralTermType type;
-
- private boolean caseSensitive = true;
- private boolean diacriticSensitive = true;
- public KoralTerm(String key) throws KoralException {
- if (key == null){
- throw new KoralException(StatusCodes.MALFORMED_QUERY,
- "KoralTerm key cannot be null.");
- }
- this.key = key;
+ private KoralTermType type;
+
+ private boolean caseSensitive = true;
+ private boolean diacriticSensitive = true;
+
+
+ public KoralTerm (String key) throws KoralException {
+ if (key == null) {
+ throw new KoralException(StatusCodes.MALFORMED_QUERY,
+ "KoralTerm key cannot be null.");
+ }
+ this.key = key;
}
-
- public KoralTerm(KoralContext context) throws KoralException {
- if (context.getKey() == null){
- throw new KoralException(StatusCodes.MALFORMED_QUERY,
- "KoralTerm key cannot be null.");
- }
- this.key = context.getKey();
- this.foundry = KoralContext.FOUNDRY;
- this.layer = KoralContext.LAYER;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String getLayer() {
+
+
+ public KoralTerm (KoralContext context) throws KoralException {
+ if (context.getKey() == null) {
+ throw new KoralException(StatusCodes.MALFORMED_QUERY,
+ "KoralTerm key cannot be null.");
+ }
+ this.key = context.getKey();
+ this.foundry = KoralContext.FOUNDRY;
+ this.layer = KoralContext.LAYER;
+ }
+
+
+ public String getValue () {
+ return value;
+ }
+
+
+ public void setValue (String value) {
+ this.value = value;
+ }
+
+
+ public String getLayer () {
return layer;
}
- public void setLayer(String layer) {
+
+ public void setLayer (String layer) {
this.layer = layer;
}
- public String getFoundry() {
+
+ public String getFoundry () {
return foundry;
}
- public void setFoundry(String foundry) {
+
+ public void setFoundry (String foundry) {
this.foundry = foundry;
}
- public KoralMatchOperator getOperator() {
- return operator;
- }
-
- public void setOperator(KoralMatchOperator operator) {
- this.operator = operator;
- }
- public String getKey() {
+ public KoralMatchOperator getOperator () {
+ return operator;
+ }
+
+
+ public void setOperator (KoralMatchOperator operator) {
+ this.operator = operator;
+ }
+
+
+ public String getKey () {
return key;
}
- public KoralTermType getType() {
+
+ public KoralTermType getType () {
return type;
}
- public void setType(KoralTermType regex) {
+
+ public void setType (KoralTermType regex) {
this.type = regex;
}
- public boolean isCaseSensitive() {
+
+ public boolean isCaseSensitive () {
return caseSensitive;
}
- public void setCaseSensitive(boolean isCaseSensitive) {
+
+ public void setCaseSensitive (boolean isCaseSensitive) {
this.caseSensitive = isCaseSensitive;
}
- public boolean isDiacriticSensitive() {
+
+ public boolean isDiacriticSensitive () {
return diacriticSensitive;
}
- public void setDiacriticSensitive(boolean diacriticSensitive) {
+
+ public void setDiacriticSensitive (boolean diacriticSensitive) {
this.diacriticSensitive = diacriticSensitive;
}
+
@Override
- public Map<String, Object> buildMap() {
+ public Map<String, Object> buildMap () {
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("@type", koralType.toString());
if (!isCaseSensitive()) {
map.put("caseInsensitive", "true");
}
- if (!isDiacriticSensitive()){
+ if (!isDiacriticSensitive()) {
map.put("diacriticInsensitive", "true");
}
-
+
map.put("key", getKey());
- if (value != null){
- map.put("value", getValue());
+ if (value != null) {
+ map.put("value", getValue());
}
- if (foundry != null){
- map.put("foundry", getFoundry());
+ if (foundry != null) {
+ map.put("foundry", getFoundry());
}
- if (layer !=null){
- map.put("layer", getLayer());
+ if (layer != null) {
+ map.put("layer", getLayer());
}
- if (type != null){
- map.put("type", getType().toString());
+ if (type != null) {
+ map.put("type", getType().toString());
}
- if (operator !=null){
- map.put("match", getOperator().toString());
- }
+ if (operator != null) {
+ map.put("match", getOperator().toString());
+ }
return map;
}
- /** Definition of possible types of koral:term.
+ /**
+ * Definition of possible types of koral:term.
*
* @author margaretha
*
*/
public enum KoralTermType {
- STRING("type:string"), REGEX("type:regex"), WILDCARD("type:wildcard"), PUNCT(
- "type:punct");
+ STRING("type:string"), REGEX("type:regex"), WILDCARD(
+ "type:wildcard"), PUNCT("type:punct");
String value;
+
KoralTermType (String value) {
this.value = value;
}
+
@Override
- public String toString() {
+ public String toString () {
return value;
}
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/object/KoralTermGroup.java b/src/main/java/de/ids_mannheim/korap/query/object/KoralTermGroup.java
index c4b1b63..9973cd0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/object/KoralTermGroup.java
+++ b/src/main/java/de/ids_mannheim/korap/query/object/KoralTermGroup.java
@@ -8,7 +8,8 @@
import de.ids_mannheim.korap.query.serialize.MapBuilder;
import de.ids_mannheim.korap.query.serialize.util.KoralException;
-/** Definition of koral:termGroup in KoralQuery.
+/**
+ * Definition of koral:termGroup in KoralQuery.
*
* @author margaretha
*
@@ -20,30 +21,37 @@
private String relation;
private List<KoralObject> operands = new ArrayList<KoralObject>();
- public KoralTermGroup (KoralTermGroupRelation relation, List<KoralObject> operands)
+
+ public KoralTermGroup (KoralTermGroupRelation relation,
+ List<KoralObject> operands)
throws KoralException {
this.relation = relation.toString();
this.operands = operands;
}
- public String getRelation() {
+
+ public String getRelation () {
return relation;
}
- public void setRelation(String relation) {
+
+ public void setRelation (String relation) {
this.relation = relation;
}
- public List<KoralObject> getOperands() {
+
+ public List<KoralObject> getOperands () {
return operands;
}
- public void setOperands(List<KoralObject> operands) {
+
+ public void setOperands (List<KoralObject> operands) {
this.operands = operands;
}
+
@Override
- public Map<String, Object> buildMap() {
+ public Map<String, Object> buildMap () {
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("@type", type.toString());
map.put("relation", getRelation());
diff --git a/src/main/java/de/ids_mannheim/korap/query/object/KoralTermGroupRelation.java b/src/main/java/de/ids_mannheim/korap/query/object/KoralTermGroupRelation.java
index 3c7707e..fa24270 100644
--- a/src/main/java/de/ids_mannheim/korap/query/object/KoralTermGroupRelation.java
+++ b/src/main/java/de/ids_mannheim/korap/query/object/KoralTermGroupRelation.java
@@ -1,6 +1,7 @@
package de.ids_mannheim.korap.query.object;
-/** Definition of the relations used within koral:termGroup.
+/**
+ * Definition of the relations used within koral:termGroup.
*
* @author margaretha
*
@@ -10,7 +11,7 @@
AND, OR;
@Override
- public String toString() {
+ public String toString () {
return "relation:" + super.toString().toLowerCase();
}
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/object/KoralToken.java b/src/main/java/de/ids_mannheim/korap/query/object/KoralToken.java
index 431b3ea..0f623a2 100644
--- a/src/main/java/de/ids_mannheim/korap/query/object/KoralToken.java
+++ b/src/main/java/de/ids_mannheim/korap/query/object/KoralToken.java
@@ -6,7 +6,8 @@
import de.ids_mannheim.korap.query.object.KoralObject;
import de.ids_mannheim.korap.query.object.KoralType;
-/** Definition of koral:token in KoralQuery.
+/**
+ * Definition of koral:token in KoralQuery.
*
* @author margaretha
*
@@ -16,24 +17,30 @@
private final static KoralType type = KoralType.TOKEN;
private KoralObject wrappedObject;
+
public KoralToken () {}
-
+
+
public KoralToken (KoralObject wrappedObject) {
this.wrappedObject = wrappedObject;
}
- public KoralObject getWrappedObject() {
- return wrappedObject;
- }
- public void setWrappedObject(KoralObject wrappedObject) {
- this.wrappedObject = wrappedObject;
- }
+
+ public KoralObject getWrappedObject () {
+ return wrappedObject;
+ }
+
+
+ public void setWrappedObject (KoralObject wrappedObject) {
+ this.wrappedObject = wrappedObject;
+ }
+
@Override
- public Map<String, Object> buildMap() {
+ public Map<String, Object> buildMap () {
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("@type", type.toString());
- if (wrappedObject != null){
+ if (wrappedObject != null) {
map.put("wrap", wrappedObject.buildMap());
}
return map;
diff --git a/src/main/java/de/ids_mannheim/korap/query/object/KoralType.java b/src/main/java/de/ids_mannheim/korap/query/object/KoralType.java
index 4992f43..a4860c8 100644
--- a/src/main/java/de/ids_mannheim/korap/query/object/KoralType.java
+++ b/src/main/java/de/ids_mannheim/korap/query/object/KoralType.java
@@ -1,24 +1,27 @@
package de.ids_mannheim.korap.query.object;
-/** Definition of various types of KoralQuery building objects.
- *
+/**
+ * Definition of various types of KoralQuery building objects.
+ *
* @author margaretha
*
*/
public enum KoralType {
- TERMGROUP("koral:termGroup"), TERM("koral:term"), TOKEN("koral:token"), SPAN(
- "koral:span"), GROUP("koral:group"), BOUNDARY("koral:boundary"), RELATION(
- "koral:relation"), DISTANCE("koral:distance"), REFERENCE(
- "koral:reference");
+ TERMGROUP("koral:termGroup"), TERM("koral:term"), TOKEN(
+ "koral:token"), SPAN("koral:span"), GROUP("koral:group"), BOUNDARY(
+ "koral:boundary"), RELATION("koral:relation"), DISTANCE(
+ "koral:distance"), REFERENCE("koral:reference");
String value;
+
KoralType (String value) {
this.value = value;
}
+
@Override
- public String toString() {
+ public String toString () {
return value;
}
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opBED.java b/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opBED.java
index fb9df4e..e52e7fb 100644
--- a/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opBED.java
+++ b/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opBED.java
@@ -73,8 +73,8 @@
for (int i = 0; i < input.length; i++) {
tree = check(input[i], 0);
- System.out.println("Parsing input: " + input[i] + ": "
- + tree.toStringTree());
+ System.out.println(
+ "Parsing input: " + input[i] + ": " + tree.toStringTree());
}
} // main
diff --git a/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opOV.java b/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opOV.java
index 6526935..9fa330f 100644
--- a/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opOV.java
+++ b/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opOV.java
@@ -46,6 +46,7 @@
* main: testprogram:
*/
+
// TODOO: input "OV()" führt zu unendlichem loop... 19.12.12/FB
// TODOO: input "#OV(FI,ALL)" -> loop, weil ALL nicht bekannter Token...
diff --git a/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opWF.java b/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opWF.java
index f107d41..5c52c3c 100644
--- a/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opWF.java
+++ b/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opWF.java
@@ -52,8 +52,8 @@
}
// AST Tree anzeigen:
- Tree tree = bLem ? (Tree) c2PQLEMReturn.getTree() : (Tree) c2PQWFReturn
- .getTree();
+ Tree tree = bLem ? (Tree) c2PQLEMReturn.getTree()
+ : (Tree) c2PQWFReturn.getTree();
// System.out.println(bLem? "opLEM: " : "opWF: " + tree.toStringTree() );
return tree;
@@ -76,8 +76,8 @@
sbWF.deleteCharAt(i);
}
- return new CommonTree(new CommonToken(tokenType, "\"" + sbWF.toString()
- + "\""));
+ return new CommonTree(
+ new CommonToken(tokenType, "\"" + sbWF.toString() + "\""));
}
@@ -104,8 +104,8 @@
else
tree = check(input[i], false, false, 0); // bStrip=false, bLem=false.
- System.out.println(bLem ? "LEM: " : "WF: " + "AST : "
- + tree.toStringTree() + "\n");
+ System.out.println(bLem ? "LEM: "
+ : "WF: " + "AST : " + tree.toStringTree() + "\n");
}
} // main
diff --git a/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_optCase.java b/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_optCase.java
index a2c5a3c..3aa50e6 100644
--- a/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_optCase.java
+++ b/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_optCase.java
@@ -47,8 +47,8 @@
for (int i = 0; i < input.length; i++) {
tree = check(input[i], 0);
- System.out.println("Parsing input: " + input[i] + ": "
- + tree.toStringTree());
+ System.out.println(
+ "Parsing input: " + input[i] + ": " + tree.toStringTree());
}
} // main
diff --git a/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/ExpressionParser.java b/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/ExpressionParser.java
index 842cabc..3bf6eb9 100644
--- a/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/ExpressionParser.java
+++ b/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/ExpressionParser.java
@@ -46,6 +46,7 @@
.asList(new String[] { FOUNDRY_CNX, FOUNDRY_OPENNLP, FOUNDRY_TT,
FOUNDRY_MATE, FOUNDRY_XIP });
+
/**
* Parses the given query node and constructs a koral object
* representation of it.
@@ -55,11 +56,12 @@
* @return a koral object representation of the given node
* @throws KoralException
*/
- public KoralObject parseExpression(QueryNode queryNode)
+ public KoralObject parseExpression (QueryNode queryNode)
throws KoralException {
return parseExpression(queryNode, false, true);
}
+
/**
* Parses the given query node using the specified parameters.
*
@@ -74,11 +76,12 @@
* @return a koral object representation of the given node
* @throws KoralException
*/
- public KoralObject parseExpression(QueryNode queryNode, boolean isNot,
+ public KoralObject parseExpression (QueryNode queryNode, boolean isNot,
boolean isToken) throws KoralException {
if (queryNode instanceof Expression) {
- return parseSimpleExpression((Expression) queryNode, isNot, isToken);
+ return parseSimpleExpression((Expression) queryNode, isNot,
+ isToken);
}
else if (queryNode instanceof ExpressionAnd) {
List<QueryNode> operands = queryNode.getChildren();
@@ -119,6 +122,7 @@
}
}
+
/**
* Handles a boolean expression by parsing the given operands and
* creates a koral token using the parsed operands and the given
@@ -131,15 +135,16 @@
* @return a koral token
* @throws KoralException
*/
- private KoralObject parseBooleanExpression(List<QueryNode> operands,
- KoralTermGroupRelation relation, boolean isToken) throws KoralException {
+ private KoralObject parseBooleanExpression (List<QueryNode> operands,
+ KoralTermGroupRelation relation, boolean isToken)
+ throws KoralException {
List<KoralObject> terms = new ArrayList<>();
for (QueryNode node : operands) {
terms.add(parseExpression(node, false, false));
}
-
+
KoralTermGroup termGroup = new KoralTermGroup(relation, terms);
- if (isToken){
+ if (isToken) {
return new KoralToken(termGroup);
}
else {
@@ -147,6 +152,7 @@
}
}
+
/**
* Parses the given simple expression considering the other
* specified parameters.
@@ -162,7 +168,7 @@
* @return
* @throws KoralException
*/
- private KoralObject parseSimpleExpression(Expression expression,
+ private KoralObject parseSimpleExpression (Expression expression,
boolean isNot, boolean isToken) throws KoralException {
KoralTerm koralTerm = parseTerm(expression, isNot);
if (isToken) {
@@ -173,6 +179,7 @@
}
}
+
/**
* Parses the given expression and constructs a KoralTerm.
*
@@ -184,7 +191,7 @@
* @return a koral term
* @throws KoralException
*/
- public KoralTerm parseTerm(Expression expression, boolean isNot)
+ public KoralTerm parseTerm (Expression expression, boolean isNot)
throws KoralException {
KoralTerm koralTerm = null;
koralTerm = new KoralTerm(expression.getRegexValue());
@@ -196,6 +203,7 @@
return koralTerm;
}
+
/**
* Parses the given layer identifier and adds it to the koral
* term.
@@ -206,7 +214,7 @@
* a layer identifier
* @throws KoralException
*/
- private void parseLayerIdentifier(KoralTerm koralTerm, String identifier)
+ private void parseLayerIdentifier (KoralTerm koralTerm, String identifier)
throws KoralException {
String layer = null;
if (identifier == null) {
@@ -224,13 +232,13 @@
}
else {
throw new KoralException(StatusCodes.UNKNOWN_QUERY_ELEMENT,
- "Layer " + identifier
- + " is unsupported.");
+ "Layer " + identifier + " is unsupported.");
}
koralTerm.setLayer(layer);
}
+
/**
* Parses the given layer qualifier and adds it to the koral term.
*
@@ -240,7 +248,7 @@
* a layer qualifier
* @throws KoralException
*/
- private void parseQualifier(KoralTerm koralTerm, String qualifier)
+ private void parseQualifier (KoralTerm koralTerm, String qualifier)
throws KoralException {
String layer = koralTerm.getLayer();
if (layer == null) {
@@ -261,13 +269,13 @@
}
else if (!supportedFoundries.contains(qualifier)) {
throw new KoralException(StatusCodes.UNKNOWN_QUERY_ELEMENT,
- "Qualifier " + qualifier
- + " is unsupported.");
+ "Qualifier " + qualifier + " is unsupported.");
}
koralTerm.setFoundry(qualifier);
}
+
/**
* Parses the given match operator and adds it to the koral term.
*
@@ -280,7 +288,7 @@
* or not.
* @throws KoralException
*/
- private void parseOperator(KoralTerm koralTerm, Operator operator,
+ private void parseOperator (KoralTerm koralTerm, Operator operator,
boolean isNot) throws KoralException {
KoralMatchOperator matchOperator = null;
if (operator == null || operator == Operator.EQUALS) {
@@ -298,6 +306,7 @@
koralTerm.setOperator(matchOperator);
}
+
/**
* Parses the given set of regex flags and adds them to the koral
* term.
@@ -308,10 +317,11 @@
* a set of regex flags
* @throws KoralException
*/
- private void parseRegexFlags(KoralTerm koralTerm, Set<RegexFlag> set)
+ private void parseRegexFlags (KoralTerm koralTerm, Set<RegexFlag> set)
throws KoralException {
// default case sensitive
- if (set == null) return;
+ if (set == null)
+ return;
ArrayList<String> names = new ArrayList<String>();
Iterator<RegexFlag> i = set.iterator();
@@ -330,13 +340,11 @@
if (names.size() == 1) {
throw new KoralException(StatusCodes.UNKNOWN_QUERY_ELEMENT,
- "Regexflag: " + names.get(0)
- + " is unsupported.");
+ "Regexflag: " + names.get(0) + " is unsupported.");
}
else if (names.size() > 1) {
throw new KoralException(StatusCodes.UNKNOWN_QUERY_ELEMENT,
- "Regexflags: " + names.toString()
- + " are unsupported.");
+ "Regexflags: " + names.toString() + " are unsupported.");
}
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/FCSSRUQueryParser.java b/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/FCSSRUQueryParser.java
index 98f6536..d896079 100644
--- a/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/FCSSRUQueryParser.java
+++ b/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/FCSSRUQueryParser.java
@@ -25,7 +25,9 @@
import eu.clarin.sru.server.fcs.parser.SimpleWithin;
import eu.clarin.sru.server.fcs.parser.SimpleWithin.Scope;
-/** This class handles FCS query nodes from the FCSParser converting FCSQL to Java objects.
+/**
+ * This class handles FCS query nodes from the FCSParser converting
+ * FCSQL to Java objects.
*
* @author margaretha
*
@@ -34,19 +36,25 @@
private ExpressionParser expressionParser;
- /** Constructs the FCSSRUQueryParser.
+
+ /**
+ * Constructs the FCSSRUQueryParser.
*
*/
public FCSSRUQueryParser () {
this.expressionParser = new ExpressionParser();
}
- /** Parses the given query node according to its type.
- * @param queryNode an FCS a query node
+
+ /**
+ * Parses the given query node according to its type.
+ *
+ * @param queryNode
+ * an FCS a query node
* @return a koral object
* @throws KoralException
*/
- public KoralObject parseQueryNode(QueryNode queryNode)
+ public KoralObject parseQueryNode (QueryNode queryNode)
throws KoralException {
if (queryNode instanceof QuerySegment) {
@@ -74,39 +82,60 @@
+ " is currently unsupported.");
}
}
-
- /** Parses the given query segment into a koral object.
- * @param segment a query segment
+
+
+ /**
+ * Parses the given query segment into a koral object.
+ *
+ * @param segment
+ * a query segment
* @return a koral object representation of the query segment
* @throws KoralException
*/
- private KoralObject parseQuerySegment(QuerySegment segment)
+ private KoralObject parseQuerySegment (QuerySegment segment)
throws KoralException {
- KoralObject object = expressionParser.parseExpression(segment.getExpression());
- return handleQuantifier(object, segment.getMinOccurs(), segment.getMaxOccurs());
+ KoralObject object = expressionParser
+ .parseExpression(segment.getExpression());
+ return handleQuantifier(object, segment.getMinOccurs(),
+ segment.getMaxOccurs());
}
-
- /** Parses the given query group into a koral object.
- * @param group a koral group
+
+
+ /**
+ * Parses the given query group into a koral object.
+ *
+ * @param group
+ * a koral group
* @return a koral object
* @throws KoralException
*/
- private KoralObject parseQueryGroup(QueryGroup group) throws KoralException {
+ private KoralObject parseQueryGroup (QueryGroup group)
+ throws KoralException {
KoralObject object = parseQueryNode(group.getFirstChild());
- return handleQuantifier(object, group.getMinOccurs(), group.getMaxOccurs());
+ return handleQuantifier(object, group.getMinOccurs(),
+ group.getMaxOccurs());
}
-
- /** Parses FCSQL quantifier into a koral boundary and adds it to a koral group
- * @param object a koral object
- * @param minOccurs minimum occurrences
- * @param maxOccurs maximum occurrences
- * @return a koral group or the given koral object when minimum and maximum occurrences are exactly 1.
+
+
+ /**
+ * Parses FCSQL quantifier into a koral boundary and adds it to a
+ * koral group
+ *
+ * @param object
+ * a koral object
+ * @param minOccurs
+ * minimum occurrences
+ * @param maxOccurs
+ * maximum occurrences
+ * @return a koral group or the given koral object when minimum
+ * and maximum occurrences are exactly 1.
*/
- private KoralObject handleQuantifier(KoralObject object, int minOccurs, int maxOccurs){
+ private KoralObject handleQuantifier (KoralObject object, int minOccurs,
+ int maxOccurs) {
if ((minOccurs == 1) && (maxOccurs == 1)) {
return object;
}
-
+
KoralBoundary boundary = new KoralBoundary(minOccurs, maxOccurs);
List<KoralObject> operand = new ArrayList<KoralObject>(1);
operand.add(object);
@@ -116,13 +145,17 @@
koralGroup.setOperands(operand);
return koralGroup;
}
-
- /** Parses a QueryWithWithin into a koral group.
- * @param queryNode a query node of type QueryWithWithin
+
+
+ /**
+ * Parses a QueryWithWithin into a koral group.
+ *
+ * @param queryNode
+ * a query node of type QueryWithWithin
* @return a koral group
* @throws KoralException
*/
- private KoralGroup parseWithinQuery(QueryWithWithin queryNode)
+ private KoralGroup parseWithinQuery (QueryWithWithin queryNode)
throws KoralException {
KoralGroup koralGroup = new KoralGroup(KoralOperation.POSITION);
koralGroup.setFrames(Arrays.asList(Frame.IS_AROUND));
@@ -134,12 +167,16 @@
return koralGroup;
}
- /** Parses the scope of a QueryWithWithin into a koral span.
- * @param scope the scope of a QueryWithWithin
+
+ /**
+ * Parses the scope of a QueryWithWithin into a koral span.
+ *
+ * @param scope
+ * the scope of a QueryWithWithin
* @return a koral span
* @throws KoralException
*/
- private KoralSpan parseWithinScope(Scope scope) throws KoralException {
+ private KoralSpan parseWithinScope (Scope scope) throws KoralException {
if (scope == null) {
throw new KoralException(StatusCodes.MALFORMED_QUERY,
"Within context is missing.");
@@ -164,12 +201,17 @@
return new KoralSpan(new KoralTerm(contextSpan));
}
- /** Parses a query disjunction into a koral group.
- * @param children a list of query nodes.
+
+ /**
+ * Parses a query disjunction into a koral group.
+ *
+ * @param children
+ * a list of query nodes.
* @return a koral group with operation disjunction
* @throws KoralException
*/
- private KoralGroup parseQueryDisjunction(List<QueryNode> children) throws KoralException {
+ private KoralGroup parseQueryDisjunction (List<QueryNode> children)
+ throws KoralException {
KoralGroup koralGroup = new KoralGroup(KoralOperation.DISJUNCTION);
List<KoralObject> operands = new ArrayList<KoralObject>();
for (QueryNode child : children) {
@@ -179,12 +221,16 @@
return koralGroup;
}
- /** Parses a sequence query into a koral group.
- * @param children a list query nodes.
+
+ /**
+ * Parses a sequence query into a koral group.
+ *
+ * @param children
+ * a list query nodes.
* @return a koral group
* @throws KoralException
*/
- private KoralGroup parseSequenceQuery(List<QueryNode> children)
+ private KoralGroup parseSequenceQuery (List<QueryNode> children)
throws KoralException {
KoralGroup koralGroup = new KoralGroup(KoralOperation.SEQUENCE);
List<KoralObject> operands = new ArrayList<KoralObject>();
@@ -199,12 +245,13 @@
if (i > 0 && i < size - 1 && findEmptyToken(child)) {
QuerySegment qs = (QuerySegment) child;
if (isLastTokenEmpty) {
- KoralBoundary boundary = (KoralBoundary) operands.get(operands.size() - 1);
+ KoralBoundary boundary = (KoralBoundary) operands
+ .get(operands.size() - 1);
updateBoundary(boundary, qs);
}
else {
- operands.add(new KoralBoundary(qs.getMinOccurs(), qs
- .getMaxOccurs()));
+ operands.add(new KoralBoundary(qs.getMinOccurs(),
+ qs.getMaxOccurs()));
isLastTokenEmpty = true;
}
isEmptyTokenFound = true;
@@ -216,89 +263,115 @@
}
if (isEmptyTokenFound) {
- operands = createDistance(koralGroup,operands);
+ operands = createDistance(koralGroup, operands);
}
koralGroup.setOperands(operands);
return koralGroup;
}
- /** Determines if there is an empty token in the given query node.
- * @param node a query node
+
+ /**
+ * Determines if there is an empty token in the given query node.
+ *
+ * @param node
+ * a query node
* @return true if an empty token is found or false otherwise.
*/
- private boolean findEmptyToken(QueryNode node) {
- if (node instanceof QuerySegment
- && ((QuerySegment) node).getExpression() instanceof ExpressionWildcard) {
+ private boolean findEmptyToken (QueryNode node) {
+ if (node instanceof QuerySegment && ((QuerySegment) node)
+ .getExpression() instanceof ExpressionWildcard) {
return true;
}
return false;
}
- /** Updates the boundary properties with the parameters in the query segment.
- * @param boundary a koral boundary
- * @param qs a query segment
+
+ /**
+ * Updates the boundary properties with the parameters in the
+ * query segment.
+ *
+ * @param boundary
+ * a koral boundary
+ * @param qs
+ * a query segment
*/
- private void updateBoundary(KoralBoundary boundary, QuerySegment qs) {
+ private void updateBoundary (KoralBoundary boundary, QuerySegment qs) {
boundary.setMin(boundary.getMin() + qs.getMinOccurs());
boundary.setMax(boundary.getMax() + qs.getMaxOccurs());
}
- /** Creates koral distances from KoralBoundary objects in the given operand list,
- * and adds the distances the koral group. Removes the KoralBoundary objects from
+
+ /**
+ * Creates koral distances from KoralBoundary objects in the given
+ * operand list,
+ * and adds the distances the koral group. Removes the
+ * KoralBoundary objects from
* the operand list and returns the new operand list.
*
- * @param koralGroup a koral group
- * @param operands a list of koral objects
- * @return an updated operand lists without KoralBoundary objects
+ * @param koralGroup
+ * a koral group
+ * @param operands
+ * a list of koral objects
+ * @return an updated operand lists without KoralBoundary objects
*/
- private List<KoralObject> createDistance(KoralGroup koralGroup, List<KoralObject> operands){
+ private List<KoralObject> createDistance (KoralGroup koralGroup,
+ List<KoralObject> operands) {
boolean isSubGroupAdded = false;
List<KoralObject> newOperands = new ArrayList<KoralObject>(
- operands.size());
- newOperands.add(operands.get(0));
+ operands.size());
+ newOperands.add(operands.get(0));
int operandSize = operands.size();
for (int i = 1; i < operandSize - 1; i++) {
KoralObject operand = operands.get(i);
if (operand instanceof KoralBoundary) {
List<KoralDistance> distances = new ArrayList<KoralDistance>();
- distances.add(new KoralDistance ((KoralBoundary) operand));
-
- if (koralGroup.getDistances() != null){
- KoralObject lastOperand = newOperands.get(newOperands.size()-1);
- KoralGroup subGroup = createSequenceGroupWithDistance(distances, lastOperand, operands.get(i+1));
+ distances.add(new KoralDistance((KoralBoundary) operand));
+
+ if (koralGroup.getDistances() != null) {
+ KoralObject lastOperand = newOperands
+ .get(newOperands.size() - 1);
+ KoralGroup subGroup = createSequenceGroupWithDistance(
+ distances, lastOperand, operands.get(i + 1));
newOperands.remove(lastOperand);
newOperands.add(subGroup);
isSubGroupAdded = true;
continue;
}
- else{
+ else {
koralGroup.setDistances(distances);
koralGroup.setInOrder(true);
}
}
- else{
- newOperands.add(operand);
+ else {
+ newOperands.add(operand);
}
isSubGroupAdded = false;
}
-
- if (!isSubGroupAdded){
- newOperands.add(operands.get(operandSize-1));
+
+ if (!isSubGroupAdded) {
+ newOperands.add(operands.get(operandSize - 1));
}
return newOperands;
}
-
- /** Creates a distance query, namely a koral group of operation sequence
+
+
+ /**
+ * Creates a distance query, namely a koral group of operation
+ * sequence
* with the given distances and operands.
- *
- * @param distances a list of distances.
- * @param operand an operand
- * @param operand2 another operand
+ *
+ * @param distances
+ * a list of distances.
+ * @param operand
+ * an operand
+ * @param operand2
+ * another operand
* @return a koral group
*/
- private KoralGroup createSequenceGroupWithDistance(List<KoralDistance> distances,
- KoralObject operand, KoralObject operand2) {
+ private KoralGroup createSequenceGroupWithDistance (
+ List<KoralDistance> distances, KoralObject operand,
+ KoralObject operand2) {
KoralGroup subGroup = new KoralGroup(KoralOperation.SEQUENCE);
subGroup.setDistances(distances);
subGroup.setInOrder(true);
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractQueryProcessor.java
index 60c2a51..72d7e0c 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractQueryProcessor.java
@@ -56,7 +56,7 @@
/**
* If true, print debug statements
*/
- public static boolean verbose = false;
+ public static boolean verbose = true;
protected Integer stackedObjects = 0;
/**
* Contains error arrays, consisting of an error code and a
@@ -206,8 +206,8 @@
public void addAlignment (int leftClassId, int rightClassId) {
- List<Integer> alignment = Arrays.asList(new Integer[] { leftClassId,
- rightClassId });
+ List<Integer> alignment = Arrays
+ .asList(new Integer[] { leftClassId, rightClassId });
alignments.add(alignment);
meta.put("alignment", alignments);
}
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 528d799..1363073 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
@@ -185,8 +185,8 @@
if (!queuedRelations.isEmpty()) {
ParseTree queued = queuedRelations.pop();
if (verbose)
- System.out.println("Taking off queue (last rel): "
- + queued.getText());
+ System.out.println(
+ "Taking off queue (last rel): " + queued.getText());
if (checkOperandsProcessedPreviously(queued)) {
processNode(queued);
}
@@ -194,8 +194,8 @@
addError(StatusCodes.UNBOUND_ANNIS_RELATION,
"The relation " + queued.getText()
+ " is not bound to any other relations.");
- requestMap
- .put("query", new LinkedHashMap<String, Object>());
+ requestMap.put("query",
+ new LinkedHashMap<String, Object>());
}
}
}
@@ -232,8 +232,8 @@
ParseTree queued = queuedRelations.getFirst();
if (checkOperandsProcessedPreviously(queued)) {
if (verbose)
- System.out.println("Taking off queue: "
- + queued.getText());
+ System.out.println(
+ "Taking off queue: " + queued.getText());
queuedRelations.removeFirst();
processNode(queued);
}
@@ -323,8 +323,8 @@
"n_ary_linguistic_term")) {
for (ParseTree refOrNode : getChildrenWithCat(lingTermNode,
"refOrNode")) {
- String refOrNodeString = refOrNode.getChild(0).toStringTree(
- parser);
+ String refOrNodeString = refOrNode.getChild(0)
+ .toStringTree(parser);
if (refOrNodeString.startsWith("#")) {
String ref = refOrNode.getChild(0).toStringTree(parser)
.substring(1);
@@ -355,7 +355,8 @@
ref = variableCount.toString();
}
nodes2refs.put(variableExprNode, ref);
- LinkedHashMap<String, Object> object = processVariableExpr(variableExprNode);
+ LinkedHashMap<String, Object> object = processVariableExpr(
+ variableExprNode);
nodeVariables.put(ref, object);
variableCount++;
// Check if this object definition is part of a "direct declaration
@@ -364,8 +365,8 @@
// objects must still be available for later reference, handle this
// here. Direct declaration relation is present when grandparent is
// n_ary_linguistic_term node.
- if (getNodeCat(variableExprNode.getParent().getParent()).equals(
- "n_ary_linguistic_term")) {
+ if (getNodeCat(variableExprNode.getParent().getParent())
+ .equals("n_ary_linguistic_term")) {
if (nodeReferencesTotal.containsKey(ref)) {
nodeReferencesTotal.put(ref,
nodeReferencesTotal.get(ref) + 1);
@@ -422,8 +423,8 @@
// (e.g. cnx/cat=NP vs mate/pos=NN)
// TODO generalize the list below -> look up layers associated with
// tokens rather than spans somewhere
- HashMap<String, Object> qNameParse = parseQNameNode(node
- .getChild(0));
+ HashMap<String, Object> qNameParse = parseQNameNode(
+ node.getChild(0));
if (Arrays.asList(new String[] { "p", "lemma", "m", "orth" })
.contains(qNameParse.get("layer"))) {
object = KoralObjectGenerator.makeToken();
@@ -451,17 +452,13 @@
HashMap<String, Object> term = (HashMap<String, Object>) object
.get("wrap");
term.putAll(parseTextSpec(node.getChild(2)));
- term.put(
- "match",
- parseMatchOperator(getFirstChildWithCat(node,
- "eqOperator")));
+ term.put("match", parseMatchOperator(
+ getFirstChildWithCat(node, "eqOperator")));
}
else {
object.putAll(parseTextSpec(node.getChild(2)));
- object.put(
- "match",
- parseMatchOperator(getFirstChildWithCat(node,
- "eqOperator")));
+ object.put("match", parseMatchOperator(
+ getFirstChildWithCat(node, "eqOperator")));
}
}
@@ -521,7 +518,8 @@
* representation
* of the operand
*/
- private LinkedHashMap<String, Object> retrieveOperand (ParseTree operandNode) {
+ private LinkedHashMap<String, Object> retrieveOperand (
+ ParseTree operandNode) {
LinkedHashMap<String, Object> operand = null;
if (!getNodeCat(operandNode.getChild(0)).equals("variableExpr")) {
String ref = operandNode.getChild(0).toStringTree(parser)
@@ -620,8 +618,10 @@
}
}
// Retrieve operands.
- LinkedHashMap<String, Object> operand1 = retrieveOperand(operandTree1);
- LinkedHashMap<String, Object> operand2 = retrieveOperand(operandTree2);
+ LinkedHashMap<String, Object> operand1 = retrieveOperand(
+ operandTree1);
+ LinkedHashMap<String, Object> operand2 = retrieveOperand(
+ operandTree2);
// 'Proper' n_ary_linguistic_operators receive a considerably
// different serialisation than 'commonparent' and 'commonancestor'
// For the latter cases, a dummy span is introduced and declared as
@@ -658,15 +658,14 @@
// for lowest level, add the underspecified node as first
// operand and wrap it in a class group
if (i == 1) {
- innerOperands
- .add(KoralObjectGenerator.wrapInClass(
- KoralObjectGenerator.makeSpan(),
- classCounter + 128));
+ innerOperands.add(KoralObjectGenerator.wrapInClass(
+ KoralObjectGenerator.makeSpan(),
+ classCounter + 128));
// add the first operand and wrap the whole group in a
// focusing reference
innerOperands.add(operand1);
- innerGroup = KoralObjectGenerator.wrapInReference(
- innerGroup, classCounter + 128);
+ innerGroup = KoralObjectGenerator
+ .wrapInReference(innerGroup, classCounter + 128);
outerOperands.add(innerGroup);
}
else {
@@ -691,8 +690,8 @@
// attributes defined in KoralQ. and can be handled more easily
}
else {
- LinkedHashMap<String, Object> operatorGroup = parseOperatorNode(node
- .getChild(i).getChild(0));
+ LinkedHashMap<String, Object> operatorGroup = parseOperatorNode(
+ node.getChild(i).getChild(0));
String groupType;
try {
groupType = (String) operatorGroup.get("groupType");
@@ -720,10 +719,10 @@
// (see following 'if')
operands = (ArrayList<Object>) group.get("operands");
- ParseTree leftChildSpec = getFirstChildWithCat(node.getChild(i)
- .getChild(0), "@l");
- ParseTree rightChildSpec = getFirstChildWithCat(node
- .getChild(i).getChild(0), "@r");
+ ParseTree leftChildSpec = getFirstChildWithCat(
+ node.getChild(i).getChild(0), "@l");
+ ParseTree rightChildSpec = getFirstChildWithCat(
+ node.getChild(i).getChild(0), "@r");
if (leftChildSpec != null || rightChildSpec != null) {
String frame = (leftChildSpec != null) ? "frames:startsWith"
: "frames:endsWith";
@@ -859,7 +858,8 @@
if (qName != null)
term = parseQNameNode(qName);
if (edgeSpecNode != null) {
- LinkedHashMap<String, Object> edgeSpec = parseEdgeSpec(edgeSpecNode);
+ LinkedHashMap<String, Object> edgeSpec = parseEdgeSpec(
+ edgeSpecNode);
String edgeSpecType = (String) edgeSpec.get("@type");
if (edgeSpecType.equals("koral:termGroup")) {
((ArrayList<Object>) edgeSpec.get("operands")).add(term);
@@ -933,7 +933,8 @@
"frames:matches" };
break;
case "_r_":
- frames = new String[] { "frames:endsWith", "frames:matches" };
+ frames = new String[] { "frames:endsWith",
+ "frames:matches" };
break;
case "_i_":
frames = new String[] { "frames:isAround" };
@@ -1000,7 +1001,8 @@
}
- private LinkedHashMap<String, Object> parseEdgeAnno (ParseTree edgeAnnoSpec) {
+ private LinkedHashMap<String, Object> parseEdgeAnno (
+ ParseTree edgeAnnoSpec) {
LinkedHashMap<String, Object> edgeAnno = KoralObjectGenerator
.makeTerm();
ParseTree textSpecNode = getFirstChildWithCat(edgeAnnoSpec, "textSpec");
@@ -1009,8 +1011,8 @@
ParseTree matchOperatorNode = getFirstChildWithCat(edgeAnnoSpec,
"eqOperator");
if (foundryNode != null)
- edgeAnno.put("foundry", foundryNode.getChild(0)
- .toStringTree(parser));
+ edgeAnno.put("foundry",
+ foundryNode.getChild(0).toStringTree(parser));
if (layerNode != null)
edgeAnno.put("layer", layerNode.getChild(0).toStringTree(parser));
edgeAnno.putAll(parseTextSpec(textSpecNode));
@@ -1027,8 +1029,8 @@
private LinkedHashMap<String, Object> boundaryFromRangeSpec (
ParseTree rangeSpec, boolean expandToMax) {
- Integer min = Integer.parseInt(rangeSpec.getChild(0).toStringTree(
- parser));
+ Integer min = Integer
+ .parseInt(rangeSpec.getChild(0).toStringTree(parser));
Integer max = min;
if (expandToMax)
max = null;
@@ -1157,8 +1159,8 @@
parser.addErrorListener(errorListener);
// Get starting rule from parser
Method startRule = AqlParser.class.getMethod("start");
- tree = (ParserRuleContext) startRule
- .invoke(parser, (Object[]) null);
+ tree = (ParserRuleContext) startRule.invoke(parser,
+ (Object[]) null);
}
// Some things went wrong ...
catch (Exception e) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr3AbstractQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr3AbstractQueryProcessor.java
index e6b2d59..9ef53b0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr3AbstractQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr3AbstractQueryProcessor.java
@@ -23,8 +23,8 @@
* @version 0.3.0
* @since 0.1.0
*/
-public abstract class Antlr3AbstractQueryProcessor extends
- AbstractQueryProcessor {
+public abstract class Antlr3AbstractQueryProcessor
+ extends AbstractQueryProcessor {
/**
* The ANTLR parser. Subclasses need to instantiate this field.
@@ -197,7 +197,8 @@
* of children
* with the given category).
*/
- protected static Tree getNthChildWithCat (Tree node, String nodeCat, int n) {
+ protected static Tree getNthChildWithCat (Tree node, String nodeCat,
+ int n) {
int counter = 0;
for (int i = 0; i < node.getChildCount(); i++) {
if (getNodeCat(node.getChild(i)).equals(nodeCat)) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractQueryProcessor.java
index 042b177..b89641a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractQueryProcessor.java
@@ -23,8 +23,8 @@
* @version 0.3.0
* @since 0.1.0
*/
-public abstract class Antlr4AbstractQueryProcessor extends
- AbstractQueryProcessor {
+public abstract class Antlr4AbstractQueryProcessor
+ extends AbstractQueryProcessor {
/**
* The ANTLR parser. Subclasses need to instantiate this field
@@ -129,7 +129,8 @@
* given
* category.
*/
- protected List<ParseTree> getChildrenWithCat (ParseTree node, String nodeCat) {
+ protected List<ParseTree> getChildrenWithCat (ParseTree node,
+ String nodeCat) {
ArrayList<ParseTree> children = new ArrayList<ParseTree>();
for (int i = 0; i < node.getChildCount(); i++) {
if (getNodeCat(node.getChild(i)).equals(nodeCat)) {
@@ -204,6 +205,9 @@
int n) {
int counter = 0;
for (int i = 0; i < node.getChildCount(); i++) {
+ if (visited.contains(node.getChild(i))) {
+ continue;
+ }
if (getNodeCat(node.getChild(i)).equals(nodeCat)) {
counter++;
if (counter == n) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessor.java
index ae544a1..1bdf9ec 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessor.java
@@ -71,8 +71,8 @@
processNode(tree);
}
else {
- addError(StatusCodes.MALFORMED_QUERY, "Could not parse query >>> "
- + query + " <<<.");
+ addError(StatusCodes.MALFORMED_QUERY,
+ "Could not parse query >>> " + query + " <<<.");
}
}
@@ -97,8 +97,8 @@
*/
if (nodeCat.equals("relation")) {
- String operator = getNodeCat(node.getChild(1).getChild(0)).equals(
- "&") ? "and" : "or";
+ String operator = getNodeCat(node.getChild(1).getChild(0))
+ .equals("&") ? "and" : "or";
LinkedHashMap<String, Object> relationGroup = KoralObjectGenerator
.makeDocGroup(operator);
putIntoSuperObject(relationGroup);
@@ -250,8 +250,8 @@
String type = (String) term.get("type");
if (type == null || type.equals("type:regex")) {
if (!(match.equals("match:eq") || match.equals("match:ne")
- || match.equals("match:contains") || match
- .equals("match:containsnot"))) {
+ || match.equals("match:contains")
+ || match.equals("match:containsnot"))) {
addError(StatusCodes.INCOMPATIBLE_OPERATOR_AND_OPERAND,
"You used an inequation operator with a string value.");
return false;
@@ -553,8 +553,8 @@
parser.addErrorListener(errorListener);
// Get starting rule from parser
Method startRule = CollectionQueryParser.class.getMethod("start");
- tree = (ParserRuleContext) startRule
- .invoke(parser, (Object[]) null);
+ tree = (ParserRuleContext) startRule.invoke(parser,
+ (Object[]) null);
}
// Some things went wrong ...
catch (Exception e) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
index fbf63ac..0d8ad23 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
@@ -86,8 +86,8 @@
* be in a sequence with any number of other nodes in this list)
*/
private final List<String> sequentiableNodeTypes = Arrays
- .asList(new String[] { "OPWF", "OPLEM", "OPMORPH", "OPBEG",
- "OPEND", "OPIN", "OPBED", "OPELEM", "OPOR", "OPAND" });
+ .asList(new String[] { "OPWF", "OPLEM", "OPMORPH", "OPBEG", "OPEND",
+ "OPIN", "OPBED", "OPELEM", "OPOR", "OPAND" });
/**
* Keeps track of sequenced nodes, i.e. nodes that implicitly
* govern a sequence, as in (C2PQ (OPWF der) (OPWF Mann)). This is
@@ -172,8 +172,8 @@
if (node == parent.getChild(0)) {
nodeHasSequentiableSiblings = false;
for (int i = 1; i < parent.getChildCount(); i++) {
- if (sequentiableNodeTypes.contains(getNodeCat(parent
- .getChild(i)))) {
+ if (sequentiableNodeTypes
+ .contains(getNodeCat(parent.getChild(i)))) {
nodeHasSequentiableSiblings = true;
continue;
}
@@ -503,8 +503,8 @@
LinkedHashMap<String, Object> focusGroup = null;
if ((boolean) positionOptions.get("matchall") == true) {
focusGroup = KoralObjectGenerator.makeClassRefOp(
- "classRefOp:delete",
- new Integer[] { 128 + classCounter++ }, 128 + classCounter);
+ "classRefOp:delete", new Integer[] { 128 + classCounter++ },
+ 128 + classCounter);
((ArrayList<Object>) focusGroup.get("operands")).add(topGroup);
}
else { // match only first argument
@@ -607,8 +607,8 @@
LinkedHashMap<String, Object> embeddedSequence = group;
if (!(openNodeCats.get(1).equals("OPBEG")
- || openNodeCats.get(1).equals("OPEND") || inOPALL || openNodeCats
- .get(1).equals("OPNHIT"))) {
+ || openNodeCats.get(1).equals("OPEND") || inOPALL
+ || openNodeCats.get(1).equals("OPNHIT"))) {
wrapOperandInClass(node, 1, 128 + classCounter);
wrapOperandInClass(node, 2, 128 + classCounter);
// Deactivated, uncomment to wrap sequence in reference.
@@ -713,18 +713,16 @@
// Step I: create element
LinkedHashMap<String, Object> span = KoralObjectGenerator.makeSpan();
if (node.getChild(0).toStringTree().equals("EMPTY")) {
- addError(
- StatusCodes.MALFORMED_QUERY,
- "Empty #ELEM() operator."
- + " Please specify a valid element key (like 's' for sentence).");
+ addError(StatusCodes.MALFORMED_QUERY, "Empty #ELEM() operator."
+ + " Please specify a valid element key (like 's' for sentence).");
return;
}
else {
int elname = 0;
Tree elnameNode = getFirstChildWithCat(node, "ELNAME");
if (elnameNode != null) {
- span.put("key", elnameNode.getChild(0).toStringTree()
- .toLowerCase());
+ span.put("key",
+ elnameNode.getChild(0).toStringTree().toLowerCase());
elname = 1;
}
if (node.getChildCount() > elname) {
@@ -777,9 +775,10 @@
layer = splitted[1];
}
term.put("layer", translateMorph(layer));
- term.put("key", attrNode.getChild(j).toStringTree());
- String match = getNodeCat(attrNode).equals("EQ") ? "eq"
- : "ne";
+ term.put("key",
+ attrNode.getChild(j).toStringTree());
+ String match = getNodeCat(attrNode).equals("EQ")
+ ? "eq" : "ne";
term.put("match", "match:" + match);
if (node.getChildCount() == elname + 1) {
termGroupOperands.add(term);
@@ -993,16 +992,26 @@
@SuppressWarnings("unchecked")
/**
- * Processes individual position conditions as provided in the OPTS node under the OPBEG node.
- * #BEG allows to specify position constrains that apply to the beginning or the end of the subquery X.
- * E.g., in #BEG(X, tpos/tpos), the 'tpos' constraints before the slash indicate conditions that apply
- * to the beginning of X, those after the slash are conditions that apply to the end of X.
- * See the official C-II documentation for more details. <br/><br/>
+ * Processes individual position conditions as provided in the
+ * OPTS node under the OPBEG node.
+ * #BEG allows to specify position constrains that apply to the
+ * beginning or the end of the subquery X.
+ * E.g., in #BEG(X, tpos/tpos), the 'tpos' constraints before the
+ * slash indicate conditions that apply
+ * to the beginning of X, those after the slash are conditions
+ * that apply to the end of X.
+ * See the official C-II documentation for more details.
+ * <br/><br/>
* What's important here is what follows: <br/>
- * Assume the query #BED(der Mann, sa/pa). This means that <b>the beginning<b/> of "der Mann" stands at
- * the beginning of a sentence and that <b>the end</b> (because this constraint comes after the slash) stands at the
- * beginning of a paragraph. The "end" means the last item, here "Mann", so this token comes at the beginning
- * of a paragraph. To capture this, we choose spanRefs: The last item of X matches the first item of the span (here: P).
+ * Assume the query #BED(der Mann, sa/pa). This means that <b>the
+ * beginning<b/> of "der Mann" stands at
+ * the beginning of a sentence and that <b>the end</b> (because
+ * this constraint comes after the slash) stands at the
+ * beginning of a paragraph. The "end" means the last item, here
+ * "Mann", so this token comes at the beginning
+ * of a paragraph. To capture this, we choose spanRefs: The last
+ * item of X matches the first item of the span (here: P).
+ *
* @param cond
* @param distributedOperands
* @param mode
@@ -1251,8 +1260,8 @@
LinkedHashMap<String, Object>[] wrapCascade) {
int i;
for (i = 0; i < wrapCascade.length - 1; i++) {
- ArrayList<Object> containerOperands = (ArrayList<Object>) wrapCascade[i + 1]
- .get("operands");
+ ArrayList<Object> containerOperands = (ArrayList<Object>) wrapCascade[i
+ + 1].get("operands");
containerOperands.add(0, wrapCascade[i]);
}
return wrapCascade[i];
@@ -1332,7 +1341,8 @@
}
catch (RecognitionException e) {
- log.error("Could not parse query. Please make sure it is well-formed.");
+ log.error(
+ "Could not parse query. Please make sure it is well-formed.");
addError(StatusCodes.MALFORMED_QUERY,
"Could not parse query. Please make sure it is well-formed.");
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CqlQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CqlQueryProcessor.java
index 2dd8985..b88a37a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CqlQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CqlQueryProcessor.java
@@ -30,29 +30,34 @@
private String version;
private boolean isCaseSensitive; // default true
+
public CqlQueryProcessor (String query) {
this(query, VERSION_1_2, true);
}
+
public CqlQueryProcessor (String query, String version) {
this(query, version, true);
}
+
public CqlQueryProcessor (String query, String version,
- boolean isCaseSensitive) {
+ boolean isCaseSensitive) {
super();
this.version = version;
this.isCaseSensitive = isCaseSensitive;
process(query);
}
+
@Override
- public Map<String, Object> getRequestMap() {
+ public Map<String, Object> getRequestMap () {
return this.requestMap;
}
+
@Override
- public void process(String query) {
+ public void process (String query) {
if ((query == null) || query.isEmpty())
addError(StatusCodes.NO_QUERY,
"SRU diagnostic 27: Empty query is unsupported.");
@@ -63,7 +68,8 @@
// requestMap.put("query", sentenceWrapper(queryMap));
}
- private Map<String, Object> sentenceWrapper(Map<String, Object> m) {
+
+ private Map<String, Object> sentenceWrapper (Map<String, Object> m) {
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("@type", "koral:group");
map.put("operation", OPERATION_POSITION);
@@ -81,7 +87,8 @@
return map;
}
- private CQLNode parseQuerytoCQLNode(String query) {
+
+ private CQLNode parseQuerytoCQLNode (String query) {
try {
int compat = -1;
switch (version) {
@@ -100,7 +107,8 @@
}
}
- private Map<String, Object> parseCQLNode(CQLNode node) {
+
+ private Map<String, Object> parseCQLNode (CQLNode node) {
if (node instanceof CQLTermNode) {
return parseTermNode((CQLTermNode) node);
@@ -112,15 +120,15 @@
return parseOrNode((CQLOrNode) node);
}
else {
- addError(
- StatusCodes.UNKNOWN_QUERY_ELEMENT,
+ addError(StatusCodes.UNKNOWN_QUERY_ELEMENT,
"SRU diagnostic 48: Only basic search including term-only "
+ "and boolean (AND,OR) operator queries are currently supported.");
return new LinkedHashMap<String, Object>();
}
}
- private Map<String, Object> parseTermNode(CQLTermNode node) {
+
+ private Map<String, Object> parseTermNode (CQLTermNode node) {
checkTermNode(node);
final String term = node.getTerm();
if ((term == null) || term.isEmpty()) {
@@ -136,7 +144,8 @@
}
}
- private Map<String, Object> parseAndNode(CQLAndNode node) {
+
+ private Map<String, Object> parseAndNode (CQLAndNode node) {
checkBooleanModifier(node);
Map<String, Object> map = new LinkedHashMap<String, Object>();
@@ -161,7 +170,8 @@
return map;
}
- private Map<String, Object> parseOrNode(CQLOrNode node) {
+
+ private Map<String, Object> parseOrNode (CQLOrNode node) {
checkBooleanModifier(node);
Map<String, Object> map = new LinkedHashMap<String, Object>();
@@ -176,7 +186,8 @@
return map;
}
- private Map<String, Object> writeSequence(String str) {
+
+ private Map<String, Object> writeSequence (String str) {
Map<String, Object> sequenceMap = new LinkedHashMap<String, Object>();
sequenceMap.put("@type", "koral:group");
sequenceMap.put("operation", OPERATION_SEQUENCE);
@@ -191,7 +202,8 @@
return sequenceMap;
}
- private Map<String, Object> writeTerm(String term) {
+
+ private Map<String, Object> writeTerm (String term) {
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("@type", "koral:term");
if (!isCaseSensitive) {
@@ -207,20 +219,21 @@
return tokenMap;
}
- private void checkBooleanModifier(CQLBooleanNode node) {
+
+ private void checkBooleanModifier (CQLBooleanNode node) {
List<Modifier> modifiers = node.getModifiers();
if ((modifiers != null) && !modifiers.isEmpty()) {
Modifier modifier = modifiers.get(0);
- addError(105,
- "SRU diagnostic 20: Relation modifier " + modifier.toCQL()
- + " is not supported.");
+ addError(105, "SRU diagnostic 20: Relation modifier "
+ + modifier.toCQL() + " is not supported.");
}
}
- private void checkTermNode(CQLTermNode node) {
+
+ private void checkTermNode (CQLTermNode node) {
// only allow "cql.serverChoice" and "words" index
- if (!(INDEX_CQL_SERVERCHOICE.equals(node.getIndex()) || INDEX_WORDS
- .equals(node.getIndex()))) {
+ if (!(INDEX_CQL_SERVERCHOICE.equals(node.getIndex())
+ || INDEX_WORDS.equals(node.getIndex()))) {
addError(105, "SRU diagnostic 16: Index " + node.getIndex()
+ " is not supported.");
}
@@ -228,18 +241,16 @@
CQLRelation relation = node.getRelation();
String baseRel = relation.getBase();
if (!(TERM_RELATION_CQL_1_1.equals(baseRel)
- || TERM_RELATION_CQL_1_2.equals(baseRel) || SUPPORTED_RELATION_EXACT
- .equals(baseRel))) {
+ || TERM_RELATION_CQL_1_2.equals(baseRel)
+ || SUPPORTED_RELATION_EXACT.equals(baseRel))) {
addError(105, "SRU diagnostic 19: Relation " + relation.getBase()
+ " is not supported.");
}
List<Modifier> modifiers = relation.getModifiers();
if ((modifiers != null) && !modifiers.isEmpty()) {
Modifier modifier = modifiers.get(0);
- addError(
- 105,
- "SRU diagnostic 20: Relation modifier "
- + modifier.getValue() + " is not supported.");
+ addError(105, "SRU diagnostic 20: Relation modifier "
+ + modifier.getValue() + " is not supported.");
}
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessor.java
index 3717cba..96991ab 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessor.java
@@ -12,8 +12,11 @@
import eu.clarin.sru.server.fcs.parser.QueryParser;
import eu.clarin.sru.server.fcs.parser.QueryParserException;
-/** FCSQLQueryProcessor is accountable for the serialization of FCSQL to KoralQuery.
- * The KoralQuery is structured as a map containing parts of JSON-LD serializations of KoralObjects.
+/**
+ * FCSQLQueryProcessor is accountable for the serialization of FCSQL
+ * to KoralQuery.
+ * The KoralQuery is structured as a map containing parts of JSON-LD
+ * serializations of KoralObjects.
*
* @author margaretha
*
@@ -26,8 +29,9 @@
super(rawQuery, parsedQuery);
}
+
@Override
- public String getQueryType() {
+ public String getQueryType () {
return Constants.FCS_QUERY_TYPE_FCS;
}
}
@@ -37,9 +41,14 @@
private final QueryParser fcsParser = new QueryParser();
private String version;
- /** Constructs FCSQLQueryProcessor for the given query and version.
- * @param query an FCS query string
- * @param version the FCSQL version of the query
+
+ /**
+ * Constructs FCSQLQueryProcessor for the given query and version.
+ *
+ * @param query
+ * an FCS query string
+ * @param version
+ * the FCSQL version of the query
*/
public FCSQLQueryProcessor (String query, String version) {
super();
@@ -47,30 +56,33 @@
process(query);
}
+
@Override
- public Map<String, Object> getRequestMap() {
+ public Map<String, Object> getRequestMap () {
return this.requestMap;
}
+
@Override
- public void process(String query) {
+ public void process (String query) {
if (isVersionValid()) {
FCSSRUQuery fcsSruQuery = parseQueryStringtoFCSQuery(query);
if (fcsSruQuery != null) {
QueryNode fcsQueryNode = fcsSruQuery.getParsedQuery();
try {
- parseFCSQueryToKoralQuery(fcsQueryNode);
- } catch (KoralException e) {
- addError(e.getStatusCode(), e.getMessage());
- }
+ parseFCSQueryToKoralQuery(fcsQueryNode);
+ }
+ catch (KoralException e) {
+ addError(e.getStatusCode(), e.getMessage());
+ }
}
}
}
- private boolean isVersionValid() {
+
+ private boolean isVersionValid () {
if (version == null || version.isEmpty()) {
- addError(StatusCodes.MISSING_VERSION,
- "Version number is missing.");
+ addError(StatusCodes.MISSING_VERSION, "Version number is missing.");
return false;
}
else if (!version.equals(VERSION_2_0)) {
@@ -81,14 +93,18 @@
return true;
}
- /** Translates the given FCS query string into an FCSSSRUQuery object.
- * @param query an FCS query string
+
+ /**
+ * Translates the given FCS query string into an FCSSSRUQuery
+ * object.
+ *
+ * @param query
+ * an FCS query string
* @return an FCSSRUQuery
*/
- private FCSSRUQuery parseQueryStringtoFCSQuery(String query) {
+ private FCSSRUQuery parseQueryStringtoFCSQuery (String query) {
if ((query == null) || query.isEmpty())
- addError(StatusCodes.NO_QUERY,
- "No query has been passed.");
+ addError(StatusCodes.NO_QUERY, "No query has been passed.");
FCSSRUQuery fcsQuery = null;
try {
QueryNode parsedQuery = fcsParser.parse(query);
@@ -99,26 +115,30 @@
}
}
catch (QueryParserException e) {
- addError(
- StatusCodes.UNKNOWN_QUERY_ERROR,
- "Query cannot be parsed, "
- + e.getMessage());
+ addError(StatusCodes.UNKNOWN_QUERY_ERROR,
+ "Query cannot be parsed, " + e.getMessage());
}
catch (Exception e) {
- addError(StatusCodes.UNKNOWN_QUERY_ERROR, "Unexpected error while parsing query.");
+ addError(StatusCodes.UNKNOWN_QUERY_ERROR,
+ "Unexpected error while parsing query.");
}
return fcsQuery;
}
- /** Generates a query map structure for the given FCS query node.
+
+ /**
+ * Generates a query map structure for the given FCS query node.
*
- * @param queryNode an FCS query node
+ * @param queryNode
+ * an FCS query node
* @throws KoralException
*/
- private void parseFCSQueryToKoralQuery(QueryNode queryNode) throws KoralException {
+ private void parseFCSQueryToKoralQuery (QueryNode queryNode)
+ throws KoralException {
FCSSRUQueryParser parser = new FCSSRUQueryParser();
KoralObject o = parser.parseQueryNode(queryNode);
Map<String, Object> queryMap = MapBuilder.buildQueryMap(o);
- if (queryMap != null) requestMap.put("query", queryMap);
+ if (queryMap != null)
+ requestMap.put("query", queryMap);
}
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MapBuilder.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MapBuilder.java
index f80c152..1dbbd9b 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MapBuilder.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MapBuilder.java
@@ -9,17 +9,20 @@
import de.ids_mannheim.korap.query.object.KoralTermGroup;
import de.ids_mannheim.korap.query.object.KoralToken;
-/**
+/**
* @author margaretha
*
*/
public class MapBuilder {
- /** Builds a query map containing JSON-LD serialization parts of the given KoralObject.
+ /**
+ * Builds a query map containing JSON-LD serialization parts of
+ * the given KoralObject.
+ *
* @param o
* @return a map
*/
- public static Map<String, Object> buildQueryMap(KoralObject o) {
+ public static Map<String, Object> buildQueryMap (KoralObject o) {
if (o != null) {
if (o instanceof KoralToken) {
KoralToken token = (KoralToken) o;
@@ -37,9 +40,9 @@
KoralTermGroup termGroup = (KoralTermGroup) o;
return termGroup.buildMap();
}
- else if (o instanceof KoralSpan){
- KoralSpan span = (KoralSpan) o;
- return span.buildMap();
+ else if (o instanceof KoralSpan) {
+ KoralSpan span = (KoralSpan) o;
+ return span.buildMap();
}
}
return null;
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQueryBuilder.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQueryBuilder.java
index cad4319..4bce12e 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQueryBuilder.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQueryBuilder.java
@@ -114,23 +114,28 @@
this.context = context;
}
- public String getRightType() {
+
+ public String getRightType () {
return this.right_type;
}
- public String getLeftType() {
+
+ public String getLeftType () {
return this.left_type;
}
- public Integer getLeftSize() {
+
+ public Integer getLeftSize () {
return this.left_size;
}
- public Integer getRightSize() {
+
+ public Integer getRightSize () {
return this.right_size;
}
- public Map raw() {
+
+ public Map raw () {
Map meta = new LinkedHashMap();
if (this.context == null) {
Map map = new LinkedHashMap();
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 62422ae..443b2df 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
@@ -12,30 +12,28 @@
import java.util.*;
/**
- * Main class for Koral, serializes queries from concrete QLs to KoralQuery
+ * Main class for Koral, serializes queries from concrete QLs to
+ * KoralQuery
*
* @author Joachim Bingel (bingel@ids-mannheim.de), Michael Hanl
- * (hanl@ids-mannheim.de), Eliza Margaretha (margaretha@ids-mannheim.de)
+ * (hanl@ids-mannheim.de), Eliza Margaretha
+ * (margaretha@ids-mannheim.de)
* @version 0.3.0
* @since 0.1.0
*/
public class QuerySerializer {
// fixme: not used in any way!
- @Deprecated
- static HashMap<String, Class<? extends AbstractQueryProcessor>> qlProcessorAssignment;
-
-
-
-
- static {
- qlProcessorAssignment = new HashMap<String, Class<? extends AbstractQueryProcessor>>();
- qlProcessorAssignment.put("poliqarpplus",
- PoliqarpPlusQueryProcessor.class);
- qlProcessorAssignment.put("cosmas2", Cosmas2QueryProcessor.class);
- qlProcessorAssignment.put("annis", AnnisQueryProcessor.class);
- qlProcessorAssignment.put("cql", CqlQueryProcessor.class);
- }
+ // @Deprecated
+ // static HashMap<String, Class<? extends AbstractQueryProcessor>> qlProcessorAssignment;
+ // static {
+ // qlProcessorAssignment = new HashMap<String, Class<? extends AbstractQueryProcessor>>();
+ // qlProcessorAssignment.put("poliqarpplus",
+ // PoliqarpPlusQueryProcessor.class);
+ // qlProcessorAssignment.put("cosmas2", Cosmas2QueryProcessor.class);
+ // qlProcessorAssignment.put("annis", AnnisQueryProcessor.class);
+ // qlProcessorAssignment.put("cql", CqlQueryProcessor.class);
+ // }
private static ObjectMapper mapper = new ObjectMapper();
private Logger qllogger = LoggerFactory.getLogger("ql");
@@ -50,16 +48,18 @@
private org.slf4j.Logger log = LoggerFactory
.getLogger(QuerySerializer.class);
- public QuerySerializer() {
+
+ public QuerySerializer () {
this.errors = new LinkedList<>();
this.warnings = new LinkedList<>();
this.messages = new LinkedList<>();
}
+
/**
* @param args
*/
- public static void main(String[] args) {
+ public static void main (String[] args) {
/*
* just for testing...
*/
@@ -72,7 +72,8 @@
System.err
.println("Usage: QuerySerializer \"query\" queryLanguage");
System.exit(1);
- } else {
+ }
+ else {
queries = new String[] { args[0] };
ql = args[1];
}
@@ -81,105 +82,134 @@
try {
jg.run(q, ql);
System.out.println();
- } catch (NullPointerException npe) {
+ }
+ catch (NullPointerException npe) {
npe.printStackTrace();
System.out.println("null\n");
- } catch (IOException e) {
+ }
+ catch (IOException e) {
e.printStackTrace();
}
}
}
+
/**
- * Runs the QuerySerializer by initializing the relevant AbstractSyntaxTree
- * implementation (depending on specified query language) and transforms and
- * writes the tree's requestMap to the specified output file.
- *
- * @param query
- * The query string
- * @param queryLanguage
- * The query language. As of 17 Dec 2014, this must be one of
- * 'poliqarpplus', 'cosmas2', 'annis' or 'cql'.
- * @throws IOException
- */
- public void run(String query, String queryLanguage) throws IOException {
+ * Runs the QuerySerializer by initializing the relevant
+ * AbstractSyntaxTree
+ * implementation (depending on specified query language) and
+ * transforms and
+ * writes the tree's requestMap to the specified output file.
+ *
+ * @param query
+ * The query string
+ * @param queryLanguage
+ * The query language. As of 17 Dec 2014, this must be
+ * one of
+ * 'poliqarpplus', 'cosmas2', 'annis' or 'cql'.
+ * @throws IOException
+ */
+ public void run (String query, String queryLanguage) throws IOException {
if (queryLanguage.equalsIgnoreCase("poliqarp")) {
ast = new PoliqarpPlusQueryProcessor(query);
- } else if (queryLanguage.equalsIgnoreCase("cosmas2")) {
+ }
+ else if (queryLanguage.equalsIgnoreCase("cosmas2")) {
ast = new Cosmas2QueryProcessor(query);
- } else if (queryLanguage.equalsIgnoreCase("poliqarpplus")) {
+ }
+ else if (queryLanguage.equalsIgnoreCase("poliqarpplus")) {
ast = new PoliqarpPlusQueryProcessor(query);
- } else if (queryLanguage.equalsIgnoreCase("cql")) {
+ }
+ else if (queryLanguage.equalsIgnoreCase("cql")) {
ast = new CqlQueryProcessor(query);
- } else if (queryLanguage.equalsIgnoreCase("fcsql")) {
- ast = new FCSQLQueryProcessor(query, "2.0");
- }else if (queryLanguage.equalsIgnoreCase("annis")) {
+ }
+ else if (queryLanguage.equalsIgnoreCase("fcsql")) {
+ ast = new FCSQLQueryProcessor(query, "2.0");
+ }
+ else if (queryLanguage.equalsIgnoreCase("annis")) {
ast = new AnnisQueryProcessor(query);
- } else {
- throw new IllegalArgumentException(queryLanguage
- + " is not a supported query language!");
+ }
+ else {
+ throw new IllegalArgumentException(
+ queryLanguage + " is not a supported query language!");
}
toJSON();
}
- public QuerySerializer setQuery(String query, String ql, String version) {
+
+ public QuerySerializer setQuery (String query, String ql, String version) {
ast = new DummyQueryProcessor();
if (query == null || query.isEmpty()) {
ast.addError(StatusCodes.NO_QUERY, "You did not specify a query!");
- } else if (ql == null || ql.isEmpty()) {
+ }
+ else if (ql == null || ql.isEmpty()) {
ast.addError(StatusCodes.NO_QUERY,
"You did not specify any query language!");
- } else if (ql.equalsIgnoreCase("poliqarp")) {
+ }
+ else if (ql.equalsIgnoreCase("poliqarp")) {
ast = new PoliqarpPlusQueryProcessor(query);
- } else if (ql.equalsIgnoreCase("cosmas2")) {
+ }
+ else if (ql.equalsIgnoreCase("cosmas2")) {
ast = new Cosmas2QueryProcessor(query);
- } else if (ql.equalsIgnoreCase("poliqarpplus")) {
+ }
+ else if (ql.equalsIgnoreCase("poliqarpplus")) {
ast = new PoliqarpPlusQueryProcessor(query);
- }else if (ql.equalsIgnoreCase("cql")) {
- if (version == null) {
+ }
+ else if (ql.equalsIgnoreCase("cql")) {
+ if (version == null) {
ast = new CqlQueryProcessor(query);
- } else {
+ }
+ else {
ast = new CqlQueryProcessor(query, version);
- }
- } else if (ql.equalsIgnoreCase("fcsql")) {
- if (version == null) {
- ast.addError(StatusCodes.MISSING_VERSION,
- "SRU Version is missing!");
- } else {
- ast = new FCSQLQueryProcessor(query, version);
- }
- } else if (ql.equalsIgnoreCase("annis")) {
+ }
+ }
+ else if (ql.equalsIgnoreCase("fcsql")) {
+ if (version == null) {
+ ast.addError(StatusCodes.MISSING_VERSION,
+ "SRU Version is missing!");
+ }
+ else {
+ ast = new FCSQLQueryProcessor(query, version);
+ }
+ }
+ else if (ql.equalsIgnoreCase("annis")) {
ast = new AnnisQueryProcessor(query);
- }else {
- ast.addError(StatusCodes.UNKNOWN_QUERY_LANGUAGE,
+ }
+ else {
+ ast.addError(StatusCodes.UNKNOWN_QUERY_LANGUAGE,
ql + " is not a supported query language!");
}
return this;
}
- public QuerySerializer setQuery(String query, String ql) {
+
+ public QuerySerializer setQuery (String query, String ql) {
return setQuery(query, ql, "");
}
- public void setVerbose(boolean verbose) {
+
+ public void setVerbose (boolean verbose) {
AbstractQueryProcessor.verbose = verbose;
}
- public final String toJSON() {
+
+ public final String toJSON () {
String ser;
try {
ser = mapper.writeValueAsString(raw());
qllogger.info("Serialized query: " + ser);
- } catch (JsonProcessingException e) {
+ }
+ catch (JsonProcessingException e) {
return "";
}
return ser;
}
- public final Map build() {
+
+ public final Map build () {
return raw();
}
+
private Map raw () {
if (ast != null) {
Map<String, Object> requestMap = new HashMap<>(ast.getRequestMap());
@@ -221,6 +251,7 @@
return new HashMap<>();
}
+
private Map<String, Object> cleanup (Map<String, Object> requestMap) {
Iterator<Map.Entry<String, Object>> set = requestMap.entrySet()
.iterator();
@@ -239,7 +270,8 @@
return requestMap;
}
- private Map<String, Object> mergeCollection (
+
+ private Map<String, Object> mergeCollection (
Map<String, Object> collection1, Map<String, Object> collection2) {
if (collection1 == null || collection1.isEmpty()) {
return collection2;
@@ -261,8 +293,9 @@
}
}
+
@Deprecated
- public QuerySerializer addMeta(String cli, String cri, int cls, int crs,
+ public QuerySerializer addMeta (String cli, String cri, int cls, int crs,
int num, int pageIndex) {
MetaQueryBuilder meta = new MetaQueryBuilder();
meta.setSpanContext(cls, cli, crs, cri);
@@ -272,17 +305,20 @@
return this;
}
- public QuerySerializer setMeta(Map<String, Object> meta) {
+
+ public QuerySerializer setMeta (Map<String, Object> meta) {
this.meta = meta;
return this;
}
- public QuerySerializer setMeta(MetaQueryBuilder meta) {
- this.meta = meta.raw();
- return this;
- }
- public QuerySerializer setCollection(String collection) {
+ public QuerySerializer setMeta (MetaQueryBuilder meta) {
+ this.meta = meta.raw();
+ return this;
+ }
+
+
+ public QuerySerializer setCollection (String collection) {
CollectionQueryProcessor tree = new CollectionQueryProcessor();
tree.process(collection);
Map<String, Object> collectionRequest = tree.getRequestMap();
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/QueryUtils.java b/src/main/java/de/ids_mannheim/korap/query/serialize/QueryUtils.java
index 47b5e09..6fca4c8 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/QueryUtils.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/QueryUtils.java
@@ -158,8 +158,8 @@
@Deprecated
- public static Map addParameters (Map request, int page, int num,
- String cli, String cri, int cls, int crs, boolean cutoff) {
+ public static Map addParameters (Map request, int page, int num, String cli,
+ String cri, int cls, int crs, boolean cutoff) {
Map ctx = new LinkedHashMap();
List left = new ArrayList();
left.add(cli);
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/TreeTemplate.java b/src/main/java/de/ids_mannheim/korap/query/serialize/TreeTemplate.java
index b6ce44b..d087bd0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/TreeTemplate.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/TreeTemplate.java
@@ -55,8 +55,8 @@
processNode(tree);
}
else {
- addError(StatusCodes.MALFORMED_QUERY, "Could not parse query >>> "
- + query + " <<<.");
+ addError(StatusCodes.MALFORMED_QUERY,
+ "Could not parse query >>> " + query + " <<<.");
}
}
@@ -158,8 +158,8 @@
// TODO replace AqlParser with parser for your Antlr4
// grammar!
Method startRule = AqlParser.class.getMethod("start");
- tree = (ParserRuleContext) startRule
- .invoke(parser, (Object[]) null);
+ tree = (ParserRuleContext) startRule.invoke(parser,
+ (Object[]) null);
}
// Some things went wrong ...
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralException.java b/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralException.java
index 343c2ae..ce72ab1 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralException.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralException.java
@@ -1,32 +1,38 @@
package de.ids_mannheim.korap.query.serialize.util;
-/** Define a custom exception for errors in parsing into and serializing KoralQuery.
+/**
+ * Define a custom exception for errors in parsing into and
+ * serializing KoralQuery.
*
* @author margaretha
*
*/
-public class KoralException extends Exception{
-
- private static final long serialVersionUID = 5463242042200109417L;
- private int statusCode;
-
- public KoralException(int code, String message) {
- super(message);
- this.statusCode = code;
- }
-
- public KoralException(int code, String message, Throwable cause) {
+public class KoralException extends Exception {
+
+ private static final long serialVersionUID = 5463242042200109417L;
+ private int statusCode;
+
+
+ public KoralException (int code, String message) {
+ super(message);
+ this.statusCode = code;
+ }
+
+
+ public KoralException (int code, String message, Throwable cause) {
super(message, cause);
this.statusCode = code;
}
- public int getStatusCode() {
- return statusCode;
- }
- public void setStatusCode(int statusCode) {
- this.statusCode = statusCode;
- }
+ public int getStatusCode () {
+ return statusCode;
+ }
-
+
+ public void setStatusCode (int statusCode) {
+ this.statusCode = statusCode;
+ }
+
+
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java b/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java
index 8381176..b59fa7e 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java
@@ -41,7 +41,8 @@
}
- public static LinkedHashMap<String, Object> makeTermGroup (String relation) {
+ public static LinkedHashMap<String, Object> makeTermGroup (
+ String relation) {
LinkedHashMap<String, Object> term = new LinkedHashMap<String, Object>();
term.put("@type", "koral:termGroup");
term.put("relation", "relation:" + relation);
@@ -126,9 +127,10 @@
group.put("operation", "operation:class");
if (setBySystem) {
classId += 128;
- qp.addMessage("A class has been introduced into the backend representation of "
- + "your query for later reference to a part of the query. The class id is "
- + classId);
+ qp.addMessage(
+ "A class has been introduced into the backend representation of "
+ + "your query for later reference to a part of the query. The class id is "
+ + classId);
}
group.put("classOut", classId);
group.put("operands", new ArrayList<Object>());
@@ -163,7 +165,8 @@
@Deprecated
- public static LinkedHashMap<String, Object> makeTreeRelation (String reltype) {
+ public static LinkedHashMap<String, Object> makeTreeRelation (
+ String reltype) {
LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
group.put("@type", "koral:treeRelation");
if (reltype != null)
@@ -206,8 +209,7 @@
if (max != null) {
group.put("max", max);
}
- qp.addMessage(
- StatusCodes.DEPRECATED_QUERY_ELEMENT,
+ qp.addMessage(StatusCodes.DEPRECATED_QUERY_ELEMENT,
"Deprecated 2014-07-24: 'min' and 'max' to be supported until 3 months from deprecation date.");
return group;
}
@@ -280,7 +282,8 @@
}
- public static void addOperandsToGroup (LinkedHashMap<String, Object> group) {
+ public static void addOperandsToGroup (
+ LinkedHashMap<String, Object> group) {
ArrayList<Object> operands = new ArrayList<Object>();
group.put("operands", operands);
}
@@ -328,10 +331,10 @@
public static int cropToMaxValue (int number) {
if (number > MAXIMUM_DISTANCE) {
number = MAXIMUM_DISTANCE;
- String warning = String
- .format("You specified a distance between two segments that is greater than "
+ String warning = String.format(
+ "You specified a distance between two segments that is greater than "
+ "the allowed max value of %d. Your query will be re-interpreted using a distance of %d.",
- MAXIMUM_DISTANCE, MAXIMUM_DISTANCE);
+ MAXIMUM_DISTANCE, MAXIMUM_DISTANCE);
qp.addWarning(warning);
}
return number;
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/util/StatusCodes.java b/src/main/java/de/ids_mannheim/korap/query/serialize/util/StatusCodes.java
index 8a7f6e0..05b9ea4 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/util/StatusCodes.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/util/StatusCodes.java
@@ -7,10 +7,10 @@
public final static int INVALID_CLASS_REFERENCE = 304;
public final static int INCOMPATIBLE_OPERATOR_AND_OPERAND = 305;
public final static int UNKNOWN_QUERY_ELEMENT = 306;
- public final static int UNKNOWN_QUERY_LANGUAGE = 307;
+ public final static int UNKNOWN_QUERY_LANGUAGE = 307;
public final static int UNBOUND_ANNIS_RELATION = 308;
- public final static int MISSING_VERSION = 309;
- public final static int UNSUPPORTED_VERSION = 310;
- public final static int QUERY_TOO_COMPLEX = 311;
- public final static int UNKNOWN_QUERY_ERROR = 399;
+ public final static int MISSING_VERSION = 309;
+ public final static int UNSUPPORTED_VERSION = 310;
+ public final static int QUERY_TOO_COMPLEX = 311;
+ public final static int UNKNOWN_QUERY_ERROR = 399;
}
\ No newline at end of file
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java
index 114fc2c..82b5b8c 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java
@@ -41,7 +41,8 @@
@Test
- public void testSingleTokens () throws JsonProcessingException, IOException {
+ public void testSingleTokens ()
+ throws JsonProcessingException, IOException {
query = "\"Mann\"";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
@@ -117,8 +118,8 @@
@Test
- public void testFoundriesLayers () throws JsonProcessingException,
- IOException {
+ public void testFoundriesLayers ()
+ throws JsonProcessingException, IOException {
query = "c=\"np\"";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
@@ -155,9 +156,10 @@
assertEquals("operation:relation", res.at("/query/operation").asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
- assertEquals("koral:relation", res.at("/query/relation/@type").asText());
- assertEquals("koral:term", res.at("/query/relation/wrap/@type")
- .asText());
+ assertEquals("koral:relation",
+ res.at("/query/relation/@type").asText());
+ assertEquals("koral:term",
+ res.at("/query/relation/wrap/@type").asText());
assertEquals("c", res.at("/query/relation/wrap/layer").asText());
query = "node > cnx/c=\"np\"";
@@ -170,9 +172,10 @@
assertEquals("np", res.at("/query/operands/1/key").asText());
assertEquals("c", res.at("/query/operands/1/layer").asText());
assertEquals("cnx", res.at("/query/operands/1/foundry").asText());
- assertEquals("koral:relation", res.at("/query/relation/@type").asText());
- assertEquals("koral:term", res.at("/query/relation/wrap/@type")
- .asText());
+ assertEquals("koral:relation",
+ res.at("/query/relation/@type").asText());
+ assertEquals("koral:term",
+ res.at("/query/relation/wrap/@type").asText());
assertEquals("c", res.at("/query/relation/wrap/layer").asText());
query = "cnx/c=\"np\" > node";
@@ -191,16 +194,17 @@
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
assertEquals("NP", res.at("/query/operands/1/key").asText());
assertEquals(true, res.at("/query/operands/2").isMissingNode());
- assertEquals("koral:relation", res.at("/query/relation/@type").asText());
- assertEquals("koral:term", res.at("/query/relation/wrap/@type")
- .asText());
+ assertEquals("koral:relation",
+ res.at("/query/relation/@type").asText());
+ assertEquals("koral:term",
+ res.at("/query/relation/wrap/@type").asText());
assertEquals("c", res.at("/query/relation/wrap/layer").asText());
}
@Test
- public void testDefPredicationInversion () throws JsonProcessingException,
- IOException {
+ public void testDefPredicationInversion ()
+ throws JsonProcessingException, IOException {
query = "#1 > #2 & cnx/cat=\"vp\" & cnx/cat=\"np\"";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
@@ -215,16 +219,17 @@
assertEquals("np", res.at("/query/operands/1/key").asText());
assertEquals("c", res.at("/query/operands/1/layer").asText());
assertEquals("cnx", res.at("/query/operands/1/foundry").asText());
- assertEquals("koral:relation", res.at("/query/relation/@type").asText());
- assertEquals("koral:term", res.at("/query/relation/wrap/@type")
- .asText());
+ assertEquals("koral:relation",
+ res.at("/query/relation/@type").asText());
+ assertEquals("koral:term",
+ res.at("/query/relation/wrap/@type").asText());
assertEquals("c", res.at("/query/relation/wrap/layer").asText());
}
@Test
- public void testSimpleDominance () throws JsonProcessingException,
- IOException {
+ public void testSimpleDominance ()
+ throws JsonProcessingException, IOException {
query = "node & node & #2 > #1";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
@@ -232,9 +237,10 @@
assertEquals("operation:relation", res.at("/query/operation").asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
- assertEquals("koral:relation", res.at("/query/relation/@type").asText());
- assertEquals("koral:term", res.at("/query/relation/wrap/@type")
- .asText());
+ assertEquals("koral:relation",
+ res.at("/query/relation/@type").asText());
+ assertEquals("koral:term",
+ res.at("/query/relation/wrap/@type").asText());
assertEquals("c", res.at("/query/relation/wrap/layer").asText());
query = "\"Mann\" & node & #2 > #1";
@@ -245,104 +251,105 @@
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
assertEquals("koral:token", res.at("/query/operands/1/@type").asText());
assertEquals("Mann", res.at("/query/operands/1/wrap/key").asText());
- assertEquals("koral:relation", res.at("/query/relation/@type").asText());
- assertEquals("koral:term", res.at("/query/relation/wrap/@type")
- .asText());
+ assertEquals("koral:relation",
+ res.at("/query/relation/@type").asText());
+ assertEquals("koral:term",
+ res.at("/query/relation/wrap/@type").asText());
assertEquals("c", res.at("/query/relation/wrap/layer").asText());
query = "\"Mann\" & node & #2 >[func=\"SB\"] #1"; //coordinates the func=SB term and requires a "c"-layer term (consituency relation/dominance)
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
- assertEquals("koral:relation", res.at("/query/relation/@type").asText());
- assertEquals("koral:termGroup", res.at("/query/relation/wrap/@type")
- .asText());
- assertEquals("relation:and", res.at("/query/relation/wrap/relation")
- .asText());
- assertEquals("c", res.at("/query/relation/wrap/operands/1/layer")
- .asText());
- assertEquals("func", res.at("/query/relation/wrap/operands/0/layer")
- .asText());
- assertEquals("SB", res.at("/query/relation/wrap/operands/0/key")
- .asText());
+ assertEquals("koral:relation",
+ res.at("/query/relation/@type").asText());
+ assertEquals("koral:termGroup",
+ res.at("/query/relation/wrap/@type").asText());
+ assertEquals("relation:and",
+ res.at("/query/relation/wrap/relation").asText());
+ assertEquals("c",
+ res.at("/query/relation/wrap/operands/1/layer").asText());
+ assertEquals("func",
+ res.at("/query/relation/wrap/operands/0/layer").asText());
+ assertEquals("SB",
+ res.at("/query/relation/wrap/operands/0/key").asText());
query = "cat=\"S\" & node & #1 >[func=\"SB\" func=\"MO\"] #2"; // quite meaningless (function is subject and modifier), but this is allowed by Annis, however its backend only regards the 1st option
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
- assertEquals("koral:relation", res.at("/query/relation/@type").asText());
- assertEquals("koral:termGroup", res.at("/query/relation/wrap/@type")
- .asText());
- assertEquals("relation:and", res.at("/query/relation/wrap/relation")
- .asText());
- assertEquals("func", res.at("/query/relation/wrap/operands/0/layer")
- .asText());
- assertEquals("SB", res.at("/query/relation/wrap/operands/0/key")
- .asText());
- assertEquals("func", res.at("/query/relation/wrap/operands/1/layer")
- .asText());
- assertEquals("MO", res.at("/query/relation/wrap/operands/1/key")
- .asText());
- assertEquals("c", res.at("/query/relation/wrap/operands/2/layer")
- .asText());
+ assertEquals("koral:relation",
+ res.at("/query/relation/@type").asText());
+ assertEquals("koral:termGroup",
+ res.at("/query/relation/wrap/@type").asText());
+ assertEquals("relation:and",
+ res.at("/query/relation/wrap/relation").asText());
+ assertEquals("func",
+ res.at("/query/relation/wrap/operands/0/layer").asText());
+ assertEquals("SB",
+ res.at("/query/relation/wrap/operands/0/key").asText());
+ assertEquals("func",
+ res.at("/query/relation/wrap/operands/1/layer").asText());
+ assertEquals("MO",
+ res.at("/query/relation/wrap/operands/1/key").asText());
+ assertEquals("c",
+ res.at("/query/relation/wrap/operands/2/layer").asText());
query = "cat=\"S\" & cat=\"NP\" & #1 >@l #2"; // all sentences starting with NP -> wrap relation in startswith and retrieve 2nd operand with focus
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("operation:position", res.at("/query/operation").asText());
- assertEquals("operation:relation", res
- .at("/query/operands/0/operation").asText());
+ assertEquals("operation:relation",
+ res.at("/query/operands/0/operation").asText());
assertEquals("frames:startsWith", res.at("/query/frames/0").asText());
- assertEquals("koral:span", res.at("/query/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:span",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("S", res.at("/query/operands/0/operands/0/key").asText());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/1/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(130, res.at("/query/operands/0/operands/1/classOut")
- .asInt());
- assertEquals("koral:span",
- res.at("/query/operands/0/operands/1/operands/0/@type")
- .asText());
- assertEquals("NP", res
- .at("/query/operands/0/operands/1/operands/0/key").asText());
- assertEquals("koral:reference", res.at("/query/operands/1/@type")
- .asText());
- assertEquals("operation:focus", res.at("/query/operands/1/operation")
- .asText());
+ assertEquals(130,
+ res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals("koral:span", res
+ .at("/query/operands/0/operands/1/operands/0/@type").asText());
+ assertEquals("NP",
+ res.at("/query/operands/0/operands/1/operands/0/key").asText());
+ assertEquals("koral:reference",
+ res.at("/query/operands/1/@type").asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/1/operation").asText());
assertEquals(130, res.at("/query/operands/1/classRef/0").asInt());
query = "cat=\"S\" & cat=\"NP\" & #1 >@r #2";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("operation:position", res.at("/query/operation").asText());
- assertEquals("operation:relation", res
- .at("/query/operands/0/operation").asText());
+ assertEquals("operation:relation",
+ res.at("/query/operands/0/operation").asText());
assertEquals("frames:endsWith", res.at("/query/frames/0").asText());
- assertEquals("koral:span", res.at("/query/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:span",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("S", res.at("/query/operands/0/operands/0/key").asText());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/1/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(130, res.at("/query/operands/0/operands/1/classOut")
- .asInt());
- assertEquals("koral:span",
- res.at("/query/operands/0/operands/1/operands/0/@type")
- .asText());
- assertEquals("NP", res
- .at("/query/operands/0/operands/1/operands/0/key").asText());
- assertEquals("koral:reference", res.at("/query/operands/1/@type")
- .asText());
- assertEquals("operation:focus", res.at("/query/operands/1/operation")
- .asText());
+ assertEquals(130,
+ res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals("koral:span", res
+ .at("/query/operands/0/operands/1/operands/0/@type").asText());
+ assertEquals("NP",
+ res.at("/query/operands/0/operands/1/operands/0/key").asText());
+ assertEquals("koral:reference",
+ res.at("/query/operands/1/@type").asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/1/operation").asText());
assertEquals(130, res.at("/query/operands/1/classRef/0").asInt());
}
@Test
- public void testIndirectDominance () throws JsonProcessingException,
- IOException {
+ public void testIndirectDominance ()
+ throws JsonProcessingException, IOException {
query = "node & node & #1 >2,4 #2";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
@@ -350,37 +357,38 @@
assertEquals("operation:relation", res.at("/query/operation").asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
- assertEquals("koral:relation", res.at("/query/relation/@type").asText());
+ assertEquals("koral:relation",
+ res.at("/query/relation/@type").asText());
assertEquals(2, res.at("/query/relation/boundary/min").asInt());
assertEquals(4, res.at("/query/relation/boundary/max").asInt());
- assertEquals("koral:term", res.at("/query/relation/wrap/@type")
- .asText());
+ assertEquals("koral:term",
+ res.at("/query/relation/wrap/@type").asText());
assertEquals("c", res.at("/query/relation/wrap/layer").asText());
query = "node & node & #1 >* #2";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals(0, res.at("/query/relation/boundary/min").asInt());
- assertEquals(true, res.at("/query/relation/boundary/max")
- .isMissingNode());
+ assertEquals(true,
+ res.at("/query/relation/boundary/max").isMissingNode());
}
@Test
- public void testMultipleDominance () throws JsonProcessingException,
- IOException {
+ public void testMultipleDominance ()
+ throws JsonProcessingException, IOException {
query = "cat=\"CP\" & cat=\"VP\" & cat=\"NP\" & #1 > #2 > #3";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:relation", res.at("/query/operation").asText());
- assertEquals("koral:reference", res.at("/query/operands/0/@type")
- .asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("koral:reference",
+ res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classRef/0").asInt());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:relation",
res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("koral:relation",
@@ -388,25 +396,21 @@
assertEquals("c",
res.at("/query/operands/0/operands/0/relation/wrap/layer")
.asText());
- assertEquals("koral:span",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
- assertEquals("c",
- res.at("/query/operands/0/operands/0/operands/0/layer")
- .asText());
- assertEquals("CP", res
- .at("/query/operands/0/operands/0/operands/0/key").asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/1/@type")
- .asText());
+ assertEquals("koral:span", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
+ assertEquals("c", res
+ .at("/query/operands/0/operands/0/operands/0/layer").asText());
+ assertEquals("CP",
+ res.at("/query/operands/0/operands/0/operands/0/key").asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/1/operation")
.asText());
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "VP",
+ assertEquals("VP",
res.at("/query/operands/0/operands/0/operands/1/operands/0/key")
.asText());
}
@@ -502,8 +506,8 @@
assertEquals("die", res.at("/query/operands/1/wrap/key").asText());
assertEquals(true, res.at("/query/inOrder").asBoolean());
assertEquals(true, res.at("/query/operands/2").isMissingNode());
- assertEquals("koral:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("koral:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("koral:boundary",
res.at("/query/distances/0/boundary/@type").asText());
assertEquals(1, res.at("/query/distances/0/boundary/min").asInt());
@@ -518,13 +522,13 @@
assertEquals("die", res.at("/query/operands/1/wrap/key").asText());
assertEquals(true, res.at("/query/inOrder").asBoolean());
assertEquals(true, res.at("/query/operands/2").isMissingNode());
- assertEquals("koral:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("koral:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("koral:boundary",
res.at("/query/distances/0/boundary/@type").asText());
assertEquals(1, res.at("/query/distances/0/boundary/min").asInt());
- assertEquals(true, res.at("/query/distances/0/boundary/max")
- .isMissingNode());
+ assertEquals(true,
+ res.at("/query/distances/0/boundary/max").isMissingNode());
query = "tok=\"der\" & tok=\"die\" & #1 .* #2";
qs.setQuery(query, "annis");
@@ -532,8 +536,8 @@
assertEquals("koral:boundary",
res.at("/query/distances/0/boundary/@type").asText());
assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
- assertEquals(true, res.at("/query/distances/0/boundary/max")
- .isMissingNode());
+ assertEquals(true,
+ res.at("/query/distances/0/boundary/max").isMissingNode());
}
@@ -558,8 +562,8 @@
assertEquals("die", res.at("/query/operands/1/wrap/key").asText());
assertEquals(false, res.at("/query/inOrder").asBoolean());
assertEquals(true, res.at("/query/operands/2").isMissingNode());
- assertEquals("koral:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("koral:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("koral:boundary",
res.at("/query/distances/0/boundary/@type").asText());
assertEquals(1, res.at("/query/distances/0/boundary/min").asInt());
@@ -571,8 +575,8 @@
assertEquals("koral:boundary",
res.at("/query/distances/0/boundary/@type").asText());
assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
- assertEquals(true, res.at("/query/distances/0/boundary/max")
- .isMissingNode());
+ assertEquals(true,
+ res.at("/query/distances/0/boundary/max").isMissingNode());
assertEquals(false, res.at("/query/inOrder").asBoolean());
}
@@ -584,8 +588,8 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("koral:reference", res.at("/query/operands/0/@type")
- .asText());
+ assertEquals("koral:reference",
+ res.at("/query/operands/0/@type").asText());
assertEquals(129, res.at("/query/operands/0/classRef/0").asInt());
assertEquals(res.at("/query/operands/0/classRef/0").asInt(),
res.at("/query/operands/0/operands/0/operands/1/classOut")
@@ -655,50 +659,43 @@
* @throws IOException
*/
@Test
- public void testNoSharedOperand () throws JsonProcessingException,
- IOException {
+ public void testNoSharedOperand ()
+ throws JsonProcessingException, IOException {
query = "cat=\"A\" & cat=\"B\" & cat=\"C\" & cat=\"D\" & #1 . #2 & #3 . #4 & #1 > #3";
// the resulting query should be equivalent to PQ+: focus(2:dominates(focus(1:{1:<A>}<B>),{2:<C>}))<D>
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("koral:reference", res.at("/query/operands/0/@type")
- .asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation")
- .asText());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:reference",
+ res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/0/operation").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:relation",
res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals("koral:reference",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:reference", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("operation:focus",
res.at("/query/operands/0/operands/0/operands/0/operation")
.asText());
- assertEquals(
- "koral:group",
+ assertEquals("koral:group",
res.at("/query/operands/0/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals(
- "operation:sequence",
+ assertEquals("operation:sequence",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operation")
.asText());
- assertEquals(
- "operation:class",
+ assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operation")
.asText());
- assertEquals(
- "A",
+ assertEquals("A",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/key")
.asText());
- assertEquals(
- "B",
+ assertEquals("B",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/key")
.asText());
- assertEquals(
- "C",
+ assertEquals("C",
res.at("/query/operands/0/operands/0/operands/1/operands/0/key")
.asText());
assertEquals("D", res.at("/query/operands/1/key").asText());
@@ -709,50 +706,41 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("koral:reference", res.at("/query/operands/0/@type")
- .asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation")
- .asText());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:reference",
+ res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/0/operation").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:relation",
res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals("koral:reference",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:reference", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("operation:focus",
res.at("/query/operands/0/operands/0/operands/0/operation")
.asText());
- assertEquals(
- "koral:group",
+ assertEquals("koral:group",
res.at("/query/operands/0/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals(
- "operation:sequence",
+ assertEquals("operation:sequence",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operation")
.asText());
- assertEquals(
- "operation:class",
+ assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operation")
.asText());
- assertEquals(
- "A",
+ assertEquals("A",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/key")
.asText());
- assertEquals(
- "B",
+ assertEquals("B",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/1/key")
.asText());
- assertEquals(
- "C",
+ assertEquals("C",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/1/operands/0/key")
.asText());
- assertEquals(
- "D",
+ assertEquals("D",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/key")
.asText());
- assertEquals(
- "E",
+ assertEquals("E",
res.at("/query/operands/0/operands/0/operands/1/operands/0/key")
.asText());
assertEquals("F", res.at("/query/operands/1/key").asText());
@@ -762,8 +750,8 @@
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals(true, res.at("/query/@type").isMissingNode());
- assertEquals(StatusCodes.UNBOUND_ANNIS_RELATION, res.at("/errors/0/0")
- .asInt());
+ assertEquals(StatusCodes.UNBOUND_ANNIS_RELATION,
+ res.at("/errors/0/0").asInt());
}
@@ -774,32 +762,29 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("koral:reference", res.at("/query/operands/0/@type")
- .asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("koral:reference",
+ res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classRef/0").asInt());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:relation",
res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals("koral:token",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:token", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("Sonne",
res.at("/query/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/1/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/1/operation")
.asText());
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "Mond",
+ assertEquals("Mond",
res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
assertEquals("Sterne", res.at("/query/operands/1/wrap/key").asText());
@@ -812,32 +797,29 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("koral:reference", res.at("/query/operands/0/@type")
- .asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("koral:reference",
+ res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classRef/0").asInt());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:relation",
res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals("koral:token",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:token", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("Sonne",
res.at("/query/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/1/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/1/operation")
.asText());
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "Mond",
+ assertEquals("Mond",
res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
assertEquals("Sterne", res.at("/query/operands/1/wrap/key").asText());
@@ -850,59 +832,50 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:relation", res.at("/query/operation").asText());
- assertEquals("koral:reference", res.at("/query/operands/0/@type")
- .asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("koral:reference",
+ res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/0/operation").asText());
assertEquals(130, res.at("/query/operands/0/classRef/0").asInt());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:relation",
res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals("koral:reference",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:reference", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("operation:focus",
res.at("/query/operands/0/operands/0/operands/0/operation")
.asText());
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/0/classRef/0")
.asInt());
- assertEquals(
- "koral:group",
+ assertEquals("koral:group",
res.at("/query/operands/0/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals(
- "operation:relation",
+ assertEquals("operation:relation",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operation")
.asText());
- assertEquals(
- "operation:class",
+ assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operation")
.asText());
- assertEquals(
- 129,
+ assertEquals(129,
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/classOut")
.asInt());
- assertEquals(
- "koral:span",
+ assertEquals("koral:span",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals(
- "NP",
+ assertEquals("NP",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/key")
.asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/1/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/1/operation")
.asText());
assertEquals(130,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "VP",
+ assertEquals("VP",
res.at("/query/operands/0/operands/0/operands/1/operands/0/key")
.asText());
assertEquals("PP", res.at("/query/operands/1/key").asText());
@@ -918,13 +891,13 @@
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:position", res.at("/query/operation").asText());
assertEquals("frames:startsWith", res.at("/query/frames/0").asText());
- assertEquals("koral:reference", res.at("/query/operands/0/@type")
- .asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("koral:reference",
+ res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classRef/0").asInt());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:relation",
res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("operation:class",
@@ -933,12 +906,10 @@
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/0/classOut")
.asInt());
- assertEquals(
- "koral:span",
+ assertEquals("koral:span",
res.at("/query/operands/0/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals(
- "NP",
+ assertEquals("NP",
res.at("/query/operands/0/operands/0/operands/0/operands/0/key")
.asText());
assertEquals("operation:class",
@@ -947,14 +918,13 @@
assertEquals(130,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "VP",
+ assertEquals("VP",
res.at("/query/operands/0/operands/0/operands/1/operands/0/key")
.asText());
- assertEquals("koral:reference", res.at("/query/operands/1/@type")
- .asText());
- assertEquals("operation:focus", res.at("/query/operands/1/operation")
- .asText());
+ assertEquals("koral:reference",
+ res.at("/query/operands/1/@type").asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/1/operation").asText());
assertEquals(130, res.at("/query/operands/1/classRef/0").asInt());
}
@@ -1014,25 +984,22 @@
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("frames:startsWith", res.at("/query/frames/0").asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("frames:endsWith",
res.at("/query/operands/0/operands/0/frames/0").asText());
- assertEquals("koral:span",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/1/@type")
- .asText());
+ assertEquals("koral:span", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/1/operation")
.asText());
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "VP",
+ assertEquals("VP",
res.at("/query/operands/0/operands/0/operands/1/operands/0/key")
.asText());
assertEquals("NP", res.at("/query/operands/1/key").asText());
@@ -1041,7 +1008,8 @@
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("frames:overlapsLeft", res.at("/query/frames/0").asText());
- assertEquals("frames:overlapsRight", res.at("/query/frames/1").asText());
+ assertEquals("frames:overlapsRight",
+ res.at("/query/frames/1").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
assertEquals("Mann", res.at("/query/operands/0/wrap/key").asText());
@@ -1057,7 +1025,8 @@
query = "node & \"Mann\" & #2 _or_ #1";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
- assertEquals("frames:overlapsRight", res.at("/query/frames/0").asText());
+ assertEquals("frames:overlapsRight",
+ res.at("/query/frames/0").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
assertEquals("Mann", res.at("/query/operands/0/wrap/key").asText());
@@ -1071,31 +1040,28 @@
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("operation:sequence",
res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals("koral:token",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:token", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("p",
res.at("/query/operands/0/operands/0/operands/0/wrap/layer")
.asText());
assertEquals("N",
res.at("/query/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/1/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/1/operation")
.asText());
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "V",
+ assertEquals("V",
res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
assertEquals("P", res.at("/query/operands/1/wrap/key").asText());
@@ -1104,31 +1070,28 @@
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("operation:sequence",
res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals("koral:token",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:token", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("p",
res.at("/query/operands/0/operands/0/operands/0/wrap/layer")
.asText());
assertEquals("N",
res.at("/query/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/1/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/1/operation")
.asText());
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "V",
+ assertEquals("V",
res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
assertEquals("P", res.at("/query/operands/1/wrap/key").asText());
@@ -1137,8 +1100,8 @@
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("operation:relation", res.at("/query/operation").asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("operation:relation",
res.at("/query/operands/0/operands/0/operation").asText());
@@ -1148,8 +1111,7 @@
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/0/classOut")
.asInt());
- assertEquals(
- "N",
+ assertEquals("N",
res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key")
.asText());
assertEquals("V",
@@ -1161,8 +1123,8 @@
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/0/operation").asText());
assertEquals(130, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("operation:relation",
res.at("/query/operands/0/operands/0/operation").asText());
@@ -1172,54 +1134,48 @@
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/0/classRef/0")
.asInt());
- assertEquals(
- "operation:relation",
+ assertEquals("operation:relation",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operation")
.asText());
- assertEquals(
- "operation:class",
+ assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operation")
.asText());
- assertEquals(
- 129,
+ assertEquals(129,
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/classOut")
.asInt());
- assertEquals(
- "NP",
+ assertEquals("NP",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/key")
.asText());
- assertEquals(
- 130,
+ assertEquals(130,
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "V",
+ assertEquals("V",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
assertEquals(131,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "P",
+ assertEquals("P",
res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
- assertEquals("operation:focus", res.at("/query/operands/1/operation")
- .asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/1/operation").asText());
assertEquals(131, res.at("/query/operands/1/classRef/0").asInt());
- assertEquals(true, res.at("/query/operands/1/operands").isMissingNode());
+ assertEquals(true,
+ res.at("/query/operands/1/operands").isMissingNode());
}
@Test
- public void testUnaryRelations () throws JsonProcessingException,
- IOException {
+ public void testUnaryRelations ()
+ throws JsonProcessingException, IOException {
query = "node & #1:tokenarity=2";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:span", res.at("/query/@type").asText());
assertEquals("koral:term", res.at("/query/attr/@type").asText());
- assertEquals("koral:boundary", res.at("/query/attr/tokenarity/@type")
- .asText());
+ assertEquals("koral:boundary",
+ res.at("/query/attr/tokenarity/@type").asText());
assertEquals(2, res.at("/query/attr/tokenarity/min").asInt());
assertEquals(2, res.at("/query/attr/tokenarity/max").asInt());
@@ -1231,8 +1187,8 @@
assertEquals("c", res.at("/query/layer").asText());
assertEquals("NP", res.at("/query/key").asText());
assertEquals("koral:term", res.at("/query/attr/@type").asText());
- assertEquals("koral:boundary", res.at("/query/attr/tokenarity/@type")
- .asText());
+ assertEquals("koral:boundary",
+ res.at("/query/attr/tokenarity/@type").asText());
assertEquals(2, res.at("/query/attr/tokenarity/min").asInt());
assertEquals(2, res.at("/query/attr/tokenarity/max").asInt());
@@ -1261,11 +1217,11 @@
assertEquals("c", res.at("/query/layer").asText());
assertEquals("NP", res.at("/query/key").asText());
assertEquals("koral:termGroup", res.at("/query/attr/@type").asText());
- assertEquals("koral:term", res.at("/query/attr/operands/0/@type")
- .asText());
+ assertEquals("koral:term",
+ res.at("/query/attr/operands/0/@type").asText());
assertEquals(true, res.at("/query/attr/operands/0/root").asBoolean());
- assertEquals("koral:term", res.at("/query/attr/operands/1/@type")
- .asText());
+ assertEquals("koral:term",
+ res.at("/query/attr/operands/1/@type").asText());
assertEquals("koral:boundary",
res.at("/query/attr/operands/1/arity/@type").asText());
assertEquals(2, res.at("/query/attr/operands/1/arity/min").asInt());
@@ -1280,12 +1236,14 @@
assertEquals("cnx", res.at("/query/operands/0/foundry").asText());
assertEquals("c", res.at("/query/operands/0/layer").asText());
assertEquals("NP", res.at("/query/operands/0/key").asText());
- assertEquals("koral:term", res.at("/query/operands/0/attr/@type")
- .asText());
+ assertEquals("koral:term",
+ res.at("/query/operands/0/attr/@type").asText());
assertEquals("koral:boundary",
res.at("/query/operands/0/attr/tokenarity/@type").asText());
- assertEquals(2, res.at("/query/operands/0/attr/tokenarity/min").asInt());
- assertEquals(2, res.at("/query/operands/0/attr/tokenarity/max").asInt());
+ assertEquals(2,
+ res.at("/query/operands/0/attr/tokenarity/min").asInt());
+ assertEquals(2,
+ res.at("/query/operands/0/attr/tokenarity/max").asInt());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
}
@@ -1298,40 +1256,35 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:relation", res.at("/query/operation").asText());
- assertEquals("koral:reference", res.at("/query/operands/0/@type")
- .asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("koral:reference",
+ res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classRef/0").asInt());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:relation",
res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/0/operation")
.asText());
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/0/classOut")
.asInt());
- assertEquals(
- "koral:span",
+ assertEquals("koral:span",
res.at("/query/operands/0/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals(
- true,
+ assertEquals(true,
res.at("/query/operands/0/operands/0/operands/0/operands/0/key")
.isMissingNode());
- assertEquals("koral:span",
- res.at("/query/operands/0/operands/0/operands/1/@type")
- .asText());
- assertEquals("NP", res
- .at("/query/operands/0/operands/0/operands/1/key").asText());
- assertEquals("c",
- res.at("/query/operands/0/operands/0/operands/1/layer")
- .asText());
+ assertEquals("koral:span", res
+ .at("/query/operands/0/operands/0/operands/1/@type").asText());
+ assertEquals("NP",
+ res.at("/query/operands/0/operands/0/operands/1/key").asText());
+ assertEquals("c", res
+ .at("/query/operands/0/operands/0/operands/1/layer").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
assertEquals("VP", res.at("/query/operands/1/key").asText());
assertEquals("c", res.at("/query/operands/1/layer").asText());
@@ -1341,13 +1294,13 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:relation", res.at("/query/operation").asText());
- assertEquals("koral:reference", res.at("/query/operands/0/@type")
- .asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("koral:reference",
+ res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:focus",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classRef/0").asInt());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:relation",
res.at("/query/operands/0/operands/0/operation").asText());
}
@@ -1359,8 +1312,8 @@
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
- assertEquals("operation:disjunction", res.at("/query/operation")
- .asText());
+ assertEquals("operation:disjunction",
+ res.at("/query/operation").asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
assertEquals("NP", res.at("/query/operands/0/key").asText());
assertEquals("c", res.at("/query/operands/0/layer").asText());
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryDuplicateTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryDuplicateTest.java
index f7c4dd1..0bef92d 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryDuplicateTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryDuplicateTest.java
@@ -25,12 +25,12 @@
ObjectMapper m = new ObjectMapper();
JsonNode first = m.readTree(serializer.toJSON());
assertNotNull(first);
- assertEquals(first.at("/collection"), m.readTree(serializer.toJSON())
- .at("/collection"));
- assertEquals(first.at("/collection"), m.readTree(serializer.toJSON())
- .at("/collection"));
- assertEquals(first.at("/collection"), m.readTree(serializer.toJSON())
- .at("/collection"));
+ assertEquals(first.at("/collection"),
+ m.readTree(serializer.toJSON()).at("/collection"));
+ assertEquals(first.at("/collection"),
+ m.readTree(serializer.toJSON()).at("/collection"));
+ assertEquals(first.at("/collection"),
+ m.readTree(serializer.toJSON()).at("/collection"));
}
}
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessorTest.java
index 0e91058..4baf88e 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessorTest.java
@@ -57,8 +57,8 @@
@Test
- public void testSpecialCharacters () throws JsonProcessingException,
- IOException {
+ public void testSpecialCharacters ()
+ throws JsonProcessingException, IOException {
collection = "[base/n=alt]";
qs.setQuery(query, ql);
qs.setCollection(collection);
@@ -122,27 +122,29 @@
@Test
- public void testTwoConjuncts () throws JsonProcessingException, IOException {
+ public void testTwoConjuncts ()
+ throws JsonProcessingException, IOException {
collection = "textClass=Sport & pubDate in 2014";
qs.setQuery(query, ql);
qs.setCollection(collection);
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:and", res.at("/collection/operation").asText());
- assertEquals("koral:doc", res.at("/collection/operands/0/@type")
- .asText());
- assertEquals("textClass", res.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc",
+ res.at("/collection/operands/0/@type").asText());
+ assertEquals("textClass",
+ res.at("/collection/operands/0/key").asText());
assertEquals("Sport", res.at("/collection/operands/0/value").asText());
- assertEquals("match:eq", res.at("/collection/operands/0/match")
- .asText());
- assertEquals("koral:doc", res.at("/collection/operands/1/@type")
- .asText());
+ assertEquals("match:eq",
+ res.at("/collection/operands/0/match").asText());
+ assertEquals("koral:doc",
+ res.at("/collection/operands/1/@type").asText());
assertEquals("pubDate", res.at("/collection/operands/1/key").asText());
assertEquals("2014", res.at("/collection/operands/1/value").asText());
- assertEquals("type:date", res.at("/collection/operands/1/type")
- .asText());
- assertEquals("match:eq", res.at("/collection/operands/1/match")
- .asText());
+ assertEquals("type:date",
+ res.at("/collection/operands/1/type").asText());
+ assertEquals("match:eq",
+ res.at("/collection/operands/1/match").asText());
collection = "textClass=Sport & pubDate=2014";
qs.setQuery(query, ql);
@@ -151,20 +153,21 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:and", res.at("/collection/operation").asText());
- assertEquals("koral:doc", res.at("/collection/operands/0/@type")
- .asText());
- assertEquals("textClass", res.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc",
+ res.at("/collection/operands/0/@type").asText());
+ assertEquals("textClass",
+ res.at("/collection/operands/0/key").asText());
assertEquals("Sport", res.at("/collection/operands/0/value").asText());
- assertEquals("match:eq", res.at("/collection/operands/0/match")
- .asText());
- assertEquals("koral:doc", res.at("/collection/operands/1/@type")
- .asText());
+ assertEquals("match:eq",
+ res.at("/collection/operands/0/match").asText());
+ assertEquals("koral:doc",
+ res.at("/collection/operands/1/@type").asText());
assertEquals("pubDate", res.at("/collection/operands/1/key").asText());
assertEquals("2014", res.at("/collection/operands/1/value").asText());
- assertEquals(true, res.at("/collection/operands/1/type")
- .isMissingNode());
- assertEquals("match:eq", res.at("/collection/operands/1/match")
- .asText());
+ assertEquals(true,
+ res.at("/collection/operands/1/type").isMissingNode());
+ assertEquals("match:eq",
+ res.at("/collection/operands/1/match").asText());
assertTrue(res.at("/warnings/0").isMissingNode());
// assertTrue(res.at("/warnings/0/0").asText().startsWith(
// "The collection query contains a value that looks like a date"));
@@ -172,105 +175,109 @@
@Test
- public void testThreeConjuncts () throws JsonProcessingException,
- IOException {
+ public void testThreeConjuncts ()
+ throws JsonProcessingException, IOException {
collection = "textClass=Sport & pubDate in 2014 & corpusId=WPD";
qs.setQuery(query, ql);
qs.setCollection(collection);
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:and", res.at("/collection/operation").asText());
- assertEquals("koral:doc", res.at("/collection/operands/0/@type")
- .asText());
- assertEquals("textClass", res.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc",
+ res.at("/collection/operands/0/@type").asText());
+ assertEquals("textClass",
+ res.at("/collection/operands/0/key").asText());
assertEquals("Sport", res.at("/collection/operands/0/value").asText());
- assertEquals("match:eq", res.at("/collection/operands/0/match")
- .asText());
- assertEquals("koral:docGroup", res.at("/collection/operands/1/@type")
- .asText());
- assertEquals("operation:and", res
- .at("/collection/operands/1/operation").asText());
+ assertEquals("match:eq",
+ res.at("/collection/operands/0/match").asText());
+ assertEquals("koral:docGroup",
+ res.at("/collection/operands/1/@type").asText());
+ assertEquals("operation:and",
+ res.at("/collection/operands/1/operation").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/0/@type").asText());
- assertEquals("pubDate", res.at("/collection/operands/1/operands/0/key")
- .asText());
- assertEquals("2014", res.at("/collection/operands/1/operands/0/value")
- .asText());
+ assertEquals("pubDate",
+ res.at("/collection/operands/1/operands/0/key").asText());
+ assertEquals("2014",
+ res.at("/collection/operands/1/operands/0/value").asText());
assertEquals("type:date",
res.at("/collection/operands/1/operands/0/type").asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/0/match").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/1/@type").asText());
- assertEquals("corpusId", res
- .at("/collection/operands/1/operands/1/key").asText());
- assertEquals("WPD", res.at("/collection/operands/1/operands/1/value")
- .asText());
+ assertEquals("corpusId",
+ res.at("/collection/operands/1/operands/1/key").asText());
+ assertEquals("WPD",
+ res.at("/collection/operands/1/operands/1/value").asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/1/match").asText());
}
@Test
- public void testTwoDisjuncts () throws JsonProcessingException, IOException {
+ public void testTwoDisjuncts ()
+ throws JsonProcessingException, IOException {
collection = "textClass=Sport | pubDate in 2014";
qs.setQuery(query, ql);
qs.setCollection(collection);
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:or", res.at("/collection/operation").asText());
- assertEquals("koral:doc", res.at("/collection/operands/0/@type")
- .asText());
- assertEquals("textClass", res.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc",
+ res.at("/collection/operands/0/@type").asText());
+ assertEquals("textClass",
+ res.at("/collection/operands/0/key").asText());
assertEquals("Sport", res.at("/collection/operands/0/value").asText());
- assertEquals("match:eq", res.at("/collection/operands/0/match")
- .asText());
- assertEquals("koral:doc", res.at("/collection/operands/1/@type")
- .asText());
+ assertEquals("match:eq",
+ res.at("/collection/operands/0/match").asText());
+ assertEquals("koral:doc",
+ res.at("/collection/operands/1/@type").asText());
assertEquals("pubDate", res.at("/collection/operands/1/key").asText());
assertEquals("2014", res.at("/collection/operands/1/value").asText());
- assertEquals("type:date", res.at("/collection/operands/1/type")
- .asText());
- assertEquals("match:eq", res.at("/collection/operands/1/match")
- .asText());
+ assertEquals("type:date",
+ res.at("/collection/operands/1/type").asText());
+ assertEquals("match:eq",
+ res.at("/collection/operands/1/match").asText());
}
@Test
- public void testThreeDisjuncts () throws JsonProcessingException,
- IOException {
+ public void testThreeDisjuncts ()
+ throws JsonProcessingException, IOException {
collection = "textClass=Sport | pubDate in 2014 | corpusId=WPD";
qs.setQuery(query, ql);
qs.setCollection(collection);
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:or", res.at("/collection/operation").asText());
- assertEquals("koral:doc", res.at("/collection/operands/0/@type")
- .asText());
- assertEquals("textClass", res.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc",
+ res.at("/collection/operands/0/@type").asText());
+ assertEquals("textClass",
+ res.at("/collection/operands/0/key").asText());
assertEquals("Sport", res.at("/collection/operands/0/value").asText());
- assertEquals("match:eq", res.at("/collection/operands/0/match")
- .asText());
- assertEquals("koral:docGroup", res.at("/collection/operands/1/@type")
- .asText());
- assertEquals("operation:or", res.at("/collection/operands/1/operation")
- .asText());
+ assertEquals("match:eq",
+ res.at("/collection/operands/0/match").asText());
+ assertEquals("koral:docGroup",
+ res.at("/collection/operands/1/@type").asText());
+ assertEquals("operation:or",
+ res.at("/collection/operands/1/operation").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/0/@type").asText());
- assertEquals("pubDate", res.at("/collection/operands/1/operands/0/key")
- .asText());
- assertEquals("2014", res.at("/collection/operands/1/operands/0/value")
- .asText());
+ assertEquals("pubDate",
+ res.at("/collection/operands/1/operands/0/key").asText());
+ assertEquals("2014",
+ res.at("/collection/operands/1/operands/0/value").asText());
assertEquals("type:date",
res.at("/collection/operands/1/operands/0/type").asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/0/match").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/1/@type").asText());
- assertEquals("corpusId", res
- .at("/collection/operands/1/operands/1/key").asText());
- assertEquals("WPD", res.at("/collection/operands/1/operands/1/value")
- .asText());
+ assertEquals("corpusId",
+ res.at("/collection/operands/1/operands/1/key").asText());
+ assertEquals("WPD",
+ res.at("/collection/operands/1/operands/1/value").asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/1/match").asText());
}
@@ -284,32 +291,33 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:or", res.at("/collection/operation").asText());
- assertEquals("koral:doc", res.at("/collection/operands/0/@type")
- .asText());
- assertEquals("textClass", res.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc",
+ res.at("/collection/operands/0/@type").asText());
+ assertEquals("textClass",
+ res.at("/collection/operands/0/key").asText());
assertEquals("Sport", res.at("/collection/operands/0/value").asText());
- assertEquals("match:eq", res.at("/collection/operands/0/match")
- .asText());
- assertEquals("koral:docGroup", res.at("/collection/operands/1/@type")
- .asText());
- assertEquals("operation:and", res
- .at("/collection/operands/1/operation").asText());
+ assertEquals("match:eq",
+ res.at("/collection/operands/0/match").asText());
+ assertEquals("koral:docGroup",
+ res.at("/collection/operands/1/@type").asText());
+ assertEquals("operation:and",
+ res.at("/collection/operands/1/operation").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/0/@type").asText());
- assertEquals("pubDate", res.at("/collection/operands/1/operands/0/key")
- .asText());
- assertEquals("2014", res.at("/collection/operands/1/operands/0/value")
- .asText());
+ assertEquals("pubDate",
+ res.at("/collection/operands/1/operands/0/key").asText());
+ assertEquals("2014",
+ res.at("/collection/operands/1/operands/0/value").asText());
assertEquals("type:date",
res.at("/collection/operands/1/operands/0/type").asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/0/match").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/1/@type").asText());
- assertEquals("corpusId", res
- .at("/collection/operands/1/operands/1/key").asText());
- assertEquals("WPD", res.at("/collection/operands/1/operands/1/value")
- .asText());
+ assertEquals("corpusId",
+ res.at("/collection/operands/1/operands/1/key").asText());
+ assertEquals("WPD",
+ res.at("/collection/operands/1/operands/1/value").asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/1/match").asText());
@@ -319,32 +327,33 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:or", res.at("/collection/operation").asText());
- assertEquals("koral:doc", res.at("/collection/operands/0/@type")
- .asText());
- assertEquals("textClass", res.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc",
+ res.at("/collection/operands/0/@type").asText());
+ assertEquals("textClass",
+ res.at("/collection/operands/0/key").asText());
assertEquals("Sport", res.at("/collection/operands/0/value").asText());
- assertEquals("match:eq", res.at("/collection/operands/0/match")
- .asText());
- assertEquals("koral:docGroup", res.at("/collection/operands/1/@type")
- .asText());
- assertEquals("operation:and", res
- .at("/collection/operands/1/operation").asText());
+ assertEquals("match:eq",
+ res.at("/collection/operands/0/match").asText());
+ assertEquals("koral:docGroup",
+ res.at("/collection/operands/1/@type").asText());
+ assertEquals("operation:and",
+ res.at("/collection/operands/1/operation").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/0/@type").asText());
- assertEquals("pubDate", res.at("/collection/operands/1/operands/0/key")
- .asText());
- assertEquals("2014", res.at("/collection/operands/1/operands/0/value")
- .asText());
+ assertEquals("pubDate",
+ res.at("/collection/operands/1/operands/0/key").asText());
+ assertEquals("2014",
+ res.at("/collection/operands/1/operands/0/value").asText());
assertEquals("type:date",
res.at("/collection/operands/1/operands/0/type").asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/0/match").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/1/@type").asText());
- assertEquals("corpusId", res
- .at("/collection/operands/1/operands/1/key").asText());
- assertEquals("WPD", res.at("/collection/operands/1/operands/1/value")
- .asText());
+ assertEquals("corpusId",
+ res.at("/collection/operands/1/operands/1/key").asText());
+ assertEquals("WPD",
+ res.at("/collection/operands/1/operands/1/value").asText());
assertEquals("match:eq",
res.at("/collection/operands/1/operands/1/match").asText());
@@ -354,16 +363,16 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:and", res.at("/collection/operation").asText());
- assertEquals("koral:docGroup", res.at("/collection/operands/0/@type")
- .asText());
- assertEquals("operation:or", res.at("/collection/operands/0/operation")
- .asText());
+ assertEquals("koral:docGroup",
+ res.at("/collection/operands/0/@type").asText());
+ assertEquals("operation:or",
+ res.at("/collection/operands/0/operation").asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/0/@type").asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/1/@type").asText());
- assertEquals("koral:doc", res.at("/collection/operands/1/@type")
- .asText());
+ assertEquals("koral:doc",
+ res.at("/collection/operands/1/@type").asText());
collection = "(textClass=Sport & pubDate in 2014) & corpusId=WPD";
qs.setQuery(query, ql);
@@ -371,16 +380,16 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:and", res.at("/collection/operation").asText());
- assertEquals("koral:docGroup", res.at("/collection/operands/0/@type")
- .asText());
- assertEquals("operation:and", res
- .at("/collection/operands/0/operation").asText());
+ assertEquals("koral:docGroup",
+ res.at("/collection/operands/0/@type").asText());
+ assertEquals("operation:and",
+ res.at("/collection/operands/0/operation").asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/0/@type").asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/1/@type").asText());
- assertEquals("koral:doc", res.at("/collection/operands/1/@type")
- .asText());
+ assertEquals("koral:doc",
+ res.at("/collection/operands/1/@type").asText());
collection = "(textClass=Sport & textClass=ausland) | (corpusID=WPD & author=White)";
qs.setQuery(query, ql);
@@ -388,30 +397,30 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:or", res.at("/collection/operation").asText());
- assertEquals("koral:docGroup", res.at("/collection/operands/0/@type")
- .asText());
- assertEquals("operation:and", res
- .at("/collection/operands/0/operation").asText());
- assertEquals("koral:docGroup", res.at("/collection/operands/1/@type")
- .asText());
- assertEquals("operation:and", res
- .at("/collection/operands/1/operation").asText());
+ assertEquals("koral:docGroup",
+ res.at("/collection/operands/0/@type").asText());
+ assertEquals("operation:and",
+ res.at("/collection/operands/0/operation").asText());
+ assertEquals("koral:docGroup",
+ res.at("/collection/operands/1/@type").asText());
+ assertEquals("operation:and",
+ res.at("/collection/operands/1/operation").asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/0/@type").asText());
- assertEquals("Sport", res.at("/collection/operands/0/operands/0/value")
- .asText());
+ assertEquals("Sport",
+ res.at("/collection/operands/0/operands/0/value").asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/1/@type").asText());
assertEquals("ausland",
res.at("/collection/operands/0/operands/1/value").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/0/@type").asText());
- assertEquals("WPD", res.at("/collection/operands/1/operands/0/value")
- .asText());
+ assertEquals("WPD",
+ res.at("/collection/operands/1/operands/0/value").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/1/@type").asText());
- assertEquals("White", res.at("/collection/operands/1/operands/1/value")
- .asText());
+ assertEquals("White",
+ res.at("/collection/operands/1/operands/1/value").asText());
collection = "(textClass=Sport & textClass=ausland) | (corpusID=WPD & author=White & pubDate in 2000)";
qs.setQuery(query, ql);
@@ -419,26 +428,26 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:docGroup", res.at("/collection/@type").asText());
assertEquals("operation:or", res.at("/collection/operation").asText());
- assertEquals("koral:docGroup", res.at("/collection/operands/0/@type")
- .asText());
- assertEquals("operation:and", res
- .at("/collection/operands/0/operation").asText());
- assertEquals("koral:docGroup", res.at("/collection/operands/1/@type")
- .asText());
- assertEquals("operation:and", res
- .at("/collection/operands/1/operation").asText());
+ assertEquals("koral:docGroup",
+ res.at("/collection/operands/0/@type").asText());
+ assertEquals("operation:and",
+ res.at("/collection/operands/0/operation").asText());
+ assertEquals("koral:docGroup",
+ res.at("/collection/operands/1/@type").asText());
+ assertEquals("operation:and",
+ res.at("/collection/operands/1/operation").asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/0/@type").asText());
- assertEquals("Sport", res.at("/collection/operands/0/operands/0/value")
- .asText());
+ assertEquals("Sport",
+ res.at("/collection/operands/0/operands/0/value").asText());
assertEquals("koral:doc",
res.at("/collection/operands/0/operands/1/@type").asText());
assertEquals("ausland",
res.at("/collection/operands/0/operands/1/value").asText());
assertEquals("koral:doc",
res.at("/collection/operands/1/operands/0/@type").asText());
- assertEquals("WPD", res.at("/collection/operands/1/operands/0/value")
- .asText());
+ assertEquals("WPD",
+ res.at("/collection/operands/1/operands/0/value").asText());
assertEquals("koral:docGroup",
res.at("/collection/operands/1/operands/1/@type").asText());
assertEquals("operation:and",
@@ -497,7 +506,8 @@
@Test
- public void testDateMonthDay () throws JsonProcessingException, IOException {
+ public void testDateMonthDay ()
+ throws JsonProcessingException, IOException {
collection = "pubDate in 2000-02";
qs.setQuery(query, ql);
qs.setCollection(collection);
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java
index 9db30b9..662c232 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java
@@ -66,8 +66,8 @@
@Test
- public void testWildcardToken () throws JsonProcessingException,
- IOException {
+ public void testWildcardToken ()
+ throws JsonProcessingException, IOException {
query = "*der";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
@@ -86,15 +86,15 @@
//
@Test
- public void testCaseSensitivityFlag () throws JsonProcessingException,
- IOException {
+ public void testCaseSensitivityFlag ()
+ throws JsonProcessingException, IOException {
query = "$deutscher";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:term", res.at("/query/wrap/@type").asText());
assertEquals("deutscher", res.at("/query/wrap/key").asText());
- assertEquals("flags:caseInsensitive", res.at("/query/wrap/flags/0")
- .asText());
+ assertEquals("flags:caseInsensitive",
+ res.at("/query/wrap/flags/0").asText());
assertEquals("orth", res.at("/query/wrap/layer").asText());
assertEquals("match:eq", res.at("/query/wrap/match").asText());
@@ -103,15 +103,17 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("koral:term", res.at("/query/operands/0/wrap/@type")
- .asText());
- assertEquals("deutscher", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("koral:term",
+ res.at("/query/operands/0/wrap/@type").asText());
+ assertEquals("deutscher",
+ res.at("/query/operands/0/wrap/key").asText());
assertEquals("flags:caseInsensitive",
res.at("/query/operands/0/wrap/flags/0").asText());
assertEquals("orth", res.at("/query/operands/0/wrap/layer").asText());
- assertEquals("match:eq", res.at("/query/operands/0/wrap/match")
- .asText());
- assertEquals("Bundestag", res.at("/query/operands/1/wrap/key").asText());
+ assertEquals("match:eq",
+ res.at("/query/operands/0/wrap/match").asText());
+ assertEquals("Bundestag",
+ res.at("/query/operands/1/wrap/key").asText());
}
@@ -174,14 +176,14 @@
assertEquals("V", res.at("/query/wrap/operands/0/key").asText());
assertEquals("p", res.at("/query/wrap/operands/0/layer").asText());
assertEquals("tt", res.at("/query/wrap/operands/0/foundry").asText());
- assertEquals("match:eq", res.at("/query/wrap/operands/0/match")
- .asText());
+ assertEquals("match:eq",
+ res.at("/query/wrap/operands/0/match").asText());
assertEquals("temp", res.at("/query/wrap/operands/1/key").asText());
assertEquals("pres", res.at("/query/wrap/operands/1/value").asText());
assertEquals("m", res.at("/query/wrap/operands/1/layer").asText());
assertEquals("mate", res.at("/query/wrap/operands/1/foundry").asText());
- assertEquals("match:ne", res.at("/query/wrap/operands/1/match")
- .asText());
+ assertEquals("match:ne",
+ res.at("/query/wrap/operands/1/match").asText());
}
@@ -257,8 +259,8 @@
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
- assertEquals("operation:disjunction", res.at("/query/operation")
- .asText());
+ assertEquals("operation:disjunction",
+ res.at("/query/operation").asText());
assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText());
assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText());
assertEquals(true, res.at("/query/operands/2").isMissingNode());
@@ -267,15 +269,15 @@
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
- assertEquals("operation:disjunction", res.at("/query/operation")
- .asText());
+ assertEquals("operation:disjunction",
+ res.at("/query/operation").asText());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:sequence", res
- .at("/query/operands/0/operation").asText());
- assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
- assertEquals("scheint", res.at("/query/operands/0/operands/1/wrap/key")
- .asText());
+ assertEquals("operation:sequence",
+ res.at("/query/operands/0/operation").asText());
+ assertEquals("Sonne",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
+ assertEquals("scheint",
+ res.at("/query/operands/0/operands/1/wrap/key").asText());
assertEquals("Mond", res.at("/query/operands/1/wrap/key").asText());
assertEquals(true, res.at("/query/operands/2").isMissingNode());
@@ -283,22 +285,22 @@
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
- assertEquals("operation:disjunction", res.at("/query/operation")
- .asText());
+ assertEquals("operation:disjunction",
+ res.at("/query/operation").asText());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:sequence", res
- .at("/query/operands/0/operation").asText());
+ assertEquals("operation:sequence",
+ res.at("/query/operands/0/operation").asText());
assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
- assertEquals("operation:sequence", res
- .at("/query/operands/1/operation").asText());
- assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
- assertEquals("scheint", res.at("/query/operands/0/operands/1/wrap/key")
- .asText());
- assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key")
- .asText());
- assertEquals("scheint", res.at("/query/operands/1/operands/1/wrap/key")
- .asText());
+ assertEquals("operation:sequence",
+ res.at("/query/operands/1/operation").asText());
+ assertEquals("Sonne",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
+ assertEquals("scheint",
+ res.at("/query/operands/0/operands/1/wrap/key").asText());
+ assertEquals("Mond",
+ res.at("/query/operands/1/operands/0/wrap/key").asText());
+ assertEquals("scheint",
+ res.at("/query/operands/1/operands/1/wrap/key").asText());
assertEquals(true, res.at("/query/operands/2").isMissingNode());
}
@@ -316,8 +318,8 @@
assertEquals(false, res.at("/query/inOrder").isMissingNode());
assertEquals(false, res.at("/query/inOrder").asBoolean());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("t", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/min").asInt());
assertEquals(0, res.at("/query/distances/0/max").asInt());
@@ -325,13 +327,14 @@
assertEquals("operation:disjunction",
res.at("/query/operands/0/operation").asText());
- assertEquals(false, res.at("/query/operands/0/inOrder").isMissingNode());
+ assertEquals(false,
+ res.at("/query/operands/0/inOrder").isMissingNode());
assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean());
- assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
- assertEquals("Mond", res.at("/query/operands/0/operands/1/wrap/key")
- .asText());
+ assertEquals("Sonne",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
+ assertEquals("Mond",
+ res.at("/query/operands/0/operands/1/wrap/key").asText());
assertEquals("koral:token", res.at("/query/operands/1/@type").asText());
assertEquals("scheint", res.at("/query/operands/1/wrap/key").asText());
@@ -345,8 +348,8 @@
assertEquals(false, res.at("/query/inOrder").asBoolean());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("t", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/min").asInt());
assertEquals(0, res.at("/query/distances/0/max").asInt());
@@ -356,13 +359,14 @@
assertEquals("operation:disjunction",
res.at("/query/operands/1/operation").asText());
- assertEquals(false, res.at("/query/operands/1/inOrder").isMissingNode());
+ assertEquals(false,
+ res.at("/query/operands/1/inOrder").isMissingNode());
assertEquals(false, res.at("/query/operands/1/inOrder").asBoolean());
- assertEquals("Sonne", res.at("/query/operands/1/operands/0/wrap/key")
- .asText());
- assertEquals("Mond", res.at("/query/operands/1/operands/1/wrap/key")
- .asText());
+ assertEquals("Sonne",
+ res.at("/query/operands/1/operands/0/wrap/key").asText());
+ assertEquals("Mond",
+ res.at("/query/operands/1/operands/1/wrap/key").asText());
// Query
query = "Regen und scheint und (Sonne oder Mond)";
@@ -374,8 +378,8 @@
assertEquals(false, res.at("/query/inOrder").isMissingNode());
assertEquals(false, res.at("/query/inOrder").asBoolean());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("t", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/min").asInt());
assertEquals(0, res.at("/query/distances/0/max").asInt());
@@ -383,10 +387,11 @@
assertEquals("Regen", res.at("/query/operands/0/wrap/key").asText());
assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
- assertEquals("operation:sequence", res
- .at("/query/operands/1/operation").asText());
+ assertEquals("operation:sequence",
+ res.at("/query/operands/1/operation").asText());
- assertEquals(false, res.at("/query/operands/1/inOrder").isMissingNode());
+ assertEquals(false,
+ res.at("/query/operands/1/inOrder").isMissingNode());
assertEquals(false, res.at("/query/operands/1/inOrder").asBoolean());
assertEquals("cosmas:distance",
@@ -394,15 +399,15 @@
assertEquals("t", res.at("/query/operands/1/distances/0/key").asText());
assertEquals(0, res.at("/query/operands/1/distances/0/min").asInt());
assertEquals(0, res.at("/query/operands/1/distances/0/max").asInt());
- assertEquals("scheint", res.at("/query/operands/1/operands/0/wrap/key")
- .asText());
- assertEquals("koral:group", res
- .at("/query/operands/1/operands/1/@type").asText());
+ assertEquals("scheint",
+ res.at("/query/operands/1/operands/0/wrap/key").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/1/operands/1/@type").asText());
- assertEquals(false, res.at("/query/operands/1/operands/1/inOrder")
- .isMissingNode());
- assertEquals(false, res.at("/query/operands/1/operands/1/inOrder")
- .asBoolean());
+ assertEquals(false,
+ res.at("/query/operands/1/operands/1/inOrder").isMissingNode());
+ assertEquals(false,
+ res.at("/query/operands/1/operands/1/inOrder").asBoolean());
assertEquals("operation:disjunction",
res.at("/query/operands/1/operands/1/operation").asText());
@@ -422,8 +427,8 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("t", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/min").asInt());
assertEquals(0, res.at("/query/distances/0/max").asInt());
@@ -437,8 +442,8 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("t", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/min").asInt());
assertEquals(0, res.at("/query/distances/0/max").asInt());
@@ -446,45 +451,45 @@
assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
assertEquals("Sonne", res.at("/query/operands/0/wrap/key").asText());
assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
- assertEquals("operation:sequence", res
- .at("/query/operands/1/operation").asText());
+ assertEquals("operation:sequence",
+ res.at("/query/operands/1/operation").asText());
assertEquals("cosmas:distance",
res.at("/query/operands/1/distances/0/@type").asText());
assertEquals("t", res.at("/query/operands/1/distances/0/key").asText());
assertEquals(0, res.at("/query/operands/1/distances/0/min").asInt());
assertEquals(0, res.at("/query/operands/1/distances/0/max").asInt());
- assertEquals(true, res.at("/query/operands/1/distances/0/exclude")
- .asBoolean());
- assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key")
- .asText());
- assertEquals("Sterne", res.at("/query/operands/1/operands/1/wrap/key")
- .asText());
+ assertEquals(true,
+ res.at("/query/operands/1/distances/0/exclude").asBoolean());
+ assertEquals("Mond",
+ res.at("/query/operands/1/operands/0/wrap/key").asText());
+ assertEquals("Sterne",
+ res.at("/query/operands/1/operands/1/wrap/key").asText());
query = "(Sonne nicht Mond) nicht Sterne";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("t", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/min").asInt());
assertEquals(0, res.at("/query/distances/0/max").asInt());
assertEquals(true, res.at("/query/distances/0/exclude").asBoolean());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:sequence", res
- .at("/query/operands/0/operation").asText());
+ assertEquals("operation:sequence",
+ res.at("/query/operands/0/operation").asText());
assertEquals("cosmas:distance",
res.at("/query/operands/0/distances/0/@type").asText());
assertEquals("t", res.at("/query/operands/0/distances/0/key").asText());
assertEquals(0, res.at("/query/operands/0/distances/0/min").asInt());
assertEquals(0, res.at("/query/operands/0/distances/0/max").asInt());
- assertEquals(true, res.at("/query/operands/0/distances/0/exclude")
- .asBoolean());
- assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
- assertEquals("Mond", res.at("/query/operands/0/operands/1/wrap/key")
- .asText());
+ assertEquals(true,
+ res.at("/query/operands/0/distances/0/exclude").asBoolean());
+ assertEquals("Sonne",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
+ assertEquals("Mond",
+ res.at("/query/operands/0/operands/1/wrap/key").asText());
assertEquals("koral:token", res.at("/query/operands/1/@type").asText());
assertEquals("Sterne", res.at("/query/operands/1/wrap/key").asText());
}
@@ -497,31 +502,31 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(1, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(4, res.at("/query/distances/0/boundary/max").asInt());
assertEquals(true, res.at("/query/inOrder").asBoolean());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:class", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("operation:class",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classOut").asInt());
assertEquals(129, res.at("/query/operands/1/classOut").asInt());
- assertEquals("koral:token", res
- .at("/query/operands/0/operands/0/@type").asText());
- assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
- assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key")
- .asText());
+ assertEquals("koral:token",
+ res.at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("Sonne",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
+ assertEquals("Mond",
+ res.at("/query/operands/1/operands/0/wrap/key").asText());
query = "Sonne /+w1:4,s0,p1:3 Mond";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(1, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(4, res.at("/query/distances/0/boundary/max").asInt());
@@ -532,22 +537,22 @@
assertEquals(3, res.at("/query/distances/2/boundary/max").asInt());
assertEquals(true, res.at("/query/inOrder").asBoolean());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:class", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("operation:class",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classOut").asInt());
assertEquals(129, res.at("/query/operands/1/classOut").asInt());
- assertEquals("koral:token", res
- .at("/query/operands/0/operands/0/@type").asText());
- assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
- assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key")
- .asText());
+ assertEquals("koral:token",
+ res.at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("Sonne",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
+ assertEquals("Mond",
+ res.at("/query/operands/1/operands/0/wrap/key").asText());
query = "Sonne /+w4 Mond";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(4, res.at("/query/distances/0/boundary/max").asInt());
@@ -555,56 +560,57 @@
query = "Sonne /-w4 Mond";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(4, res.at("/query/distances/0/boundary/max").asInt());
- assertEquals("Mond", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
- assertEquals("Sonne", res.at("/query/operands/1/operands/0/wrap/key")
- .asText());
+ assertEquals("Mond",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
+ assertEquals("Sonne",
+ res.at("/query/operands/1/operands/0/wrap/key").asText());
query = "Sonne /w4 Mond";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(4, res.at("/query/distances/0/boundary/max").asInt());
- assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
- assertEquals("Mond", res.at("/query/operands/1/operands/0/wrap/key")
- .asText());
+ assertEquals("Sonne",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
+ assertEquals("Mond",
+ res.at("/query/operands/1/operands/0/wrap/key").asText());
assertEquals(false, res.at("/query/inOrder").asBoolean());
}
@Test
- public void testOPPROXNested () throws JsonProcessingException, IOException {
+ public void testOPPROXNested ()
+ throws JsonProcessingException, IOException {
query = "Sonne /+w1:4 Mond /+w1:7 Sterne";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(1, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(4, res.at("/query/distances/0/boundary/max").asInt());
assertEquals(true, res.at("/query/inOrder").asBoolean());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:class", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("operation:class",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classOut").asInt());
- assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
+ assertEquals("Sonne",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
assertEquals(129, res.at("/query/operands/1/classOut").asInt());
assertEquals("operation:sequence",
res.at("/query/operands/1/operands/0/operation").asText());
- assertEquals("w", res
- .at("/query/operands/1/operands/0/distances/0/key").asText());
+ assertEquals("w", res.at("/query/operands/1/operands/0/distances/0/key")
+ .asText());
assertEquals(1,
res.at("/query/operands/1/operands/0/distances/0/boundary/min")
.asInt());
@@ -614,29 +620,25 @@
assertEquals(130,
res.at("/query/operands/1/operands/0/operands/0/classOut")
.asInt());
- assertEquals(
- "Mond",
+ assertEquals("Mond",
res.at("/query/operands/1/operands/0/operands/0/operands/0/wrap/key")
.asText());
assertEquals(130,
res.at("/query/operands/1/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "Sterne",
+ assertEquals("Sterne",
res.at("/query/operands/1/operands/0/operands/1/operands/0/wrap/key")
.asText());
query = "Sonne /+w1:4 Mond /-w1:7 Sterne";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
- assertEquals("Sonne", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
- assertEquals(
- "Sterne",
+ assertEquals("Sonne",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
+ assertEquals("Sterne",
res.at("/query/operands/1/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals(
- "Mond",
+ assertEquals("Mond",
res.at("/query/operands/1/operands/0/operands/1/operands/0/wrap/key")
.asText());
@@ -645,23 +647,23 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(4, res.at("/query/distances/0/boundary/max").asInt());
assertEquals(true, res.at("/query/inOrder").asBoolean());
assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
- assertEquals("operation:class", res.at("/query/operands/1/operation")
- .asText());
+ assertEquals("operation:class",
+ res.at("/query/operands/1/operation").asText());
assertEquals(129, res.at("/query/operands/1/classOut").asInt());
- assertEquals("Sonne", res.at("/query/operands/1/operands/0/wrap/key")
- .asText());
+ assertEquals("Sonne",
+ res.at("/query/operands/1/operands/0/wrap/key").asText());
assertEquals(129, res.at("/query/operands/0/classOut").asInt());
assertEquals("operation:sequence",
res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals("w", res
- .at("/query/operands/0/operands/0/distances/0/key").asText());
+ assertEquals("w", res.at("/query/operands/0/operands/0/distances/0/key")
+ .asText());
assertEquals(0,
res.at("/query/operands/0/operands/0/distances/0/boundary/min")
.asInt());
@@ -671,15 +673,13 @@
assertEquals(130,
res.at("/query/operands/0/operands/0/operands/0/classOut")
.asInt());
- assertEquals(
- "Mond",
+ assertEquals("Mond",
res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key")
.asText());
assertEquals(130,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "Sterne",
+ assertEquals("Sterne",
res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
@@ -695,12 +695,12 @@
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(130, res.at("/query/classRef/0").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:class", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("operation:class",
+ res.at("/query/operands/0/operation").asText());
assertEquals("classRefCheck:includes",
res.at("/query/operands/0/classRefCheck/0").asText());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:position",
res.at("/query/operands/0/operands/0/operation").asText());
assertEquals(true, res.at("/query/operands/0/operands/0/frames/0")
@@ -708,37 +708,32 @@
assertEquals(129, res.at("/query/operands/0/classIn/0").asInt());
assertEquals(130, res.at("/query/operands/0/classIn/1").asInt());
assertEquals(131, res.at("/query/operands/0/classOut").asInt());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/0/operation")
.asText());
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/0/classOut")
.asInt());
- assertEquals(
- "koral:span",
+ assertEquals("koral:span",
res.at("/query/operands/0/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals(
- "s",
+ assertEquals("s",
res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/1/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/1/operation")
.asText());
assertEquals(130,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "koral:token",
+ assertEquals("koral:token",
res.at("/query/operands/0/operands/0/operands/1/operands/0/@type")
.asText());
- assertEquals(
- "wegen",
+ assertEquals("wegen",
res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
@@ -749,33 +744,32 @@
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(130, res.at("/query/classRef/0").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:position", res
- .at("/query/operands/0/operation").asText());
- assertEquals("frames:startsWith", res.at("/query/operands/0/frames/0")
- .asText());
- assertEquals("frames:matches", res.at("/query/operands/0/frames/1")
- .asText());
- assertEquals(true, res.at("/query/operands/0/frames/2").isMissingNode());
+ assertEquals("operation:position",
+ res.at("/query/operands/0/operation").asText());
+ assertEquals("frames:startsWith",
+ res.at("/query/operands/0/frames/0").asText());
+ assertEquals("frames:matches",
+ res.at("/query/operands/0/frames/1").asText());
+ assertEquals(true,
+ res.at("/query/operands/0/frames/2").isMissingNode());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/classOut")
- .asInt());
- assertEquals("koral:span",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals(129,
+ res.at("/query/operands/0/operands/0/classOut").asInt());
+ assertEquals("koral:span", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("s",
res.at("/query/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/1/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(130, res.at("/query/operands/0/operands/1/classOut")
- .asInt());
- assertEquals("koral:token",
- res.at("/query/operands/0/operands/1/operands/0/@type")
- .asText());
+ assertEquals(130,
+ res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals("koral:token", res
+ .at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("wegen",
res.at("/query/operands/0/operands/1/operands/0/wrap/key")
.asText());
@@ -783,11 +777,12 @@
query = "wegen #IN(F) <s>";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
- assertEquals(true, res.at("/query/operands/0/classRefCheck")
- .isMissingNode());
- assertEquals("frames:matches", res.at("/query/operands/0/frames/0")
- .asText());
- assertEquals(true, res.at("/query/operands/0/frames/1").isMissingNode());
+ assertEquals(true,
+ res.at("/query/operands/0/classRefCheck").isMissingNode());
+ assertEquals("frames:matches",
+ res.at("/query/operands/0/frames/0").asText());
+ assertEquals(true,
+ res.at("/query/operands/0/frames/1").isMissingNode());
query = "wegen #IN(FI) <s>";
qs.setQuery(query, "cosmas2");
@@ -812,10 +807,10 @@
query = "wegen #IN(%, L) <s>";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
- assertEquals("frames:startsWith", res.at("/query/operands/0/frames/0")
- .asText());
- assertEquals("frames:matches", res.at("/query/operands/0/frames/1")
- .asText());
+ assertEquals("frames:startsWith",
+ res.at("/query/operands/0/frames/0").asText());
+ assertEquals("frames:matches",
+ res.at("/query/operands/0/frames/1").asText());
// assertEquals(true, res.at("/query/operands/0/operands/0/exclude").isMissingNode());
query = "wegen #IN(FE,%,MIN) <s>";
@@ -837,20 +832,20 @@
res.at("/query/operands/0/classRefCheck/0").asText());
assertEquals("frames:matches",
res.at("/query/operands/0/operands/0/frames/0").asText());
- assertEquals(true, res.at("/query/operands/0/operands/0/exclude")
- .asBoolean());
+ assertEquals(true,
+ res.at("/query/operands/0/operands/0/exclude").asBoolean());
query = "wegen #IN(FE,ALL,%,MAX) <s>";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("operation:merge", res.at("/query/operation").asText());
- assertEquals("operation:class", res.at("/query/operands/0/operation")
- .asText());
- assertEquals("classRefOp:delete", res
- .at("/query/operands/0/classRefOp").asText());
+ assertEquals("operation:class",
+ res.at("/query/operands/0/operation").asText());
+ assertEquals("classRefOp:delete",
+ res.at("/query/operands/0/classRefOp").asText());
assertEquals(131, res.at("/query/operands/0/classIn/0").asInt());
- assertEquals("classRefCheck:equals",
- res.at("/query/operands/0/operands/0/classRefCheck/0").asText());
+ assertEquals("classRefCheck:equals", res
+ .at("/query/operands/0/operands/0/classRefCheck/0").asText());
assertEquals("frames:matches",
res.at("/query/operands/0/operands/0/operands/0/frames/0")
.asText());
@@ -869,51 +864,46 @@
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(130, res.at("/query/classRef/0").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:class", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("operation:class",
+ res.at("/query/operands/0/operation").asText());
assertEquals("classRefCheck:intersects",
res.at("/query/operands/0/classRefCheck/0").asText());
// assertEquals("classRefOp:merge", res.at("/query/operands/0/classRefOp").asText());
assertEquals(131, res.at("/query/operands/0/classOut").asInt());
assertEquals(129, res.at("/query/operands/0/classIn/0").asInt());
assertEquals(130, res.at("/query/operands/0/classIn/1").asInt());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:position",
res.at("/query/operands/0/operands/0/operation").asText());
assertEquals(true, res.at("/query/operands/0/operands/0/frames/0")
.isMissingNode());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/0/operation")
.asText());
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/0/classOut")
.asInt());
- assertEquals(
- "koral:span",
+ assertEquals("koral:span",
res.at("/query/operands/0/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals(
- "s",
+ assertEquals("s",
res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/1/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/1/operation")
.asText());
assertEquals(130,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "koral:token",
+ assertEquals("koral:token",
res.at("/query/operands/0/operands/0/operands/1/operands/0/@type")
.asText());
- assertEquals(
- "wegen",
+ assertEquals("wegen",
res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
@@ -967,158 +957,142 @@
assertEquals(0, res.at("/query/spanRef/0").asInt());
assertEquals(1, res.at("/query/spanRef/1").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:sequence", res
- .at("/query/operands/0/operation").asText());
+ assertEquals("operation:sequence",
+ res.at("/query/operands/0/operation").asText());
assertEquals("cosmas:distance",
res.at("/query/operands/0/distances/0/@type").asText());
assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
- assertEquals(3, res.at("/query/operands/0/distances/0/boundary/min")
- .asInt());
- assertEquals(5, res.at("/query/operands/0/distances/0/boundary/max")
- .asInt());
+ assertEquals(3,
+ res.at("/query/operands/0/distances/0/boundary/min").asInt());
+ assertEquals(5,
+ res.at("/query/operands/0/distances/0/boundary/max").asInt());
assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean());
- assertEquals("koral:token", res
- .at("/query/operands/0/operands/0/@type").asText());
- assertEquals("der", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
- assertEquals("Mann", res.at("/query/operands/0/operands/1/wrap/key")
- .asText());
+ assertEquals("koral:token",
+ res.at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("der",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
+ assertEquals("Mann",
+ res.at("/query/operands/0/operands/1/wrap/key").asText());
query = "#BEG(der /w3:5 Mann) /+w10 kommt";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(10, res.at("/query/distances/0/boundary/max").asInt());
assertEquals(true, res.at("/query/inOrder").asBoolean());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:class", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("operation:class",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classOut").asInt());
assertEquals("koral:reference",
res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:focus",
res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals(0, res.at("/query/operands/0/operands/0/spanRef/0")
- .asInt());
- assertEquals(1, res.at("/query/operands/0/operands/0/spanRef/1")
- .asInt());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals(0,
+ res.at("/query/operands/0/operands/0/spanRef/0").asInt());
+ assertEquals(1,
+ res.at("/query/operands/0/operands/0/spanRef/1").asInt());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("operation:sequence",
res.at("/query/operands/0/operands/0/operands/0/operation")
.asText());
- assertEquals(
- "cosmas:distance",
+ assertEquals("cosmas:distance",
res.at("/query/operands/0/operands/0/operands/0/distances/0/@type")
.asText());
- assertEquals(
- "w",
+ assertEquals("w",
res.at("/query/operands/0/operands/0/operands/0/distances/0/key")
.asText());
- assertEquals(
- 3,
+ assertEquals(3,
res.at("/query/operands/0/operands/0/operands/0/distances/0/boundary/min")
.asInt());
- assertEquals(
- 5,
+ assertEquals(5,
res.at("/query/operands/0/operands/0/operands/0/distances/0/boundary/max")
.asInt());
assertEquals(false,
res.at("/query/operands/0/operands/0/operands/0/inOrder")
.asBoolean());
- assertEquals(
- "koral:token",
+ assertEquals("koral:token",
res.at("/query/operands/0/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals(
- "der",
+ assertEquals("der",
res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals(
- "Mann",
+ assertEquals("Mann",
res.at("/query/operands/0/operands/0/operands/0/operands/1/wrap/key")
.asText());
- assertEquals("operation:class", res.at("/query/operands/1/operation")
- .asText());
+ assertEquals("operation:class",
+ res.at("/query/operands/1/operation").asText());
assertEquals(129, res.at("/query/operands/1/classOut").asInt());
- assertEquals("koral:token", res
- .at("/query/operands/1/operands/0/@type").asText());
- assertEquals("kommt", res.at("/query/operands/1/operands/0/wrap/key")
- .asText());
+ assertEquals("koral:token",
+ res.at("/query/operands/1/operands/0/@type").asText());
+ assertEquals("kommt",
+ res.at("/query/operands/1/operands/0/wrap/key").asText());
query = "kommt /+w10 #BEG(der /w3:5 Mann)";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(10, res.at("/query/distances/0/boundary/max").asInt());
assertEquals(true, res.at("/query/inOrder").asBoolean());
assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
- assertEquals("operation:class", res.at("/query/operands/1/operation")
- .asText());
+ assertEquals("operation:class",
+ res.at("/query/operands/1/operation").asText());
assertEquals(129, res.at("/query/operands/1/classOut").asInt());
assertEquals("koral:reference",
res.at("/query/operands/1/operands/0/@type").asText());
assertEquals("operation:focus",
res.at("/query/operands/1/operands/0/operation").asText());
- assertEquals(0, res.at("/query/operands/1/operands/0/spanRef/0")
- .asInt());
- assertEquals(1, res.at("/query/operands/1/operands/0/spanRef/1")
- .asInt());
- assertEquals("koral:group",
- res.at("/query/operands/1/operands/0/operands/0/@type")
- .asText());
+ assertEquals(0,
+ res.at("/query/operands/1/operands/0/spanRef/0").asInt());
+ assertEquals(1,
+ res.at("/query/operands/1/operands/0/spanRef/1").asInt());
+ assertEquals("koral:group", res
+ .at("/query/operands/1/operands/0/operands/0/@type").asText());
assertEquals("operation:sequence",
res.at("/query/operands/1/operands/0/operands/0/operation")
.asText());
- assertEquals(
- "cosmas:distance",
+ assertEquals("cosmas:distance",
res.at("/query/operands/1/operands/0/operands/0/distances/0/@type")
.asText());
- assertEquals(
- "w",
+ assertEquals("w",
res.at("/query/operands/1/operands/0/operands/0/distances/0/key")
.asText());
- assertEquals(
- 3,
+ assertEquals(3,
res.at("/query/operands/1/operands/0/operands/0/distances/0/boundary/min")
.asInt());
- assertEquals(
- 5,
+ assertEquals(5,
res.at("/query/operands/1/operands/0/operands/0/distances/0/boundary/max")
.asInt());
assertEquals(false,
res.at("/query/operands/1/operands/0/operands/0/inOrder")
.asBoolean());
- assertEquals(
- "koral:token",
+ assertEquals("koral:token",
res.at("/query/operands/1/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals(
- "der",
+ assertEquals("der",
res.at("/query/operands/1/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals(
- "Mann",
+ assertEquals("Mann",
res.at("/query/operands/1/operands/0/operands/0/operands/1/wrap/key")
.asText());
- assertEquals("operation:class", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("operation:class",
+ res.at("/query/operands/0/operation").asText());
assertEquals(129, res.at("/query/operands/0/classOut").asInt());
- assertEquals("koral:token", res
- .at("/query/operands/0/operands/0/@type").asText());
- assertEquals("kommt", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
+ assertEquals("koral:token",
+ res.at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("kommt",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
query = "#END(der /w3:5 Mann)";
qs.setQuery(query, "cosmas2");
@@ -1128,22 +1102,22 @@
assertEquals(-1, res.at("/query/spanRef/0").asInt());
assertEquals(1, res.at("/query/spanRef/1").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:sequence", res
- .at("/query/operands/0/operation").asText());
+ assertEquals("operation:sequence",
+ res.at("/query/operands/0/operation").asText());
assertEquals("cosmas:distance",
res.at("/query/operands/0/distances/0/@type").asText());
assertEquals("w", res.at("/query/operands/0/distances/0/key").asText());
- assertEquals(3, res.at("/query/operands/0/distances/0/boundary/min")
- .asInt());
- assertEquals(5, res.at("/query/operands/0/distances/0/boundary/max")
- .asInt());
+ assertEquals(3,
+ res.at("/query/operands/0/distances/0/boundary/min").asInt());
+ assertEquals(5,
+ res.at("/query/operands/0/distances/0/boundary/max").asInt());
assertEquals(false, res.at("/query/operands/0/inOrder").asBoolean());
- assertEquals("koral:token", res
- .at("/query/operands/0/operands/0/@type").asText());
- assertEquals("der", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
- assertEquals("Mann", res.at("/query/operands/0/operands/1/wrap/key")
- .asText());
+ assertEquals("koral:token",
+ res.at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("der",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
+ assertEquals("Mann",
+ res.at("/query/operands/0/operands/1/wrap/key").asText());
}
@@ -1172,18 +1146,18 @@
assertEquals("w", res.at("/query/key").asText());
assertEquals("koral:termGroup", res.at("/query/attr/@type").asText());
assertEquals("relation:and", res.at("/query/attr/relation").asText());
- assertEquals("koral:term", res.at("/query/attr/operands/0/@type")
- .asText());
+ assertEquals("koral:term",
+ res.at("/query/attr/operands/0/@type").asText());
assertEquals("N", res.at("/query/attr/operands/0/key").asText());
assertEquals("p", res.at("/query/attr/operands/0/layer").asText());
- assertEquals("match:ne", res.at("/query/attr/operands/0/match")
- .asText());
- assertEquals("koral:term", res.at("/query/attr/operands/1/@type")
- .asText());
+ assertEquals("match:ne",
+ res.at("/query/attr/operands/0/match").asText());
+ assertEquals("koral:term",
+ res.at("/query/attr/operands/1/@type").asText());
assertEquals("V", res.at("/query/attr/operands/1/key").asText());
assertEquals("p", res.at("/query/attr/operands/1/layer").asText());
- assertEquals("match:ne", res.at("/query/attr/operands/1/match")
- .asText());
+ assertEquals("match:ne",
+ res.at("/query/attr/operands/1/match").asText());
query = "#ELEM(W ANA != 'N A V' Genre = Sport)";
qs.setQuery(query, "cosmas2");
@@ -1192,16 +1166,16 @@
assertEquals("w", res.at("/query/key").asText());
assertEquals("koral:termGroup", res.at("/query/attr/@type").asText());
assertEquals("relation:and", res.at("/query/attr/relation").asText());
- assertEquals("koral:termGroup", res.at("/query/attr/operands/0/@type")
- .asText());
- assertEquals("relation:and", res.at("/query/attr/operands/0/relation")
- .asText());
- assertEquals("N", res.at("/query/attr/operands/0/operands/0/key")
- .asText());
- assertEquals("A", res.at("/query/attr/operands/0/operands/1/key")
- .asText());
- assertEquals("V", res.at("/query/attr/operands/0/operands/2/key")
- .asText());
+ assertEquals("koral:termGroup",
+ res.at("/query/attr/operands/0/@type").asText());
+ assertEquals("relation:and",
+ res.at("/query/attr/operands/0/relation").asText());
+ assertEquals("N",
+ res.at("/query/attr/operands/0/operands/0/key").asText());
+ assertEquals("A",
+ res.at("/query/attr/operands/0/operands/1/key").asText());
+ assertEquals("V",
+ res.at("/query/attr/operands/0/operands/2/key").asText());
assertEquals("Genre", res.at("/query/attr/operands/1/layer").asText());
assertEquals("Sport", res.at("/query/attr/operands/1/key").asText());
@@ -1212,30 +1186,30 @@
assertEquals("w", res.at("/query/key").asText());
assertEquals("koral:termGroup", res.at("/query/attr/@type").asText());
assertEquals("relation:and", res.at("/query/attr/relation").asText());
- assertEquals("koral:termGroup", res.at("/query/attr/operands/0/@type")
- .asText());
- assertEquals("relation:and", res.at("/query/attr/operands/0/relation")
- .asText());
- assertEquals("koral:termGroup", res.at("/query/attr/operands/1/@type")
- .asText());
- assertEquals("relation:and", res.at("/query/attr/operands/1/relation")
- .asText());
- assertEquals("N", res.at("/query/attr/operands/0/operands/0/key")
- .asText());
- assertEquals("A", res.at("/query/attr/operands/0/operands/1/key")
- .asText());
- assertEquals("V", res.at("/query/attr/operands/0/operands/2/key")
- .asText());
+ assertEquals("koral:termGroup",
+ res.at("/query/attr/operands/0/@type").asText());
+ assertEquals("relation:and",
+ res.at("/query/attr/operands/0/relation").asText());
+ assertEquals("koral:termGroup",
+ res.at("/query/attr/operands/1/@type").asText());
+ assertEquals("relation:and",
+ res.at("/query/attr/operands/1/relation").asText());
+ assertEquals("N",
+ res.at("/query/attr/operands/0/operands/0/key").asText());
+ assertEquals("A",
+ res.at("/query/attr/operands/0/operands/1/key").asText());
+ assertEquals("V",
+ res.at("/query/attr/operands/0/operands/2/key").asText());
assertEquals("match:ne",
res.at("/query/attr/operands/0/operands/2/match").asText());
- assertEquals("Genre", res.at("/query/attr/operands/1/operands/0/layer")
- .asText());
- assertEquals("Sport", res.at("/query/attr/operands/1/operands/0/key")
- .asText());
- assertEquals("Genre", res.at("/query/attr/operands/1/operands/1/layer")
- .asText());
- assertEquals("Politik", res.at("/query/attr/operands/1/operands/1/key")
- .asText());
+ assertEquals("Genre",
+ res.at("/query/attr/operands/1/operands/0/layer").asText());
+ assertEquals("Sport",
+ res.at("/query/attr/operands/1/operands/0/key").asText());
+ assertEquals("Genre",
+ res.at("/query/attr/operands/1/operands/1/layer").asText());
+ assertEquals("Politik",
+ res.at("/query/attr/operands/1/operands/1/key").asText());
assertEquals("match:ne",
res.at("/query/attr/operands/1/operands/1/match").asText());
}
@@ -1250,8 +1224,8 @@
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("gehen", res.at("/query/operands/0/wrap/key").asText());
assertEquals("voran", res.at("/query/operands/1/wrap/key").asText());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(1, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(10, res.at("/query/distances/0/boundary/max").asInt());
@@ -1261,26 +1235,26 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("cosmas:distance", res.at("/query/distances/0/@type")
- .asText());
+ assertEquals("cosmas:distance",
+ res.at("/query/distances/0/@type").asText());
assertEquals("w", res.at("/query/distances/0/key").asText());
assertEquals(1, res.at("/query/distances/0/boundary/min").asInt());
assertEquals(10, res.at("/query/distances/0/boundary/max").asInt());
assertEquals("gehen", res.at("/query/operands/0/wrap/key").asText());
assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
- assertEquals("operation:sequence", res
- .at("/query/operands/1/operation").asText());
+ assertEquals("operation:sequence",
+ res.at("/query/operands/1/operation").asText());
assertEquals("cosmas:distance",
res.at("/query/operands/1/distances/0/@type").asText());
assertEquals("w", res.at("/query/operands/1/distances/0/key").asText());
- assertEquals(1, res.at("/query/operands/1/distances/0/boundary/min")
- .asInt());
- assertEquals(4, res.at("/query/operands/1/distances/0/boundary/max")
- .asInt());
- assertEquals("voran", res.at("/query/operands/1/operands/0/wrap/key")
- .asText());
- assertEquals("schnell", res.at("/query/operands/1/operands/1/wrap/key")
- .asText());
+ assertEquals(1,
+ res.at("/query/operands/1/distances/0/boundary/min").asInt());
+ assertEquals(4,
+ res.at("/query/operands/1/distances/0/boundary/max").asInt());
+ assertEquals("voran",
+ res.at("/query/operands/1/operands/0/wrap/key").asText());
+ assertEquals("schnell",
+ res.at("/query/operands/1/operands/1/wrap/key").asText());
}
@@ -1295,31 +1269,29 @@
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(129, res.at("/query/classRef/0").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:class", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("operation:class",
+ res.at("/query/operands/0/operation").asText());
assertEquals("classRefOp:inversion",
res.at("/query/operands/0/classRefOp").asText());
assertEquals(130, res.at("/query/operands/0/classIn/0").asInt());
assertEquals(131, res.at("/query/operands/0/classIn/1").asInt());
assertEquals(129, res.at("/query/operands/0/classOut").asInt());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:sequence",
res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals("cosmas:distance",
- res.at("/query/operands/0/operands/0/distances/0/@type")
- .asText());
- assertEquals("w", res
- .at("/query/operands/0/operands/0/distances/0/key").asText());
+ assertEquals("cosmas:distance", res
+ .at("/query/operands/0/operands/0/distances/0/@type").asText());
+ assertEquals("w", res.at("/query/operands/0/operands/0/distances/0/key")
+ .asText());
assertEquals(1,
res.at("/query/operands/0/operands/0/distances/0/boundary/min")
.asInt());
assertEquals(10,
res.at("/query/operands/0/operands/0/distances/0/boundary/max")
.asInt());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/0/operation")
.asText());
@@ -1329,16 +1301,13 @@
assertEquals(131,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "koral:token",
+ assertEquals("koral:token",
res.at("/query/operands/0/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals(
- "gehen",
+ assertEquals("gehen",
res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals(
- "voran",
+ assertEquals("voran",
res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
@@ -1349,63 +1318,55 @@
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(129, res.at("/query/classRef/0").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:class", res.at("/query/operands/0/operation")
- .asText());
+ assertEquals("operation:class",
+ res.at("/query/operands/0/operation").asText());
assertEquals("classRefOp:inversion",
res.at("/query/operands/0/classRefOp").asText());
assertEquals(130, res.at("/query/operands/0/classIn/0").asInt());
assertEquals(131, res.at("/query/operands/0/classIn/1").asInt());
assertEquals(129, res.at("/query/operands/0/classOut").asInt());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:sequence",
res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals("cosmas:distance",
- res.at("/query/operands/0/operands/0/distances/0/@type")
- .asText());
- assertEquals("w", res
- .at("/query/operands/0/operands/0/distances/0/key").asText());
+ assertEquals("cosmas:distance", res
+ .at("/query/operands/0/operands/0/distances/0/@type").asText());
+ assertEquals("w", res.at("/query/operands/0/operands/0/distances/0/key")
+ .asText());
assertEquals(1,
res.at("/query/operands/0/operands/0/distances/0/boundary/min")
.asInt());
assertEquals(10,
res.at("/query/operands/0/operands/0/distances/0/boundary/max")
.asInt());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/0/operation")
.asText());
assertEquals(130,
res.at("/query/operands/0/operands/0/operands/0/classOut")
.asInt());
- assertEquals(
- "gehen",
+ assertEquals("gehen",
res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key")
.asText());
assertEquals(131,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
// assertEquals("classRefOp:merge", res.at("/query/operands/0/operands/0/operands/1/classRefOp").asText());
- assertEquals(
- "operation:sequence",
+ assertEquals("operation:sequence",
res.at("/query/operands/0/operands/0/operands/1/operands/0/operation")
.asText());
- assertEquals(
- 132,
+ assertEquals(132,
res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/classOut")
.asInt());
- assertEquals(
- "voran",
+ assertEquals("voran",
res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals(
- 132,
+ assertEquals(132,
res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "Beispiel",
+ assertEquals("Beispiel",
res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/1/operands/0/wrap/key")
.asText());
@@ -1421,25 +1382,24 @@
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(129, res.at("/query/classRef/0").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:position", res
- .at("/query/operands/0/operation").asText());
- assertEquals("frames:startsWith", res.at("/query/operands/0/frames/0")
- .asText());
+ assertEquals("operation:position",
+ res.at("/query/operands/0/operation").asText());
+ assertEquals("frames:startsWith",
+ res.at("/query/operands/0/frames/0").asText());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/1/classOut")
- .asInt());
- assertEquals("koral:token",
- res.at("/query/operands/0/operands/1/operands/0/@type")
- .asText());
+ assertEquals(129,
+ res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals("koral:token", res
+ .at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("der",
res.at("/query/operands/0/operands/1/operands/0/wrap/key")
.asText());
- assertEquals("koral:span", res.at("/query/operands/0/operands/0/@type")
- .asText());
- assertEquals("s", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
+ assertEquals("koral:span",
+ res.at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("s",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
query = "#BED(der Mann , +pe)";
qs.setQuery(query, "cosmas2");
@@ -1448,21 +1408,20 @@
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(129, res.at("/query/classRef/0").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:position", res
- .at("/query/operands/0/operation").asText());
- assertEquals("frames:matches", res.at("/query/operands/0/frames/0")
- .asText());
+ assertEquals("operation:position",
+ res.at("/query/operands/0/operation").asText());
+ assertEquals("frames:matches",
+ res.at("/query/operands/0/frames/0").asText());
assertEquals("koral:reference",
res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:focus",
res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals(-1, res.at("/query/operands/0/operands/0/spanRef/0")
- .asInt());
- assertEquals(1, res.at("/query/operands/0/operands/0/spanRef/1")
- .asInt());
- assertEquals("koral:span",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals(-1,
+ res.at("/query/operands/0/operands/0/spanRef/0").asInt());
+ assertEquals(1,
+ res.at("/query/operands/0/operands/0/spanRef/1").asInt());
+ assertEquals("koral:span", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("p",
res.at("/query/operands/0/operands/0/operands/0/wrap/key")
.asText());
@@ -1470,29 +1429,25 @@
res.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:focus",
res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(0, res.at("/query/operands/0/operands/1/spanRef/0")
- .asInt());
- assertEquals(1, res.at("/query/operands/0/operands/1/spanRef/1")
- .asInt());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/1/operands/0/@type")
- .asText());
+ assertEquals(0,
+ res.at("/query/operands/0/operands/1/spanRef/0").asInt());
+ assertEquals(1,
+ res.at("/query/operands/0/operands/1/spanRef/1").asInt());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/1/operands/0/operation")
.asText());
assertEquals(129,
res.at("/query/operands/0/operands/1/operands/0/classOut")
.asInt());
- assertEquals(
- "operation:sequence",
+ assertEquals("operation:sequence",
res.at("/query/operands/0/operands/1/operands/0/operands/0/operation")
.asText());
- assertEquals(
- "der",
+ assertEquals("der",
res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals(
- "Mann",
+ assertEquals("Mann",
res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/wrap/key")
.asText());
@@ -1503,78 +1458,68 @@
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(129, res.at("/query/classRef/0").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:position", res
- .at("/query/operands/0/operation").asText());
- assertEquals("frames:matches", res.at("/query/operands/0/frames/0")
- .asText());
+ assertEquals("operation:position",
+ res.at("/query/operands/0/operation").asText());
+ assertEquals("frames:matches",
+ res.at("/query/operands/0/frames/0").asText());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:position",
res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("frames:startsWith",
res.at("/query/operands/0/operands/0/frames/0").asText());
- assertEquals("koral:span",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:span", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("s",
res.at("/query/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/1/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/1/operation")
.asText());
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "operation:sequence",
+ assertEquals("operation:sequence",
res.at("/query/operands/0/operands/0/operands/1/operands/0/operation")
.asText());
- assertEquals(
- "der",
+ assertEquals("der",
res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/wrap/key")
.asText());
- assertEquals(
- "Mann",
+ assertEquals("Mann",
res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/1/wrap/key")
.asText());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/1/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:position",
res.at("/query/operands/0/operands/1/operation").asText());
assertEquals("frames:startsWith",
res.at("/query/operands/0/operands/1/frames/0").asText());
- assertEquals(true, res.at("/query/operands/0/operands/1/exclude")
- .asBoolean());
- assertEquals("koral:span",
- res.at("/query/operands/0/operands/1/operands/0/@type")
- .asText());
+ assertEquals(true,
+ res.at("/query/operands/0/operands/1/exclude").asBoolean());
+ assertEquals("koral:span", res
+ .at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("p",
res.at("/query/operands/0/operands/1/operands/0/wrap/key")
.asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/1/operands/1/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/1/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/1/operands/1/operation")
.asText());
assertEquals(130,
res.at("/query/operands/0/operands/1/operands/1/classOut")
.asInt());
- assertEquals(
- "operation:sequence",
+ assertEquals("operation:sequence",
res.at("/query/operands/0/operands/1/operands/1/operands/0/operation")
.asText());
- assertEquals(
- "der",
+ assertEquals("der",
res.at("/query/operands/0/operands/1/operands/1/operands/0/operands/0/wrap/key")
.asText());
- assertEquals(
- "Mann",
+ assertEquals("Mann",
res.at("/query/operands/0/operands/1/operands/1/operands/0/operands/1/wrap/key")
.asText());
@@ -1582,8 +1527,8 @@
@Test
- public void testColonSeparatedConditions () throws JsonProcessingException,
- IOException {
+ public void testColonSeparatedConditions ()
+ throws JsonProcessingException, IOException {
query = "der:sa";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
@@ -1591,25 +1536,24 @@
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(129, res.at("/query/classRef/0").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:position", res
- .at("/query/operands/0/operation").asText());
- assertEquals("frames:startsWith", res.at("/query/operands/0/frames/0")
- .asText());
+ assertEquals("operation:position",
+ res.at("/query/operands/0/operation").asText());
+ assertEquals("frames:startsWith",
+ res.at("/query/operands/0/frames/0").asText());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/1/classOut")
- .asInt());
- assertEquals("koral:token",
- res.at("/query/operands/0/operands/1/operands/0/@type")
- .asText());
+ assertEquals(129,
+ res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals("koral:token", res
+ .at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("der",
res.at("/query/operands/0/operands/1/operands/0/wrap/key")
.asText());
- assertEquals("koral:span", res.at("/query/operands/0/operands/0/@type")
- .asText());
- assertEquals("s", res.at("/query/operands/0/operands/0/wrap/key")
- .asText());
+ assertEquals("koral:span",
+ res.at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("s",
+ res.at("/query/operands/0/operands/0/wrap/key").asText());
query = "der:sa,-pa";
qs.setQuery(query, "cosmas2");
@@ -1618,60 +1562,54 @@
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(129, res.at("/query/classRef/0").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:position", res
- .at("/query/operands/0/operation").asText());
- assertEquals("frames:matches", res.at("/query/operands/0/frames/0")
- .asText());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("operation:position",
+ res.at("/query/operands/0/operation").asText());
+ assertEquals("frames:matches",
+ res.at("/query/operands/0/frames/0").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:position",
res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("frames:startsWith",
res.at("/query/operands/0/operands/0/frames/0").asText());
- assertEquals("koral:span",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:span", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("s",
res.at("/query/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/1/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/1/operation")
.asText());
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "der",
+ assertEquals("der",
res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/1/@type").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:position",
res.at("/query/operands/0/operands/1/operation").asText());
assertEquals("frames:startsWith",
res.at("/query/operands/0/operands/1/frames/0").asText());
- assertEquals(true, res.at("/query/operands/0/operands/1/exclude")
- .asBoolean());
- assertEquals("koral:span",
- res.at("/query/operands/0/operands/1/operands/0/@type")
- .asText());
+ assertEquals(true,
+ res.at("/query/operands/0/operands/1/exclude").asBoolean());
+ assertEquals("koral:span", res
+ .at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("p",
res.at("/query/operands/0/operands/1/operands/0/wrap/key")
.asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/1/operands/1/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/1/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/1/operands/1/operation")
.asText());
assertEquals(130,
res.at("/query/operands/0/operands/1/operands/1/classOut")
.asInt());
- assertEquals(
- "der",
+ assertEquals("der",
res.at("/query/operands/0/operands/1/operands/1/operands/0/wrap/key")
.asText());
@@ -1682,156 +1620,125 @@
assertEquals("operation:focus", res.at("/query/operation").asText());
assertEquals(129, res.at("/query/classRef/0").asInt());
assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:position", res
- .at("/query/operands/0/operation").asText());
- assertEquals("frames:matches", res.at("/query/operands/0/frames/0")
- .asText());
- assertEquals("koral:group", res
- .at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("operation:position",
+ res.at("/query/operands/0/operation").asText());
+ assertEquals("frames:matches",
+ res.at("/query/operands/0/frames/0").asText());
+ assertEquals("koral:group",
+ res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:position",
res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("frames:startsWith",
res.at("/query/operands/0/operands/0/frames/0").asText());
- assertEquals("koral:span",
- res.at("/query/operands/0/operands/0/operands/0/@type")
- .asText());
+ assertEquals("koral:span", res
+ .at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("s",
res.at("/query/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/0/operands/1/@type")
- .asText());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/1/operation")
.asText());
assertEquals(129,
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "der",
+ assertEquals("der",
res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
assertEquals("koral:reference",
res.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:focus",
res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(130, res.at("/query/operands/0/operands/1/classRef/0")
- .asInt());
- assertEquals("koral:group",
- res.at("/query/operands/0/operands/1/operands/0/@type")
- .asText());
+ assertEquals(130,
+ res.at("/query/operands/0/operands/1/classRef/0").asInt());
+ assertEquals("koral:group", res
+ .at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("operation:position",
res.at("/query/operands/0/operands/1/operands/0/operation")
.asText());
assertEquals("frames:matches",
res.at("/query/operands/0/operands/1/operands/0/frames/0")
.asText());
- assertEquals(
- "koral:group",
+ assertEquals("koral:group",
res.at("/query/operands/0/operands/1/operands/0/operands/0/@type")
.asText());
- assertEquals(
- "operation:position",
+ assertEquals("operation:position",
res.at("/query/operands/0/operands/1/operands/0/operands/0/operation")
.asText());
- assertEquals(
- "frames:startsWith",
+ assertEquals("frames:startsWith",
res.at("/query/operands/0/operands/1/operands/0/operands/0/frames/0")
.asText());
- assertEquals(
- true,
+ assertEquals(true,
res.at("/query/operands/0/operands/1/operands/0/operands/0/exclude")
.asBoolean());
- assertEquals(
- "koral:span",
+ assertEquals("koral:span",
res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/@type")
.asText());
- assertEquals(
- "p",
+ assertEquals("p",
res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/wrap/key")
.asText());
- assertEquals(
- "koral:group",
+ assertEquals("koral:group",
res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/@type")
.asText());
- assertEquals(
- "operation:class",
+ assertEquals("operation:class",
res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operation")
.asText());
- assertEquals(
- 130,
+ assertEquals(130,
res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/classOut")
.asInt());
- assertEquals(
- "der",
+ assertEquals("der",
res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
- assertEquals(
- "koral:group",
+ assertEquals("koral:group",
res.at("/query/operands/0/operands/1/operands/0/operands/1/@type")
.asText());
- assertEquals(
- "operation:position",
+ assertEquals("operation:position",
res.at("/query/operands/0/operands/1/operands/0/operands/1/operation")
.asText());
- assertEquals(
- "frames:matches",
+ assertEquals("frames:matches",
res.at("/query/operands/0/operands/1/operands/0/operands/1/frames/0")
.asText());
- assertEquals(
- "koral:reference",
+ assertEquals("koral:reference",
res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/@type")
.asText());
- assertEquals(
- "operation:focus",
+ assertEquals("operation:focus",
res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/operation")
.asText());
- assertEquals(
- -1,
+ assertEquals(-1,
res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/spanRef/0")
.asInt());
- assertEquals(
- 1,
+ assertEquals(1,
res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/spanRef/1")
.asInt());
- assertEquals(
- "koral:span",
+ assertEquals("koral:span",
res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/operands/0/@type")
.asText());
- assertEquals(
- "t",
+ assertEquals("t",
res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/operands/0/wrap/key")
.asText());
- assertEquals(
- "koral:reference",
+ assertEquals("koral:reference",
res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/@type")
.asText());
- assertEquals(
- "operation:focus",
+ assertEquals("operation:focus",
res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operation")
.asText());
- assertEquals(
- 0,
+ assertEquals(0,
res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/spanRef/0")
.asInt());
- assertEquals(
- 1,
+ assertEquals(1,
res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/spanRef/1")
.asInt());
- assertEquals(
- "koral:group",
+ assertEquals("koral:group",
res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/@type")
.asText());
- assertEquals(
- "operation:class",
+ assertEquals("operation:class",
res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/operation")
.asText());
- assertEquals(
- 131,
+ assertEquals(131,
res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/classOut")
.asInt());
- assertEquals(
- "der",
+ assertEquals("der",
res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/operands/0/wrap/key")
.asText());
}
@@ -1845,17 +1752,15 @@
assertEquals(true, res.at("/query/@type").isMissingNode());
assertEquals(StatusCodes.INCOMPATIBLE_OPERATOR_AND_OPERAND,
res.at("/errors/0/0").asInt());
- assertTrue(res
- .at("/errors/0/1")
- .asText()
- .startsWith(
- "Something went wrong parsing the argument in MORPH()"));
+ assertTrue(res.at("/errors/0/1").asText().startsWith(
+ "Something went wrong parsing the argument in MORPH()"));
query = "MORPH(tt/p=\"foo)";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals(true, res.at("/query/@type").isMissingNode());
- assertEquals(StatusCodes.MALFORMED_QUERY, res.at("/errors/0/0").asInt());
+ assertEquals(StatusCodes.MALFORMED_QUERY,
+ res.at("/errors/0/0").asInt());
assertTrue(res.at("/errors/0/1").asText()
.startsWith("Early closing parenthesis"));
@@ -1863,7 +1768,8 @@
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
assertEquals(true, res.at("/query/@type").isMissingNode());
- assertEquals(StatusCodes.MALFORMED_QUERY, res.at("/errors/0/0").asInt());
+ assertEquals(StatusCodes.MALFORMED_QUERY,
+ res.at("/errors/0/0").asInt());
assertTrue(res.at("/errors/0/1").asText()
.startsWith("Early closing parenthesis"));
}
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/CqlQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/CqlQueryProcessorTest.java
index 5af4b60..3c43112 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/CqlQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/CqlQueryProcessorTest.java
@@ -16,13 +16,15 @@
String VERSION = "1.2";
ObjectMapper mapper = new ObjectMapper();
- private List<Object> getError(CqlQueryProcessor processor) {
+
+ private List<Object> getError (CqlQueryProcessor processor) {
List<Object> errors = (List<Object>) processor.requestMap.get("errors");
return (List<Object>) errors.get(0);
}
+
@Test
- public void testExceptions() throws CQLParseException, IOException {
+ public void testExceptions () throws CQLParseException, IOException {
query = "(Kuh) prox (Germ) ";
CqlQueryProcessor cqlTree = new CqlQueryProcessor(query, VERSION);
List<Object> error = getError(cqlTree);
@@ -53,8 +55,10 @@
error.get(1));
}
+
@Test
- public void testAndQuery() throws CQLParseException, IOException, Exception {
+ public void testAndQuery ()
+ throws CQLParseException, IOException, Exception {
query = "(Sonne) and (scheint)";
String jsonLd = "{@type : koral:group, operation : operation:sequence, inOrder : false,"
+ "distances:[ "
@@ -65,9 +69,10 @@
+ "}]}";
CqlQueryProcessor cqlTree = new CqlQueryProcessor(query, VERSION);
- String serializedQuery = mapper.writeValueAsString(cqlTree
- .getRequestMap().get("query"));
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
+ String serializedQuery = mapper
+ .writeValueAsString(cqlTree.getRequestMap().get("query"));
+ assertEquals(jsonLd.replace(" ", ""),
+ serializedQuery.replace("\"", ""));
// /System.out.println(serializedQuery);
// CosmasTree ct = new CosmasTree("Sonne und scheint");
// serializedQuery =
@@ -76,9 +81,10 @@
// serializedQuery.replace("\"", ""));
}
+
@Test
- public void testBooleanQuery() throws CQLParseException, IOException,
- Exception {
+ public void testBooleanQuery ()
+ throws CQLParseException, IOException, Exception {
query = "((Sonne) or (Mond)) and (scheint)";
String jsonLd = "{@type:koral:group, operation:operation:sequence, inOrder : false, distances:["
+ "{@type:koral:distance, key:s, min:0, max:0}"
@@ -90,9 +96,10 @@
+ "{@type:koral:token, wrap:{@type:koral:term, key:scheint, layer:orth, match:match:eq}}"
+ "]}";
CqlQueryProcessor cqlTree = new CqlQueryProcessor(query, VERSION);
- String serializedQuery = mapper.writeValueAsString(cqlTree
- .getRequestMap().get("query"));
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
+ String serializedQuery = mapper
+ .writeValueAsString(cqlTree.getRequestMap().get("query"));
+ assertEquals(jsonLd.replace(" ", ""),
+ serializedQuery.replace("\"", ""));
query = "(scheint) and ((Sonne) or (Mond))";
jsonLd = "{@type:koral:group, operation:operation:sequence, inOrder : false, distances:["
@@ -104,14 +111,17 @@
+ "{@type:koral:token, wrap:{@type:koral:term, key:Mond, layer:orth, match:match:eq}}"
+ "]}" + "]}";
cqlTree = new CqlQueryProcessor(query, VERSION);
- serializedQuery = mapper.writeValueAsString(cqlTree.getRequestMap()
- .get("query"));
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
+ serializedQuery = mapper
+ .writeValueAsString(cqlTree.getRequestMap().get("query"));
+ assertEquals(jsonLd.replace(" ", ""),
+ serializedQuery.replace("\"", ""));
}
+
@Test
- public void testOrQuery() throws CQLParseException, IOException, Exception {
+ public void testOrQuery ()
+ throws CQLParseException, IOException, Exception {
query = "(Sonne) or (Mond)";
String jsonLd = "{@type:koral:group, operation:operation:or, operands:["
+ "{@type:koral:token, wrap:{@type:koral:term, key:Sonne, layer:orth, match:match:eq}},"
@@ -119,9 +129,10 @@
+ "]}";
CqlQueryProcessor cqlTree = new CqlQueryProcessor(query, VERSION);
- String serializedQuery = mapper.writeValueAsString(cqlTree
- .getRequestMap().get("query"));
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
+ String serializedQuery = mapper
+ .writeValueAsString(cqlTree.getRequestMap().get("query"));
+ assertEquals(jsonLd.replace(" ", ""),
+ serializedQuery.replace("\"", ""));
query = "(\"Sonne scheint\") or (Mond)";
jsonLd = "{@type:koral:group, operation:operation:or, operands:["
@@ -133,9 +144,10 @@
+ "]}";
cqlTree = new CqlQueryProcessor(query, VERSION);
- serializedQuery = mapper.writeValueAsString(cqlTree.getRequestMap()
- .get("query"));
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
+ serializedQuery = mapper
+ .writeValueAsString(cqlTree.getRequestMap().get("query"));
+ assertEquals(jsonLd.replace(" ", ""),
+ serializedQuery.replace("\"", ""));
query = "(\"Sonne scheint\") or (\"Mond scheint\")";
jsonLd = "{@type:koral:group, operation:operation:or, operands:["
@@ -148,25 +160,29 @@
+ "{@type:koral:token, wrap:{@type:koral:term, key:scheint, layer:orth, match:match:eq}}"
+ "]}" + "]}";
cqlTree = new CqlQueryProcessor(query, VERSION);
- serializedQuery = mapper.writeValueAsString(cqlTree.getRequestMap()
- .get("query"));
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
+ serializedQuery = mapper
+ .writeValueAsString(cqlTree.getRequestMap().get("query"));
+ assertEquals(jsonLd.replace(" ", ""),
+ serializedQuery.replace("\"", ""));
}
+
@Test
- public void testTermQuery() throws CQLParseException, IOException,
- Exception {
+ public void testTermQuery ()
+ throws CQLParseException, IOException, Exception {
query = "Sonne";
String jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:Sonne, layer:orth, match:match:eq}}";
CqlQueryProcessor cqlTree = new CqlQueryProcessor(query, VERSION);
- String serializedQuery = mapper.writeValueAsString(cqlTree
- .getRequestMap().get("query"));
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
+ String serializedQuery = mapper
+ .writeValueAsString(cqlTree.getRequestMap().get("query"));
+ assertEquals(jsonLd.replace(" ", ""),
+ serializedQuery.replace("\"", ""));
}
+
@Test
- public void testPhraseQuery() throws CQLParseException, IOException,
- Exception {
+ public void testPhraseQuery ()
+ throws CQLParseException, IOException, Exception {
query = "\"der Mann\"";
String jsonLd = "{@type:koral:group, operation:operation:sequence, operands:["
+ "{@type:koral:token, wrap:{@type:koral:term, key:der, layer:orth, match:match:eq}},"
@@ -174,9 +190,10 @@
+ "]}";
CqlQueryProcessor cqlTree = new CqlQueryProcessor(query, VERSION);
- String serializedQuery = mapper.writeValueAsString(cqlTree
- .getRequestMap().get("query"));
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
+ String serializedQuery = mapper
+ .writeValueAsString(cqlTree.getRequestMap().get("query"));
+ assertEquals(jsonLd.replace(" ", ""),
+ serializedQuery.replace("\"", ""));
query = "der Mann schläft";
jsonLd = "{@type:koral:group, operation:operation:sequence, operands:["
@@ -186,8 +203,9 @@
+ "]}";
cqlTree = new CqlQueryProcessor(query, VERSION);
- serializedQuery = mapper.writeValueAsString(cqlTree.getRequestMap()
- .get("query"));
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
+ serializedQuery = mapper
+ .writeValueAsString(cqlTree.getRequestMap().get("query"));
+ assertEquals(jsonLd.replace(" ", ""),
+ serializedQuery.replace("\"", ""));
}
}
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLComplexTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLComplexTest.java
index 990f611..7f937f3 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLComplexTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLComplexTest.java
@@ -19,6 +19,7 @@
String jsonLd;
List<Object> error;
+
// -------------------------------------------------------------------------
// simple-query ::= '(' main_query ')' /* grouping */
// | implicit-query
@@ -29,10 +30,9 @@
// -------------------------------------------------------------------------
// simple-query ::= '(' main_query ')' /* grouping */
@Test
- public void testGroupQuery() throws IOException {
+ public void testGroupQuery () throws IOException {
query = "(\"blaue\"|\"grüne\")";
- jsonLd = "{@type:koral:group,"
- + "operation:operation:disjunction,"
+ jsonLd = "{@type:koral:group," + "operation:operation:disjunction,"
+ "operands:["
+ "{@type:koral:token, wrap:{@type:koral:term,key:blaue,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}},"
+ "{@type:koral:token, wrap:{@type:koral:term,key:grüne,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}]}";;
@@ -41,13 +41,12 @@
// group and disjunction
query = "([pos=\"NN\"]|[cnx:pos=\"N\"]|[text=\"Mann\"])";
jsonLd = "{@type:koral:token,wrap:{@type:koral:term,key:N,foundry:cnx,layer:p,type:type:regex,match:match:eq}}";
- FCSQLQueryProcessorTest
- .validateNode(query, "/query/operands/1", jsonLd);
+ FCSQLQueryProcessorTest.validateNode(query, "/query/operands/1",
+ jsonLd);
// a group contains a sequence
query = "([text=\"blaue\"][pos=\"NN\"])";
- jsonLd = "{@type:koral:group,"
- + "operation:operation:sequence,"
+ jsonLd = "{@type:koral:group," + "operation:operation:sequence,"
+ "operands:["
+ "{@type:koral:token,wrap:{@type:koral:term,key:blaue,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}},"
+ "{@type:koral:token,wrap:{@type:koral:term,key:NN,foundry:tt,layer:p,type:type:regex,match:match:eq}}"
@@ -62,12 +61,12 @@
// | simple-query quantifier /* quatification */
// -------------------------------------------------------------------------
+
// | simple-query "|" main-query /* or */
@Test
- public void testOrQuery() throws IOException {
+ public void testOrQuery () throws IOException {
query = "\"man\"|\"Mann\"";
- jsonLd = "{@type:koral:group,"
- + "operation:operation:disjunction,"
+ jsonLd = "{@type:koral:group," + "operation:operation:disjunction,"
+ "operands:["
+ "{@type:koral:token,wrap:{@type:koral:term,key:man,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}},"
+ "{@type:koral:token,wrap:{@type:koral:term,key:Mann,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}]}";
@@ -75,25 +74,24 @@
query = "[pos=\"NN\"]|\"Mann\"";
jsonLd = "{@type:koral:token,wrap:{@type:koral:term,key:NN,foundry:tt,layer:p,type:type:regex,match:match:eq}}";
- FCSQLQueryProcessorTest
- .validateNode(query, "/query/operands/0", jsonLd);
+ FCSQLQueryProcessorTest.validateNode(query, "/query/operands/0",
+ jsonLd);
// group with two segment queries
query = "[pos=\"NN\"]|[text=\"Mann\"]";
- jsonLd = "{@type:koral:group,"
- + "operation:operation:disjunction,"
+ jsonLd = "{@type:koral:group," + "operation:operation:disjunction,"
+ "operands:["
+ "{@type:koral:token, wrap:{@type:koral:term,key:NN,foundry:tt,layer:p,type:type:regex,match:match:eq}},"
+ "{@type:koral:token, wrap:{@type:koral:term,key:Mann,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}]}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
}
+
// | simple-query main-query /* sequence */
@Test
- public void testSequenceQuery() throws IOException {
+ public void testSequenceQuery () throws IOException {
query = "\"blaue|grüne\" [pos = \"NN\"]";
- jsonLd = "{@type:koral:group, "
- + "operation:operation:sequence, "
+ jsonLd = "{@type:koral:group, " + "operation:operation:sequence, "
+ "operands:["
+ "{@type:koral:token, wrap:{@type:koral:term, key:blaue|grüne, foundry:opennlp, layer:orth, type:type:regex, match:match:eq}},"
+ "{@type:koral:token, wrap:{@type:koral:term, key:NN, foundry:tt, layer:p, type:type:regex, match:match:eq}}"
@@ -105,15 +103,13 @@
query = "\"blaue\" \"grüne\" [pos = \"NN\"]";
jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:grüne, foundry:opennlp, layer:orth, type:type:regex, match:match:eq}}";
- FCSQLQueryProcessorTest
- .validateNode(query, "/query/operands/1", jsonLd);
+ FCSQLQueryProcessorTest.validateNode(query, "/query/operands/1",
+ jsonLd);
// sequence and disjunction
query = "([pos=\"NN\"]|[cnx:pos=\"N\"])[text=\"Mann\"]";
- jsonLd = "{@type:koral:group,"
- + "operation:operation:sequence,"
- + "operands:["
- + "{@type:koral:group,"
+ jsonLd = "{@type:koral:group," + "operation:operation:sequence,"
+ + "operands:[" + "{@type:koral:group,"
+ "operation:operation:disjunction,"
+ "operands:[{@type:koral:token,wrap:{@type:koral:term,key:NN,foundry:tt,layer:p,type:type:regex,match:match:eq}},"
+ "{@type:koral:token,wrap:{@type:koral:term,key:N,foundry:cnx,layer:p,type:type:regex,match:match:eq}}"
@@ -121,49 +117,49 @@
+ "{@type:koral:token,wrap:{@type:koral:term,key:Mann,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}"
+ "]}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
-
+
query = "[text=\"Mann\"]([pos=\"NN\"]|[cnx:pos=\"N\"])";
- jsonLd = "{@type:koral:group,"
- + "operation:operation:disjunction,"
+ jsonLd = "{@type:koral:group," + "operation:operation:disjunction,"
+ "operands:[{@type:koral:token,wrap:{@type:koral:term,key:NN,foundry:tt,layer:p,type:type:regex,match:match:eq}},"
+ "{@type:koral:token,wrap:{@type:koral:term,key:N,foundry:cnx,layer:p,type:type:regex,match:match:eq}}"
+ "]}";
- FCSQLQueryProcessorTest.validateNode(query, "/query/operands/1", jsonLd);
+ FCSQLQueryProcessorTest.validateNode(query, "/query/operands/1",
+ jsonLd);
}
+
@Test
- public void testSequenceOfQueryGroups() throws IOException {
+ public void testSequenceOfQueryGroups () throws IOException {
query = "(\"blaue\"|\"grüne\")([pos=\"NN\"]|[cnx:pos=\"N\"])";
FCSQLQueryProcessorTest.validateNode(query, "/query/@type",
"koral:group");
FCSQLQueryProcessorTest.validateNode(query, "/query/operation",
"operation:sequence");
- jsonLd = "{@type:koral:group,"
- + "operation:operation:disjunction,"
+ jsonLd = "{@type:koral:group," + "operation:operation:disjunction,"
+ "operands:["
+ "{@type:koral:token,wrap:{@type:koral:term,key:blaue,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}},"
+ "{@type:koral:token,wrap:{@type:koral:term,key:grüne,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}"
+ "]}";
- FCSQLQueryProcessorTest
- .validateNode(query, "/query/operands/0", jsonLd);
+ FCSQLQueryProcessorTest.validateNode(query, "/query/operands/0",
+ jsonLd);
jsonLd = "{@type:koral:group,operation:operation:disjunction,"
+ "operands:["
+ "{@type:koral:token,wrap:{@type:koral:term,key:NN,foundry:tt,layer:p,type:type:regex,match:match:eq}},"
+ "{@type:koral:token,wrap:{@type:koral:term,key:N,foundry:cnx,layer:p,type:type:regex,match:match:eq}}"
+ "]}";
- FCSQLQueryProcessorTest
- .validateNode(query, "/query/operands/1", jsonLd);
+ FCSQLQueryProcessorTest.validateNode(query, "/query/operands/1",
+ jsonLd);
}
+
// | simple-query quantifier /* quatification */
@Test
- public void testSimpleQueryWithQuantifier() throws IOException {
+ public void testSimpleQueryWithQuantifier () throws IOException {
// repetition
query = "\"die\"{2}";
- jsonLd = "{@type:koral:group,"
- + "operation:operation:repetition,"
+ jsonLd = "{@type:koral:group," + "operation:operation:repetition,"
+ "operands:["
+ "{@type:koral:token,wrap:{@type:koral:term,key:die,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}],"
+ "boundary:{@type:koral:boundary,min:2,max:2}}";
@@ -199,40 +195,35 @@
// segment query with quantifier
query = "[cnx:pos=\"A\"]*";
- jsonLd = "{@type:koral:group,"
- + "operation:operation:repetition,"
+ jsonLd = "{@type:koral:group," + "operation:operation:repetition,"
+ "operands:[{@type:koral:token,wrap:{@type:koral:term,key:A,foundry:cnx,layer:p,type:type:regex,match:match:eq}}],"
+ "boundary:{@type:koral:boundary,min:0}}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
}
+
@Test
- public void testGroupQueryWithQuantifier() throws JsonProcessingException {
+ public void testGroupQueryWithQuantifier () throws JsonProcessingException {
// group with quantifier
query = "(\"blaue\"|\"grüne\")*";
- jsonLd = "{@type:koral:group,"
- + "operation:operation:repetition,"
- + "operands:["
- + "{@type:koral:group,"
- + "operation:operation:disjunction,"
- + "operands:["
+ jsonLd = "{@type:koral:group," + "operation:operation:repetition,"
+ + "operands:[" + "{@type:koral:group,"
+ + "operation:operation:disjunction," + "operands:["
+ "{@type:koral:token, wrap:{@type:koral:term,key:blaue,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}},"
+ "{@type:koral:token, wrap:{@type:koral:term,key:grüne,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}"
+ "]}]," + "boundary:{@type:koral:boundary,min:0}}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
}
+
// wildcards
@Test
- public void testQueryWithEmptyToken() throws IOException {
+ public void testQueryWithEmptyToken () throws IOException {
// expansion query
query = "[]{2}\"Hund\"";
- jsonLd = "{@type:koral:group, "
- + "operation:operation:sequence, "
- + "operands:["
- + "{@type:koral:group,"
- + "operation:operation:repetition,"
- + "operands:["
+ jsonLd = "{@type:koral:group, " + "operation:operation:sequence, "
+ + "operands:[" + "{@type:koral:group,"
+ + "operation:operation:repetition," + "operands:["
+ "{@type:koral:token}],"
+ "boundary:{@type:koral:boundary,min:2,max:2}},"
+ "{@type:koral:token, "
@@ -244,8 +235,8 @@
jsonLd = "{@type:koral:group," + "operation:operation:repetition,"
+ "operands:[{@type:koral:token}],"
+ "boundary:{@type:koral:boundary,min:2,max:2}}";
- FCSQLQueryProcessorTest
- .validateNode(query, "/query/operands/1", jsonLd);
+ FCSQLQueryProcessorTest.validateNode(query, "/query/operands/1",
+ jsonLd);
// arbitrary tokens
query = "[]{2}";
@@ -262,22 +253,23 @@
FCSQLQueryProcessorTest.validateNode(query, "/query/operands", jsonLd);
}
+
@Test
- public void testDistanceQuery() throws IOException {
+ public void testDistanceQuery () throws IOException {
// distance query
query = "\"Katze\" [] \"Hund\"";
jsonLd = "{@type:koral:group,operation:operation:sequence,inOrder:true,"
+ "distances:["
+ "{@type:koral:distance,key:w,boundary:{@type:koral:boundary,min:1,max:1}}"
- + "],"
- + "operands:["
+ + "]," + "operands:["
+ "{@type:koral:token,wrap:{@type:koral:term,key:Katze,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}},"
+ "{@type:koral:token,wrap:{@type:koral:term,key:Hund,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}]}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
}
+
@Test
- public void testDistanceQueryWithQuantifier() throws IOException {
+ public void testDistanceQueryWithQuantifier () throws IOException {
query = "\"Katze\" []* \"Hund\"";
jsonLd = "{@type:koral:distance,key:w,boundary:{@type:koral:boundary,min:0}}";
FCSQLQueryProcessorTest.validateNode(query, "/query/distances/0",
@@ -299,8 +291,9 @@
jsonLd);
}
+
@Test
- public void testDistanceQueryWithMultipleWildcards() throws IOException {
+ public void testDistanceQueryWithMultipleWildcards () throws IOException {
// sequences of wildcards
query = "\"Katze\" []{3}[] \"Hund\"";
jsonLd = "{@type:koral:distance,key:w,boundary:{@type:koral:boundary,min:4,max:4}}";
@@ -319,27 +312,22 @@
// multiple occurrences of wildcards
query = "\"Katze\" []{3} \"Hund\" []{1,2} [cnx:pos=\"V\"]";
- jsonLd = "{@type:koral:group,"
- + "operation:operation:sequence,"
- + "inOrder:true,"
- + "distances:["
+ jsonLd = "{@type:koral:group," + "operation:operation:sequence,"
+ + "inOrder:true," + "distances:["
+ "{@type:koral:distance,key:w,boundary:{@type:koral:boundary,min:3,max:3}}"
- + "],"
- + "operands:["
+ + "]," + "operands:["
+ "{@type:koral:token,wrap:{@type:koral:term,key:Katze,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}},"
- + "{@type:koral:group,"
- + "operation:operation:sequence,"
- + "inOrder:true,"
- + "distances:["
+ + "{@type:koral:group," + "operation:operation:sequence,"
+ + "inOrder:true," + "distances:["
+ "{@type:koral:distance,key:w,boundary:{@type:koral:boundary,min:1,max:2}}"
- + "],"
- + "operands:["
+ + "]," + "operands:["
+ "{@type:koral:token,wrap:{@type:koral:term,key:Hund,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}},"
+ "{@type:koral:token,wrap:{@type:koral:term,key:V,foundry:cnx,layer:p,type:type:regex,match:match:eq}}]}"
+ "]}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
}
+
// -------------------------------------------------------------------------
// query ::= main-query within-part?
// -------------------------------------------------------------------------
@@ -347,19 +335,17 @@
// simple-within-part ::= "within" simple-within-scope
@Test
- public void testWithinQuery() throws IOException {
+ public void testWithinQuery () throws IOException {
query = "'grün' within s";
- jsonLd = "{@type:koral:group,"
- + "operation:operation:position,"
+ jsonLd = "{@type:koral:group," + "operation:operation:position,"
+ "operands:["
+ "{@type:koral:span,wrap:{@type:koral:term,key:s,foundry:base,layer:s}},"
+ "{@type:koral:token,wrap:{@type:koral:term,key:grün,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}"
+ "]}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
-
+
query = "[cnx:pos=\"VVFIN\"] within s";
- jsonLd = "{@type:koral:group,"
- + "operation:operation:position,"
+ jsonLd = "{@type:koral:group," + "operation:operation:position,"
+ "operands:["
+ "{@type:koral:span,wrap:{@type:koral:term,key:s,foundry:base,layer:s}},"
+ "{@type:koral:token,wrap:{@type:koral:term,key:VVFIN,foundry:cnx,layer:p,type:type:regex,match:match:eq}}"
@@ -371,28 +357,27 @@
query = "[cnx:pos=\"VVFIN\"] within p";
jsonLd = "{@type:koral:span,wrap:{@type:koral:term,key:p,foundry:base,layer:s}}";
- FCSQLQueryProcessorTest
- .validateNode(query, "/query/operands/0", jsonLd);
+ FCSQLQueryProcessorTest.validateNode(query, "/query/operands/0",
+ jsonLd);
query = "[cnx:pos=\"VVFIN\"] within text";
jsonLd = "{@type:koral:span,wrap:{@type:koral:term,key:t,foundry:base,layer:s}}";
- FCSQLQueryProcessorTest
- .validateNode(query, "/query/operands/0", jsonLd);
+ FCSQLQueryProcessorTest.validateNode(query, "/query/operands/0",
+ jsonLd);
query = "[cnx:pos=\"VVFIN\"] within u";
- error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query,
- "2.0"));
+ error = FCSQLQueryProcessorTest
+ .getError(new FCSQLQueryProcessor(query, "2.0"));
assertEquals(311, error.get(0));
- assertEquals(
- "Within scope UTTERANCE is currently unsupported.",
+ assertEquals("Within scope UTTERANCE is currently unsupported.",
(String) error.get(1));
}
+
@Test
- public void testWithinQueryWithEmptyTokens() throws IOException {
+ public void testWithinQueryWithEmptyTokens () throws IOException {
query = "[] within s";
- jsonLd = "{@type:koral:group,"
- + "operation:operation:position,"
+ jsonLd = "{@type:koral:group," + "operation:operation:position,"
+ "operands:["
+ "{@type:koral:span,wrap:{@type:koral:term,key:s,foundry:base,layer:s}},"
+ "{@type:koral:token}" + "]}";
@@ -402,55 +387,54 @@
jsonLd = "{@type:koral:group," + "operation:operation:repetition,"
+ "operands:[{@type:koral:token}],"
+ "boundary:{@type:koral:boundary,min:1}}";
- FCSQLQueryProcessorTest
- .validateNode(query, "/query/operands/1", jsonLd);
+ FCSQLQueryProcessorTest.validateNode(query, "/query/operands/1",
+ jsonLd);
}
+
@Test
- public void testWithinQueryWithGroupQuery() throws IOException {
+ public void testWithinQueryWithGroupQuery () throws IOException {
query = "(\"blaue\"|\"grüne\")+ within s";
jsonLd = "{@type:koral:span,wrap:{@type:koral:term,key:s,foundry:base,layer:s}}";
- FCSQLQueryProcessorTest
- .validateNode(query, "/query/operands/0", jsonLd);
- jsonLd = "{@type:koral:group,"
- + "operation:operation:repetition,"
- + "operands:["
- + "{@type:koral:group,"
- + "operation:operation:disjunction,"
- + "operands:["
+ FCSQLQueryProcessorTest.validateNode(query, "/query/operands/0",
+ jsonLd);
+ jsonLd = "{@type:koral:group," + "operation:operation:repetition,"
+ + "operands:[" + "{@type:koral:group,"
+ + "operation:operation:disjunction," + "operands:["
+ "{@type:koral:token, wrap:{@type:koral:term,key:blaue,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}},"
+ "{@type:koral:token, wrap:{@type:koral:term,key:grüne,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}"
+ "]}]," + "boundary:{@type:koral:boundary,min:1}}";
- FCSQLQueryProcessorTest
- .validateNode(query, "/query/operands/1", jsonLd);
+ FCSQLQueryProcessorTest.validateNode(query, "/query/operands/1",
+ jsonLd);
}
+
@Test
- public void testWrongQuery() throws IOException {
-
+ public void testWrongQuery () throws IOException {
+
String errorMessage = "Query cannot be parsed, an unexpcected occured exception while parsing";
-
+
// expression should always be within a segment
query = "!(mate:lemma=\"sein\" | mate:pos=\"PPOSS\")";
- error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query,
- "2.0"));
+ error = FCSQLQueryProcessorTest
+ .getError(new FCSQLQueryProcessor(query, "2.0"));
assertEquals(399, error.get(0));
assertEquals(errorMessage, error.get(1).toString());
query = "![mate:lemma=\"sein\" | mate:pos=\"PPOSS\"]";
- error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query,
- "2.0"));
+ error = FCSQLQueryProcessorTest
+ .getError(new FCSQLQueryProcessor(query, "2.0"));
assertEquals(errorMessage, error.get(1).toString());
query = "(\"blaue\"&\"grüne\")";
- error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query,
- "2.0"));
+ error = FCSQLQueryProcessorTest
+ .getError(new FCSQLQueryProcessor(query, "2.0"));
assertEquals(errorMessage, error.get(1).toString());
query = "[pos=\"NN\"]&[text=\"Mann\"]";
- error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query,
- "2.0"));
+ error = FCSQLQueryProcessorTest
+ .getError(new FCSQLQueryProcessor(query, "2.0"));
assertEquals(399, error.get(0));
assertEquals(errorMessage, error.get(1).toString());
}
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessorTest.java
index 8fa70df..576cdb2 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessorTest.java
@@ -24,51 +24,57 @@
String jsonLd;
List<Object> error;
- public static void runAndValidate(String query, String jsonLd)
+
+ public static void runAndValidate (String query, String jsonLd)
throws JsonProcessingException {
FCSQLQueryProcessor processor = new FCSQLQueryProcessor(query, "2.0");
- String serializedQuery = mapper.writeValueAsString(processor
- .getRequestMap().get("query"));
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
+ String serializedQuery = mapper
+ .writeValueAsString(processor.getRequestMap().get("query"));
+ assertEquals(jsonLd.replace(" ", ""),
+ serializedQuery.replace("\"", ""));
}
- public static void validateNode(String query, String path, String jsonLd)
+
+ public static void validateNode (String query, String path, String jsonLd)
throws JsonProcessingException, IOException {
qs.setQuery(query, "fcsql", "2.0");
node = mapper.readTree(qs.toJSON());
String serializedQuery = mapper.writeValueAsString(node.at(path));
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
+ assertEquals(jsonLd.replace(" ", ""),
+ serializedQuery.replace("\"", ""));
}
- public static List<Object> getError(FCSQLQueryProcessor processor) {
+
+ public static List<Object> getError (FCSQLQueryProcessor processor) {
List<Object> errors = (List<Object>) processor.requestMap.get("errors");
return (List<Object>) errors.get(0);
}
+
@Test
- public void testVersion() throws JsonProcessingException {
+ public void testVersion () throws JsonProcessingException {
error = getError(new FCSQLQueryProcessor("\"Sonne\"", "1.0"));
assertEquals(310, error.get(0));
- assertEquals("Only supports SRU version 2.0.",
- error.get(1));
+ assertEquals("Only supports SRU version 2.0.", error.get(1));
error = getError(new FCSQLQueryProcessor("\"Sonne\"", null));
assertEquals(309, error.get(0));
- assertEquals("Version number is missing.",
- error.get(1));
+ assertEquals("Version number is missing.", error.get(1));
}
+
// regexp ::= quoted-string
@Test
- public void testTermQuery() throws JsonProcessingException {
+ public void testTermQuery () throws JsonProcessingException {
query = "\"Sonne\"";
jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:Sonne, "
+ "foundry:opennlp, layer:orth, type:type:regex, match:match:eq}}";
runAndValidate(query, jsonLd);
}
+
@Test
- public void testRegex() throws JsonProcessingException {
+ public void testRegex () throws JsonProcessingException {
query = "[text=\"M(a|ä)nn(er)?\"]";
jsonLd = "{@type:koral:token,wrap:{@type:koral:term,"
+ "key:M(a|ä)nn(er)?,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}";
@@ -93,10 +99,11 @@
// query = "\"a\\.\"";
}
+
// flagged-regexp ::= regexp
// | regexp "/" regexp-flag+
@Test
- public void testTermQueryWithRegexFlag() throws IOException {
+ public void testTermQueryWithRegexFlag () throws IOException {
query = "\"Fliegen\" /c";
jsonLd = "{@type:koral:token, wrap:{@type:koral:term, caseInsensitive:true, "
+ "key:Fliegen, foundry:opennlp, layer:orth, type:type:regex, match:match:eq}}";
@@ -113,25 +120,25 @@
FCSQLQueryProcessorTest.validateNode(query, "/query/wrap", jsonLd);
query = "\"Fliegen\" /l";
- error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query,
- "2.0"));
+ error = FCSQLQueryProcessorTest
+ .getError(new FCSQLQueryProcessor(query, "2.0"));
assertEquals(306, error.get(0));
String msg = (String) error.get(1);
assertEquals(true, msg.startsWith("Regexflags"));
query = "\"Fliegen\" /d";
- error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query,
- "2.0"));
+ error = FCSQLQueryProcessorTest
+ .getError(new FCSQLQueryProcessor(query, "2.0"));
assertEquals(306, error.get(0));
- assertEquals(
- "Regexflag: IGNORE_DIACRITICS is unsupported.",
+ assertEquals("Regexflag: IGNORE_DIACRITICS is unsupported.",
(String) error.get(1));
}
+
// operator ::= "=" /* equals */
// | "!=" /* non-equals */
@Test
- public void testOperator() throws IOException {
+ public void testOperator () throws IOException {
query = "[cnx:pos != \"N\"]";
jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:N, "
+ "foundry:cnx, layer:p, type:type:regex, match:match:ne}}";
@@ -143,9 +150,11 @@
// attribute ::= simple-attribute | qualified-attribute
// -------------------------------------------------------------------------
+
// simple-attribute ::= identifier
@Test
- public void testTermQueryWithSpecificLayer() throws JsonProcessingException {
+ public void testTermQueryWithSpecificLayer ()
+ throws JsonProcessingException {
query = "[text = \"Sonne\"]";
jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:Sonne, "
+ "foundry:opennlp, layer:orth, type:type:regex, match:match:eq}}";
@@ -162,9 +171,10 @@
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
}
+
// qualified-attribute ::= identifier ":" identifier
@Test
- public void testTermQueryWithQualifier() throws JsonProcessingException {
+ public void testTermQueryWithQualifier () throws JsonProcessingException {
query = "[mate:lemma = \"sein\"]";
jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:sein, "
+ "foundry:mate, layer:l, type:type:regex, match:match:eq}}";
@@ -183,14 +193,13 @@
// | expression "&" expression /* and */
// -------------------------------------------------------------------------
+
// | expression "|" expression /* or */
@Test
- public void testExpressionOr() throws IOException {
+ public void testExpressionOr () throws IOException {
query = "[mate:lemma=\"sein\" | mate:pos=\"PPOSS\"]";
- jsonLd = "{@type: koral:token,"
- + " wrap: { @type: koral:termGroup,"
- + "relation: relation:or,"
- + " operands:["
+ jsonLd = "{@type: koral:token," + " wrap: { @type: koral:termGroup,"
+ + "relation: relation:or," + " operands:["
+ "{@type: koral:term, key: sein, foundry: mate, layer: l, type:type:regex, match: match:eq},"
+ "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:eq}]}}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
@@ -201,14 +210,13 @@
jsonLd);
}
+
// | expression "&" expression /* and */
@Test
- public void testExpressionAnd() throws IOException {
+ public void testExpressionAnd () throws IOException {
query = "[mate:lemma=\"sein\" & mate:pos=\"PPOSS\"]";
- jsonLd = "{@type: koral:token,"
- + " wrap: { @type: koral:termGroup,"
- + "relation: relation:and,"
- + " operands:["
+ jsonLd = "{@type: koral:token," + " wrap: { @type: koral:termGroup,"
+ + "relation: relation:and," + " operands:["
+ "{@type: koral:term, key: sein, foundry: mate, layer: l, type:type:regex, match: match:eq},"
+ "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:eq}]}}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
@@ -220,25 +228,24 @@
// | attribute operator flagged-regexp
// -------------------------------------------------------------------------
+
// basic-expression ::= '(' expression ')' /* grouping */
@Test
- public void testExpressionGroup() throws JsonProcessingException {
+ public void testExpressionGroup () throws JsonProcessingException {
query = "[(text=\"blau\"|pos=\"ADJ\")]";
- jsonLd = "{@type: koral:token,"
- + "wrap: {@type: koral:termGroup,"
- + "relation: relation:or,"
- + "operands: ["
+ jsonLd = "{@type: koral:token," + "wrap: {@type: koral:termGroup,"
+ + "relation: relation:or," + "operands: ["
+ "{@type: koral:term, key: blau, foundry: opennlp, layer: orth, type:type:regex,match: match:eq},"
+ "{@type: koral:term, key: ADJ, foundry: tt, layer: p, type:type:regex, match: match:eq}]}}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
}
+
@Test
- public void testMultipleBooleanExpressions() throws IOException {
+ public void testMultipleBooleanExpressions () throws IOException {
query = "[mate:lemma=\"sein\" & (mate:pos=\"PPOSS\"|mate:pos=\"VAFIN\")]";
- jsonLd = "{@type: koral:termGroup,"
- + "relation: relation:or,"
+ jsonLd = "{@type: koral:termGroup," + "relation: relation:or,"
+ " operands:["
+ "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:eq},"
+ "{@type: koral:term, key: VAFIN, foundry: mate, layer: p, type:type:regex, match: match:eq}]}";
@@ -246,25 +253,25 @@
jsonLd);
FCSQLQueryProcessorTest.validateNode(query, "/query/wrap/relation",
"relation:and");
-
+
query = "[(cnx:lemma=\"sein\" | mate:pos=\"PPOSS\") | mate:pos=\"VAFIN\"]";
- jsonLd = "{@type: koral:termGroup,"
- + "relation: relation:or,"
+ jsonLd = "{@type: koral:termGroup," + "relation: relation:or,"
+ " operands:["
+ "{@type: koral:term, key: sein, foundry: cnx, layer: l, type:type:regex, match: match:eq},"
+ "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:eq}]}";
FCSQLQueryProcessorTest.validateNode(query, "/query/wrap/operands/0",
jsonLd);
-
+
query = "[(cnx:lemma=\"sein\" | mate:pos=\"PPOSS\") & text=\"ist\"]";
jsonLd = "{@type: koral:term, key: ist, foundry: opennlp, layer: orth, type:type:regex, match: match:eq}";
FCSQLQueryProcessorTest.validateNode(query, "/query/wrap/operands/1",
jsonLd);
}
+
// "!" expression /* not */
@Test
- public void testExpressionNot() throws IOException {
+ public void testExpressionNot () throws IOException {
jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:NN, "
+ "foundry:tt, layer:p, type:type:regex, match:match:eq}}";
query = "[!pos != \"NN\"]";
@@ -275,28 +282,25 @@
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
query = "[mate:lemma=\"sein\" & !mate:pos=\"PPOSS\"]";
- jsonLd = "{@type: koral:token,"
- + " wrap: { "
- + "@type: koral:termGroup,"
- + "relation: relation:and,"
+ jsonLd = "{@type: koral:token," + " wrap: { "
+ + "@type: koral:termGroup," + "relation: relation:and,"
+ " operands:["
+ "{@type: koral:term, key: sein, foundry: mate, layer: l, type:type:regex, match: match:eq},"
+ "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:ne}]}}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
}
-
+
+
@Test
- public void testNotExpressionGroup() throws JsonProcessingException {
+ public void testNotExpressionGroup () throws JsonProcessingException {
query = "[!(mate:lemma=\"sein\" & mate:pos=\"PPOSS\")]";
- jsonLd = "{@type: koral:token,"
- + " wrap: { "
- + "@type: koral:termGroup,"
- + "relation: relation:or,"
+ jsonLd = "{@type: koral:token," + " wrap: { "
+ + "@type: koral:termGroup," + "relation: relation:or,"
+ " operands:["
+ "{@type: koral:term, key: sein, foundry: mate, layer: l, type:type:regex, match: match:ne},"
+ "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:ne}]}}";
//FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
-
+
error = getError(new FCSQLQueryProcessor(query, "2.0"));
assertEquals(399, error.get(0));
assertEquals(
@@ -304,41 +308,37 @@
error.get(1));
}
+
@Test
- public void testExceptions() throws JsonProcessingException {
+ public void testExceptions () throws JsonProcessingException {
// unsupported lemma und qualifier
query = "[opennlp:lemma = \"sein\"]";
error = getError(new FCSQLQueryProcessor(query, "2.0"));
assertEquals(306, error.get(0));
- assertEquals(
- "Layer lemma with qualifier opennlp is unsupported.",
+ assertEquals("Layer lemma with qualifier opennlp is unsupported.",
error.get(1));
query = "[tt:morph = \"sein\"]";
error = getError(new FCSQLQueryProcessor(query, "2.0"));
assertEquals(306, error.get(0));
- assertEquals("Layer morph is unsupported.",
- error.get(1));
+ assertEquals("Layer morph is unsupported.", error.get(1));
// unsupported qualifier
query = "[malt:lemma = \"sein\"]";
error = getError(new FCSQLQueryProcessor(query, "2.0"));
assertEquals(306, error.get(0));
- assertEquals("Qualifier malt is unsupported.",
- error.get(1));
+ assertEquals("Qualifier malt is unsupported.", error.get(1));
// unsupported layer
query = "[cnx:morph = \"heit\"]";
error = getError(new FCSQLQueryProcessor(query, "2.0"));
assertEquals(306, error.get(0));
- assertEquals("Layer morph is unsupported.",
- error.get(1));
+ assertEquals("Layer morph is unsupported.", error.get(1));
// missing layer
query = "[cnx=\"V\"]";
error = getError(new FCSQLQueryProcessor(query, "2.0"));
assertEquals(306, error.get(0));
- assertEquals("Layer cnx is unsupported.",
- error.get(1));
+ assertEquals("Layer cnx is unsupported.", error.get(1));
}
}