All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dmg.pmml.tree.DefaultNodeTransformer Maven / Gradle / Ivy

There is a newer version: 1.6.5
Show newest version
/*
 * Copyright (c) 2019 Villu Ruusmann
 */
package org.dmg.pmml.tree;

public class DefaultNodeTransformer implements NodeTransformer {

	@Override
	public Node fromComplexNode(ComplexNode complexNode){

		if(complexNode.hasExtensions() || (complexNode.getPartition() != null) || (complexNode.getEmbeddedModel() != null)){
			return complexNode;
		} // End if

		if(complexNode.hasScoreDistributions()){
			return new ClassifierNode(complexNode);
		}

		Number recordCount = complexNode.getRecordCount();

		if(complexNode.hasNodes()){

			if(recordCount != null){
				return new CountingBranchNode(complexNode);
			} else

			{
				return new BranchNode(complexNode);
			}
		} else

		{
			if(recordCount != null){
				return new CountingLeafNode(complexNode);
			} else

			{
				return new LeafNode(complexNode);
			}
		}
	}

	@Override
	public ComplexNode toComplexNode(Node node){

		if(node instanceof ComplexNode){
			ComplexNode complexNode = (ComplexNode)node;

			return complexNode;
		}

		ComplexNode complexNode = new ComplexNode(node);

		return complexNode;
	}

	public static final DefaultNodeTransformer INSTANCE = new DefaultNodeTransformer();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy