From: <jen...@us...> - 2009-04-17 09:34:46
|
Revision: 1710 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1710&view=rev Author: jenslehmann Date: 2009-04-17 09:34:44 +0000 (Fri, 17 Apr 2009) Log Message: ----------- CELOE bug fixes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-04-17 06:36:08 UTC (rev 1709) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-04-17 09:34:44 UTC (rev 1710) @@ -410,7 +410,7 @@ } else { // none of the superclasses of the class to learn must appear on the // outermost property level - TreeSet<Description> toTest = new TreeSet<Description>(); + TreeSet<Description> toTest = new TreeSet<Description>(descriptionComparator); toTest.add(classToDescribe); while(!toTest.isEmpty()) { Description d = toTest.pollFirst(); Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java 2009-04-17 06:36:08 UTC (rev 1709) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java 2009-04-17 09:34:44 UTC (rev 1710) @@ -39,6 +39,7 @@ import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.Property; import org.dllearner.core.owl.Restriction; import org.dllearner.core.owl.Union; import org.dllearner.core.owl.Negation; @@ -572,6 +573,11 @@ } } + /** + * Counts occurrences of \forall in description. + * @param description A description. + * @return Number of \forall occurrences. + */ public static int getForallOccurences(Description description) { int count = 0; if(description instanceof ObjectAllRestriction) { @@ -583,6 +589,13 @@ return count; } + /** + * Gets the "contexts" of all \forall occurrences in a description. A context + * is a set of properties, i.e. in \exists hasChild.\exists hasBrother.\forall hasChild.male, + * the context of the only \forall occurrence is [hasChild, hasBrother, hasChild]. + * @param description A description. + * @return Set of property contexts. + */ public static SortedSet<PropertyContext> getForallContexts(Description description) { return getForallContexts(description, new PropertyContext()); } @@ -590,17 +603,23 @@ private static SortedSet<PropertyContext> getForallContexts(Description description, PropertyContext currentContext) { // the context changes if we have a restriction if(description instanceof Restriction) { - ObjectProperty op = (ObjectProperty) ((Restriction)description).getRestrictedPropertyExpression(); - currentContext.add(op); - // if we have an all-restriction, we return it; otherwise we only change the context - // and call the method on the child - if(description instanceof ObjectAllRestriction) { - TreeSet<PropertyContext> contexts = new TreeSet<PropertyContext>(); - contexts.add(currentContext); - contexts.addAll(getForallContexts(description.getChild(0), currentContext)); - return contexts; + Property op = (Property) ((Restriction)description).getRestrictedPropertyExpression(); + // object restrictions + if(op instanceof ObjectProperty) { + currentContext.add((ObjectProperty)op); + // if we have an all-restriction, we return it; otherwise we only change the context + // and call the method on the child + if(description instanceof ObjectAllRestriction) { + TreeSet<PropertyContext> contexts = new TreeSet<PropertyContext>(); + contexts.add(currentContext); + contexts.addAll(getForallContexts(description.getChild(0), currentContext)); + return contexts; + } else { + return getForallContexts(description.getChild(0), currentContext); + } + // we have a data restriction => no \forall can occur in those } else { - return getForallContexts(description.getChild(0), currentContext); + return new TreeSet<PropertyContext>(); } // for non-restrictions, we collect contexts over all children } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |