Generalized LinkedHashMap to Map or changed it to HashMap.
Change-Id: If15b88928c7a9f86a21324f0761d13a7814792bd
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 7b101a9..8a0a260 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
@@ -2,7 +2,7 @@
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.LinkedHashMap;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -19,40 +19,41 @@
* JSON-LD tree for that query.
*
* @author Joachim Bingel (bingel@ids-mannheim.de)
+ * @author Eliza Margaretha (margaretha@ids-mannheim.de)
* @version 0.3.0
* @since 0.1.0
*/
public abstract class AbstractQueryProcessor {
- Logger log;
+ protected Logger log;
/**
* The query string.
*/
- String query;
+ protected String query;
/**
* Top-level map representing the whole request.
*/
- LinkedHashMap<String, Object> requestMap = new LinkedHashMap<String, Object>();
+ protected Map<String, Object> requestMap = new HashMap<String, Object>();
/**
* Keeps track of open node categories.
*/
- LinkedList<String> openNodeCats = new LinkedList<String>();
+ protected LinkedList<String> openNodeCats = new LinkedList<String>();
/**
* Keeps track of all visited nodes in a tree.
*/
- List<ParseTree> visited = new ArrayList<ParseTree>();
+ protected List<ParseTree> visited = new ArrayList<ParseTree>();
/**
* Keeps track of active object, used for inserting new KoralQuery
* objects
* into last created objects.
*/
- LinkedList<Map<String, Object>> objectStack = new LinkedList<Map<String, Object>>();
+ protected LinkedList<Map<String, Object>> objectStack = new LinkedList<Map<String, Object>>();
/**
* Keeps track of how many objects there are to pop after every
* recursion
* of {@link #processNode(ParseTree)}
*/
- LinkedList<Integer> objectsToPop = new LinkedList<Integer>();
+ protected LinkedList<Integer> objectsToPop = new LinkedList<Integer>();
/**
* If true, print debug statements
*/
@@ -62,34 +63,34 @@
* Contains error arrays, consisting of an error code and a
* message.
*/
- private ArrayList<List<Object>> errors = new ArrayList<List<Object>>();
+ private List<List<Object>> errors = new ArrayList<List<Object>>();
/**
* Contains warning arrays, consisting of a warning code
* (optional) and a
* message.
*/
- private ArrayList<List<Object>> warnings = new ArrayList<List<Object>>();
+ private List<List<Object>> warnings = new ArrayList<List<Object>>();
/**
* Contains other messages.
*/
- private ArrayList<List<Object>> messages = new ArrayList<List<Object>>();
+ private List<List<Object>> messages = new ArrayList<List<Object>>();
/**
* Virtual collection queries.
*/
- private LinkedHashMap<String, Object> collection = new LinkedHashMap<String, Object>();
+ private Object collection = new HashMap<String, Object>();
/**
* Holds information on displaying directives.
*/
- private LinkedHashMap<String, Object> meta = new LinkedHashMap<String, Object>();
+ private Map<String, Object> meta = new HashMap<String, Object>();
/**
* Indicates which classes are to be highlighted in KWIC view.
*/
- private ArrayList<Integer> highlightClasses = new ArrayList<Integer>();
+ private List<Integer> highlightClasses = new ArrayList<Integer>();
/**
* Indicates positions of alignment rulers in KWIC view.
*/
- private ArrayList<List<Integer>> alignments = new ArrayList<List<Integer>>();
+ private List<List<Integer>> alignments = new ArrayList<List<Integer>>();
AbstractQueryProcessor () {
@@ -99,7 +100,7 @@
requestMap.put("warnings", warnings);
requestMap.put("messages", messages);
requestMap.put("collection", collection);
- requestMap.put("query", new LinkedHashMap<String, Object>());
+ requestMap.put("query", new HashMap<String, Object>());
requestMap.put("meta", meta);
}
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 2611ab9..a5f269f 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
@@ -4,7 +4,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.Map;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -17,9 +16,8 @@
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.commons.lang.math.Fraction;
-import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import de.ids_mannheim.korap.query.object.KoralFrame;
import de.ids_mannheim.korap.query.object.KoralOperation;
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 4667430..df1ca73 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
@@ -13,7 +13,8 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.LinkedHashMap;
+import java.util.HashMap;
+import java.util.Map;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -100,7 +101,7 @@
if (nodeCat.equals("relation")) {
String operator = getNodeCat(node.getChild(1).getChild(0)).equals(
"&") ? "and" : "or";
- LinkedHashMap<String, Object> relationGroup = KoralObjectGenerator
+ Map<String, Object> relationGroup = KoralObjectGenerator
.makeDocGroup(operator);
putIntoSuperObject(relationGroup);
objectStack.push(relationGroup);
@@ -112,14 +113,14 @@
String field = fieldNode.getChild(0).toStringTree(parser);
ParseTree operatorNode = getFirstChildWithCat(node, "operator");
ParseTree valueNode = getFirstChildWithCat(node, "value");
- LinkedHashMap<String, Object> term = KoralObjectGenerator.makeDoc();
+ Map<String, Object> term = KoralObjectGenerator.makeDoc();
term.put("key", field);
term.putAll(parseValue(valueNode));
String match = operatorNode.getText();
term.put("match", "match:" + interpretMatchOperator(match));
if (!checkOperatorValueConformance(term)) {
- requestMap = new LinkedHashMap<String, Object>();
+ requestMap = new HashMap<String, Object>();
return;
}
// if (QueryUtils.checkDateValidity(valueNode.getText())) {
@@ -140,13 +141,13 @@
ParseTree dateOpNode = getFirstChildWithCat(node, "dateOp");
ParseTree dateNode = getFirstChildWithCat(node, "date");
- LinkedHashMap<String, Object> term = KoralObjectGenerator.makeDoc();
+ Map<String, Object> term = KoralObjectGenerator.makeDoc();
term.put("key", field);
term.putAll(parseValue(dateNode));
String match = dateOpNode.getText();
term.put("match", "match:" + interpretMatchOperator(match));
if (!checkOperatorValueConformance(term)) {
- requestMap = new LinkedHashMap<String, Object>();
+ requestMap = new HashMap<String, Object>();
return;
}
if (!QueryUtils.checkDateValidity(dateNode.getText())) {
@@ -161,7 +162,7 @@
}
if (nodeCat.equals("token")) {
- LinkedHashMap<String, Object> token = KoralObjectGenerator
+ Map<String, Object> token = KoralObjectGenerator
.makeToken();
// handle negation
List<ParseTree> negations = getChildrenWithCat(node, "!");
@@ -171,7 +172,7 @@
negated = true;
if (getNodeCat(node.getChild(0)).equals("key")) {
// no 'term' child, but direct key specification: process here
- LinkedHashMap<String, Object> term = KoralObjectGenerator
+ Map<String, Object> term = KoralObjectGenerator
.makeTerm();
String key = node.getChild(0).getText();
if (getNodeCat(node.getChild(0).getChild(0)).equals("regex")) {
@@ -203,7 +204,7 @@
}
else {
// child is 'term' or 'termGroup' -> process in extra method
- LinkedHashMap<String, Object> termOrTermGroup = parseTermOrTermGroup(
+ Map<String, Object> termOrTermGroup = parseTermOrTermGroup(
node.getChild(1), negated);
token.put("wrap", termOrTermGroup);
}
@@ -246,7 +247,7 @@
* (inequation operators <,>,<=,>= may only be used with dates).
*/
private boolean checkOperatorValueConformance (
- LinkedHashMap<String, Object> term) {
+ Map<String, Object> term) {
String match = (String) term.get("match");
String type = (String) term.get("type");
if (type == null || type.equals("type:regex")) {
@@ -262,8 +263,8 @@
}
- private LinkedHashMap<String, Object> parseValue (ParseTree valueNode) {
- LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
+ private Map<String, Object> parseValue (ParseTree valueNode) {
+ Map<String, Object> map = new HashMap<String, Object>();
if (getNodeCat(valueNode).equals("date")) {
map.put("type", "type:date");
checkDateValidity(valueNode);
@@ -387,13 +388,13 @@
}
- private void putIntoSuperObject (LinkedHashMap<String, Object> object) {
+ private void putIntoSuperObject (Map<String, Object> object) {
putIntoSuperObject(object, 0);
}
@SuppressWarnings({ "unchecked" })
- private void putIntoSuperObject (LinkedHashMap<String, Object> object,
+ private void putIntoSuperObject (Map<String, Object> object,
int objStackPosition) {
if (objectStack.size() > objStackPosition) {
ArrayList<Object> topObjectOperands = (ArrayList<Object>) objectStack
@@ -407,7 +408,7 @@
}
- private LinkedHashMap<String, Object> parseTermOrTermGroup (ParseTree node,
+ private Map<String, Object> parseTermOrTermGroup (ParseTree node,
boolean negated) {
return parseTermOrTermGroup(node, negated, "token");
}
@@ -426,11 +427,11 @@
* @return A term or termGroup object, depending on input
*/
@SuppressWarnings("unchecked")
- private LinkedHashMap<String, Object> parseTermOrTermGroup (ParseTree node,
+ private Map<String, Object> parseTermOrTermGroup (ParseTree node,
boolean negatedGlobal, String mode) {
if (getNodeCat(node).equals("term")) {
String key = null;
- LinkedHashMap<String, Object> term = KoralObjectGenerator
+ Map<String, Object> term = KoralObjectGenerator
.makeTerm();
// handle negation
boolean negated = negatedGlobal;
@@ -505,7 +506,7 @@
// For termGroups, establish a boolean relation between operands
// and recursively call this function with the term or termGroup
// operands.
- LinkedHashMap<String, Object> termGroup = null;
+ Map<String, Object> termGroup = null;
ParseTree leftOp = null;
ParseTree rightOp = null;
// check for leading/trailing parantheses
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 705963c..ca88711 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
@@ -43,39 +43,39 @@
private static Logger log = LoggerFactory
.getLogger(Cosmas2QueryProcessor.class);
- LinkedList<LinkedHashMap<String, Object>[]> toWrapStack = new LinkedList<LinkedHashMap<String, Object>[]>();
+ private LinkedList<Map<String, Object>[]> toWrapStack = new LinkedList<Map<String, Object>[]>();
/**
* Field for repetition query (Kleene + or * operations, or
* min/max queries: {2,4}
*/
- String repetition = "";
+ private String repetition = "";
/**
* Global control structure for fieldGroups, keeps track of open
* fieldGroups.
*/
- LinkedList<ArrayList<Object>> openFieldGroups = new LinkedList<ArrayList<Object>>();
+ private LinkedList<ArrayList<Object>> openFieldGroups = new LinkedList<ArrayList<Object>>();
/**
* Keeps track of how many toWrap objects there are to pop after
* every recursion of {@link #processNode(ParseTree)}
*/
- LinkedList<Integer> toWrapsToPop = new LinkedList<Integer>();
+ private LinkedList<Integer> toWrapsToPop = new LinkedList<Integer>();
/**
* Flag that indicates whether token fields or meta fields are
* currently being processed
*/
- boolean inMeta = false;
+ private boolean inMeta = false;
/**
* If true, a sequence (OPPROX node) is governed by an OPALL node
* (ALL()-operator), which requires to match all tokens of the
* sequence.
*/
- boolean inOPALL = false;
- boolean inOPNHIT = false;
+ private boolean inOPALL = false;
+ private boolean inOPNHIT = false;
/**
*
*/
- int classCounter = 1;
- boolean negate = false;
+ private int classCounter = 1;
+ private boolean negate = false;
/**
* Allows for the definition of objects to be wrapped around the
@@ -83,13 +83,13 @@
* parent node of the argument, the number of the argument and an
* object in whose operands list the argument shall be wrapped.
*/
- Table<Tree, Integer, LinkedHashMap<String, Object>> operandWrap = HashBasedTable
+ private Table<Tree, Integer, Map<String, Object>> operandWrap = HashBasedTable
.create();
/**
* Keeps track of all visited nodes in a tree
*/
- List<Tree> visited = new ArrayList<Tree>();
+ private List<Tree> visited = new ArrayList<Tree>();
Integer stackedToWrap = 0;
/**
@@ -191,7 +191,7 @@
}
if (nodeHasSequentiableSiblings) {
// Step I: create sequence
- LinkedHashMap<String, Object> sequence = KoralObjectGenerator
+ Map<String, Object> sequence = KoralObjectGenerator
.makeGroup(KoralOperation.SEQUENCE);
// push sequence on object stack but don't
// increment stackedObjects counter since
@@ -325,7 +325,7 @@
private void processOPEND_OPBEG (Tree node) {
// Step I: create group
String nodeCat = getNodeCat(node);
- LinkedHashMap<String, Object> beggroup = new LinkedHashMap<String, Object>();
+ Map<String, Object> beggroup = new HashMap<String, Object>();
beggroup.put("@type", "koral:reference");
beggroup.put("operation", "operation:focus");
ArrayList<Integer> spanRef = new ArrayList<Integer>();
@@ -364,7 +364,7 @@
Tree endConditions = getFirstChildWithCat(node.getChild(optsChild),
"TPEND");
- LinkedHashMap<String, Object> submatchgroup = KoralObjectGenerator
+ Map<String, Object> submatchgroup = KoralObjectGenerator
.makeReference(classCounter + 128);
ArrayList<Object> submatchOperands = new ArrayList<Object>();
submatchgroup.put("operands", submatchOperands);
@@ -373,7 +373,7 @@
// Step II: collect all conditions, create groups for them in
// processPositionCondition()
ArrayList<Object> distributedOperands = new ArrayList<Object>();
- ArrayList<LinkedHashMap<String, Object>> conditionGroups = new ArrayList<LinkedHashMap<String, Object>>();
+ ArrayList<Map<String, Object>> conditionGroups = new ArrayList<Map<String, Object>>();
if (begConditions != null) {
for (Tree condition : getChildren(begConditions)) {
conditionGroups.add(processPositionCondition(condition,
@@ -391,7 +391,7 @@
// indicates where to insert next condition group
ArrayList<Object> currentLowestOperands = submatchOperands;
int conditionCount = 0;
- for (LinkedHashMap<String, Object> conditionGroup : conditionGroups) {
+ for (Map<String, Object> conditionGroup : conditionGroups) {
conditionCount++;
if (conditionGroups.size() == 1) {
submatchOperands.add(conditionGroup);
@@ -399,7 +399,7 @@
else if (conditionCount < conditionGroups.size()) {
ArrayList<KoralFrame> frames = new ArrayList<KoralFrame>();
frames.add(KoralFrame.MATCHES);
- LinkedHashMap<String, Object> matchesGroup = KoralObjectGenerator
+ Map<String, Object> matchesGroup = KoralObjectGenerator
.makePosition(frames);
@SuppressWarnings("unchecked")
ArrayList<Object> matchesOperands = (ArrayList<Object>) matchesGroup
@@ -410,7 +410,7 @@
// focus to grep out only the query term to which the
// constraint applies
if (conditionCount > 1) {
- LinkedHashMap<String, Object> focus = KoralObjectGenerator
+ Map<String, Object> focus = KoralObjectGenerator
.makeReference(classCounter + 128 - 2);
ArrayList<Object> focusOperands = new ArrayList<Object>();
focus.put("operands", focusOperands);
@@ -434,11 +434,10 @@
classCounter + 128 + 2 };
// classRef.add(classCounter + 1); // yes, do this twice (two
// classes)!
- LinkedHashMap<String, Object> group = KoralObjectGenerator
+ Map<String, Object> group = KoralObjectGenerator
.makeReference(classCounter + 128);
- LinkedHashMap<String, Object> classRefCheck = KoralObjectGenerator
- .makeClassRefOp(ClassRefOp.INVERSION, classRef,
- classCounter + 128);
+ Map<String, Object> classRefCheck = KoralObjectGenerator.makeClassRefOp(
+ ClassRefOp.INVERSION, classRef, classCounter + 128);
ArrayList<Object> operands = new ArrayList<Object>();
operands.add(classRefCheck);
group.put("operands", operands);
@@ -458,8 +457,7 @@
if (operandWrap.containsRow(parent)) {
// Step I: create group
int argNr = nodeCat.equals("ARG1") ? 1 : 2;
- LinkedHashMap<String, Object> container = operandWrap.row(parent)
- .get(argNr);
+ Map<String, Object> container = operandWrap.row(parent).get(argNr);
// Step II: ingest
if (container != null) {
objectStack.push(container);
@@ -513,22 +511,26 @@
private void processOPIN_OPOV (Tree node) {
String nodeCat = getNodeCat(node);
- // LinkedHashMap<String, Object> posgroup =
+ // Map<String, Object> posgroup =
// makePosition(null);
boolean isExclusion = isExclusion(node);
- KoralOperation operation;
+ Map<String, Object> posGroup;
if (isExclusion) {
- operation = KoralOperation.EXCLUSION;
+ posGroup = KoralObjectGenerator.makeGroup(KoralOperation.EXCLUSION);
}
else {
- operation = KoralOperation.POSITION;
+ posGroup = KoralObjectGenerator.makeGroup(KoralOperation.POSITION);
+ // mark this an inverted operands object
+ invertedOperandsLists
+ .push((ArrayList<Object>) posGroup.get("operands"));
wrapOperandInClass(node, 2, 128 + classCounter++);
wrapOperandInClass(node, 1, 128 + classCounter++);
- }
+ // EM: why bother inverting the operands and creating classes and focus?
+ // can't we agree on the first operand to be the results, like in
+ // operation:exclusion?
- Map<String, Object> posGroup = KoralObjectGenerator
- .makeGroup(operation);
+ }
Map<String, Object> positionOptions;
if (nodeCat.equals("OPIN")) {
@@ -547,28 +549,25 @@
ArrayList<ClassRefCheck> checkList = (ArrayList<ClassRefCheck>) positionOptions
.get("classRefCheck");
- // EM: why bother inverting the operands and creating classes and focus?
- // can't we agree on the first operand to be the results, like in operation:exclusion?
- if (!isExclusion) {
- // mark this an inverted operands object
- invertedOperandsLists
- .push((ArrayList<Object>) posGroup.get("operands"));
-
- // Step II: wrap in classRefCheck and/or focus and decide where to put
+ // Step II: wrap in classRefCheck and/or focus and decide where to put
+ if (isExclusion) {
if (!checkList.isEmpty()) {
- posGroup = addClassRefCheck(checkList, posGroup);
- }
- posGroup = addClassFocus((boolean) positionOptions.get("matchall"),
- posGroup);
+ wrapOperandInClass(node, 1, 128 + classCounter++);
+ wrapOperandInClass(node, 2, 128 + classCounter++);
+ posGroup = addClassRefCheck(
+ (ArrayList<ClassRefCheck>) positionOptions
+ .get("classRefCheck"),
+ posGroup);
+ }
}
- else if (!checkList.isEmpty()) {
- wrapOperandInClass(node, 1, 128 + classCounter++);
- wrapOperandInClass(node, 2, 128 + classCounter++);
- posGroup = addClassRefCheck(
- (ArrayList<ClassRefCheck>) positionOptions
- .get("classRefCheck"),
- posGroup);
+ else {
+ if (!checkList.isEmpty()) {
+ posGroup = addClassRefCheck(
+ (ArrayList<ClassRefCheck>) positionOptions
+ .get("classRefCheck"),
+ posGroup);
+ }
posGroup = addClassFocus((boolean) positionOptions.get("matchall"),
posGroup);
}
@@ -576,7 +575,7 @@
// wrap in 'merge' operation if grouping option is set
if (positionOptions.containsKey("grouping")
&& (boolean) positionOptions.get("grouping")) {
- LinkedHashMap<String, Object> mergeOperation = KoralObjectGenerator
+ Map<String, Object> mergeOperation = KoralObjectGenerator
.makeGroup(KoralOperation.MERGE);
ArrayList<Object> mergeOperands = (ArrayList<Object>) mergeOperation
.get("operands");
@@ -594,7 +593,7 @@
Tree typ = prox_opts.getChild(0);
Tree dist_list = prox_opts.getChild(1);
// Step I: create group
- LinkedHashMap<String, Object> group = KoralObjectGenerator
+ Map<String, Object> group = KoralObjectGenerator
.makeGroup(KoralOperation.SEQUENCE);
ArrayList<Object> constraints = new ArrayList<Object>();
@@ -639,7 +638,7 @@
if (!meas.equals("w") && min == 0) {
processSpanDistance(meas, min, max);
}
- LinkedHashMap<String, Object> distance = KoralObjectGenerator
+ Map<String, Object> distance = KoralObjectGenerator
.makeDistance(meas, min, max);
// override @type, min/max to be treated according to
// Cosmas particularities
@@ -664,7 +663,7 @@
}
}
group.put("inOrder", inOrder);
- LinkedHashMap<String, Object> embeddedSequence = group;
+ Map<String, Object> embeddedSequence = group;
if (!(openNodeCats.get(1).equals("OPBEG")
|| openNodeCats.get(1).equals("OPEND") || inOPALL
@@ -677,7 +676,7 @@
classCounter++;
}
else if (openNodeCats.get(1).equals("OPNHIT")) {
- LinkedHashMap<String, Object> repetition = KoralObjectGenerator
+ Map<String, Object> repetition = KoralObjectGenerator
.makeRepetition(min, max);
((ArrayList<Object>) repetition.get("operands"))
.add(KoralObjectGenerator.makeToken());
@@ -687,13 +686,13 @@
// different keys, like /w4,s0?
}
- // LinkedHashMap<String, Object> sequence = null;
+ // Map<String, Object> sequence = null;
// if (putIntoOverlapDisjunction) {
// sequence = embeddedSequence;
// group = KoralObjectGenerator.makeGroup("or");
// ArrayList<Object> disjOperands =
// (ArrayList<Object>) group.get("operands");
- // LinkedHashMap<String, Object> overlapsGroup = KoralObjectGenerator
+ // Map<String, Object> overlapsGroup = KoralObjectGenerator
// .makePosition(new String[0]);
//
// ArrayList<Object> overlapsOperands =
@@ -727,7 +726,7 @@
private void processOPOR (Tree node) {
// Step I: create group
- LinkedHashMap<String, Object> disjunction = KoralObjectGenerator
+ Map<String, Object> disjunction = KoralObjectGenerator
.makeGroup(KoralOperation.DISJUNCTION);
disjunction.put("inOrder", false); // Order is not important
objectStack.push(disjunction);
@@ -740,11 +739,11 @@
private void processOPAND_OPNOT (Tree node) {
// Step I: create group
String nodeCat = getNodeCat(node);
- LinkedHashMap<String, Object> distgroup = KoralObjectGenerator
+ Map<String, Object> distgroup = KoralObjectGenerator
.makeGroup(KoralOperation.SEQUENCE);
distgroup.put("inOrder", false); // Order is not important
ArrayList<Object> distances = new ArrayList<Object>();
- LinkedHashMap<String, Object> zerodistance = KoralObjectGenerator
+ Map<String, Object> zerodistance = KoralObjectGenerator
.makeDistance("t", 0, 0);
zerodistance.put("@type", "cosmas:distance"); // overwrite @type: cosmas:distance!
if (nodeCat.equals("OPNOT"))
@@ -762,7 +761,7 @@
private void processOPLABEL (Tree node) {
// Step I: create element
String key = node.getChild(0).toStringTree().replaceAll("<|>", "");
- LinkedHashMap<String, Object> elem = KoralObjectGenerator.makeSpan(key);
+ Map<String, Object> elem = KoralObjectGenerator.makeSpan(key);
// Step II: decide where to put
putIntoSuperObject(elem);
}
@@ -772,7 +771,7 @@
@SuppressWarnings("unchecked")
private void processOPELEM (Tree node) {
// Step I: create element
- LinkedHashMap<String, Object> span = KoralObjectGenerator.makeSpan();
+ Map<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).");
@@ -793,7 +792,7 @@
span.put("key", elnameNode.getChild(0).toStringTree()
.toLowerCase());
*/
- LinkedHashMap<String, Object> fm = termToFieldMap(
+ Map<String, Object> fm = termToFieldMap(
elnameNode.getChild(0).toStringTree());
if (fm == null)
@@ -821,14 +820,14 @@
* to avoid a top-level group that only contains a
* sub-group).
*/
- LinkedHashMap<String, Object> termGroup = KoralObjectGenerator
+ Map<String, Object> termGroup = KoralObjectGenerator
.makeTermGroup(KoralTermGroupRelation.AND);
ArrayList<Object> termGroupOperands = (ArrayList<Object>) termGroup
.get("operands");
for (int i = elname; i < node.getChildCount(); i++) {
Tree attrNode = node.getChild(i);
if (attrNode.getChildCount() == 2) {
- LinkedHashMap<String, Object> term = KoralObjectGenerator
+ Map<String, Object> term = KoralObjectGenerator
.makeTerm();
termGroupOperands.add(term);
String layer = attrNode.getChild(0).toStringTree();
@@ -845,13 +844,13 @@
term.put("match", match.toString());
}
else {
- LinkedHashMap<String, Object> subTermGroup = KoralObjectGenerator
+ Map<String, Object> subTermGroup = KoralObjectGenerator
.makeTermGroup(KoralTermGroupRelation.AND);
ArrayList<Object> subTermGroupOperands = (ArrayList<Object>) subTermGroup
.get("operands");
int j;
for (j = 1; j < attrNode.getChildCount(); j++) {
- LinkedHashMap<String, Object> term = KoralObjectGenerator
+ Map<String, Object> term = KoralObjectGenerator
.makeTerm();
String layer = attrNode.getChild(0).toStringTree();
String[] splitted = layer.split("/");
@@ -883,8 +882,7 @@
// possibly only one term was present throughout all
// nodes: extract it from the group
if (termGroupOperands.size() == 1) {
- termGroup = (LinkedHashMap<String, Object>) termGroupOperands
- .get(0);
+ termGroup = (Map<String, Object>) termGroupOperands.get(0);
}
// TODO: This should be improved ...
@@ -905,9 +903,9 @@
// Step I: get info
String[] morphterms = node.getChild(0).toStringTree().replace(" ", "")
.split("&");
- LinkedHashMap<String, Object> token = KoralObjectGenerator.makeToken();
+ Map<String, Object> token = KoralObjectGenerator.makeToken();
ArrayList<Object> terms = new ArrayList<Object>();
- LinkedHashMap<String, Object> fieldMap = null;
+ Map<String, Object> fieldMap = null;
for (String morphterm : morphterms) {
@@ -924,7 +922,7 @@
}
else {
- LinkedHashMap<String, Object> termGroup = KoralObjectGenerator
+ Map<String, Object> termGroup = KoralObjectGenerator
.makeTermGroup(KoralTermGroupRelation.AND);
termGroup.put("operands", terms);
token.put("wrap", termGroup);
@@ -944,11 +942,10 @@
private void processOPWF_OPLEM (Tree node) {
String nodeCat = getNodeCat(node);
// Step I: get info
- LinkedHashMap<String, Object> token = KoralObjectGenerator.makeToken();
+ Map<String, Object> token = KoralObjectGenerator.makeToken();
objectStack.push(token);
stackedObjects++;
- LinkedHashMap<String, Object> fieldMap = KoralObjectGenerator
- .makeTerm();
+ Map<String, Object> fieldMap = KoralObjectGenerator.makeTerm();
token.put("wrap", fieldMap);
// make category-specific fieldMap entry
String attr = nodeCat.equals("OPWF") ? "orth" : "lemma";
@@ -1007,8 +1004,7 @@
* The class id.
*/
private void wrapOperandInClass (Tree node, int arg, int cls) {
- LinkedHashMap<String, Object> clsGroup = KoralObjectGenerator
- .makeSpanClass(cls);
+ Map<String, Object> clsGroup = KoralObjectGenerator.makeSpanClass(cls);
wrapOperand(node, arg, clsGroup);
}
@@ -1028,7 +1024,7 @@
* be wrapped.
*/
private void wrapOperand (Tree node, int arg,
- LinkedHashMap<String, Object> container) {
+ Map<String, Object> container) {
operandWrap.put(node, arg, container);
}
@@ -1070,7 +1066,7 @@
* @param mode
* @return
*/
- private LinkedHashMap<String, Object> processPositionCondition (Tree cond,
+ private Map<String, Object> processPositionCondition (Tree cond,
ArrayList<Object> distributedOperands, String mode) {
boolean negated = false;
String elem; // the 'span' (s/p/t)
@@ -1115,20 +1111,19 @@
// as operands, possibly wrapped in spanRefs
ArrayList<KoralFrame> frames = new ArrayList<KoralFrame>();
frames.add(position);
- LinkedHashMap<String, Object> positionGroup = KoralObjectGenerator
+ Map<String, Object> positionGroup = KoralObjectGenerator
.makePosition(frames);
if (negated)
positionGroup.put("exclude", true);
ArrayList<Object> posOperands = new ArrayList<Object>();
- LinkedHashMap<String, Object> classGroup = KoralObjectGenerator
+ Map<String, Object> classGroup = KoralObjectGenerator
.makeSpanClass(128 + classCounter++);
classGroup.put("operands", distributedOperands);
positionGroup.put("operands", posOperands);
- LinkedHashMap<String, Object> span = KoralObjectGenerator
- .makeSpan(elem);
+ Map<String, Object> span = KoralObjectGenerator.makeSpan(elem);
objectStack.push(classGroup);
if (hitSpanRef != null) {
- LinkedHashMap<String, Object> spanRefAroundHit = KoralObjectGenerator
+ Map<String, Object> spanRefAroundHit = KoralObjectGenerator
.makeSpanReference(hitSpanRef, KoralOperation.FOCUS);
((ArrayList<Object>) spanRefAroundHit.get("operands"))
.add(classGroup);
@@ -1136,7 +1131,7 @@
classGroup = spanRefAroundHit;
}
if (elemSpanRef != null) {
- LinkedHashMap<String, Object> spanRefAroundSpan = KoralObjectGenerator
+ Map<String, Object> spanRefAroundSpan = KoralObjectGenerator
.makeSpanReference(elemSpanRef, KoralOperation.FOCUS);
((ArrayList<Object>) spanRefAroundSpan.get("operands")).add(span);
// re-assign after wrapping span in spanRef
@@ -1148,13 +1143,13 @@
}
- private LinkedHashMap<String, Object> parseOPINOptions (Tree node,
+ private Map<String, Object> parseOPINOptions (Tree node,
boolean isExclusion) {
Tree posnode = getFirstChildWithCat(node, "POS");
Tree rangenode = getFirstChildWithCat(node, "RANGE");
Tree groupnode = getFirstChildWithCat(node, "GROUP");
- LinkedHashMap<String, Object> posOptions = new LinkedHashMap<String, Object>();
+ Map<String, Object> posOptions = new HashMap<String, Object>();
ArrayList<KoralFrame> positions = new ArrayList<KoralFrame>();
ArrayList<ClassRefCheck> classRefCheck = new ArrayList<ClassRefCheck>();
posOptions.put("matchall", false);
@@ -1180,7 +1175,7 @@
String range = rangenode.getChild(0).toStringTree().toLowerCase();
if (range.equals("all")) {
posOptions.put("matchall", true);
- // LinkedHashMap<String,Object> ref =
+ // Map<String,Object> ref =
// makeResetReference(); // reset all defined classes
// wrapOperand(node,2,ref);
}
@@ -1261,13 +1256,13 @@
}
- private LinkedHashMap<String, Object> parseOPOVOptions (Tree node) {
+ private Map<String, Object> parseOPOVOptions (Tree node) {
boolean negatePosition = false;
Tree posnode = getFirstChildWithCat(node, "POS");
Tree rangenode = getFirstChildWithCat(node, "RANGE");
Tree exclnode = getFirstChildWithCat(node, "EXCL");
Tree groupnode = getFirstChildWithCat(node, "GROUP");
- LinkedHashMap<String, Object> posOptions = new LinkedHashMap<String, Object>();
+ Map<String, Object> posOptions = new HashMap<String, Object>();
ArrayList<KoralFrame> positions = new ArrayList<KoralFrame>();
ArrayList<ClassRefCheck> classRefCheck = new ArrayList<ClassRefCheck>();
posOptions.put("matchall", false);
@@ -1321,7 +1316,7 @@
String range = rangenode.getChild(0).toStringTree().toLowerCase();
if (range.equals("all")) {
posOptions.put("matchall", true);
- // LinkedHashMap<String,Object> ref =
+ // Map<String,Object> ref =
// makeResetReference(); // reset all defined classes
// wrapOperand(node,2,ref);
}
@@ -1344,8 +1339,7 @@
@SuppressWarnings({ "unchecked" })
- private LinkedHashMap<String, Object> wrap (
- LinkedHashMap<String, Object>[] wrapCascade) {
+ private Map<String, Object> wrap (Map<String, Object>[] wrapCascade) {
int i;
for (i = 0; i < wrapCascade.length - 1; i++) {
ArrayList<Object> containerOperands = (ArrayList<Object>) wrapCascade[i
@@ -1375,7 +1369,7 @@
}
- private void putIntoSuperObject (LinkedHashMap<String, Object> object) {
+ private void putIntoSuperObject (Map<String, Object> object) {
putIntoSuperObject(object, 0);
}
@@ -1408,7 +1402,7 @@
}
- private LinkedHashMap<String, Object> termToFieldMap (String term) {
+ private Map<String, Object> termToFieldMap (String term) {
// regex group #2 is foundry, #4 layer, #5 operator,
// #6 key, #8 value
@@ -1422,11 +1416,11 @@
if (!m.matches()) {
addError(StatusCodes.INCOMPATIBLE_OPERATOR_AND_OPERAND,
"Something went wrong parsing the argument in MORPH() or #ELEM().");
- requestMap.put("query", new LinkedHashMap<String, Object>());
+ requestMap.put("query", new HashMap<String, Object>());
return null;
};
- LinkedHashMap<String, Object> fieldMap = null;
+ Map<String, Object> fieldMap = null;
fieldMap = KoralObjectGenerator.makeTerm();
if (m.group(2) != null)
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 e8dc203..792ba7d 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
@@ -44,7 +44,7 @@
.getLogger(PoliqarpPlusQueryProcessor.class);
private int classCounter = 1;
- LinkedHashMap<ParseTree, Integer> classWrapRegistry = new LinkedHashMap<ParseTree, Integer>();
+ Map<ParseTree, Integer> classWrapRegistry = new HashMap<ParseTree, Integer>();
/**
@@ -114,7 +114,7 @@
// in a class, e.g. by an alignment operation
if (classWrapRegistry.containsKey(node)) {
Integer classId = classWrapRegistry.get(node);
- LinkedHashMap<String, Object> spanClass = KoralObjectGenerator
+ Map<String, Object> spanClass = KoralObjectGenerator
.makeSpanClass(classId);
putIntoSuperObject(spanClass);
objectStack.push(spanClass);
@@ -221,7 +221,7 @@
// Cover possible quantification (i.e. repetition) of segment
ParseTree quantification = getFirstChildWithCat(node, "repetition");
if (quantification != null) {
- LinkedHashMap<String, Object> quantGroup = KoralObjectGenerator
+ Map<String, Object> quantGroup = KoralObjectGenerator
.makeGroup(KoralOperation.REPETITION);
Integer[] minmax = parseRepetition(quantification);
quantGroup.put("boundary",
@@ -254,7 +254,7 @@
return;
}
}
- LinkedHashMap<String, Object> sequence = KoralObjectGenerator
+ Map<String, Object> sequence = KoralObjectGenerator
.makeGroup(KoralOperation.SEQUENCE);
putIntoSuperObject(sequence);
@@ -273,8 +273,8 @@
Integer[] minmax = parseEmptySegments(node);
// object will be either a repetition group or a single empty
// token
- LinkedHashMap<String, Object> object;
- LinkedHashMap<String, Object> emptyToken = KoralObjectGenerator
+ Map<String, Object> object;
+ Map<String, Object> emptyToken = KoralObjectGenerator
.makeToken();
if (minmax[0] != 1 || minmax[1] == null || minmax[1] != 1) {
object = KoralObjectGenerator.makeRepetition(minmax[0], minmax[1]);
@@ -295,7 +295,7 @@
classId = Integer.parseInt(
node.getChild(1).getChild(0).toStringTree(parser));
}
- LinkedHashMap<String, Object> classGroup = KoralObjectGenerator
+ Map<String, Object> classGroup = KoralObjectGenerator
.makeSpanClass(classId);
addHighlightClass(classId);
putIntoSuperObject(classGroup);
@@ -305,7 +305,7 @@
private void processToken (ParseTree node) {
- LinkedHashMap<String, Object> token = KoralObjectGenerator.makeToken();
+ Map<String, Object> token = KoralObjectGenerator.makeToken();
// handle negation
List<ParseTree> negations = getChildrenWithCat(node, "!");
int termOrTermGroupChildId = 1;
@@ -318,7 +318,7 @@
if (getNodeCat(node.getChild(0)).equals("key")) {
// no 'term' child, but direct key specification: process here
- LinkedHashMap<String, Object> term = KoralObjectGenerator
+ Map<String, Object> term = KoralObjectGenerator
.makeTerm();
String key = node.getChild(0).getText();
@@ -360,7 +360,7 @@
}
else {
// child is 'term' or 'termGroup' -> process in extra method
- LinkedHashMap<String, Object> termOrTermGroup = parseTermOrTermGroup(
+ Map<String, Object> termOrTermGroup = parseTermOrTermGroup(
node.getChild(termOrTermGroupChildId), negated);
token.put("wrap", termOrTermGroup);
}
@@ -423,8 +423,8 @@
boolean negated = false;
if (negations.size() % 2 == 1)
negated = true;
- LinkedHashMap<String, Object> span = KoralObjectGenerator.makeSpan();
- LinkedHashMap<String, Object> wrappedTerm = KoralObjectGenerator
+ Map<String, Object> span = KoralObjectGenerator.makeSpan();
+ Map<String, Object> wrappedTerm = KoralObjectGenerator
.makeTerm();
span.put("wrap", wrappedTerm);
ParseTree keyNode = getFirstChildWithCat(node, "key");
@@ -457,12 +457,12 @@
wrappedTerm.put("match", KoralMatchOperator.NOT_EQUALS.toString());
}
if (termNode != null) {
- LinkedHashMap<String, Object> termOrTermGroup = parseTermOrTermGroup(
+ Map<String, Object> termOrTermGroup = parseTermOrTermGroup(
termNode, negated, "span");
span.put("attr", termOrTermGroup);
}
if (termGroupNode != null) {
- LinkedHashMap<String, Object> termOrTermGroup = parseTermOrTermGroup(
+ Map<String, Object> termOrTermGroup = parseTermOrTermGroup(
termGroupNode, negated, "span");
span.put("attr", termOrTermGroup);
}
@@ -473,7 +473,7 @@
private void processDisjunction (ParseTree node) {
- LinkedHashMap<String, Object> disjunction = KoralObjectGenerator
+ Map<String, Object> disjunction = KoralObjectGenerator
.makeGroup(KoralOperation.DISJUNCTION);
putIntoSuperObject(disjunction);
objectStack.push(disjunction);
@@ -482,7 +482,7 @@
private void processPosition (ParseTree node) {
- LinkedHashMap<String, Object> position = parseFrame(node.getChild(0));
+ Map<String, Object> position = parseFrame(node.getChild(0));
putIntoSuperObject(position);
objectStack.push(position);
stackedObjects++;
@@ -490,11 +490,11 @@
private void processRelation (ParseTree node) {
- LinkedHashMap<String, Object> relationGroup = KoralObjectGenerator
+ Map<String, Object> relationGroup = KoralObjectGenerator
.makeGroup(KoralOperation.RELATION);
- LinkedHashMap<String, Object> relation = KoralObjectGenerator
+ Map<String, Object> relation = KoralObjectGenerator
.makeRelation();
- LinkedHashMap<String, Object> term = KoralObjectGenerator.makeTerm();
+ Map<String, Object> term = KoralObjectGenerator.makeTerm();
relationGroup.put("relation", relation);
relation.put("wrap", term);
if (node.getChild(0).getText().equals("dominates")) {
@@ -543,7 +543,7 @@
addError(StatusCodes.INVALID_CLASS_REFERENCE, msg);
}
}
- LinkedHashMap<String, Object> classGroup = KoralObjectGenerator
+ Map<String, Object> classGroup = KoralObjectGenerator
.makeSpanClass(classId);
addHighlightClass(classId);
putIntoSuperObject(classGroup);
@@ -580,7 +580,7 @@
else {
classRefs.add(1); // default
}
- LinkedHashMap<String, Object> referenceGroup = KoralObjectGenerator
+ Map<String, Object> referenceGroup = KoralObjectGenerator
.makeReference(classRefs);
String type = node.getChild(0).toStringTree(parser);
@@ -601,7 +601,7 @@
private void processSubmatch (ParseTree node) {
- LinkedHashMap<String, Object> submatch = KoralObjectGenerator
+ Map<String, Object> submatch = KoralObjectGenerator
.makeReference(null);
submatch.put("operands", new ArrayList<Object>());
ParseTree startpos = getFirstChildWithCat(node, "startpos");
@@ -641,13 +641,13 @@
private void processWithin (ParseTree node) {
ParseTree domainNode = node.getChild(1);
String domain = getNodeCat(domainNode);
- LinkedHashMap<String, Object> span = KoralObjectGenerator
+ Map<String, Object> span = KoralObjectGenerator
.makeSpan(domain);
- LinkedHashMap<String, Object> queryObj = (LinkedHashMap<String, Object>) requestMap
+ Map<String, Object> queryObj = (Map<String, Object>) requestMap
.get("query");
ArrayList<KoralFrame> frames = new ArrayList<KoralFrame>();
frames.add(KoralFrame.IS_AROUND);
- LinkedHashMap<String, Object> contains = KoralObjectGenerator
+ Map<String, Object> contains = KoralObjectGenerator
.makePosition(frames);
ArrayList<Object> operands = (ArrayList<Object>) contains
.get("operands");
@@ -719,7 +719,7 @@
}
- private LinkedHashMap<String, Object> parseFrame (ParseTree node) {
+ private Map<String, Object> parseFrame (ParseTree node) {
String operator = node.toStringTree(parser).toLowerCase();
ArrayList<KoralFrame> frames = new ArrayList<KoralFrame>();
switch (operator) {
@@ -746,7 +746,7 @@
}
- private LinkedHashMap<String, Object> parseTermOrTermGroup (ParseTree node,
+ private Map<String, Object> parseTermOrTermGroup (ParseTree node,
boolean negated) {
return parseTermOrTermGroup(node, negated, "token");
}
@@ -767,7 +767,7 @@
* @return A term or termGroup object, depending on input
*/
@SuppressWarnings("unchecked")
- private LinkedHashMap<String, Object> parseTermOrTermGroup (ParseTree node,
+ private Map<String, Object> parseTermOrTermGroup (ParseTree node,
boolean negatedGlobal, String mode) {
String nodeCat = getNodeCat(node);
@@ -781,7 +781,7 @@
};
String key = null;
- LinkedHashMap<String, Object> term = KoralObjectGenerator
+ Map<String, Object> term = KoralObjectGenerator
.makeTerm();
// handle negation
boolean negated = negatedGlobal;
@@ -875,7 +875,7 @@
// For termGroups, establish a boolean relation between
// operands and recursively call this function with
// the term or termGroup operands
- LinkedHashMap<String, Object> termGroup = null;
+ Map<String, Object> termGroup = null;
ParseTree leftOp = null;
ParseTree rightOp = null;
// check for leading/trailing parantheses
@@ -919,7 +919,7 @@
* @param object
* The object to be inserted
*/
- private void putIntoSuperObject (LinkedHashMap<String, Object> object) {
+ private void putIntoSuperObject (Map<String, Object> object) {
putIntoSuperObject(object, 0);
}
@@ -939,7 +939,7 @@
* the stack is the super object.
*/
@SuppressWarnings({ "unchecked" })
- private void putIntoSuperObject (LinkedHashMap<String, Object> object,
+ private void putIntoSuperObject (Map<String, Object> object,
int objStackPosition) {
if (objectStack.size() > objStackPosition) {
ArrayList<Object> topObjectOperands = (ArrayList<Object>) objectStack
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..f5f7819 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
@@ -42,7 +42,7 @@
public static String queryLanguageVersion;
private AbstractQueryProcessor ast;
- private Map<String, Object> collection = new LinkedHashMap<>();
+ private Map<String, Object> collection = new HashMap<>();
private Map<String, Object> meta;
private List<Object> errors;
private List<Object> warnings;
@@ -251,7 +251,7 @@
return collection1;
}
else {
- LinkedHashMap<String, Object> docGroup = KoralObjectGenerator
+ Map<String, Object> docGroup = KoralObjectGenerator
.makeDocGroup("and");
ArrayList<Object> operands = (ArrayList<Object>) docGroup
.get("operands");
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 8fbb7fc..6949812 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
@@ -2,9 +2,9 @@
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
+import java.util.HashMap;
import java.util.Map;
+import java.util.List;
import de.ids_mannheim.korap.query.object.ClassRefCheck;
import de.ids_mannheim.korap.query.object.ClassRefOp;
@@ -16,41 +16,40 @@
public class KoralObjectGenerator {
- protected static final Integer MAXIMUM_DISTANCE = 100;
+ private static final Integer MAXIMUM_DISTANCE = 100;
private static AbstractQueryProcessor qp;
-
public static void setQueryProcessor (AbstractQueryProcessor qp) {
KoralObjectGenerator.qp = qp;
}
- public static LinkedHashMap<String, Object> makeSpan () {
- LinkedHashMap<String, Object> span = new LinkedHashMap<String, Object>();
+ public static Map<String, Object> makeSpan () {
+ Map<String, Object> span = new HashMap<String, Object>();
span.put("@type", KoralType.SPAN.toString());
return span;
}
- public static LinkedHashMap<String, Object> makeSpan (String key) {
- LinkedHashMap<String, Object> span = new LinkedHashMap<String, Object>();
+ public static Map<String, Object> makeSpan (String key) {
+ Map<String, Object> span = new HashMap<String, Object>();
span.put("@type", KoralType.SPAN.toString());
- LinkedHashMap<String, Object> term = makeTerm();
+ Map<String, Object> term = makeTerm();
term.put("key", key);
span.put("wrap", term);
return span;
}
- public static LinkedHashMap<String, Object> makeTerm () {
- LinkedHashMap<String, Object> term = new LinkedHashMap<String, Object>();
+ public static Map<String, Object> makeTerm () {
+ Map<String, Object> term = new HashMap<String, Object>();
term.put("@type", KoralType.TERM.toString());
return term;
}
- public static LinkedHashMap<String, Object> makeTermGroup (KoralTermGroupRelation relation) {
- LinkedHashMap<String, Object> term = new LinkedHashMap<String, Object>();
+ public static Map<String, Object> makeTermGroup (KoralTermGroupRelation relation) {
+ Map<String, Object> term = new HashMap<String, Object>();
term.put("@type", KoralType.TERMGROUP.toString());
term.put("relation", relation.toString());
term.put("operands", new ArrayList<Object>());
@@ -58,15 +57,15 @@
}
- public static LinkedHashMap<String, Object> makeDoc () {
- LinkedHashMap<String, Object> term = new LinkedHashMap<String, Object>();
+ public static Map<String, Object> makeDoc () {
+ Map<String, Object> term = new HashMap<String, Object>();
term.put("@type", KoralType.DOCUMENT.toString());
return term;
}
- public static LinkedHashMap<String, Object> makeDocGroup (String relation) {
- LinkedHashMap<String, Object> term = new LinkedHashMap<String, Object>();
+ public static Map<String, Object> makeDocGroup (String relation) {
+ Map<String, Object> term = new HashMap<String, Object>();
term.put("@type", KoralType.DOCUMENTGROUP.toString());
term.put("operation", "operation:" + relation);
term.put("operands", new ArrayList<Object>());
@@ -74,15 +73,15 @@
}
- public static LinkedHashMap<String, Object> makeToken () {
- LinkedHashMap<String, Object> token = new LinkedHashMap<String, Object>();
+ public static Map<String, Object> makeToken () {
+ Map<String, Object> token = new HashMap<String, Object>();
token.put("@type", KoralType.TOKEN.toString());
return token;
}
- public static LinkedHashMap<String, Object> makeGroup (KoralOperation operation) {
- LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+ public static Map<String, Object> makeGroup (KoralOperation operation) {
+ Map<String, Object> group = new HashMap<String, Object>();
group.put("@type", KoralType.GROUP.toString());
group.put("operation", operation.toString());
group.put("operands", new ArrayList<Object>());
@@ -90,17 +89,17 @@
}
- public static LinkedHashMap<String, Object> makeRepetition (Integer min,
+ public static Map<String, Object> makeRepetition (Integer min,
Integer max) {
- LinkedHashMap<String, Object> group = makeGroup(KoralOperation.REPETITION);
+ Map<String, Object> group = makeGroup(KoralOperation.REPETITION);
group.put("boundary", makeBoundary(min, max));
return group;
}
@Deprecated
- public static LinkedHashMap<String, Object> makePosition (KoralFrame frame) {
- LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+ public static Map<String, Object> makePosition (KoralFrame frame) {
+ Map<String, Object> group = new HashMap<String, Object>();
group.put("@type", KoralType.GROUP.toString());
group.put("operation", KoralOperation.POSITION.toString());
group.put("frame", frame.toString());
@@ -109,9 +108,9 @@
}
- public static LinkedHashMap<String, Object> makePosition (
+ public static Map<String, Object> makePosition (
List<KoralFrame> allowedFrames) {
- LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+ Map<String, Object> group = new HashMap<String, Object>();
group.put("@type", KoralType.GROUP.toString());
group.put("operation", KoralOperation.POSITION.toString());
group.put("frames", Converter.enumListToStringList(allowedFrames));
@@ -119,15 +118,15 @@
return group;
}
- public static LinkedHashMap<String, Object> makeSpanClass (int classId) {
+ public static Map<String, Object> makeSpanClass (int classId) {
return makeSpanClass(classId, false);
}
@Deprecated
- public static LinkedHashMap<String, Object> makeSpanClass (int classId,
+ public static Map<String, Object> makeSpanClass (int classId,
boolean setBySystem) {
- LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+ Map<String, Object> group = new HashMap<String, Object>();
group.put("@type", KoralType.GROUP.toString());
group.put("operation", KoralOperation.CLASS.toString());
if (setBySystem) {
@@ -142,9 +141,9 @@
}
- public static LinkedHashMap<String, Object> makeClassRefCheck (
+ public static Map<String, Object> makeClassRefCheck (
ArrayList<ClassRefCheck> checks, Integer[] classIn, int classOut) {
- LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+ Map<String, Object> group = new HashMap<String, Object>();
group.put("@type", KoralType.GROUP.toString());
group.put("operation", KoralOperation.CLASS.toString());
group.put("classRefCheck", Converter.enumListToStringList(checks));
@@ -155,9 +154,9 @@
}
- public static LinkedHashMap<String, Object> makeClassRefOp (
+ public static Map<String, Object> makeClassRefOp (
ClassRefOp operation, Integer[] classIn, int classOut) {
- LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+ Map<String, Object> group = new HashMap<String, Object>();
group.put("@type", KoralType.GROUP.toString());
group.put("operation", KoralOperation.CLASS.toString());
group.put("classRefOp", operation.toString());
@@ -169,8 +168,8 @@
// @Deprecated
-// public static LinkedHashMap<String, Object> makeTreeRelation (String reltype) {
-// LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+// public static Map<String, Object> makeTreeRelation (String reltype) {
+// Map<String, Object> group = new HashMap<String, Object>();
// group.put("@type", "koral:treeRelation");
// if (reltype != null)
// group.put("reltype", reltype);
@@ -178,16 +177,16 @@
// }
- public static LinkedHashMap<String, Object> makeRelation () {
- LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+ public static Map<String, Object> makeRelation () {
+ Map<String, Object> group = new HashMap<String, Object>();
group.put("@type", KoralType.RELATION.toString());
return group;
}
- public static LinkedHashMap<String, Object> makeBoundary (Integer min,
+ public static Map<String, Object> makeBoundary (Integer min,
Integer max) {
- LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+ Map<String, Object> group = new HashMap<String, Object>();
group.put("@type", KoralType.BOUNDARY.toString());
group.put("min", min);
if (max != null) {
@@ -197,9 +196,9 @@
}
- public static LinkedHashMap<String, Object> makeDistance (String key,
+ public static Map<String, Object> makeDistance (String key,
Integer min, Integer max) {
- LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+ Map<String, Object> group = new HashMap<String, Object>();
if (key.equals("w")) {
group.put("@type", KoralType.DISTANCE.toString());
}
@@ -219,9 +218,9 @@
}
- public static LinkedHashMap<String, Object> makeReference (
+ public static Map<String, Object> makeReference (
ArrayList<Integer> classRefs, KoralOperation operation) {
- LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+ Map<String, Object> group = new HashMap<String, Object>();
group.put("@type", KoralType.REFERENCE.toString());
group.put("operation", operation.toString());
if (classRefs != null && !classRefs.isEmpty()) {
@@ -231,14 +230,14 @@
}
- public static LinkedHashMap<String, Object> makeReference (
+ public static Map<String, Object> makeReference (
ArrayList<Integer> classRefs) {
return makeReference(classRefs, KoralOperation.FOCUS);
}
@Deprecated
- public static LinkedHashMap<String, Object> makeReference (int classRef,
+ public static Map<String, Object> makeReference (int classRef,
KoralOperation operation, boolean setBySystem) {
ArrayList<Integer> classRefs = new ArrayList<Integer>();
if (setBySystem)
@@ -249,7 +248,7 @@
@Deprecated
- public static LinkedHashMap<String, Object> makeReference (int classRef,
+ public static Map<String, Object> makeReference (int classRef,
boolean setBySystem) {
ArrayList<Integer> classRefs = new ArrayList<Integer>();
if (setBySystem)
@@ -259,14 +258,14 @@
}
- public static LinkedHashMap<String, Object> makeReference (int classRef) {
+ public static Map<String, Object> makeReference (int classRef) {
return makeReference(classRef, false);
}
@Deprecated
- public static LinkedHashMap<String, Object> makeResetReference () {
- LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+ public static Map<String, Object> makeResetReference () {
+ Map<String, Object> group = new HashMap<String, Object>();
group.put("@type", KoralType.REFERENCE.toString());
group.put("operation", KoralOperation.FOCUS.toString());
group.put("reset", true);
@@ -275,9 +274,9 @@
}
- public static LinkedHashMap<String, Object> makeSpanReference (
+ public static Map<String, Object> makeSpanReference (
Integer[] spanRef, KoralOperation operation) {
- LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+ Map<String, Object> group = new HashMap<String, Object>();
group.put("@type", KoralType.REFERENCE.toString());
group.put("operation", operation.toString());
group.put("spanRef", Arrays.asList(spanRef));
@@ -286,7 +285,7 @@
}
- public static void addOperandsToGroup (LinkedHashMap<String, Object> group) {
+ public static void addOperandsToGroup (Map<String, Object> group) {
ArrayList<Object> operands = new ArrayList<Object>();
group.put("operands", operands);
}
@@ -294,7 +293,7 @@
public static Map<String, Object> wrapInReference (
Map<String, Object> group, Integer classId) {
- LinkedHashMap<String, Object> refGroup = makeReference(classId);
+ Map<String, Object> refGroup = makeReference(classId);
ArrayList<Object> operands = new ArrayList<Object>();
operands.add(group);
refGroup.put("operands", operands);
@@ -303,10 +302,10 @@
@Deprecated
- public static LinkedHashMap<String, Object> wrapInReference (
- LinkedHashMap<String, Object> group, Integer classId,
+ public static Map<String, Object> wrapInReference (
+ Map<String, Object> group, Integer classId,
boolean setBySystem) {
- LinkedHashMap<String, Object> refGroup = makeReference(classId);
+ Map<String, Object> refGroup = makeReference(classId);
ArrayList<Object> operands = new ArrayList<Object>();
operands.add(group);
refGroup.put("operands", operands);