From: <jen...@us...> - 2009-02-26 16:24:28
|
Revision: 1635 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1635&view=rev Author: jenslehmann Date: 2009-02-26 16:24:18 +0000 (Thu, 26 Feb 2009) Log Message: ----------- - started \forall checks - some beautification of output descriptions Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-02-26 15:29:25 UTC (rev 1634) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-02-26 16:24:18 UTC (rev 1635) @@ -43,6 +43,7 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.Restriction; import org.dllearner.core.owl.Thing; import org.dllearner.learningproblems.ClassLearningProblem; @@ -341,6 +342,15 @@ return false; } + // perform forall sanity tests (TODO: move to separate method) + if(parentNode != null && ConceptTransformation.getForallOccurences(description) > ConceptTransformation.getForallOccurences(parentNode.getDescription())) { + // we have an additional \forall construct, so we now fetch the contexts + // in which it occurs + List<List<ObjectProperty>> contexts = ConceptTransformation.getForallContexts(description); + List<List<ObjectProperty>> parentContexts = ConceptTransformation.getForallContexts(parentNode.getDescription()); + + } + // quality of description (return if too weak) double accuracy = learningProblem.getAccuracyOrTooWeak(description, minAcc); descriptionTests++; @@ -559,4 +569,5 @@ public int getMinimumHorizontalExpansion() { return minHorizExp; } + } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-02-26 15:29:25 UTC (rev 1634) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-02-26 16:24:18 UTC (rev 1635) @@ -502,8 +502,12 @@ // (of course we only have to clone the leafs of a class description tree) if (description instanceof NamedClass) { return (TreeSet<Individual>) classInstancesPos.get((NamedClass) description).clone(); - } else if (description instanceof Negation && description.getChild(0) instanceof NamedClass) { - return (TreeSet<Individual>) classInstancesNeg.get((NamedClass) description.getChild(0)).clone(); + } else if (description instanceof Negation) { + if(description.getChild(0) instanceof NamedClass) { + return (TreeSet<Individual>) classInstancesNeg.get((NamedClass) description.getChild(0)).clone(); + } + // implement retrieval as default negation + return Helper.difference((TreeSet<Individual>) individuals.clone(), getIndividualsImpl(description.getChild(0))); } else if (description instanceof Thing) { return (TreeSet<Individual>) individuals.clone(); } else if (description instanceof Nothing) { Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java 2009-02-26 15:29:25 UTC (rev 1634) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java 2009-02-26 16:24:18 UTC (rev 1635) @@ -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.Restriction; import org.dllearner.core.owl.Union; import org.dllearner.core.owl.Negation; import org.dllearner.core.owl.ObjectPropertyExpression; @@ -570,4 +571,44 @@ // return false; } } + + public static int getForallOccurences(Description description) { + int count = 0; + if(description instanceof ObjectAllRestriction) { + count++; + } + for(Description child : description.getChildren()) { + count += getForallOccurences(child); + } + return count; + } + + public static List<List<ObjectProperty>> getForallContexts(Description description) { + return getForallContexts(description, new LinkedList<ObjectProperty>()); + } + + private static List<List<ObjectProperty>> getForallContexts(Description description, List<ObjectProperty> 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) { + List<List<ObjectProperty>> contexts = new LinkedList<List<ObjectProperty>>(); + contexts.add(currentContext); + contexts.addAll(getForallContexts(description.getChild(0), currentContext)); + return contexts; + } else { + return getForallContexts(description.getChild(0), currentContext); + } + // for non-restrictions, we collect contexts over all children + } else { + List<List<ObjectProperty>> contexts = new LinkedList<List<ObjectProperty>>(); + for(Description child : description.getChildren()) { + contexts.addAll(getForallContexts(child, currentContext)); + } + return contexts; + } + } } Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java 2009-02-26 15:29:25 UTC (rev 1634) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java 2009-02-26 16:24:18 UTC (rev 1635) @@ -52,7 +52,7 @@ private ConceptComparator conceptComparator = new ConceptComparator(); private Map<Description,Map<Description,Boolean>> cachedSubclassOf = new TreeMap<Description,Map<Description,Boolean>>(conceptComparator); - private boolean beautify = false; + private boolean beautify = true; public DescriptionMinimizer(ReasonerComponent reasoner) { this.reasoner = reasoner; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |