From: <jen...@us...> - 2009-01-16 16:24:49
|
Revision: 1577 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1577&view=rev Author: jenslehmann Date: 2009-01-16 16:24:44 +0000 (Fri, 16 Jan 2009) Log Message: ----------- two EL operator unit tests (failing) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-12 18:34:36 UTC (rev 1576) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-16 16:24:44 UTC (rev 1577) @@ -78,6 +78,7 @@ */ @Test public void test1() throws ParseException, ComponentInitException { + System.out.println("TEST 1"); ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE); // input description @@ -158,6 +159,7 @@ @Test public void test2() throws ParseException, IOException { + System.out.println("TEST 2"); // Logger logger = Logger.getRootLogger(); // logger.setLevel(Level.TRACE); // SimpleLayout layout = new SimpleLayout(); @@ -165,21 +167,90 @@ // logger.removeAllAppenders(); // logger.addAppender(app); - ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE); + ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE_NO_DR); // input description - Description input = KBParser.parseConcept("(human AND (EXISTS has.bird AND EXISTS has.cat))"); + Description input = KBParser.parseConcept("(human AND EXISTS hasPet.bird)"); ConceptTransformation.cleanConcept(input); + Set<String> desiredString = new TreeSet<String>(); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS has.human))"); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS has.cat))"); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS has.EXISTS has.TOP))"); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS hasPet.cat))"); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS hasPet.EXISTS has.TOP))"); + desiredString.add("(human AND (EXISTS hasPet.bird AND EXISTS hasChild.TOP))"); + + ConceptComparator cc = new ConceptComparator(); + SortedSet<Description> desired = new TreeSet<Description>(cc); + for(String str : desiredString) { + Description tmp = KBParser.parseConcept(str); + ConceptTransformation.cleanConcept(tmp); + ConceptTransformation.transformToOrderedForm(tmp, cc); + desired.add(tmp); + System.out.println("desired: " + tmp.toString(KBParser.internalNamespace, null)); + } + RefinementOperator operator = new ELDown2(rs); - operator.refine(input); + Set<Description> refinements = operator.refine(input); +// assertTrue(refinements.size() == desired.size()); + System.out.println("\nproduced refinements and their unit test status (true = assertion satisfied):"); + for(Description refinement : refinements) { + ConceptTransformation.transformToOrderedForm(refinement, cc); + boolean ok = desired.contains(refinement); + System.out.println(ok + ": " + refinement.toString(KBParser.internalNamespace, null)); +// assertTrue(desired.contains(refinement)); + } } @Test - public void test3() throws ComponentInitException, ParseException, IOException { + public void test3() throws ParseException, IOException { + System.out.println("TEST 3"); + ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE_NO_DISJOINT); + // input description + Description input = KBParser.parseConcept("(human AND (EXISTS hasChild.human AND EXISTS has.animal))"); + ConceptTransformation.cleanConcept(input); + + Set<String> desiredString = new TreeSet<String>(); + desiredString.add("(human AND (animal AND (EXISTS hasChild.human AND EXISTS has.animal)))"); + desiredString.add("(human AND (EXISTS hasChild.human AND EXISTS has.(animal AND human)))"); + desiredString.add("(human AND (EXISTS hasChild.human AND EXISTS has.bird))"); + desiredString.add("(human AND (EXISTS hasChild.human AND EXISTS has.cat))"); + desiredString.add("(human AND (EXISTS hasChild.human AND EXISTS hasPet.animal))"); + desiredString.add("(human AND (EXISTS hasChild.human AND (EXISTS has.TOP AND EXISTS has.animal)))"); + desiredString.add("(human AND (EXISTS hasChild.human AND EXISTS has.(animal AND EXISTS has.TOP)))"); + desiredString.add("(human AND (EXISTS hasChild.human AND (EXISTS has.animal AND EXISTS has.EXISTS has.TOP)))"); + + ConceptComparator cc = new ConceptComparator(); + SortedSet<Description> desired = new TreeSet<Description>(cc); + for(String str : desiredString) { + Description tmp = KBParser.parseConcept(str); + ConceptTransformation.cleanConcept(tmp); + ConceptTransformation.transformToOrderedForm(tmp, cc); + desired.add(tmp); + System.out.println("desired: " + tmp.toString(KBParser.internalNamespace, null)); + } + + RefinementOperator operator = new ELDown2(rs); + + Set<Description> refinements = operator.refine(input); + +// assertTrue(refinements.size() == desired.size()); + System.out.println("\nproduced refinements and their unit test status (true = assertion satisfied):"); + for(Description refinement : refinements) { + ConceptTransformation.transformToOrderedForm(refinement, cc); + boolean ok = desired.contains(refinement); + System.out.println(ok + ": " + refinement.toString(KBParser.internalNamespace, null)); +// assertTrue(desired.contains(refinement)); + } + } + +// @Test + public void test4() throws ComponentInitException, ParseException, IOException { + Logger logger = Logger.getRootLogger(); logger.setLevel(Level.TRACE); SimpleLayout layout = new SimpleLayout(); @@ -205,7 +276,7 @@ } - @Test +// @Test public void asTest() throws ComponentInitException, MalformedURLException { ComponentManager cm = ComponentManager.getInstance(); Modified: trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2009-01-12 18:34:36 UTC (rev 1576) +++ trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2009-01-16 16:24:44 UTC (rev 1577) @@ -36,7 +36,7 @@ */ public final class TestOntologies { - public enum TestOntology { EMPTY, SIMPLE, SIMPLE2, SIMPLE3, R1SUBR2, DATA1, FIVE_ROLES }; + public enum TestOntology { EMPTY, SIMPLE, SIMPLE_NO_DR, SIMPLE_NO_DISJOINT, SIMPLE2, SIMPLE3, R1SUBR2, DATA1, FIVE_ROLES }; public static ReasonerComponent getTestOntology(TestOntology ont) { String kbString = ""; @@ -54,6 +54,22 @@ kbString += "bird SUB animal.\n"; kbString += "cat SUB animal.\n"; kbString += "(human AND animal) = BOTTOM.\n"; + } else if(ont.equals(TestOntology.SIMPLE_NO_DR)) { + kbString += "Subrole(hasChild, has).\n"; + kbString += "Subrole(hasPet, has).\n"; + kbString += "bird SUB animal.\n"; + kbString += "cat SUB animal.\n"; + kbString += "(human AND animal) = BOTTOM.\n"; + } else if(ont.equals(TestOntology.SIMPLE_NO_DISJOINT)) { + kbString += "OPDOMAIN(hasChild) = human.\n"; + kbString += "OPRANGE(hasChild) = human.\n"; + kbString += "OPDOMAIN(hasPet) = human.\n"; + kbString += "OPRANGE(hasPet) = animal.\n"; + kbString += "Subrole(hasChild, has).\n"; + kbString += "Subrole(hasPet, has).\n"; + kbString += "bird SUB animal.\n"; + kbString += "cat SUB animal.\n"; + kbString += "human SUB TOP.\n"; } else if(ont.equals(TestOntology.SIMPLE2)) { kbString += "Subrole(r2,r3).\n"; kbString += "a1 SUB TOP.\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |