org.mindswap.pellet.taxonomy
Class Taxonomy

java.lang.Object
  extended by org.mindswap.pellet.taxonomy.Taxonomy

public class Taxonomy
extends java.lang.Object

Author:
Evren Sirin

Field Summary
static boolean BOTTOM_UP
           
static boolean DEBUG
          Deprecated. Edit log4j.properties instead to turn on debugging
static boolean DETAILED_DEBUG
          Deprecated. Edit log4j.properties instead to turn on debugging
static boolean SUB
           
static boolean SUPER
           
static boolean TOP_DOWN
           
 
Constructor Summary
Taxonomy()
           
Taxonomy(boolean hideTopBottom)
           
 
Method Summary
 void addEquivalentNode(aterm.ATermAppl c, TaxonomyNode node)
           
 TaxonomyNode addNode(aterm.ATermAppl c)
           
 TaxonomyNode addNode(aterm.ATermAppl c, boolean hide)
           
 java.util.List computeLCA(aterm.ATermList list)
          Given a list of concepts, find all the Least Common Ancestors (LCA).
 boolean contains(aterm.ATermAppl c)
           
 java.util.Set getAllEquivalents(aterm.ATermAppl c)
          Returns all the classes that are equivalent to class c.
 TaxonomyNode getBottom()
           
 java.util.Set getClasses()
           
 java.util.Set getDirectTypes(aterm.ATermAppl ind)
          Get all the direct classes individual belongs to.
 java.util.Set getEquivalents(aterm.ATermAppl c)
          Returns all the classes that are equivalent to class c.
 java.util.Set getFlattenedSubSupers(aterm.ATermAppl c, boolean direct, boolean subOrSuper)
           
 java.util.Set getInstances(aterm.ATermAppl c)
          Returns all the instances of concept c.
 java.util.Set getInstances(aterm.ATermAppl c, boolean direct)
          Returns the instances of class c.
 TaxonomyNode getNode(aterm.ATermAppl c)
           
 java.util.Set getSubs(aterm.ATermAppl c)
          Returns all the (named) subclasses of class c.
 java.util.Set getSubs(aterm.ATermAppl c, boolean direct)
          Returns the (named) subclasses of class c.
 java.util.Set getSubs(aterm.ATermAppl c, boolean direct, boolean flat)
           
 java.util.Set getSubSupers(aterm.ATermAppl c, boolean direct, boolean subOrSuper, boolean flat)
           
 java.util.Set getSupers(aterm.ATermAppl c)
          Returns all the superclasses (implicitly or explicitly defined) of class c.
 java.util.Set getSupers(aterm.ATermAppl c, boolean direct)
          Returns the (named) superclasses of class c.
 java.util.Set getSupers(aterm.ATermAppl c, boolean direct, boolean flat)
           
 TaxonomyNode getTop()
           
 java.util.Set getTypes(aterm.ATermAppl ind)
          Get all the named classes individual belongs to.
 java.util.Set getTypes(aterm.ATermAppl ind, boolean direct)
          Returns the classes individual belongs to.
 boolean isEquivalent(aterm.ATermAppl x, aterm.ATermAppl y)
          Checks if x is equivalent to y
 Bool isSubNodeOf(aterm.ATermAppl x, aterm.ATermAppl y)
          Checks if x has an ancestor y.
 void merge(TaxonomyNode node1, TaxonomyNode node2)
           
 void print()
           
 void print(OutputFormatter out)
           
 void removeCycles(TaxonomyNode node)
          Walk through the super nodes of the given node and when a cycle is detected merge all the nodes in that path
 void removeNode(TaxonomyNode node)
           
 java.util.List topologocialSort()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG
Deprecated. Edit log4j.properties instead to turn on debugging

DETAILED_DEBUG

public static boolean DETAILED_DEBUG
Deprecated. Edit log4j.properties instead to turn on debugging

SUB

public static boolean SUB

SUPER

public static boolean SUPER

TOP_DOWN

public static boolean TOP_DOWN

BOTTOM_UP

public static boolean BOTTOM_UP
Constructor Detail

Taxonomy

public Taxonomy()

Taxonomy

public Taxonomy(boolean hideTopBottom)
Method Detail

getBottom

public TaxonomyNode getBottom()

getTop

public TaxonomyNode getTop()

getClasses

public java.util.Set getClasses()

contains

public boolean contains(aterm.ATermAppl c)

addNode

public TaxonomyNode addNode(aterm.ATermAppl c)

addNode

public TaxonomyNode addNode(aterm.ATermAppl c,
                            boolean hide)

addEquivalentNode

public void addEquivalentNode(aterm.ATermAppl c,
                              TaxonomyNode node)

getNode

public TaxonomyNode getNode(aterm.ATermAppl c)

removeNode

public void removeNode(TaxonomyNode node)

getInstances

public java.util.Set getInstances(aterm.ATermAppl c)
Returns all the instances of concept c. If TOP concept is used every individual in the knowledge base will be returned

Parameters:
c - Class whose instances are returned
Returns:
A set of ATerm objects

getInstances

public java.util.Set getInstances(aterm.ATermAppl c,
                                  boolean direct)
Returns the instances of class c. Depending on the second parameter the resulting list will include all or only the direct instances, i.e. if the individual is not type of any other class that is a subclass of c.

Parameters:
c - Class whose instances are found
direct - If true return only the direct instances, otherwise return all the instances
Returns:
A set of ATerm objects

isEquivalent

public boolean isEquivalent(aterm.ATermAppl x,
                            aterm.ATermAppl y)
Checks if x is equivalent to y

Parameters:
x - Name of the first class
y - Name of the second class
Returns:
true if x is equivalent to y

isSubNodeOf

public Bool isSubNodeOf(aterm.ATermAppl x,
                        aterm.ATermAppl y)
Checks if x has an ancestor y.

Parameters:
x - Name of the node
y - Name of the ancestor ode
Returns:
true if x has an ancestor y

getSubs

public java.util.Set getSubs(aterm.ATermAppl c)
Returns all the (named) subclasses of class c. The class c itself is not included in the list but all the other classes that are equivalent to c are put into the list. Also note that the returned list will always have at least one element, that is the BOTTOM concept. By definition BOTTOM concept is subclass of every concept. This function is equivalent to calling getSubClasses(c, true).

Parameters:
c - class whose subclasses are returned
Returns:
A set of sets, where each set in the collection represents an equivalence class. The elements of the inner class are ATermAppl objects.

getSubs

public java.util.Set getSubs(aterm.ATermAppl c,
                             boolean direct)
Returns the (named) subclasses of class c. Depending onthe second parameter the resulting list will include either all subclasses or only the direct subclasses. A class d is a direct subclass of c iff
  1. d is subclass of c
  2. there is no other class x different from c and d such that x is subclass of c and d is subclass of x
The class c itself is not included in the list but all the other classes that are sameAs c are put into the list. Also note that the returned list will always have at least one element. The list will either include one other concept from the hierarchy or the BOTTOM concept if no other class is subsumed by c. By definition BOTTOM concept is subclass of every concept.

Parameters:
c - Class whose subclasses are found
direct - If true return only direct subclasses elese return all the subclasses
Returns:
A set of sets, where each set in the collection represents an equivalence class. The elements of the inner class are ATermAppl objects.

getSupers

public java.util.Set getSupers(aterm.ATermAppl c)
Returns all the superclasses (implicitly or explicitly defined) of class c. The class c itself is not included in the list. but all the other classes that are sameAs c are put into the list. Also note that the returned list will always have at least one element, that is TOP concept. By definition TOP concept is superclass of every concept. This function is equivalent to calling getSuperClasses(c, true).

Parameters:
c - class whose superclasses are returned
Returns:
A set of sets, where each set in the collection represents an equivalence class. The elements of the inner class are ATermAppl objects.

getSupers

public java.util.Set getSupers(aterm.ATermAppl c,
                               boolean direct,
                               boolean flat)

getSubs

public java.util.Set getSubs(aterm.ATermAppl c,
                             boolean direct,
                             boolean flat)

getSupers

public java.util.Set getSupers(aterm.ATermAppl c,
                               boolean direct)
Returns the (named) superclasses of class c. Depending on the second parameter the resulting list will include either all or only the direct superclasses. A class d is a direct superclass of c iff
  1. d is superclass of c
  2. there is no other class x such that x is superclass of c and d is superclass of x
The class c itself is not included in the list but all the other classes that are sameAs c are put into the list. Also note that the returned list will always have at least one element. The list will either include one other concept from the hierarchy or the TOP concept if no other class subsumes c. By definition TOP concept is superclass of every concept.

Parameters:
c - Class whose subclasses are found
direct - If true return all the superclasses else return only direct superclasses
Returns:
A set of sets, where each set in the collection represents an equivalence class. The elements of the inner class are ATermAppl objects.

getSubSupers

public java.util.Set getSubSupers(aterm.ATermAppl c,
                                  boolean direct,
                                  boolean subOrSuper,
                                  boolean flat)

getFlattenedSubSupers

public java.util.Set getFlattenedSubSupers(aterm.ATermAppl c,
                                           boolean direct,
                                           boolean subOrSuper)

getEquivalents

public java.util.Set getEquivalents(aterm.ATermAppl c)
Returns all the classes that are equivalent to class c. Class c itself is NOT included in the result.

Parameters:
c - class whose equivalent classes are found
Returns:
A set of ATerm objects

getAllEquivalents

public java.util.Set getAllEquivalents(aterm.ATermAppl c)
Returns all the classes that are equivalent to class c. Class c itself is included in the result.

Parameters:
c - class whose equivalent classes are found
Returns:
A set of ATerm objects

getDirectTypes

public java.util.Set getDirectTypes(aterm.ATermAppl ind)
Get all the direct classes individual belongs to.

Parameters:
ind - An individual name
Returns:
A set of sets, where each set in the collection represents an equivalence class. The elements of the inner class are ATermAppl objects.

getTypes

public java.util.Set getTypes(aterm.ATermAppl ind)
Get all the named classes individual belongs to. The result is returned as a set of sets where each

Parameters:
ind - An individual name
Returns:
A set of sets, where each set in the collection represents an equivalence class. The elements of the inner class are ATermAppl objects.

getTypes

public java.util.Set getTypes(aterm.ATermAppl ind,
                              boolean direct)
Returns the classes individual belongs to. Depending on the second parameter the resulting list will include either all types or only the direct types.

Parameters:
ind - An individual name
direct - If true return only the direct types, otherwise return all types
Returns:
A set of sets, where each set in the collection represents an equivalence class. The elements of the inner class are ATermAppl objects.

topologocialSort

public java.util.List topologocialSort()

removeCycles

public void removeCycles(TaxonomyNode node)
Walk through the super nodes of the given node and when a cycle is detected merge all the nodes in that path

Parameters:
node -

merge

public void merge(TaxonomyNode node1,
                  TaxonomyNode node2)

computeLCA

public java.util.List computeLCA(aterm.ATermList list)
Given a list of concepts, find all the Least Common Ancestors (LCA). Note that a taxonomy is DAG not a tree so we do not have a unique LCA but a set of LCA. The function might return a singleton list that contains TOP if there are no lower level nodes that satisfy the LCA condition.

Parameters:
names -
Returns:

print

public void print()

print

public void print(OutputFormatter out)


Copyright © 2007-2009 Natalya Keberle. All Rights Reserved.