From: <jen...@us...> - 2009-12-08 21:48:07
|
Revision: 1929 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1929&view=rev Author: jenslehmann Date: 2009-12-08 21:47:58 +0000 (Tue, 08 Dec 2009) Log Message: ----------- operator test added Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java trunk/src/dl-learner/org/dllearner/algorithms/el/StableHeuristic.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/el/ELLearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java 2009-12-02 08:56:36 UTC (rev 1928) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java 2009-12-08 21:47:58 UTC (rev 1929) @@ -159,8 +159,11 @@ // convert tree to standard description Description description = descriptionTree.transformToDescription(); + +// double accuracy = getLearningProblem().getAccuracyOrTooWeak(description, 0); int negCovers = getLearningProblem().coveredNegativeExamplesOrTooWeak(description); if(negCovers == -1) { +// if(accuracy == -1) { node.setTooWeak(); } else { node.setCoveredNegatives(negCovers); @@ -200,6 +203,7 @@ private boolean stoppingCriteriaSatisfied() { // in some cases, there could be no candidate left ... if(candidates.isEmpty()) { +// System.out.println("EMPTY"); return true; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/StableHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/StableHeuristic.java 2009-12-02 08:56:36 UTC (rev 1928) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/StableHeuristic.java 2009-12-08 21:47:58 UTC (rev 1929) @@ -19,6 +19,7 @@ */ package org.dllearner.algorithms.el; + /** * A stable comparator for search tree nodes. Stable means that the order * of nodes will not change during the run of the learning algorithm. In @@ -30,10 +31,30 @@ */ public class StableHeuristic implements ELHeuristic { + private ELDescriptionTreeComparator cmp = new ELDescriptionTreeComparator(); + @Override public int compare(SearchTreeNode o1, SearchTreeNode o2) { - // TODO Auto-generated method stub - return 0; + + double diff = o2.getCoveredNegatives() - o1.getCoveredNegatives(); + + if(diff>0) { + return 1; + } else if(diff<0) { + return -1; + } else { + + double sizeDiff = o2.getDescriptionTree().size - o1.getDescriptionTree().size; + + if(sizeDiff == 0) { + return cmp.compare(o1.getDescriptionTree(), o2.getDescriptionTree()); + } else if(sizeDiff>0) { + return 1; + } else { + return -1; + } + + } } } Modified: trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java 2009-12-02 08:56:36 UTC (rev 1928) +++ trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java 2009-12-08 21:47:58 UTC (rev 1929) @@ -42,6 +42,8 @@ import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; import org.dllearner.reasoning.OWLAPIReasoner; +import org.dllearner.refinementoperators.ELDown2; +import org.dllearner.refinementoperators.RefinementOperator; import org.dllearner.refinementoperators.RhoDRDown; import org.dllearner.test.junit.TestOntologies.TestOntology; import org.dllearner.utilities.Helper; @@ -174,6 +176,19 @@ assertTrue(results.size()==desiredResultSize); } + @Test + public void rhoDRDownTest4() throws ParseException, LearningProblemUnsupportedException { + ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.RHO1); + RefinementOperator operator = new RhoDRDown(rs); + Description concept = KBParser.parseConcept("(car AND EXISTS hasOwner.person)"); +// Description concept = Thing.instance; + Set<Description> refinements = operator.refine(concept, 6); + for(Description refinement : refinements) { + System.out.println(refinement); + } + } + + private String uri(String name) { return "\""+baseURI+name+"\""; } Modified: trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2009-12-02 08:56:36 UTC (rev 1928) +++ trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2009-12-08 21:47:58 UTC (rev 1929) @@ -42,7 +42,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 }; + 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 static ReasonerComponent getTestOntology(TestOntology ont) { String kbString = ""; @@ -110,6 +110,15 @@ kbString += "r3(a,b).\n"; kbString += "r4(a,b).\n"; kbString += "r5(a,b).\n"; + } else if(ont.equals(TestOntology.RHO1)) { + kbString += "suv SUB car.\n"; + kbString += "limo SUB car.\n"; + kbString += "man SUB person.\n"; + kbString += "woman SUB person.\n"; + kbString += "(person AND car) = BOTTOM.\n"; + kbString += "OPDOMAIN(hasOwner) = car.\n"; + kbString += "OPRANGE(hasOwner) = person.\n"; + kbString += "hasOwner(opel123,person123).\n"; } else if(ont.equals(TestOntology.FATHER_OE)) { owlFile = "examples/family/father_oe.owl"; } else if(ont.equals(TestOntology.CARCINOGENESIS)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |