@Override public VisitorAction visit(Node node){ if(node.hasNodes()){ List<Node> nodes = node.getNodes(); Collections.sort(nodes, NodeSorter.COMPARATOR); } return super.visit(node); }
@Override public VisitorAction visit(Node node){ if(node.hasNodes()){ List<Node> nodes = node.getNodes(); Collections.sort(nodes, NodeSorter.COMPARATOR); } return super.visit(node); }
@Override public void enterNode(Node node){ if(node.hasNodes()){ List<Node> children = node.getNodes(); children: while(true){ ListIterator<Node> childIt = children.listIterator(); grandChildren: while(childIt.hasNext()){ Node child = childIt.next(); Iterator<Node> grandChildIt = getChildren(child); if(grandChildIt == null){ continue grandChildren; } childIt.remove(); while(grandChildIt.hasNext()){ Node grandChild = grandChildIt.next(); grandChildIt.remove(); childIt.add(grandChild); } childIt.add(child); continue children; } break; } } }
@Override public VisitorAction visit(Node node){ if(!node.hasNodes()){ process(node); } return super.visit(node); }
@Override public VisitorAction visit(Node node){ if(!node.hasNodes()){ process(node); } return super.visit(node); }
private ImmutableBiMap.Builder<String, Node> collectNodes(Node node, AtomicInteger index, ImmutableBiMap.Builder<String, Node> builder){ builder = EntityUtil.put(node, index, builder); if(!node.hasNodes()){ return builder; } List<Node> children = node.getNodes(); for(Node child : children){ builder = collectNodes(child, index, builder); } return builder; } });
if(node.hasNodes()){ List<Node> children = node.getNodes();
if(node.hasNodes()){ List<Node> children = node.getNodes();
if(node.hasNodes()){ List<Node> children = node.getNodes();
private Trail handleTrue(Trail trail, Node node, EvaluationContext context){ // A "true" leaf node if(!node.hasNodes()){ return trail.selectNode(node); } trail.push(node); List<Node> children = node.getNodes(); for(int i = 0, max = children.size(); i < max; i++){ Node child = children.get(i); Boolean status = evaluateNode(trail, child, context); if(status == null){ Trail destination = handleMissingValue(trail, node, child, context); if(destination != null){ return destination; } } else if(status.booleanValue()){ return handleTrue(trail, child, context); } } // A "true" non-leaf node return handleNoTrueChild(trail); }
if(node.hasNodes()){ List<Node> children = node.getNodes();
@Override public void exitNode(Node node){ Predicate predicate = node.getPredicate(); if(predicate instanceof True){ Node parentNode = getParentNode(); if(parentNode == null){ return; } if((MiningFunction.REGRESSION).equals(this.miningFunction)){ initScore(parentNode, node); replaceChildWithGrandchildren(parentNode, node); } else if((MiningFunction.CLASSIFICATION).equals(this.miningFunction)){ // Replace intermediate nodes, but not terminal nodes if(node.hasNodes()){ replaceChildWithGrandchildren(parentNode, node); } } else { throw new IllegalArgumentException(); } } }
if(node.hasNodes()){ List<Node> children = node.getNodes();
@Override public void exitNode(Node node){ Predicate predicate = node.getPredicate(); if(predicate instanceof True){ Node parentNode = getParentNode(); if(parentNode == null){ return; } if((MiningFunction.REGRESSION).equals(this.miningFunction)){ initScore(parentNode, node); replaceChildWithGrandchildren(parentNode, node); } else if((MiningFunction.CLASSIFICATION).equals(this.miningFunction)){ // Replace intermediate nodes, but not terminal nodes if(node.hasNodes()){ replaceChildWithGrandchildren(parentNode, node); } } else { throw new IllegalArgumentException(); } } }
if(node.hasNodes()){ List<Node> children = node.getNodes();
if(node.hasNodes()){ List<Node> children = node.getNodes();
static public ComplexNode toComplexNode(Node node){ ComplexNode result = new ComplexNode() .setId(node.getId()) .setScore(node.getScore()) .setRecordCount(node.getRecordCount()) .setDefaultChild(node.getDefaultChild()) .setPredicate(node.getPredicate()); if(node.hasNodes()){ (result.getNodes()).addAll(node.getNodes()); } // End if if(node.hasScoreDistributions()){ (result.getScoreDistributions()).addAll(node.getScoreDistributions()); } return result; } }
if(node.hasNodes()){ (value.getNodes()).addAll(node.getNodes());
if(node.hasNodes()){ (value.getNodes()).addAll(node.getNodes());