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

com.articulate.sigma.TaxoNode Maven / Gradle / Ivy

Go to download

Sigma knowledge engineering system is an system for developing, viewing and debugging theories in first order logic. It works with Knowledge Interchange Format (KIF) and is optimized for the Suggested Upper Merged Ontology (SUMO) www.ontologyportal.org.

There is a newer version: 2.10
Show newest version
package com.articulate.sigma;
import java.util.ArrayList;

import com.articulate.sigma.KB;

/** This code is copyright Articulate Software (c) 2003.  Some portions
copyright Teknowledge (c) 2003 and reused under the terms of the GNU license.
This software is released under the GNU Public License .
Users of this code also consent, by use of this code, to credit Articulate Software
and Teknowledge in any writings, briefings, publications, presentations, or 
other representations of any software which incorporates, builds on, or uses this 
code.  Please cite the following article in any publication with references:

Pease, A., (2003). The Sigma Ontology Development Environment, 
in Working Notes of the IJCAI-2003 Workshop on Ontology and Distributed Systems,
August 9, Acapulco, Mexico.  See also http://sigmakee.sourceforge.net
*/

/** ***************************************************************
 * Class that holds information about each node in the tree.
 * A node may either display all its children, or just one, which leads
 * to a particular child node the user is interested in.
 */
public class TaxoNode {

    public String name = ""; // the name of the SUMO term;
    public ArrayList parents = new ArrayList();    
    public ArrayList children = new ArrayList();   
    public boolean childrenExpanded = false;
    public TaxoNode oneChild = null;                // only one child may be displayed

    /** ***************************************************************
     */
    public String toHTML(String kbHref, int indentLevel) {

        StringBuffer sb = new StringBuffer();
        int width = indentLevel * 10;
        if (parents == null || parents.size() == 0) {
            KB kb = KBmanager.getMgr().getKB(TaxoModel.kbName);
            ArrayList forms = kb.askWithRestriction(0,TaxoModel.relation,1,name);
            forms = TaxoModel.removeCached(forms);
            if (forms.size() > 0) 
                sb.append(" ");
            else
                sb.append(" ");
        }
        else
            sb.append(" ");
        if (childrenExpanded) 
            sb.append(" ");
        else
            sb.append(" ");
        sb.append("" + name + "
\n"); if (childrenExpanded) { for (int i = 0; i < children.size(); i++) { TaxoNode child = (TaxoNode) children.get(i); sb.append(child.toHTML(kbHref,indentLevel+1)); } } if (oneChild != null) sb.append(oneChild.toHTML(kbHref,indentLevel+1)); return sb.toString(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy