ProximityDFRTraversal extends Traversal { @Override public Node afterNode(Node original, Parameters queryParams) throws Exception { if (original.getOperator().equals("pdfr")) { boolean sequential = queryParams.get("pdfrSeq", this.sequentialDefault); double tw = queryParams.get("termLambda", twDefault); double c = queryParams.get("c", cDefault); double pw = 1.0 - tw ; double cp = queryParams.get("cp", cpDefault); String termScoringModel = queryParams.get("pdfrTerm", termScoringModelDefault); String proxScoringModel = queryParams.get("pdfrProx", proxScoringModelDefault); int windowSize = (int) queryParams.get("windowSize", windowSizeDefault); Node root = new Node("combine"); root.getNodeParameters().set("norm", false); root.getNodeParameters().set("0", tw); root.getNodeParameters().set("1", pw); Node unigramNode = new Node("combine"); for (int i = 0; i < original.numChildren(); i++) { Node scorer = new Node(termScoringModel); scorer.getNodeParameters().set("c", c); scorer.addChild(StructuredQuery.parse("#lengths:document:part=lengths()")); scorer.addChild(original.getChild(i)); unigramNode.addChild(scorer); } root.addChild(unigramNode); if (original.numChildren() > 1) { Node proxNode; if (sequential) { proxNode = createSequentialProxNode(original.getInternalNodes(), proxScoringModel, cp, windowSize); } else { proxNode = createFullProxNode(original.getInternalNodes(), proxScoringModel, cp, windowSize); } root.addChild(proxNode); } return root; } return original; } ProximityDFRTraversal(Retrieval ret);  ProximityDFRTraversal(Parameters p); @Override void beforeNode(Node object, Parameters qp); @Override Node afterNode(Node original, Parameters queryParams);  }
@Test public void testSomeMethod() throws Exception { Parameters qparams = Parameters.create(); qparams.set("termLambda", 0.91); ProximityDFRTraversal traversal = new ProximityDFRTraversal(Parameters.create()); Node pl2root = StructuredQuery.parse("#pdfr( test query )"); Node out = traversal.afterNode(pl2root, qparams); Node exp = StructuredQuery.parse("#combine:0=0.91:1=0.08999999999999997:norm=false( #combine( " + "#pl2:c=6.0( #lengths:document:part=lengths() #text:test() ) " + "#pl2:c=6.0( #lengths:document:part=lengths() #text:query() ) ) " + "#combine( " + "#bil2:c=0.05( #lengths:document:part=lengths() #ordered:5( #text:test() #text:query() ) ) ) )"); assertEquals(out.toString(), exp.toString()); }