Cqlf => Koral
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 52c5c78..34e8aac 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
@@ -23,7 +23,7 @@
import de.ids_mannheim.korap.query.parse.annis.AqlLexer;
import de.ids_mannheim.korap.query.parse.annis.AqlParser;
import de.ids_mannheim.korap.query.serialize.util.Antlr4DescriptiveErrorListener;
-import de.ids_mannheim.korap.query.serialize.util.CqlfObjectGenerator;
+import de.ids_mannheim.korap.query.serialize.util.KoralObjectGenerator;
/**
* Map representation of ANNIS QL syntax tree as returned by ANTLR
@@ -88,7 +88,7 @@
private LinkedHashMap<String, Integer> nodeReferencesProcessed = new LinkedHashMap<String, Integer>();
public AnnisQueryProcessor(String query) {
- CqlfObjectGenerator.setQueryProcessor(this);
+ KoralObjectGenerator.setQueryProcessor(this);
process(query);
}
@@ -119,6 +119,7 @@
if (verbose) {
System.err.println(" "+objectStack);
+ System.err.println(" "+operandStack);
System.out.println(openNodeCats);
}
@@ -224,7 +225,7 @@
private void processExprTop(ParseTree node) {
List<ParseTree> andTopExprs = getChildrenWithCat(node, "andTopExpr");
if (andTopExprs.size() > 1) {
- LinkedHashMap<String, Object> topOr = CqlfObjectGenerator.makeGroup("or");
+ LinkedHashMap<String, Object> topOr = KoralObjectGenerator.makeGroup("or");
requestMap.put("query", topOr);
objectStack.push(topOr);
}
@@ -235,11 +236,11 @@
String firstChildNodeCat = getNodeCat(node.getChild(0));
LinkedHashMap<String, Object> object = null;
if (firstChildNodeCat.equals("node")) {
- object = CqlfObjectGenerator.makeSpan();
+ object = KoralObjectGenerator.makeSpan();
} else if (firstChildNodeCat.equals("tok")) {
- object = CqlfObjectGenerator.makeToken();
+ object = KoralObjectGenerator.makeToken();
if (node.getChildCount() > 1) { // empty tokens do not wrap a term
- LinkedHashMap<String, Object> term = CqlfObjectGenerator.makeTerm();
+ LinkedHashMap<String, Object> term = KoralObjectGenerator.makeTerm();
term.put("layer", "orth");
object.put("wrap", term);
}
@@ -248,17 +249,17 @@
// TODO generalize the list below -> look up layers associated with tokens rather than spans somewhere
HashMap<String, Object> qNameParse = parseQNameNode(node.getChild(0));
if (Arrays.asList(new String[]{"p", "lemma", "m", "orth"}).contains(qNameParse.get("layer"))) {
- object = CqlfObjectGenerator.makeToken();
- LinkedHashMap<String, Object> term = CqlfObjectGenerator.makeTerm();
+ object = KoralObjectGenerator.makeToken();
+ LinkedHashMap<String, Object> term = KoralObjectGenerator.makeTerm();
object.put("wrap", term);
term.putAll(qNameParse);
} else {
- object = CqlfObjectGenerator.makeSpan();
+ object = KoralObjectGenerator.makeSpan();
object.putAll(qNameParse);
}
} else if (firstChildNodeCat.equals("textSpec")) {
- object = CqlfObjectGenerator.makeToken();
- LinkedHashMap<String, Object> term = CqlfObjectGenerator.makeTerm();
+ object = KoralObjectGenerator.makeToken();
+ LinkedHashMap<String, Object> term = KoralObjectGenerator.makeTerm();
object.put("wrap", term);
term.put("layer", "orth");
term.putAll(parseTextSpec(node.getChild(0)));
@@ -309,12 +310,12 @@
if (nodeReferencesTotal.get(ref) > 1) {
if (nodeReferencesProcessed.get(ref)==0) {
refClassMapping.put(ref, classCounter);
- operand = CqlfObjectGenerator.wrapInClass(operand, classCounter++);
+ operand = KoralObjectGenerator.wrapInClass(operand, classCounter++);
} else if (nodeReferencesProcessed.get(ref)>0 && nodeReferencesTotal.get(ref)>1) {
try {
- operand = CqlfObjectGenerator.wrapInReference(operandStack.pop(), refClassMapping.get(ref), true);
+ operand = KoralObjectGenerator.wrapInReference(operandStack.pop(), refClassMapping.get(ref), true);
} catch (NoSuchElementException e) {
- operand = CqlfObjectGenerator.makeReference(refClassMapping.get(ref));
+ operand = KoralObjectGenerator.makeReference(refClassMapping.get(ref), true);
}
}
nodeReferencesProcessed.put(ref, nodeReferencesProcessed.get(ref)+1);
@@ -348,14 +349,14 @@
// This is modeled here...
if (reltype.equals("commonparent") || reltype.equals("commonancestor")) {
// make an (outer) group and an inner group containing the dummy node or previous relations
- group = CqlfObjectGenerator.makeGroup("relation");
- LinkedHashMap<String,Object> innerGroup = CqlfObjectGenerator.makeGroup("relation");
- LinkedHashMap<String,Object> relation = CqlfObjectGenerator.makeRelation();
- LinkedHashMap<String,Object> term = CqlfObjectGenerator.makeTerm();
+ group = KoralObjectGenerator.makeGroup("relation");
+ LinkedHashMap<String,Object> innerGroup = KoralObjectGenerator.makeGroup("relation");
+ LinkedHashMap<String,Object> relation = KoralObjectGenerator.makeRelation();
+ LinkedHashMap<String,Object> term = KoralObjectGenerator.makeTerm();
term.put("layer", "c");
relation.put("wrap", term);
// commonancestor is an indirect commonparent relation
- if (reltype.equals("commonancestor")) relation.put("boundary", CqlfObjectGenerator.makeBoundary(1, null));
+ if (reltype.equals("commonancestor")) relation.put("boundary", KoralObjectGenerator.makeBoundary(1, null));
group.put("relation", relation);
innerGroup.put("relation", relation);
// Get operands list before possible re-assignment of 'group' (see following 'if')
@@ -363,23 +364,23 @@
ArrayList<Object> innerOperands = (ArrayList<Object>) innerGroup.get("operands");
// for lowest level, add the underspecified node as first operand and wrap it in a class group
if (i == 1) {
- innerOperands.add(CqlfObjectGenerator.wrapInClass(CqlfObjectGenerator.makeSpan(), classCounter));
+ innerOperands.add(KoralObjectGenerator.wrapInClass(KoralObjectGenerator.makeSpan(), classCounter));
// add the first operand and wrap the whole group in a focusing reference
innerOperands.add(operand1);
- innerGroup = CqlfObjectGenerator.wrapInReference(innerGroup, classCounter, true);
+ innerGroup = KoralObjectGenerator.wrapInReference(innerGroup, classCounter, true);
outerOperands.add(innerGroup);
} else {
outerOperands.add(operandStack.pop());
}
// Lookahead: if next operator is not commonparent or commonancestor, wrap in class for accessibility
if (i < node.getChildCount()-2 && !getNodeCat(node.getChild(i+2).getChild(0)).startsWith("common")) {
- operand2 = CqlfObjectGenerator.wrapInClass(operand2, ++classCounter);
+ operand2 = KoralObjectGenerator.wrapInClass(operand2, ++classCounter);
}
outerOperands.add(operand2);
// Wrap in another reference object in case other relations are following
if (i < node.getChildCount()-2) {
- group = CqlfObjectGenerator.wrapInReference(group, classCounter, true);
+ group = KoralObjectGenerator.wrapInReference(group, classCounter, true);
}
// All other n-ary linguistic relations have special 'relation' attributes defined in CQLF and can be
// handled more easily...
@@ -392,12 +393,12 @@
groupType = "relation";
}
if (groupType.equals("relation") || groupType.equals("treeRelation")) {
- group = CqlfObjectGenerator.makeGroup(groupType);
+ group = KoralObjectGenerator.makeGroup(groupType);
LinkedHashMap<String, Object> relation = new LinkedHashMap<String, Object>();
putAllButGroupType(relation, operatorGroup);
group.put("relation", relation);
} else if (groupType.equals("sequence")) {
- group = CqlfObjectGenerator.makeGroup(groupType);
+ group = KoralObjectGenerator.makeGroup(groupType);
putAllButGroupType(group, operatorGroup);
} else if (groupType.equals("position")) {
group = new LinkedHashMap<String,Object>();
@@ -411,16 +412,16 @@
ParseTree rightChildSpec = getFirstChildWithCat(node.getChild(i).getChild(0), "@r");
if (leftChildSpec != null || rightChildSpec != null) {
String frame = (leftChildSpec!=null) ? "frames:startswith" : "frames:endswith";
- LinkedHashMap<String,Object> positionGroup = CqlfObjectGenerator.makePosition(new String[]{frame}, null);
- operand2 = CqlfObjectGenerator.wrapInClass(operand2, ++classCounter);
+ LinkedHashMap<String,Object> positionGroup = KoralObjectGenerator.makePosition(new String[]{frame}, null);
+ operand2 = KoralObjectGenerator.wrapInClass(operand2, ++classCounter);
((ArrayList<Object>) positionGroup.get("operands")).add(group);
- ((ArrayList<Object>) positionGroup.get("operands")).add(CqlfObjectGenerator.makeReference(classCounter,true));
+ ((ArrayList<Object>) positionGroup.get("operands")).add(KoralObjectGenerator.makeReference(classCounter,true));
group = positionGroup;
}
// Wrap in reference object in case other relations are following
if (i < node.getChildCount()-2) {
- group = CqlfObjectGenerator.wrapInReference(group, classCounter, true);
+ group = KoralObjectGenerator.wrapInReference(group, classCounter, true);
}
// Inject operands.
@@ -436,14 +437,14 @@
if (i == 1) {
// for the first operator, include both operands
if (operand1 != null) operands.add(operand1);
- if (operand2 != null) operands.add(CqlfObjectGenerator.wrapInClass(operand2, classCounter++));
+ if (operand2 != null) operands.add(KoralObjectGenerator.wrapInClass(operand2, classCounter++));
// Don't put this into the super object directly but store on operandStack
// (because this group will have to be an operand of a subsequent operator)
operandStack.push(group);
// for all subsequent operators, only take the 2nd operand (first was already added by previous operator)
} else if (i < node.getChildCount()-2) {
// for all intermediate operators, include other previous groups and 2nd operand. Store this on the operandStack, too.
- if (operand2 != null) operands.add(CqlfObjectGenerator.wrapInClass(operand2, classCounter++));
+ if (operand2 != null) operands.add(KoralObjectGenerator.wrapInClass(operand2, classCounter++));
operands.add(0, operandStack.pop());
operandStack.push(group);
} else if (i == node.getChildCount()-2) {
@@ -453,6 +454,7 @@
}
}
// Final step: decide what to do with the 'group' object, depending on whether all relations have been processed
+ System.err.println(i == node.getChildCount()-2 && relationCounter == totalRelationCount);
if (i == node.getChildCount()-2 && relationCounter == totalRelationCount) {
putIntoSuperObject(group);
if (!operandStack.isEmpty()) {
@@ -476,7 +478,7 @@
*/
private LinkedHashMap<String, Object> parseUnaryOperator(ParseTree node) {
LinkedHashMap<String, Object> attr = new LinkedHashMap<String, Object>();
- LinkedHashMap<String, Object> term = CqlfObjectGenerator.makeTerm();
+ LinkedHashMap<String, Object> term = KoralObjectGenerator.makeTerm();
String op = node.getChild(1).toStringTree(parser).substring(1);
if (op.equals("arity") || op.equals("tokenarity")) {
LinkedHashMap<String, Object> boundary = boundaryFromRangeSpec(node.getChild(3), false);
@@ -494,13 +496,13 @@
String operator = getNodeCat(operatorNode);
// DOMINANCE
if (operator.equals("dominance")) {
- relation = CqlfObjectGenerator.makeRelation();
+ relation = KoralObjectGenerator.makeRelation();
relation.put("groupType", "relation");
ParseTree qName = getFirstChildWithCat(operatorNode, "qName");
ParseTree edgeSpecNode = getFirstChildWithCat(operatorNode, "edgeSpec");
ParseTree star = getFirstChildWithCat(operatorNode, "*");
ParseTree rangeSpec = getFirstChildWithCat(operatorNode, "rangeSpec");
- LinkedHashMap<String,Object> term = CqlfObjectGenerator.makeTerm();
+ LinkedHashMap<String,Object> term = KoralObjectGenerator.makeTerm();
term.put("layer", "c");
if (qName != null) term = parseQNameNode(qName);
if (edgeSpecNode != null) {
@@ -510,31 +512,31 @@
((ArrayList<Object>) edgeSpec.get("operands")).add(term);
term = edgeSpec;
} else {
- term = CqlfObjectGenerator.makeTermGroup("and");
+ term = KoralObjectGenerator.makeTermGroup("and");
ArrayList<Object> termGroupOperands = (ArrayList<Object>) term.get("operands");
termGroupOperands.add(edgeSpec);
- LinkedHashMap<String,Object> constTerm = CqlfObjectGenerator.makeTerm();
+ LinkedHashMap<String,Object> constTerm = KoralObjectGenerator.makeTerm();
constTerm.put("layer", "c");
termGroupOperands.add(constTerm);
}
}
- if (star != null) relation.put("boundary", CqlfObjectGenerator.makeBoundary(0, null));
+ if (star != null) relation.put("boundary", KoralObjectGenerator.makeBoundary(0, null));
if (rangeSpec != null) relation.put("boundary", boundaryFromRangeSpec(rangeSpec));
relation.put("wrap", term);
}
else if (operator.equals("pointing")) {
// String reltype = operatorNode.getChild(1).toStringTree(parser);
- relation = CqlfObjectGenerator.makeRelation();
+ relation = KoralObjectGenerator.makeRelation();
relation.put("groupType", "relation");
ParseTree qName = getFirstChildWithCat(operatorNode, "qName");
ParseTree edgeSpec = getFirstChildWithCat(operatorNode, "edgeSpec");
ParseTree star = getFirstChildWithCat(operatorNode, "*");
ParseTree rangeSpec = getFirstChildWithCat(operatorNode, "rangeSpec");
// if (qName != null) relation.putAll(parseQNameNode(qName));
- LinkedHashMap<String,Object> term = CqlfObjectGenerator.makeTerm();
+ LinkedHashMap<String,Object> term = KoralObjectGenerator.makeTerm();
if (qName != null) term.putAll(parseQNameNode(qName));
if (edgeSpec != null) term.putAll(parseEdgeSpec(edgeSpec));
- if (star != null) relation.put("boundary", CqlfObjectGenerator.makeBoundary(0, null));
+ if (star != null) relation.put("boundary", KoralObjectGenerator.makeBoundary(0, null));
if (rangeSpec != null) relation.put("boundary", boundaryFromRangeSpec(rangeSpec));
relation.put("wrap", term);
}
@@ -545,7 +547,7 @@
ParseTree star = getFirstChildWithCat(operatorNode, "*");
ArrayList<Object> distances = new ArrayList<Object>();
if (star != null) {
- distances.add(CqlfObjectGenerator.makeDistance("w", 0, null));
+ distances.add(KoralObjectGenerator.makeDistance("w", 0, null));
relation.put("distances", distances);
}
if (rangeSpec != null) {
@@ -583,7 +585,7 @@
}
// relation.put("frames", frames);
// relation.put("sharedClasses", sharedClasses);
- relation = CqlfObjectGenerator.makePosition(frames, new String[]{});
+ relation = KoralObjectGenerator.makePosition(frames, new String[]{});
relation.put("groupType", "position");
}
else if (operator.equals("identity")) {
@@ -603,7 +605,7 @@
List<ParseTree> annos = getChildrenWithCat(edgeSpec, "edgeAnno");
if (annos.size() == 1) return parseEdgeAnno(annos.get(0));
else {
- LinkedHashMap<String,Object> termGroup = CqlfObjectGenerator.makeTermGroup("and");
+ LinkedHashMap<String,Object> termGroup = KoralObjectGenerator.makeTermGroup("and");
ArrayList<Object> operands = (ArrayList<Object>) termGroup.get("operands");
for (ParseTree anno : annos) {
operands.add(parseEdgeAnno(anno));
@@ -636,7 +638,7 @@
if (expandToMax) max = null;
if (rangeSpec.getChildCount()==3)
max = Integer.parseInt(rangeSpec.getChild(2).toStringTree(parser));
- return CqlfObjectGenerator.makeBoundary(min, max);
+ return KoralObjectGenerator.makeBoundary(min, max);
}
private LinkedHashMap<String, Object> parseDistance(ParseTree rangeSpec) {
@@ -644,7 +646,7 @@
Integer max = null;
if (rangeSpec.getChildCount()==3)
max = Integer.parseInt(rangeSpec.getChild(2).toStringTree(parser));
- return CqlfObjectGenerator.makeDistance("w", min, max);
+ return KoralObjectGenerator.makeDistance("w", min, max);
}
private LinkedHashMap<String, Object> parseTextSpec(ParseTree node) {
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 b76ad29..acad4d6 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
@@ -3,7 +3,7 @@
import de.ids_mannheim.korap.query.parse.collection.CollectionQueryLexer;
import de.ids_mannheim.korap.query.parse.collection.CollectionQueryParser;
import de.ids_mannheim.korap.query.serialize.util.Antlr4DescriptiveErrorListener;
-import de.ids_mannheim.korap.query.serialize.util.CqlfObjectGenerator;
+import de.ids_mannheim.korap.query.serialize.util.KoralObjectGenerator;
import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
import org.antlr.v4.runtime.*;
@@ -42,16 +42,16 @@
Integer stackedObjects = 0;
public CollectionQueryProcessor() {
- CqlfObjectGenerator.setQueryProcessor(this);
+ KoralObjectGenerator.setQueryProcessor(this);
}
public CollectionQueryProcessor(boolean verbose) {
- CqlfObjectGenerator.setQueryProcessor(this);
+ KoralObjectGenerator.setQueryProcessor(this);
CollectionQueryProcessor.verbose = verbose;
}
public CollectionQueryProcessor(String query) {
- CqlfObjectGenerator.setQueryProcessor(this);
+ KoralObjectGenerator.setQueryProcessor(this);
process(query);
}
@@ -94,7 +94,7 @@
if (nodeCat.equals("relation")) {
String operator = node.getChild(1).getChild(0).toStringTree(parser).equals("&") ? "and" : "or";
- LinkedHashMap<String, Object> relationGroup = CqlfObjectGenerator.makeDocGroup(operator);
+ LinkedHashMap<String, Object> relationGroup = KoralObjectGenerator.makeDocGroup(operator);
putIntoSuperObject(relationGroup);
objectStack.push(relationGroup);
stackedObjects++;
@@ -105,7 +105,7 @@
String field = fieldNode.getChild(0).toStringTree(parser);
ParseTree operatorNode = getFirstChildWithCat(node, "operator");
ParseTree valueNode = getFirstChildWithCat(node, "value");
- LinkedHashMap<String, Object> term = CqlfObjectGenerator.makeDoc();
+ LinkedHashMap<String, Object> term = KoralObjectGenerator.makeDoc();
term.put("key", field);
term.putAll(parseValue(valueNode));
String match = operatorNode.getText();
@@ -128,7 +128,7 @@
ParseTree dateOpNode = getFirstChildWithCat(node, "dateOp");
ParseTree dateNode = getFirstChildWithCat(node, "date");
- LinkedHashMap<String, Object> term = CqlfObjectGenerator.makeDoc();
+ LinkedHashMap<String, Object> term = KoralObjectGenerator.makeDoc();
term.put("key", field);
term.putAll(parseValue(dateNode));
String match = dateOpNode.getText();
@@ -141,7 +141,7 @@
}
if (nodeCat.equals("token")) {
- LinkedHashMap<String,Object> token = CqlfObjectGenerator.makeToken();
+ LinkedHashMap<String,Object> token = KoralObjectGenerator.makeToken();
// handle negation
List<ParseTree> negations = getChildrenWithCat(node, "!");
boolean negated = false;
@@ -149,7 +149,7 @@
if (negations.size() % 2 == 1) negated = true;
if (getNodeCat(node.getChild(0)).equals("key")) {
// no 'term' child, but direct key specification: process here
- LinkedHashMap<String,Object> term = CqlfObjectGenerator.makeTerm();
+ LinkedHashMap<String,Object> term = KoralObjectGenerator.makeTerm();
String key = node.getChild(0).getText();
if (getNodeCat(node.getChild(0).getChild(0)).equals("regex")) {
isRegex = true;
@@ -373,7 +373,7 @@
private LinkedHashMap<String, Object> parseTermOrTermGroup(ParseTree node, boolean negatedGlobal, String mode) {
if (getNodeCat(node).equals("term")) {
String key = null;
- LinkedHashMap<String,Object> term = CqlfObjectGenerator.makeTerm();
+ LinkedHashMap<String,Object> term = KoralObjectGenerator.makeTerm();
// handle negation
boolean negated = negatedGlobal;
boolean isRegex = false;
@@ -441,7 +441,7 @@
// establish boolean relation
ParseTree boolOp = getFirstChildWithCat(node, "booleanOp");
String operator = boolOp.getText().equals("&") ? "and" : "or";
- termGroup = CqlfObjectGenerator.makeTermGroup(operator);
+ termGroup = KoralObjectGenerator.makeTermGroup(operator);
ArrayList<Object> operands = (ArrayList<Object>) termGroup.get("operands");
// recursion with left/right operands
operands.add(parseTermOrTermGroup(leftOp, negatedGlobal, mode));
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java
index db161a0..8ff5474 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java
@@ -3,7 +3,7 @@
import de.ids_mannheim.korap.query.parse.poliqarpplus.PoliqarpPlusLexer;
import de.ids_mannheim.korap.query.parse.poliqarpplus.PoliqarpPlusParser;
import de.ids_mannheim.korap.query.serialize.util.Antlr4DescriptiveErrorListener;
-import de.ids_mannheim.korap.query.serialize.util.CqlfObjectGenerator;
+import de.ids_mannheim.korap.query.serialize.util.KoralObjectGenerator;
import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
import org.antlr.v4.runtime.*;
@@ -39,7 +39,7 @@
* @throws QueryException
*/
public PoliqarpPlusQueryProcessor (String query) {
- CqlfObjectGenerator.setQueryProcessor(this);
+ KoralObjectGenerator.setQueryProcessor(this);
process(query);
log.info(">>> " + requestMap.get("query") + " <<<");
}
@@ -195,10 +195,10 @@
ParseTree quantification = getFirstChildWithCat(node, "repetition");
if (quantification != null) {
LinkedHashMap<String, Object> quantGroup =
- CqlfObjectGenerator.makeGroup("repetition");
+ KoralObjectGenerator.makeGroup("repetition");
Integer[] minmax = parseRepetition(quantification);
quantGroup.put("boundary",
- CqlfObjectGenerator.makeBoundary(minmax[0], minmax[1]));
+ KoralObjectGenerator.makeBoundary(minmax[0], minmax[1]));
putIntoSuperObject(quantGroup);
objectStack.push(quantGroup);
stackedObjects++;
@@ -207,13 +207,13 @@
private void processSequence(ParseTree node) {
LinkedHashMap<String, Object> sequence =
- CqlfObjectGenerator.makeGroup("sequence");
+ KoralObjectGenerator.makeGroup("sequence");
ParseTree distanceNode = getFirstChildWithCat(node, "distance");
if (distanceNode != null) {
Integer[] minmax = parseDistance(distanceNode);
LinkedHashMap<String, Object> distance =
- CqlfObjectGenerator.makeDistance("w", minmax[0], minmax[1]);
+ KoralObjectGenerator.makeDistance("w", minmax[0], minmax[1]);
sequence.put("inOrder", true);
ArrayList<Object> distances = new ArrayList<Object>();
distances.add(distance);
@@ -237,9 +237,9 @@
// token
LinkedHashMap<String, Object> object;
LinkedHashMap<String, Object> emptyToken =
- CqlfObjectGenerator.makeToken();
+ KoralObjectGenerator.makeToken();
if (minmax[0] != 1 || minmax[1] == null || minmax[1] != 1) {
- object = CqlfObjectGenerator.makeRepetition(minmax[0], minmax[1]);
+ object = KoralObjectGenerator.makeRepetition(minmax[0], minmax[1]);
((ArrayList<Object>) object.get("operands")).add(emptyToken);
}
else {
@@ -257,14 +257,14 @@
.toStringTree(parser));
}
LinkedHashMap<String, Object> classGroup =
- CqlfObjectGenerator.makeSpanClass(classId, false);
+ KoralObjectGenerator.makeSpanClass(classId, false);
putIntoSuperObject(classGroup);
objectStack.push(classGroup);
stackedObjects++;
}
private void processToken(ParseTree node) {
- LinkedHashMap<String, Object> token = CqlfObjectGenerator.makeToken();
+ LinkedHashMap<String, Object> token = KoralObjectGenerator.makeToken();
// handle negation
List<ParseTree> negations = getChildrenWithCat(node, "!");
boolean negated = false;
@@ -273,7 +273,7 @@
negated = true;
if (getNodeCat(node.getChild(0)).equals("key")) {
// no 'term' child, but direct key specification: process here
- LinkedHashMap<String, Object> term = CqlfObjectGenerator.makeTerm();
+ LinkedHashMap<String, Object> term = KoralObjectGenerator.makeTerm();
String key = node.getChild(0).getText();
if (getNodeCat(node.getChild(0).getChild(0)).equals("regex")) {
isRegex = true;
@@ -317,7 +317,7 @@
@SuppressWarnings("unchecked")
private void processAlignment(ParseTree node) {
LinkedHashMap<String, Object> alignClass =
- CqlfObjectGenerator.makeSpanClass(++classCounter, false);
+ KoralObjectGenerator.makeSpanClass(++classCounter, false);
LinkedHashMap<String, Object> metaMap =
(LinkedHashMap<String, Object>) requestMap.get("meta");
if (metaMap.containsKey("alignment")) {
@@ -345,7 +345,7 @@
boolean negated = false;
if (negations.size() % 2 == 1)
negated = true;
- LinkedHashMap<String, Object> span = CqlfObjectGenerator.makeSpan();
+ LinkedHashMap<String, Object> span = KoralObjectGenerator.makeSpan();
ParseTree keyNode = getFirstChildWithCat(node, "key");
ParseTree layerNode = getFirstChildWithCat(node, "layer");
ParseTree foundryNode = getFirstChildWithCat(node, "foundry");
@@ -385,7 +385,7 @@
private void processDisjunction(ParseTree node) {
LinkedHashMap<String, Object> disjunction =
- CqlfObjectGenerator.makeGroup("or");
+ KoralObjectGenerator.makeGroup("or");
putIntoSuperObject(disjunction);
objectStack.push(disjunction);
stackedObjects++;
@@ -400,9 +400,9 @@
private void processRelation(ParseTree node) {
LinkedHashMap<String, Object> relationGroup =
- CqlfObjectGenerator.makeGroup("relation");
+ KoralObjectGenerator.makeGroup("relation");
LinkedHashMap<String, Object> relation =
- CqlfObjectGenerator.makeRelation();
+ KoralObjectGenerator.makeRelation();
relationGroup.put("relation", relation);
if (node.getChild(0).getText().equals("dominates")) {
relation.put("layer", "c");
@@ -423,7 +423,7 @@
if (repetition != null) {
Integer[] minmax = parseRepetition(repetition);
relation.put("boundary",
- CqlfObjectGenerator.makeBoundary(minmax[0], minmax[1]));
+ KoralObjectGenerator.makeBoundary(minmax[0], minmax[1]));
}
putIntoSuperObject(relationGroup);
objectStack.push(relationGroup);
@@ -453,7 +453,7 @@
}
}
LinkedHashMap<String, Object> classGroup =
- CqlfObjectGenerator.makeSpanClass(classId, false);
+ KoralObjectGenerator.makeSpanClass(classId, false);
putIntoSuperObject(classGroup);
objectStack.push(classGroup);
stackedObjects++;
@@ -497,7 +497,7 @@
classRefs.add(1);
}
LinkedHashMap<String, Object> referenceGroup =
- CqlfObjectGenerator.makeReference(classRefs);
+ KoralObjectGenerator.makeReference(classRefs);
String type = node.getChild(0).toStringTree(parser);
// Default is focus(), if deviating catch here
@@ -525,7 +525,7 @@
private void processSubmatch(ParseTree node) {
LinkedHashMap<String, Object> submatch =
- CqlfObjectGenerator.makeReference(null);
+ KoralObjectGenerator.makeReference(null);
submatch.put("operands", new ArrayList<Object>());
ParseTree startpos = getFirstChildWithCat(node, "startpos");
ParseTree length = getFirstChildWithCat(node, "length");
@@ -558,9 +558,9 @@
private void processWithin(ParseTree node) {
ParseTree domainNode = node.getChild(1);
String domain = getNodeCat(domainNode);
- LinkedHashMap<String, Object> span = CqlfObjectGenerator.makeSpan(domain);
+ LinkedHashMap<String, Object> span = KoralObjectGenerator.makeSpan(domain);
LinkedHashMap<String, Object> queryObj = (LinkedHashMap<String, Object>) requestMap.get("query");
- LinkedHashMap<String, Object> contains = CqlfObjectGenerator.makePosition(new String[]{"frames:contains"}, null);
+ LinkedHashMap<String, Object> contains = KoralObjectGenerator.makePosition(new String[]{"frames:contains"}, null);
ArrayList<Object> operands = (ArrayList<Object>) contains.get("operands");
operands.add(span);
operands.add(queryObj);
@@ -650,7 +650,7 @@
classRefCheck = new String[] { "classRefCheck:intersects" };
break;
}
- return CqlfObjectGenerator.makePosition(frames, classRefCheck);
+ return KoralObjectGenerator.makePosition(frames, classRefCheck);
}
private LinkedHashMap<String, Object> parseTermOrTermGroup(ParseTree node,
@@ -676,7 +676,7 @@
if (nodeCat.equals("term")) {
String key = null;
LinkedHashMap<String, Object> term =
- CqlfObjectGenerator.makeTerm();
+ KoralObjectGenerator.makeTerm();
// handle negation
boolean negated = negatedGlobal;
boolean isRegex = false;
@@ -767,7 +767,7 @@
// establish boolean relation
ParseTree boolOp = getFirstChildWithCat(node, "boolOp");
String operator = boolOp.getText().equals("&") ? "and" : "or";
- termGroup = CqlfObjectGenerator.makeTermGroup(operator);
+ termGroup = KoralObjectGenerator.makeTermGroup(operator);
ArrayList<Object> operands = (ArrayList<Object>) termGroup
.get("operands");
// recursion with left/right operands
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 9c74336..27caa3d 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
@@ -18,7 +18,7 @@
import de.ids_mannheim.korap.query.parse.annis.AqlLexer;
//TODO replace AqlParser with parser for your Antlr4 grammar!
import de.ids_mannheim.korap.query.parse.annis.AqlParser;
-import de.ids_mannheim.korap.query.serialize.util.CqlfObjectGenerator;
+import de.ids_mannheim.korap.query.serialize.util.KoralObjectGenerator;
import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
/**
@@ -34,7 +34,7 @@
* @param parser The ANTLR parser instance that generated the parse tree
*/
public TreeTemplate(String query) {
- CqlfObjectGenerator.setQueryProcessor(this);
+ KoralObjectGenerator.setQueryProcessor(this);
process(query);
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/util/CqlfObjectGenerator.java b/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java
similarity index 99%
rename from src/main/java/de/ids_mannheim/korap/query/serialize/util/CqlfObjectGenerator.java
rename to src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java
index 50b71a6..45135ef 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/util/CqlfObjectGenerator.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java
@@ -6,13 +6,13 @@
import de.ids_mannheim.korap.query.serialize.AbstractQueryProcessor;
-public class CqlfObjectGenerator {
+public class KoralObjectGenerator {
protected static final Integer MAXIMUM_DISTANCE = 100;
private static AbstractQueryProcessor qp;
public static void setQueryProcessor(AbstractQueryProcessor qp) {
- CqlfObjectGenerator.qp = qp;
+ KoralObjectGenerator.qp = qp;
}
public static LinkedHashMap<String, Object> makeSpan() {