korap:reference in Poliqarp+, focus() instead of shrink()
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
index 51ec0f0..67cef8c 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
@@ -740,11 +740,10 @@
             }
         }
 
-        if (nodeCat.equals("shrink")) {
-            LinkedHashMap<String, Object> shrinkGroup = new LinkedHashMap<String, Object>();
-            objectStack.push(shrinkGroup);
+        if (nodeCat.equals("focus")) {
+            
             stackedObjects++;
-            ArrayList<Object> shrinkOperands = new ArrayList<Object>();
+            ArrayList<Object> referenceOperands = new ArrayList<Object>();
             // Step I: get info
             ArrayList<Integer> classRefs = new ArrayList<Integer>();
             String classRefOp = null;
@@ -770,26 +769,25 @@
             } else {
                 classRefs.add(0);
             }
-            shrinkGroup.put("@type", "korap:group");
+            LinkedHashMap<String, Object> referenceGroup = makeReference(classRefs);
+            objectStack.push(referenceGroup);
             String type = node.getChild(0).toStringTree(parser);
-            String operation = type.equals("shrink") ? "submatch" : "split";
-            shrinkGroup.put("operation", "operation:" + operation);
-            shrinkGroup.put("classRef", classRefs);
+            if (type.equals("split")) referenceGroup.put("operation", "operation:split");
             if (classRefOp != null) {
-                shrinkGroup.put("classRefOp", "classRefOp:" + classRefOp);
+                referenceGroup.put("classRefOp", "classRefOp:" + classRefOp);
             }
-            shrinkGroup.put("operands", shrinkOperands);
+            referenceGroup.put("operands", referenceOperands);
             int i = 1;
             // Step II: decide where to put the group
             // add group to sequence only if it is not an only child (in that case, sq_segments has already added the info and is just waiting for the relevant info)
             if (node.getParent().getChildCount() > 1) {
                 ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(i).get("operands"); // this shrinkGroup is on top
-                topSequenceOperands.add(shrinkGroup);
+                topSequenceOperands.add(referenceGroup);
             } else if (openNodeCats.get(2).equals("query")) {
-                requestMap.put("query", shrinkGroup);
+                requestMap.put("query", referenceGroup);
             } else if (objectStack.size() > 1) {
                 ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(i).get("operands");
-                topSequenceOperands.add(shrinkGroup);
+                topSequenceOperands.add(referenceGroup);
             }
             visited.add(node.getChild(0));
         }
@@ -1003,9 +1001,9 @@
 		 * For testing
 		 */
         String[] queries = new String[]{
-                "shrink(1|2:{1:[base=der]}{2:[base=Mann]})",
+                "focus(1|2:{1:[base=der]}{2:[base=Mann]})",
                 "{[base=Mann]}",
-                "shrink(1:[orth=Der]{1:[orth=Mann][orth=geht]})",
+                "focus(1:[orth=Der]{1:[orth=Mann][orth=geht]})",
                 "[base=Mann/i]",
                 "[cnx/base=pos:n]",
                 "<cnx/c=np>",
@@ -1016,11 +1014,12 @@
                 "[base=der] within s",
                 "([orth=der][base=katze])|([orth=eine][base=baum])",
                 "[orth=der][base=katze]|[orth=eine][base=baum]",
-                "shrink(1:{[base=der]}{1:[pos=ADJA]})",
+                "focus(1:{[base=der]}{1:[pos=ADJA]})",
                 "[mate/m : tense=pres]",
                 "[cnx/base=pos:n]",
                 "deutscher/i",
-                "[orth=deutscher/i]"
+                "[orth=deutscher/i]",
+                "deutscher Bundestag/i"
         };
 		PoliqarpPlusTree.verbose=true;
         for (String q : queries) {
diff --git a/src/test/java/PoliqarpPlusTreeTest.java b/src/test/java/PoliqarpPlusTreeTest.java
index 9da4cfc..28dd0cf 100644
--- a/src/test/java/PoliqarpPlusTreeTest.java
+++ b/src/test/java/PoliqarpPlusTreeTest.java
@@ -88,6 +88,16 @@
 		ppt = new PoliqarpPlusTree(query);
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(cs4.replaceAll(" ", ""), map.replaceAll(" ", ""));
+		
+		query="deutscher Bundestag/i";
+		String cs5 = 
+				"{@type=korap:group, operation=operation:sequence, operands=[" +
+						"{@type=korap:token, wrap={@type=korap:term, key=deutscher, layer=orth, match=match:eq}}," +
+						"{@type=korap:token, wrap={@type=korap:term, key=Bundestag, layer=orth, match=match:eq, caseInsensitive=true}}" +
+					"]}";
+		ppt = new PoliqarpPlusTree(query);
+		map = ppt.getRequestMap().get("query").toString();
+		assertEquals(cs5.replaceAll(" ", ""), map.replaceAll(" ", ""));
 	}
 	
 	@Test
@@ -707,7 +717,7 @@
 	public void testShrinkSplit() throws QueryException {
 		// shrink([orth=Der]{[orth=Mann]})
 		String shr1 = 
-			"{@type=korap:group, operation=operation:submatch, classRef=[0], operands=[" +
+			"{@type=korap:reference, classRef=[0], operands=[" +
 				"{@type=korap:group, operation=operation:sequence, operands=[" +
 					"{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}," +
 					"{@type=korap:group, operation=operation:class, class=0, operands=[" +
@@ -715,13 +725,13 @@
 					"]}" +
 				"]}" +
 			"]}";
-		ppt = new PoliqarpPlusTree("shrink([orth=Der]{[orth=Mann]})");
+		ppt = new PoliqarpPlusTree("focus([orth=Der]{[orth=Mann]})");
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(shr1.replaceAll(" ", ""), map.replaceAll(" ", ""));
 		
 		// shrink([orth=Der]{[orth=Mann][orth=geht]})
 		String shr2 = 
-			"{@type=korap:group, operation=operation:submatch, classRef=[0], operands=[" +
+			"{@type=korap:reference, classRef=[0], operands=[" +
 				"{@type=korap:group, operation=operation:sequence, operands=[" +
 					"{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}," +
 					"{@type=korap:group, operation=operation:class, class=0, operands=[" +
@@ -732,13 +742,13 @@
 					"]}" +
 				"]}" +
 			"]}";
-		ppt = new PoliqarpPlusTree("shrink([orth=Der]{[orth=Mann][orth=geht]})");
+		ppt = new PoliqarpPlusTree("focus([orth=Der]{[orth=Mann][orth=geht]})");
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(shr2.replaceAll(" ", ""), map.replaceAll(" ", ""));
 		
 		// shrink(1:[orth=Der]{1:[orth=Mann][orth=geht]})
 		String shr3 = 
-			"{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
+			"{@type=korap:reference, classRef=[1], operands=[" +
 				"{@type=korap:group, operation=operation:sequence, operands=[" +
 					"{@type=korap:token, wrap={@type=korap:term, key=Der, layer=orth, match=match:eq}}," +
 					"{@type=korap:group, operation=operation:class, class=1, operands=[" +
@@ -749,13 +759,13 @@
 					"]}" +
 				"]}" +
 			"]}";
-		ppt = new PoliqarpPlusTree("shrink(1:[orth=Der]{1:[orth=Mann][orth=geht]})");
+		ppt = new PoliqarpPlusTree("focus(1:[orth=Der]{1:[orth=Mann][orth=geht]})");
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(shr3.replaceAll(" ", ""), map.replaceAll(" ", ""));
 		
 		// shrink(1:startswith(<s>,{1:<np>}))
 		String shr4 = 
-			"{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
+			"{@type=korap:reference, classRef=[1], operands=[" +
 				"{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
 					"{@type=korap:span, key=s}," +
 					"{@type=korap:group, operation=operation:class, class=1, operands=[" +
@@ -763,13 +773,13 @@
 					"]}" +
 				"]}" +
 			"]}";
-		ppt = new PoliqarpPlusTree("shrink(1:startswith(<s>,{1:<np>}))");
+		ppt = new PoliqarpPlusTree("focus(1:startswith(<s>,{1:<np>}))");
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(shr4.replaceAll(" ", ""), map.replaceAll(" ", ""));
 		
 		// shrink(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) 
 		String shr5 = 
-			"{@type=korap:group, operation=operation:submatch, classRef=[3], operands=[" +
+			"{@type=korap:reference, classRef=[3], operands=[" +
 				"{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
 					"{@type=korap:span, key=s}," +
 					"{@type=korap:group, operation=operation:class, class=3, operands=[" +
@@ -787,13 +797,13 @@
 					"]}" +
 				"]}" +
 			"]}";
-		ppt = new PoliqarpPlusTree("shrink(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
+		ppt = new PoliqarpPlusTree("focus(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(shr5.replaceAll(" ", ""), map.replaceAll(" ", ""));
 		
 		// split(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) 
 		String shr6 = 
-			"{@type=korap:group, operation=operation:split, classRef=[3], operands=[" +
+			"{@type=korap:reference, classRef=[3], operation=operation:split, operands=[" +
 				"{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
 					"{@type=korap:span, key=s}," +
 					"{@type=korap:group, operation=operation:class, class=3, operands=[" +
@@ -817,7 +827,7 @@
 		
 		// split(2|3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) 
 		String shr7 = 
-			"{@type=korap:group, operation=operation:split, classRef=[2, 3], classRefOp=classRefOp:intersection, operands=[" +
+			"{@type=korap:reference, classRef=[2, 3], operation=operation:split, classRefOp=classRefOp:intersection, operands=[" +
 				"{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
 					"{@type=korap:span, key=s}," +
 					"{@type=korap:group, operation=operation:class, class=3, operands=[" +
@@ -841,7 +851,7 @@
 		
 		
 		String shr8 = 
-			"{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
+			"{@type=korap:reference, classRef=[1], operands=[" +
 				"{@type=korap:group, operation=operation:sequence, operands=[" +
 					"{@type=korap:group, operation=operation:class, class=0, operands=[" +
 						"{@type=korap:token, wrap={@type=korap:term, key=der, layer=lemma, match=match:eq}}" +
@@ -851,7 +861,7 @@
 					"]}" +
 				"]}" +
 			"]}";
-		ppt = new PoliqarpPlusTree("shrink(1:{[base=der]}{1:[pos=ADJA]})");
+		ppt = new PoliqarpPlusTree("focus(1:{[base=der]}{1:[pos=ADJA]})");
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(shr8.replaceAll(" ", ""), map.replaceAll(" ", ""));