
treelib.Node Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pmml-python Show documentation
Show all versions of pmml-python Show documentation
JPMML Python to PMML converter
/*
* Copyright (c) 2022 Villu Ruusmann
*
* This file is part of JPMML-Python
*
* JPMML-Python is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* JPMML-Python is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with JPMML-Python. If not, see .
*/
package treelib;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.jpmml.python.PythonObject;
public class Node extends PythonObject {
public Node(String module, String name){
super(module, name);
}
public Node selectPredecessor(Tree tree){
Map predecessor = getPredecessor();
Integer identifier = (Integer)predecessor.get(tree.getIdentifier());
return tree.selectNode(identifier);
}
public List selectSuccessors(Tree tree){
Map successors = getSuccessors();
Collection identifiers = (Collection)successors.get(tree.getIdentifier());
if(identifiers == null){
return Collections.emptyList();
}
return tree.selectNodes(identifiers);
}
public Boolean getExpanded(){
return getBoolean("expanded");
}
public Integer getIdentifier(){
return getInteger("_identifier");
}
public Map getPredecessor(){
return getDict("_predecessor");
}
public Map getSuccessors(){
return getDict("_successors");
}
public Object getTag(){
return getTag(Object.class);
}
public E getTag(Class extends E> clazz){
return get("_tag", clazz);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy