From: <jen...@us...> - 2009-04-06 10:58:50
|
Revision: 1682 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1682&view=rev Author: jenslehmann Date: 2009-04-06 10:58:30 +0000 (Mon, 06 Apr 2009) Log Message: ----------- fixed some problems detected by unit tests Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java trunk/src/dl-learner/org/dllearner/test/junit/ELDescriptionTreeTests.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java trunk/src/dl-learner/org/dllearner/utilities/Helper.java Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-04-03 07:48:52 UTC (rev 1681) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-04-06 10:58:30 UTC (rev 1682) @@ -266,7 +266,7 @@ public boolean hasTypeImpl(Description description, Individual individual) throws ReasoningMethodUnsupportedException { -// System.out.println(description + " " + individual); +// System.out.println("FIC: " + description + " " + individual); if (description instanceof NamedClass) { return classInstancesPos.get((NamedClass) description).contains(individual); Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2009-04-03 07:48:52 UTC (rev 1681) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2009-04-06 10:58:30 UTC (rev 1682) @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2007-2009, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.reasoning; import java.util.HashSet; @@ -22,6 +41,13 @@ import org.dllearner.utilities.Helper; import org.dllearner.utilities.datastructures.SortedSetTuple; +/** + * + * Reasoner for fast retrieval inference (other tasks redirected to OWL API reasoner). Not actively used anymore. + * + * @author Jens Lehmann + * + */ public class FastRetrievalReasoner extends ReasonerComponent { private FastRetrievalReasonerConfigurator configurator; @@ -36,16 +62,13 @@ Set<ObjectProperty> atomicRoles; SortedSet<Individual> individuals; - ReasonerComponent rs; ReasonerComponent rc; - - public FastRetrievalReasoner(Set<KnowledgeSource> sources) { super(sources); this.configurator = new FastRetrievalReasonerConfigurator(this); - rc = ComponentFactory.getDIGReasoner(sources); + rc = ComponentFactory.getOWLAPIReasoner(sources); try { rc.init(); } catch (ComponentInitException e1) { @@ -57,7 +80,7 @@ individuals = rc.getIndividuals(); // rs = new ReasonerComponent(rc); try { - abox = Helper.createFlatABox(rs); + abox = Helper.createFlatABox(rc); } catch (ReasoningMethodUnsupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -130,7 +153,7 @@ // Negation neg = new Negation(subConcept); // Intersection c = new Intersection(neg,superConcept); // return fastRetrieval.calculateSets(c).getPosSet().isEmpty(); - return rs.isSuperClassOf(superConcept, subConcept); + return rc.isSuperClassOf(superConcept, subConcept); } // @Override @@ -154,7 +177,7 @@ @Override public boolean isSatisfiableImpl() { - return rs.isSatisfiable(); + return rc.isSatisfiable(); } @Override Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2009-04-03 07:48:52 UTC (rev 1681) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2009-04-06 10:58:30 UTC (rev 1682) @@ -185,6 +185,8 @@ public RhoDRDown(ReasonerComponent reasoningService) { // this(reasoningService, reasoningService.getClassHierarchy(), null, true, true, true, true, true, 3, true, true, true, true, null); this.rs = reasoningService; + this.subHierarchy = rs.getClassHierarchy(); + init(); } public RhoDRDown(ReasonerComponent reasoner, ClassHierarchy subHierarchy, Description startClass, RefinementOperatorConfigurator configurator) { Modified: trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java 2009-04-03 07:48:52 UTC (rev 1681) +++ trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java 2009-04-06 10:58:30 UTC (rev 1682) @@ -48,7 +48,12 @@ JUnitCore.main("org.dllearner.test.junit.ComponentTests", "org.dllearner.test.junit.ReasonerTests", - "org.dllearner.test.junit.RefinementOperatorTests"); + "org.dllearner.test.junit.RefinementOperatorTests", + "org.dllearner.test.junit.ELDescriptionTreeTests", + "org.dllearner.test.junit.ELDownTests", + "org.dllearner.test.junit.MinimizeTests", + "org.dllearner.test.junit.SimulationTests", + "org.dllearner.test.junit.UtilitiesTests"); } } Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDescriptionTreeTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDescriptionTreeTests.java 2009-04-03 07:48:52 UTC (rev 1681) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDescriptionTreeTests.java 2009-04-06 10:58:30 UTC (rev 1682) @@ -85,7 +85,7 @@ ConceptTransformation.cleanConcept(d); ELDescriptionTree tree = new ELDescriptionTree(rs, d); // clone performance (false for simple unit test, true for clone performance test) - boolean testPerformance = true; + boolean testPerformance = false; ELDescriptionTree treeCloned = null; if(testPerformance) { int runs = 1000000; Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-04-03 07:48:52 UTC (rev 1681) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-04-06 10:58:30 UTC (rev 1682) @@ -284,6 +284,7 @@ } } + // not part of the regular test suite, since Galen 2 is required // @Test public void test4() throws ComponentInitException, ParseException, IOException { @@ -312,6 +313,7 @@ } + // not part of the regular test suite, since Galen 2 is required // @Test public void asTest() throws ComponentInitException, MalformedURLException { Modified: trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2009-04-03 07:48:52 UTC (rev 1681) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2009-04-06 10:58:30 UTC (rev 1682) @@ -39,8 +39,8 @@ import org.dllearner.kb.OWLFile; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; +import org.dllearner.reasoning.DIGReasoner; import org.dllearner.reasoning.FastInstanceChecker; -import org.dllearner.reasoning.OWLAPIReasoner; import org.junit.Test; /** @@ -78,8 +78,13 @@ * Performs an instance checks on all reasoner components to verify that * they all return the correct result. */ -// @Test + @Test public void instanceCheckTest() { + + // DIG can be excluded from test since it requires a separate DIG reasoner and is no + // longer the default reasoning mechanism + boolean excludeDIG = true; + try { ComponentManager cm = ComponentManager.getInstance(); KB kb = getSimpleKnowledgeBase(); @@ -91,6 +96,9 @@ Individual i = new Individual(KBParser.getInternalURI("stephen")); List<Class<? extends ReasonerComponent>> reasonerClasses = cm.getReasonerComponents(); for (Class<? extends ReasonerComponent> reasonerClass : reasonerClasses) { + if(excludeDIG && reasonerClass.equals(DIGReasoner.class)) { + continue; + } ReasonerComponent reasoner = cm.reasoner(reasonerClass, ks); reasoner.init(); // long startTime = System.nanoTime(); @@ -116,7 +124,7 @@ * @throws ComponentInitException * @throws ParseException */ -// @Test + @Test public void fastInstanceCheckTest() throws ComponentInitException, ParseException { String file = "examples/carcinogenesis/carcinogenesis.owl"; ComponentManager cm = ComponentManager.getInstance(); @@ -128,7 +136,7 @@ e.printStackTrace(); } ks.init(); - ReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, ks); + ReasonerComponent reasoner = cm.reasoner(FastInstanceChecker.class, ks); reasoner.init(); baseURI = reasoner.getBaseURI(); @@ -137,7 +145,7 @@ List<List<Individual>> negIndividuals = new LinkedList<List<Individual>>(); // TODO manually verify that the results are indeed correct - testDescriptions.add(KBParser.parseConcept("\"http://dl-learner.org/carcinogenesis#Compound\" AND (\"http://dl-learner.org/carcinogenesis#amesTestPositive\" = true OR >= 2 \"http://dl-learner.org/carcinogenesis#hasStructure\" \"http://dl-learner.org/carcinogenesis#Ar_halide\"))")); + testDescriptions.add(KBParser.parseConcept("(\"http://dl-learner.org/carcinogenesis#Compound\" AND ((\"http://dl-learner.org/carcinogenesis#amesTestPositive\" IS TRUE) OR >= 2 \"http://dl-learner.org/carcinogenesis#hasStructure\".\"http://dl-learner.org/carcinogenesis#Ar_halide\"))")); posIndividuals.add(getIndSet("d113","d133","d171","d262","d265","d294","d68","d77","d79")); negIndividuals.add(getIndSet("d139","d199","d202","d203","d283","d42")); @@ -150,16 +158,18 @@ List<Individual> neg = negIndividuals.get(i); for(Individual ind : pos) { + System.out.println("description: " + description.toString(baseURI, null) + " individual: " + ind.toString(baseURI, null)); assertTrue(reasoner.hasType(description, ind)); } for(Individual ind : neg) { + System.out.println("description: " + description.toString(baseURI, null) + " individual: " + ind.toString(baseURI, null)); assertTrue(!reasoner.hasType(description, ind)); } } } -// @Test + @Test public void fastInstanceCheck2() throws ComponentInitException, ParseException { String file = "examples/epc/sap_epc.owl"; ComponentManager cm = ComponentManager.getInstance(); @@ -217,7 +227,8 @@ } private String uri(String name) { - return "\""+baseURI+name+"\""; +// return "\""+baseURI+name+"\""; + return baseURI+name; } } Modified: trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java 2009-04-03 07:48:52 UTC (rev 1681) +++ trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java 2009-04-06 10:58:30 UTC (rev 1682) @@ -102,13 +102,13 @@ RhoDRDown op = new RhoDRDown(reasoner); Description concept = KBParser.parseConcept("(\"http://localhost/aris/sap_model.owl#EPC\" AND EXISTS \"http://localhost/aris/sap_model.owl#hasModelElements\".\"http://localhost/aris/sap_model.owl#Object\")"); - Set<Description> results = op.refine(concept, 6); + Set<Description> results = op.refine(concept,10); for(Description result : results) { - System.out.println(result); + System.out.println(result.toString("http://localhost/aris/sap_model.owl#",null)); } - int desiredResultSize = 141; + int desiredResultSize = 116; if(results.size() != desiredResultSize) { System.out.println(results.size() + " results found, but should be " + desiredResultSize + "."); } Modified: trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2009-04-03 07:48:52 UTC (rev 1681) +++ trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2009-04-06 10:58:30 UTC (rev 1682) @@ -122,10 +122,10 @@ KnowledgeSource source; // parse KB string if one has been specified - if(!kbString.isEmpty()) { + if(!kbString.isEmpty() || ont.equals(TestOntology.EMPTY)) { KB kb = KBParser.parseKBFile(kbString); source = new KBFile(kb); - // parse OWL file otherwise + // do nothing for empty ontology } else { source = cm.knowledgeSource(OWLFile.class); try { Modified: trunk/src/dl-learner/org/dllearner/utilities/Helper.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2009-04-03 07:48:52 UTC (rev 1681) +++ trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2009-04-06 10:58:30 UTC (rev 1682) @@ -556,18 +556,22 @@ long dematStartTime = System.currentTimeMillis(); FlatABox aBox = new FlatABox(); // FlatABox.getInstance(); - for (NamedClass atomicConcept : rs.getNamedClasses()) { - aBox.atomicConceptsPos.put(atomicConcept.getName(), getStringSet(rs - .getIndividuals(atomicConcept))); - Negation negatedAtomicConcept = new Negation(atomicConcept); - aBox.atomicConceptsNeg.put(atomicConcept.getName(), getStringSet(rs - .getIndividuals(negatedAtomicConcept))); - aBox.concepts.add(atomicConcept.getName()); + if(!rs.getNamedClasses().isEmpty()) { + for (NamedClass atomicConcept : rs.getNamedClasses()) { + aBox.atomicConceptsPos.put(atomicConcept.getName(), getStringSet(rs + .getIndividuals(atomicConcept))); + Negation negatedAtomicConcept = new Negation(atomicConcept); + aBox.atomicConceptsNeg.put(atomicConcept.getName(), getStringSet(rs + .getIndividuals(negatedAtomicConcept))); + aBox.concepts.add(atomicConcept.getName()); + } } - for (ObjectProperty atomicRole : rs.getObjectProperties()) { - aBox.rolesPos.put(atomicRole.getName(), getStringMap(rs.getPropertyMembers(atomicRole))); - aBox.roles.add(atomicRole.getName()); + if(!rs.getObjectProperties().isEmpty()) { + for (ObjectProperty atomicRole : rs.getObjectProperties()) { + aBox.rolesPos.put(atomicRole.getName(), getStringMap(rs.getPropertyMembers(atomicRole))); + aBox.roles.add(atomicRole.getName()); + } } aBox.domain = getStringSet(rs.getIndividuals()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |