From: <jen...@us...> - 2010-02-10 13:08:35
|
Revision: 2005 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2005&view=rev Author: jenslehmann Date: 2010-02-10 12:19:56 +0000 (Wed, 10 Feb 2010) Log Message: ----------- - implemented CELOE option to reuse an existing definition for learning a new one (involves using upward refinement to detect an appropriate start class) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-02-10 11:57:19 UTC (rev 2004) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-02-10 12:19:56 UTC (rev 2005) @@ -50,6 +50,7 @@ import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosNegLPStandard; import org.dllearner.learningproblems.PosOnlyLP; +import org.dllearner.refinementoperators.OperatorInverter; import org.dllearner.refinementoperators.RefinementOperator; import org.dllearner.refinementoperators.RhoDRDown; import org.dllearner.utilities.Helper; @@ -219,15 +220,51 @@ // capture all instances), but owl:Thing for learning subclasses (since it is // superfluous to add super classes in this case) if(isEquivalenceProblem) { - Set<Description> superClasses = reasoner.getClassHierarchy().getSuperClasses(classToDescribe); - if(superClasses.size() > 1) { - startClass = new Intersection(new LinkedList<Description>(superClasses)); - } else if(superClasses.size() == 1){ - startClass = (Description) superClasses.toArray()[0]; + Set<Description> existingDefinitions = reasoner.getAssertedDefinitions(classToDescribe); + if(configurator.getReuseExistingDescription() && (existingDefinitions.size() > 0)) { + // the existing definition is reused, which in the simplest case means to + // use it as a start class or, if it is already too specific, generalise it + + // pick the longest existing definition as candidate + Description existingDefinition = null; + int highestLength = 0; + for(Description exDef : existingDefinitions) { + if(exDef.getLength() > highestLength) { + existingDefinition = exDef; + highestLength = exDef.getLength(); + } + } + + LinkedList<Description> startClassCandidates = new LinkedList<Description>(); + startClassCandidates.add(existingDefinition); + ((RhoDRDown)operator).setDropDisjuncts(true); + RefinementOperator upwardOperator = new OperatorInverter(operator); + + // use upward refinement until we find an appropriate start class + boolean startClassFound = false; + do { + Description candidate = startClassCandidates.pollFirst(); + if(((ClassLearningProblem)learningProblem).getRecall(candidate)<1.0) { + // add upward refinements to list + startClassCandidates.addAll(upwardOperator.refine(candidate, candidate.getLength())); + } else { + startClassFound = true; + } + } while(!startClassFound); + + ((RhoDRDown)operator).setDropDisjuncts(false); + } else { - startClass = Thing.instance; - logger.warn(classToDescribe + " is equivalent to owl:Thing. Usually, it is not " + - "sensible to learn a description in this case."); + Set<Description> superClasses = reasoner.getClassHierarchy().getSuperClasses(classToDescribe); + if(superClasses.size() > 1) { + startClass = new Intersection(new LinkedList<Description>(superClasses)); + } else if(superClasses.size() == 1){ + startClass = (Description) superClasses.toArray()[0]; + } else { + startClass = Thing.instance; + logger.warn(classToDescribe + " is equivalent to owl:Thing. Usually, it is not " + + "sensible to learn a description in this case."); + } } } } else if(learningProblem instanceof PosOnlyLP) { Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2010-02-10 11:57:19 UTC (rev 2004) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2010-02-10 12:19:56 UTC (rev 2005) @@ -263,6 +263,21 @@ } @Override + public Set<Description> getAssertedDefinitions(NamedClass namedClass) { + try { + return getAssertedDefinitionsImpl(namedClass); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + protected Set<Description> getAssertedDefinitionsImpl(NamedClass namedClass) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + @Override public final Set<Description> isSuperClassOf(Set<Description> superConcepts, Description subConcept) { reasoningStartTimeTmp = System.nanoTime(); Modified: trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java 2010-02-10 11:57:19 UTC (rev 2004) +++ trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java 2010-02-10 12:19:56 UTC (rev 2005) @@ -94,6 +94,13 @@ public boolean isEquivalentClass(Description class1, Description class2); /** + * Returns all asserted owl:equivalence class axioms for the given class. + * @param namedClass A named class in the background knowledge. + * @return A set of descriptions asserted to be equal to the named class. + */ + public Set<Description> getAssertedDefinitions(NamedClass namedClass); + + /** * Checks which of <code>superClasses</code> are super classes of <code>subClass</code> * @param superClasses A set of (supposed) super classes. * @param subClasses The (supposed) sub class. Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2010-02-10 11:57:19 UTC (rev 2004) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2010-02-10 12:19:56 UTC (rev 2005) @@ -1111,9 +1111,10 @@ * @param nc the class * @return the asserted class definitions */ - public Set<Description> getAssertedDefinitions(NamedClass nc){ + @Override + public Set<Description> getAssertedDefinitionsImpl(NamedClass nc){ OWLClass owlClass = OWLAPIDescriptionConvertVisitor.getOWLDescription(nc).asOWLClass(); - Set<OWLDescription> OWLAPIDefinitions = owlClass.getEquivalentClasses(new HashSet<OWLOntology>(owlAPIOntologies)); + Set<OWLDescription> owlAPIDefinitions = owlClass.getEquivalentClasses(new HashSet<OWLOntology>(owlAPIOntologies)); // TODO converting to DL-Learner format Set<Description> definitions = new HashSet<Description>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |