From: <jen...@us...> - 2009-02-19 13:21:16
|
Revision: 1615 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1615&view=rev Author: jenslehmann Date: 2009-02-19 12:08:55 +0000 (Thu, 19 Feb 2009) Log Message: ----------- fast retrieval ctd. 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/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-02-19 10:07:39 UTC (rev 1614) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-02-19 12:08:55 UTC (rev 1615) @@ -123,7 +123,7 @@ options.add(CommonConfigOptions.useNegation()); options.add(CommonConfigOptions.useBooleanDatatypes()); options.add(CommonConfigOptions.useDoubleDatatypes()); - options.add(CommonConfigOptions.maxExecutionTimeInSeconds(10)); + options.add(CommonConfigOptions.maxExecutionTimeInSeconds(1)); options.add(CommonConfigOptions.getNoisePercentage()); options.add(CommonConfigOptions.getMaxDepth(4)); return options; @@ -187,7 +187,12 @@ Description startClass; if(isEquivalenceProblem) { Set<Description> superClasses = reasoner.getClassHierarchy().getSuperClasses(classToDescribe); - startClass = new Intersection(new LinkedList<Description>(superClasses)); + if(superClasses.size() > 1) { + startClass = new Intersection(new LinkedList<Description>(superClasses)); + } else { + startClass = (Description) superClasses.toArray()[0]; + } + } else { startClass = Thing.instance; } @@ -246,6 +251,8 @@ // logger.info("solution : " + bestDescriptionToString()); logger.info(getSolutionString()); +// System.out.println(startNode.toTreeString(baseURI)); + isRunning = false; } @@ -270,6 +277,11 @@ return false; } + // check whether the description is allowed + if(!isDescriptionAllowed(description)) { + return false; + } + // quality of description (return if too weak) double accuracy = learningProblem.getAccuracyOrTooWeak(description, minAcc); if(accuracy == -1) { @@ -296,6 +308,29 @@ return true; } + // checks whether the description is allowed + private boolean isDescriptionAllowed(Description description) { + if(isEquivalenceProblem) { + // for equivalence problems, we need to check that the class we are learning does + // not itself occur on the outermost level (property depth 0) + if(description instanceof NamedClass) { + if(description.equals(classToDescribe)) { + return false; + } + } else if(description.getChildren().size() > 1) { + for(Description child : description.getChildren()) { + if(child.equals(classToDescribe)) { + return false; + } + } + } + } else { + + } + + return true; + } + // check whether the node is a potential solution candidate // (sufficient accuracy; minimal; rewriting steps?) private boolean checkNode(OENode node) { Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-02-19 10:07:39 UTC (rev 1614) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-02-19 12:08:55 UTC (rev 1615) @@ -157,7 +157,7 @@ "This option controls how to interpret the all quantifier in \forall r.C. The standard option is" + "to return all those which do not have an r-filler not in C. The domain semantics is to use those" + "which are in the domain of r and do not have an r-filler not in C. The forallExists semantics is to" + - "use those which have at least one r-filler and do not have an r-filler not in C.", "forallExists"); + "use those which have at least one r-filler and do not have an r-filler not in C.", "standard"); forallSemantics.setAllowedValues(new String[] { "standard", "domain", "forallExists" }); // closure option? see: // http://owlapi.svn.sourceforge.net/viewvc/owlapi/owl1_1/trunk/tutorial/src/main/java/uk/ac/manchester/owl/tutorial/examples/ClosureAxiomsExample.java?view=markup @@ -548,7 +548,7 @@ SortedSet<Individual> inds = entry.getValue(); for(Individual ind : inds) { if(targetSet.contains(ind)) { - returnSet.add(ind); + returnSet.add(entry.getKey()); // once we found an individual, we do not need to check the others continue; } @@ -559,7 +559,7 @@ // \forall restrictions are difficult to handle; assume we want to check // \forall hasChild.male with domain(hasChild)=Person; then for all non-persons // this is satisfied trivially (all of their non-existing children are male) - if(!configurator.getForallRetrievalSemantics().equals("forallExists")) { + if(!configurator.getForallRetrievalSemantics().equals("standard")) { throw new Error("Only forallExists semantics currently implemented."); } @@ -576,7 +576,8 @@ } ObjectProperty op = (ObjectProperty) ope; Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); - SortedSet<Individual> returnSet = new TreeSet<Individual>(mapping.keySet()); +// SortedSet<Individual> returnSet = new TreeSet<Individual>(mapping.keySet()); + SortedSet<Individual> returnSet = (SortedSet<Individual>) individuals.clone(); // each individual is connected to a set of individuals via the property; // we loop through the complete mapping @@ -584,7 +585,7 @@ SortedSet<Individual> inds = entry.getValue(); for(Individual ind : inds) { if(!targetSet.contains(ind)) { - returnSet.remove(ind); + returnSet.remove(entry.getKey()); continue; } } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2009-02-19 10:07:39 UTC (rev 1614) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2009-02-19 12:08:55 UTC (rev 1615) @@ -327,8 +327,8 @@ System.exit(0); */ - if(startClass != null) - this.startClass = startClass; +// if(startClass != null) +// this.startClass = startClass; } /* (non-Javadoc) Modified: trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2009-02-19 10:07:39 UTC (rev 1614) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2009-02-19 12:08:55 UTC (rev 1615) @@ -25,6 +25,7 @@ import java.net.MalformedURLException; import java.util.LinkedList; import java.util.List; +import java.util.SortedSet; import org.apache.log4j.Logger; import org.dllearner.core.ComponentInitException; @@ -158,9 +159,9 @@ } } - @Test +// @Test public void fastInstanceCheck2() throws ComponentInitException, ParseException { - String file = "examples/epc/conf/sap_modell_komplett_2.owl"; + String file = "examples/epc/sap_epc.owl"; ComponentManager cm = ComponentManager.getInstance(); KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); try { @@ -180,6 +181,33 @@ System.out.println(result); } + // simple unit test for new retrieval algorithm + @Test + public void fastInstanceCheck3() throws MalformedURLException, ComponentInitException, ParseException { + String file = "examples/family/father_oe.owl"; + ComponentManager cm = ComponentManager.getInstance(); + KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); + cm.applyConfigEntry(ks, "url", new File(file).toURI().toURL()); + ks.init(); + ReasonerComponent reasoner = cm.reasoner(FastInstanceChecker.class, ks); + reasoner.init(); + baseURI = reasoner.getBaseURI(); + Description description = KBParser.parseConcept("(\"http://example.com/father#male\" AND EXISTS \"http://example.com/father#hasChild\".TOP)"); +// Description description = KBParser.parseConcept("EXISTS \"http://example.com/father#hasChild\".TOP"); + SortedSet<Individual> result = reasoner.getIndividuals(description); + assertTrue(result.size()==3); + assertTrue(result.contains(new Individual("http://example.com/father#markus"))); + assertTrue(result.contains(new Individual("http://example.com/father#martin"))); + assertTrue(result.contains(new Individual("http://example.com/father#stefan"))); +// System.out.println(result); + + Description description2 = KBParser.parseConcept("(\"http://example.com/father#male\" AND ALL \"http://example.com/father#hasChild\".\"http://example.com/father#father\")"); + SortedSet<Individual> result2 = reasoner.getIndividuals(description2); + assertTrue(result2.size()==2); + assertTrue(result2.contains(new Individual("http://example.com/father#heinz"))); + assertTrue(result2.contains(new Individual("http://example.com/father#stefan"))); + } + private List<Individual> getIndSet(String... inds) { List<Individual> individuals = new LinkedList<Individual>(); for(String ind : inds) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |