From: <jen...@us...> - 2010-02-10 14:16:33
|
Revision: 2008 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2008&view=rev Author: jenslehmann Date: 2010-02-10 14:16:26 +0000 (Wed, 10 Feb 2010) Log Message: ----------- some bugfixes 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/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/refinementoperators/OperatorInverter.java trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.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 13:04:33 UTC (rev 2007) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-02-10 14:16:26 UTC (rev 2008) @@ -21,6 +21,7 @@ import java.text.DecimalFormat; import java.util.Collection; +import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -206,8 +207,6 @@ filterFollowsFromKB = configurator.getFilterDescriptionsFollowingFromKB() && isClassLearningProblem; - System.out.println("filter follows from KB: " + filterFollowsFromKB); - // actions specific to ontology engineering if(isClassLearningProblem) { ClassLearningProblem problem = (ClassLearningProblem) learningProblem; @@ -242,16 +241,34 @@ // use upward refinement until we find an appropriate start class boolean startClassFound = false; + Description candidate; do { - Description candidate = startClassCandidates.pollFirst(); + candidate = startClassCandidates.pollFirst(); if(((ClassLearningProblem)learningProblem).getRecall(candidate)<1.0) { // add upward refinements to list - startClassCandidates.addAll(upwardOperator.refine(candidate, candidate.getLength())); + Set<Description> refinements = upwardOperator.refine(candidate, candidate.getLength()); +// System.out.println("ref: " + refinements); + LinkedList<Description> refinementList = new LinkedList<Description>(refinements); +// Collections.reverse(refinementList); +// System.out.println("list: " + refinementList); + startClassCandidates.addAll(refinementList); +// System.out.println("candidates: " + startClassCandidates); } else { startClassFound = true; } } while(!startClassFound); + startClass = candidate; + if(startClass.equals(existingDefinition)) { + logger.info("Reusing existing description " + startClass.toManchesterSyntaxString(baseURI, prefixes) + " as start class for learning algorithm."); + } else { + logger.info("Generalised existing description " + existingDefinition.toManchesterSyntaxString(baseURI, prefixes) + " to " + startClass.toManchesterSyntaxString(baseURI, prefixes) + ", which is used as start class for the learning algorithm."); + } + +// System.out.println("start class: " + startClass); +// System.out.println("existing def: " + existingDefinition); +// System.out.println(reasoner.getIndividuals(existingDefinition)); + ((RhoDRDown)operator).setDropDisjuncts(false); } else { Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2010-02-10 13:04:33 UTC (rev 2007) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2010-02-10 14:16:26 UTC (rev 2008) @@ -1059,4 +1059,9 @@ return rc.remainsSatisfiableImpl(axiom); } + @Override + protected Set<Description> getAssertedDefinitionsImpl(NamedClass nc) { + return rc.getAssertedDefinitionsImpl(nc); + } + } Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2010-02-10 13:04:33 UTC (rev 2007) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2010-02-10 14:16:26 UTC (rev 2008) @@ -66,6 +66,7 @@ import org.dllearner.kb.OWLFile; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.utilities.owl.ConceptComparator; +import org.dllearner.utilities.owl.DLLearnerDescriptionConvertVisitor; import org.dllearner.utilities.owl.OWLAPIAxiomConvertVisitor; import org.dllearner.utilities.owl.OWLAPIConverter; import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; @@ -1112,16 +1113,14 @@ * @return the asserted class definitions */ @Override - public Set<Description> getAssertedDefinitionsImpl(NamedClass nc){ + protected Set<Description> getAssertedDefinitionsImpl(NamedClass nc){ OWLClass owlClass = OWLAPIDescriptionConvertVisitor.getOWLDescription(nc).asOWLClass(); - Set<OWLDescription> owlAPIDefinitions = owlClass.getEquivalentClasses(new HashSet<OWLOntology>(owlAPIOntologies)); - - // TODO converting to DL-Learner format + Set<OWLDescription> owlAPIDescriptions = owlClass.getEquivalentClasses(new HashSet<OWLOntology>(owlAPIOntologies)); Set<Description> definitions = new HashSet<Description>(); - + for(OWLDescription owlAPIDescription : owlAPIDescriptions) { + definitions.add(DLLearnerDescriptionConvertVisitor.getDLLearnerDescription(owlAPIDescription)); + } return definitions; - } - } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/OperatorInverter.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/OperatorInverter.java 2010-02-10 13:04:33 UTC (rev 2007) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/OperatorInverter.java 2010-02-10 14:16:26 UTC (rev 2008) @@ -60,13 +60,16 @@ @Override public Set<Description> refine(Description description, int maxLength) { Description negatedDescription = getNegation(description); +// System.out.println("negated description: " + negatedDescription); // concept length can change because of the conversion process; as a heuristic // we increase maxLength by the length difference of negated and original concept int lengthDiff = Math.max(0, negatedDescription.getLength() - description.getLength()); - Set<Description> refinements = operator.refine(negatedDescription, maxLength+lengthDiff); + Set<Description> refinements = operator.refine(negatedDescription, maxLength+lengthDiff+1); +// System.out.println("refinv: " + refinements); TreeSet<Description> results = new TreeSet<Description>(cc); for(Description d : refinements) { Description dNeg = getNegation(d); +// System.out.println("dNeg: " + dNeg); // to satisfy the guarantee that the method does not return longer // concepts, we perform an additional check if(!guaranteeLength || dNeg.getLength() <= maxLength) { Modified: trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java 2010-02-10 13:04:33 UTC (rev 2007) +++ trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java 2010-02-10 14:16:26 UTC (rev 2008) @@ -189,6 +189,19 @@ } @Test + public void rhoDRDownTest5() throws ParseException, LearningProblemUnsupportedException { + ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SWORE); + RefinementOperator operator = new RhoDRDown(rs); +// Description concept = KBParser.parseConcept("((NOT \"http://ns.softwiki.de/req/Requirement\") OR (ALL \"http://ns.softwiki.de/req/isCreatedBy\".(NOT \"http://ns.softwiki.de/req/Creditor\")))"); + Description concept = KBParser.parseConcept("(NOT \"http://ns.softwiki.de/req/Requirement\" OR ALL \"http://ns.softwiki.de/req/isCreatedBy\".NOT \"http://ns.softwiki.de/req/Creditor\")"); + System.out.println(concept); + Set<Description> refinements = operator.refine(concept, 7); + for(Description refinement : refinements) { + System.out.println(refinement); + } + } + + @Test public void invertedOperatorTest() throws ParseException { ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.RHO1); RhoDRDown rho = new RhoDRDown(rs); Modified: trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2010-02-10 13:04:33 UTC (rev 2007) +++ trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2010-02-10 14:16:26 UTC (rev 2008) @@ -41,7 +41,7 @@ */ public final class TestOntologies { - public enum TestOntology { EMPTY, SIMPLE, SIMPLE_NO_DR, SIMPLE_NO_DISJOINT, SIMPLE_NO_DR_DISJOINT, SIMPLE2, SIMPLE3, R1SUBR2, DATA1, FIVE_ROLES, FATHER_OE, CARCINOGENESIS, EPC_OE, KRK_ZERO_ONE, DBPEDIA_OWL, TRAINS_OWL, RHO1 }; + public enum TestOntology { EMPTY, SIMPLE, SIMPLE_NO_DR, SIMPLE_NO_DISJOINT, SIMPLE_NO_DR_DISJOINT, SIMPLE2, SIMPLE3, R1SUBR2, DATA1, FIVE_ROLES, FATHER_OE, CARCINOGENESIS, EPC_OE, KRK_ZERO_ONE, DBPEDIA_OWL, TRAINS_OWL, RHO1, SWORE }; public static ReasonerComponent getTestOntology(TestOntology ont) { String kbString = ""; @@ -130,6 +130,8 @@ owlFile = "/home/jl/promotion/ontologien/dbpedia.owl"; } else if(ont.equals(TestOntology.TRAINS_OWL)) { owlFile = "examples/cross-benchmark/trains/trains.owl"; + } else if(ont.equals(TestOntology.SWORE)) { + owlFile = "examples/swore/swore.rdf"; } try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |