From: <lor...@us...> - 2011-11-16 20:27:27
|
Revision: 3412 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3412&view=rev Author: lorenz_b Date: 2011-11-16 20:27:21 +0000 (Wed, 16 Nov 2011) Log Message: ----------- Added method to get all subclasses. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/core/owl/ClassHierarchy.java Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/ClassHierarchy.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/ClassHierarchy.java 2011-11-16 20:22:43 UTC (rev 3411) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/ClassHierarchy.java 2011-11-16 20:27:21 UTC (rev 3412) @@ -19,6 +19,7 @@ package org.dllearner.core.owl; +import java.util.HashSet; import java.util.Set; import java.util.SortedSet; import java.util.TreeMap; @@ -87,6 +88,28 @@ // return (TreeSet<Description>) subsumptionHierarchyDown.get(concept).clone(); // } } + + public SortedSet<Description> getSubClasses(Description concept, boolean direct) { + SortedSet<Description> result = subsumptionHierarchyDown.get(concept); + if(result == null) { + logger.error("Query for sub class of " + concept + " in subsumption hierarchy, but the class is not contained in the (downward) hierarchy, e.g. because the class does not exist or is ignored. Returning empty result instead."); + return new TreeSet<Description>(); + } + for(Description sub : new HashSet<Description>(result)){ + result.addAll(getSubClasses(sub, false)); + } + + return new TreeSet<Description>(result); + + // commented out, because these hacks just worked around a problem +// if (subsumptionHierarchyDown == null) { +// return new TreeSet<Description>(); +// } else if (subsumptionHierarchyDown.get(concept) == null) { +// return new TreeSet<Description>(); +// } else { +// return (TreeSet<Description>) subsumptionHierarchyDown.get(concept).clone(); +// } + } /** * Computes the siblings of the specified descriptions. Siblings are all those This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |