From: <jen...@us...> - 2008-11-10 18:09:23
|
Revision: 1504 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1504&view=rev Author: jenslehmann Date: 2008-11-10 18:09:19 +0000 (Mon, 10 Nov 2008) Log Message: ----------- - reasoner component redesign continued - SVN partially broken Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/SubsumptionComparator.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/IndividualReasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/ReasonerOld.java trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java trunk/src/dl-learner/org/dllearner/examples/KRKModular.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java trunk/src/dl-learner/org/dllearner/scripts/TestValidation.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/test/ComponentTest.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/utilities/Helper.java trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderOWL.java trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticPositiveExampleFinderOWL.java trunk/src/dl-learner/org/dllearner/utilities/owl/OntologyCloser.java trunk/src/dl-learner/org/dllearner/utilities/owl/OntologyCloserOWLAPI.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/owl/ClassHierarchy.java trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/core/ReasonerComponentOld.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/core/owl/SubsumptionHierarchy.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-11-10 16:53:59 UTC (rev 1503) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-11-10 18:09:19 UTC (rev 1504) @@ -36,7 +36,7 @@ import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectPropertyHierarchy; import org.dllearner.core.owl.ObjectSomeRestriction; -import org.dllearner.core.owl.SubsumptionHierarchy; +import org.dllearner.core.owl.ClassHierarchy; import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.UnsupportedLanguageException; @@ -66,12 +66,12 @@ // since we store simulation information in the tree and simulation // updates depend on background knowledge) protected ReasonerComponent rs; - protected SubsumptionHierarchy subsumptionHierarchy; + protected ClassHierarchy subsumptionHierarchy; protected ObjectPropertyHierarchy roleHierarchy; public ELDescriptionTree(ReasonerComponent rs) { this.rs = rs; - subsumptionHierarchy = rs.getSubsumptionHierarchy(); + subsumptionHierarchy = rs.getClassHierarchy(); roleHierarchy = rs.getRoleHierarchy(); } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-11-10 16:53:59 UTC (rev 1503) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-11-10 18:09:19 UTC (rev 1504) @@ -359,7 +359,7 @@ // during the run of the algorithm // reasoner.prepareSubsumptionHierarchy(usedConcepts); if(improveSubsumptionHierarchy) - reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); + reasoner.getClassHierarchy().improveSubsumptionHierarchy(); // reasoner.prepareRoleHierarchy(usedRoles); // prepare datatype hierarchy only if necessary // if(reasoner.hasDatatypeSupport()) Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-11-10 16:53:59 UTC (rev 1503) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-11-10 18:09:19 UTC (rev 1504) @@ -719,7 +719,7 @@ // Test aller Konzepte auf properness (mit DIG in nur einer Anfrage) if (usePropernessChecks) { long propCalcReasoningStart = System.nanoTime(); - improperConcepts = rs.subsumes(toEvaluateConcepts, concept); + improperConcepts = rs.isSuperClassOf(toEvaluateConcepts, concept); propernessTestsReasoner += toEvaluateConcepts.size(); // boolean isProper = // !learningProblem.getReasonerComponent().subsumes(refinement, @@ -813,7 +813,7 @@ for (Individual i : coveredPositives) { // TODO: move code to a separate function if (quality != -1) { - boolean covered = rs.instanceCheck(refinement, i); + boolean covered = rs.hasType(refinement, i); if (!covered) misclassifiedPositives++; else @@ -831,7 +831,7 @@ newlyCoveredNegatives = new HashSet<Individual>(); for (Individual i : coveredNegatives) { - boolean covered = rs.instanceCheck(refinement, i); + boolean covered = rs.hasType(refinement, i); if (covered) newlyCoveredNegatives.add(i); } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/SubsumptionComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/SubsumptionComparator.java 2008-11-10 16:53:59 UTC (rev 1503) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/SubsumptionComparator.java 2008-11-10 18:09:19 UTC (rev 1504) @@ -23,11 +23,11 @@ public int compare(Description concept1, Description concept2) { // return true if concept1 is a super concept of concept2 - boolean value1 = rs.subsumes(concept1, concept2); + boolean value1 = rs.isSuperClassOf(concept1, concept2); if(value1) return 1; - boolean value2 = rs.subsumes(concept2, concept1); + boolean value2 = rs.isSuperClassOf(concept2, concept1); if(value2) return -1; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-11-10 16:53:59 UTC (rev 1503) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-11-10 18:09:19 UTC (rev 1504) @@ -374,7 +374,7 @@ // during the run of the algorithm // reasoner.prepareSubsumptionHierarchy(usedConcepts); if(improveSubsumptionHierarchy) - reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); + reasoner.getClassHierarchy().improveSubsumptionHierarchy(); // reasoner.prepareRoleHierarchy(usedRoles); } @@ -759,7 +759,7 @@ if(toEvaluateConcepts.size()>0) { // Test aller Konzepte auf properness (mit DIG in nur einer Anfrage) long propCalcReasoningStart = System.nanoTime(); - improperConcepts = reasoner.subsumes(toEvaluateConcepts, concept); + improperConcepts = reasoner.isSuperClassOf(toEvaluateConcepts, concept); propernessTestsReasoner+=toEvaluateConcepts.size(); // boolean isProper = !learningProblem.getReasonerComponent().subsumes(refinement, concept); propernessCalcReasoningTimeNs += System.nanoTime() - propCalcReasoningStart; Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-11-10 16:53:59 UTC (rev 1503) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-11-10 18:09:19 UTC (rev 1504) @@ -621,7 +621,7 @@ } else if (name.equals("showSubsumptionHierarchy")) { if (cliOption.getStringValue().equals("true")) { System.out.println("Subsumption Hierarchy:"); - System.out.println(rs.getSubsumptionHierarchy()); + System.out.println(rs.getClassHierarchy()); } // satisfiability check } else if (name.equals("checkSatisfiability")) { @@ -812,7 +812,7 @@ // pose retrieval query Set<Individual> result = null; - result = rs.retrieval(concept); + result = rs.getIndividuals(concept); logger.info("retrieval result (" + result.size() + "): " + result); Modified: trunk/src/dl-learner/org/dllearner/core/IndividualReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/IndividualReasoner.java 2008-11-10 16:53:59 UTC (rev 1503) +++ trunk/src/dl-learner/org/dllearner/core/IndividualReasoner.java 2008-11-10 18:09:19 UTC (rev 1504) @@ -20,9 +20,12 @@ package org.dllearner.core; import java.util.Set; +import java.util.SortedSet; +import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; +import org.dllearner.utilities.datastructures.SortedSetTuple; /** * Reasoning requests/queries related to individuals in the knowledge base. @@ -41,4 +44,32 @@ */ public Set<NamedClass> getTypes(Individual individual); + /** + * Checks whether <code>individual</code> is instance of <code>description</code>. + * For instance, "Leipzig" may be an instance of "City". + * + * @param description An OWL class description. + * @param individual An individual. + * @return True if the instance has the description as type and false otherwise. + */ + public boolean hasType(Description description, Individual individual); + + /** + * Gets all instances of a given class description in the knowledge base. + * @param description An OWL class description. + * @return All instances of the class description. + */ + public SortedSet<Individual> getIndividuals(Description description); + + /** + * Performs a query for all instances of the given class description and + * its negation. (Note that in OWL it is possible that the reasoner can + * neither deduce that an individual is instance of a class nor its + * negation.) This method might be more efficient that performing a + * two retrievals. + * + * @param description An OWL class description. + * @return All instances of the class description and its negation. + */ + public SortedSetTuple<Individual> doubleRetrieval(Description description); } Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-11-10 16:53:59 UTC (rev 1503) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-11-10 18:09:19 UTC (rev 1504) @@ -40,7 +40,7 @@ import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectPropertyHierarchy; -import org.dllearner.core.owl.SubsumptionHierarchy; +import org.dllearner.core.owl.ClassHierarchy; import org.dllearner.reasoning.ReasonerType; import org.dllearner.utilities.datastructures.SortedSetTuple; import org.dllearner.utilities.owl.OWLVocabulary; @@ -54,18 +54,18 @@ * * Guidelines for extending the class: * <ul> - * <li>add the needed method to the corresponding interface (currenty - * {@link BaseReasoner}, {@link SchemaReasoner}, {@link IndividualReasoner} - * exist)</li> - * <li>reasoning methods which need to be supported by all reasoners: - * create method() and methodImpl() here, where the former is an overridden, final - * method delegating to the latter abstract, protected method</li> - * <li>reasoning method, which do not need to be supported by all reasoners: - * create method() and methodImpl() as before, but this time methodImpl() is - * not abstract and throws a {@link ReasoningMethodUnsupportedException} - * </li> - * <li>a few very basic methods (where we do not care about statistics) - * do not have an "Impl" variant, e.g. getting all named classes of a KB</li> + * <li>add the needed method to the corresponding interface (currenty + * {@link BaseReasoner}, {@link SchemaReasoner}, {@link IndividualReasoner} + * exist)</li> + * <li>reasoning methods which need to be supported by all reasoners: create + * method() and methodImpl() here, where the former is an overridden, final + * method delegating to the latter abstract, protected method</li> + * <li>reasoning method, which do not need to be supported by all reasoners: + * create method() and methodImpl() as before, but this time methodImpl() is not + * abstract and throws a {@link ReasoningMethodUnsupportedException} </li> + * <li>a few very basic methods (where we do not care about statistics) do not + * have an "Impl" variant, e.g. getting all named classes of a KB; those are + * directly inherited from the reasoner interface</li> * </ul> * Note, that the method delegation is done to collect statistical information * about reasoning performance, e.g. count how often certain methods were called @@ -105,9 +105,9 @@ private List<ObjectProperty> atomicRolesList; // hierarchies (they are computed the first time they are needed) - private SubsumptionHierarchy subsumptionHierarchy; - private ObjectPropertyHierarchy roleHierarchy; - private DatatypePropertyHierarchy datatypePropertyHierarchy; + private ClassHierarchy subsumptionHierarchy = null; + private ObjectPropertyHierarchy roleHierarchy = null; + private DatatypePropertyHierarchy datatypePropertyHierarchy = null; /** * The underlying knowledge sources. @@ -173,6 +173,16 @@ } /** + * Notify the reasoner component that the underlying knowledge base has + * changed and all caches (for named classes, subsumption hierarchies, etc.) + * should be invalidaded. TODO Currently, nothing is done to behave + * correctly after updates. + */ + public void setUpdated() { + // TODO currently, nothing is done to behave correctly after updates + } + + /** * Call this method to release the knowledge base. Not calling the method * may (depending on the underlying reasoner) result in resources for this * knowledge base not being freed, which can cause memory leaks. @@ -199,17 +209,19 @@ } return types; } - - protected Set<NamedClass> getTypesImpl(Individual individual) throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException("Reasoner does not support to determine type of individual."); + + protected Set<NamedClass> getTypesImpl(Individual individual) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException( + "Reasoner does not support to determine type of individual."); } - + @Override - public final boolean subsumes(Description superClass, Description subClass) { + public final boolean isSuperClassOf(Description superClass, Description subClass) { reasoningStartTimeTmp = System.nanoTime(); boolean result = false; try { - result = subsumesImpl(superClass, subClass); + result = isSuperClassOfImpl(superClass, subClass); } catch (ReasoningMethodUnsupportedException e) { handleExceptions(e); } @@ -220,12 +232,18 @@ return result; } + protected boolean isSuperClassOfImpl(Description superConcept, Description subConcept) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + @Override - public final Set<Description> subsumes(Set<Description> superConcepts, Description subConcept) { + public final Set<Description> isSuperClassOf(Set<Description> superConcepts, + Description subConcept) { reasoningStartTimeTmp = System.nanoTime(); Set<Description> result = null; try { - result = subsumesImpl(superConcepts, subConcept); + result = isSuperClassOfImpl(superConcepts, subConcept); } catch (ReasoningMethodUnsupportedException e) { handleExceptions(e); } @@ -234,29 +252,25 @@ reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; subsumptionReasoningTimeNs += reasoningDurationTmp; overallReasoningTimeNs += reasoningDurationTmp; - return result; - } - - public SortedSetTuple<Individual> doubleRetrieval(Description concept) { - reasoningStartTimeTmp = System.nanoTime(); - SortedSetTuple<Individual> result; - try { - result = doubleRetrievalImpl(concept); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; - otherReasoningTimeNs += reasoningDurationTmp; - overallReasoningTimeNs += reasoningDurationTmp; return result; } - public SortedSetTuple<Individual> doubleRetrieval(Description concept, Description adc) { + protected Set<Description> isSuperClassOfImpl(Set<Description> superConcepts, + Description subConcept) throws ReasoningMethodUnsupportedException { + Set<Description> returnSet = new HashSet<Description>(); + for (Description superConcept : superConcepts) { + if (isSuperClassOf(superConcept, subConcept)) + returnSet.add(superConcept); + } + return returnSet; + } + + @Override + public final SortedSetTuple<Individual> doubleRetrieval(Description concept) { reasoningStartTimeTmp = System.nanoTime(); SortedSetTuple<Individual> result; try { - result = doubleRetrievalImpl(concept, adc); + result = doubleRetrievalImpl(concept); } catch (ReasoningMethodUnsupportedException e) { handleExceptions(e); return null; @@ -267,11 +281,17 @@ return result; } - public SortedSet<Individual> retrieval(Description concept) { + protected SortedSetTuple<Individual> doubleRetrievalImpl(Description concept) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + @Override + public final SortedSet<Individual> getIndividuals(Description concept) { reasoningStartTimeTmp = System.nanoTime(); SortedSet<Individual> result; try { - result = retrievalImpl(concept); + result = getIndividualsImpl(concept); } catch (ReasoningMethodUnsupportedException e) { handleExceptions(e); return null; @@ -283,11 +303,17 @@ return result; } - public boolean instanceCheck(Description concept, Individual s) { + protected SortedSet<Individual> getIndividualsImpl(Description concept) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + @Override + public final boolean hasType(Description concept, Individual s) { reasoningStartTimeTmp = System.nanoTime(); boolean result = false; try { - result = instanceCheckImpl(concept, s); + result = hasTypeImpl(concept, s); } catch (ReasoningMethodUnsupportedException e) { handleExceptions(e); } @@ -298,6 +324,13 @@ return result; } + protected boolean hasTypeImpl(Description concept, Individual individual) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + // ////// STOPPED HERE ////////// + public SortedSet<Individual> instanceCheck(Description concept, Set<Individual> s) { // logger.debug("instanceCheck "+concept.toKBSyntaxString()); reasoningStartTimeTmp = System.nanoTime(); @@ -324,7 +357,7 @@ * @return A set of more general concepts. */ public SortedSet<Description> getMoreGeneralConcepts(Description concept) { - return getSubsumptionHierarchy().getMoreGeneralConcepts(concept); + return getClassHierarchy().getMoreGeneralConcepts(concept); } /** @@ -335,7 +368,7 @@ * @return A set of more special concepts. */ public SortedSet<Description> getMoreSpecialConcepts(Description concept) { - return getSubsumptionHierarchy().getMoreSpecialConcepts(concept); + return getClassHierarchy().getMoreSpecialConcepts(concept); } /** @@ -418,22 +451,29 @@ return getDatatypePropertyHierarchy().getMostSpecialRoles(); } - protected void prepareSubsumptionHierarchy() throws ReasoningMethodUnsupportedException { + protected ClassHierarchy prepareSubsumptionHierarchy() throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException( "Subsumption hierarchy creation not supported by this reasoner."); } - public SubsumptionHierarchy getSubsumptionHierarchy() { - if (subsumptionHierarchy == null) { - try { - prepareSubsumptionHierarchy(); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); + @Override + public final ClassHierarchy getClassHierarchy() { + try { + if (subsumptionHierarchy == null) { + subsumptionHierarchy = prepareSubsumptionHierarchy(); } +// subsumptionHierarchy = getSubsumptionHierarchyImpl(); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); } + return subsumptionHierarchy; } + public ClassHierarchy getSubsumptionHierarchyImpl() throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + protected void prepareRoleHierarchy() throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException( "Object property hierarchy creation not supported by this reasoner."); @@ -723,36 +763,6 @@ return nrOfMultiInstanceChecks; } - public boolean subsumesImpl(Description superConcept, Description subConcept) - throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public Set<Description> subsumesImpl(Description superConcept, Set<Description> subConcepts) - throws ReasoningMethodUnsupportedException { - Set<Description> returnSet = new HashSet<Description>(); - for (Description subConcept : subConcepts) { - if (subsumes(superConcept, subConcept)) - returnSet.add(subConcept); - } - return returnSet; - } - - public Set<Description> subsumesImpl(Set<Description> superConcepts, Description subConcept) - throws ReasoningMethodUnsupportedException { - Set<Description> returnSet = new HashSet<Description>(); - for (Description superConcept : superConcepts) { - if (subsumes(superConcept, subConcept)) - returnSet.add(superConcept); - } - return returnSet; - } - - public SortedSet<Individual> retrievalImpl(Description concept) - throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - public Set<Individual> getRelatedIndividualsImpl(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); @@ -864,26 +874,16 @@ return ret; } - public boolean instanceCheckImpl(Description concept, Individual individual) - throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - public SortedSet<Individual> instanceCheckImpl(Description concept, Set<Individual> individuals) throws ReasoningMethodUnsupportedException { SortedSet<Individual> returnSet = new TreeSet<Individual>(); for (Individual individual : individuals) { - if (instanceCheck(concept, individual)) + if (hasType(concept, individual)) returnSet.add(individual); } return returnSet; } - public SortedSetTuple<Individual> doubleRetrievalImpl(Description concept) - throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - public SortedSetTuple<Individual> doubleRetrievalImpl(Description concept, Description adc) throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); @@ -893,11 +893,8 @@ throw new ReasoningMethodUnsupportedException(); } - public SubsumptionHierarchy getSubsumptionHierarchyImpl() - throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } + public void prepareRoleHierarchyImpl(Set<ObjectProperty> allowedRoles) throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); Deleted: trunk/src/dl-learner/org/dllearner/core/ReasonerComponentOld.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponentOld.java 2008-11-10 16:53:59 UTC (rev 1503) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponentOld.java 2008-11-10 18:09:19 UTC (rev 1504) @@ -1,304 +0,0 @@ -/** - * Copyright (C) 2007, 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.core; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeMap; -import java.util.TreeSet; -import java.util.Map.Entry; - -import org.dllearner.core.owl.Constant; -import org.dllearner.core.owl.DataRange; -import org.dllearner.core.owl.DatatypeProperty; -import org.dllearner.core.owl.DatatypePropertyHierarchy; -import org.dllearner.core.owl.Entity; -import org.dllearner.core.owl.NamedClass; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.Individual; -import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.core.owl.ObjectPropertyHierarchy; -import org.dllearner.core.owl.SubsumptionHierarchy; -import org.dllearner.utilities.datastructures.SortedSetTuple; - -/** - * Component representing a reasoner. - * - * @author Jens Lehmann - * - */ -@Deprecated -public abstract class ReasonerComponentOld extends Component implements ReasonerOld { - - protected Set<KnowledgeSource> sources; - - public ReasonerComponentOld(Set<KnowledgeSource> sources) { - this.sources = sources; - } - - /** - * @return the sources - */ - public Set<KnowledgeSource> getSources() { - return sources; - } - - /** - * Method to exchange the reasoner underlying the learning - * problem. - * Implementations, which do not only use the provided sources - * class variable, must make sure that a call to this method - * indeed changes them. - * @param sources The new knowledge sources. - */ - public void changeSources(Set<KnowledgeSource> sources) { - this.sources = sources; - } - - public abstract boolean hasDatatypeSupport(); - - public boolean subsumes(Description superConcept, Description subConcept) - throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public Set<Description> subsumes(Description superConcept, Set<Description> subConcepts) - throws ReasoningMethodUnsupportedException { - Set<Description> returnSet = new HashSet<Description>(); - for (Description subConcept : subConcepts) { - if (subsumes(superConcept, subConcept)) - returnSet.add(subConcept); - } - return returnSet; - } - - public Set<Description> subsumes(Set<Description> superConcepts, Description subConcept) - throws ReasoningMethodUnsupportedException { - Set<Description> returnSet = new HashSet<Description>(); - for (Description superConcept : superConcepts) { - if (subsumes(superConcept, subConcept)) - returnSet.add(superConcept); - } - return returnSet; - } - - public SortedSet<Individual> retrieval(Description concept) - throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public Set<Constant> getLabel(Entity entity) throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - - public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) - throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public Map<Individual, SortedSet<Constant>> getDatatypeMembers(DatatypeProperty datatypeProperty) - throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - // convenience method to get int value mappings of a datatype property - public Map<Individual, SortedSet<Integer>> getIntDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { - Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembers(datatypeProperty); - Map<Individual, SortedSet<Integer>> ret = new TreeMap<Individual, SortedSet<Integer>>(); - for(Entry<Individual, SortedSet<Constant>> e : mapping.entrySet()) { - SortedSet<Constant> values = e.getValue(); - SortedSet<Integer> valuesInt = new TreeSet<Integer>(); - for(Constant c : values) { - int v = Integer.parseInt(c.getLiteral()); - valuesInt.add(v); - } - ret.put(e.getKey(),valuesInt); - } - return ret; - } - - // convenience method to get double value mappings of a datatype property - public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { - Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembers(datatypeProperty); - Map<Individual, SortedSet<Double>> ret = new TreeMap<Individual, SortedSet<Double>>(); - for(Entry<Individual, SortedSet<Constant>> e : mapping.entrySet()) { - SortedSet<Constant> values = e.getValue(); - SortedSet<Double> valuesDouble = new TreeSet<Double>(); - for(Constant c : values) { - double v = Double.parseDouble(c.getLiteral()); - valuesDouble.add(v); - } - ret.put(e.getKey(),valuesDouble); - } - return ret; - } - - // convenience method to get boolean value mappings of a datatype property - public Map<Individual, SortedSet<Boolean>> getBooleanDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { - Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembers(datatypeProperty); - Map<Individual, SortedSet<Boolean>> ret = new TreeMap<Individual, SortedSet<Boolean>>(); - for(Entry<Individual, SortedSet<Constant>> e : mapping.entrySet()) { - SortedSet<Constant> values = e.getValue(); - SortedSet<Boolean> valuesBoolean = new TreeSet<Boolean>(); - for(Constant c : values) { - boolean v = Boolean.parseBoolean(c.getLiteral()); - valuesBoolean.add(v); - } - ret.put(e.getKey(),valuesBoolean); - } - return ret; - } - - // convenience method returning those values which have value "true" for this - // datatype property - public SortedSet<Individual> getTrueDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { - Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembers(datatypeProperty); - SortedSet<Individual> ret = new TreeSet<Individual>(); - for(Entry<Individual, SortedSet<Constant>> e : mapping.entrySet()) { - SortedSet<Constant> values = e.getValue(); - for(Constant c : values) { - boolean v = Boolean.parseBoolean(c.getLiteral()); - if(v == true) - ret.add(e.getKey()); - } - } - return ret; - } - - // convenience method returning those values which have value "false" for this - // datatype property - public SortedSet<Individual> getFalseDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { - Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembers(datatypeProperty); - SortedSet<Individual> ret = new TreeSet<Individual>(); - for(Entry<Individual, SortedSet<Constant>> e : mapping.entrySet()) { - SortedSet<Constant> values = e.getValue(); - for(Constant c : values) { - boolean v = Boolean.parseBoolean(c.getLiteral()); - if(v == false) - ret.add(e.getKey()); - } - } - return ret; - } - - public boolean instanceCheck(Description concept, Individual individual) - throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public SortedSet<Individual> instanceCheck(Description concept, Set<Individual> individuals) - throws ReasoningMethodUnsupportedException { - SortedSet<Individual> returnSet = new TreeSet<Individual>(); - for (Individual individual : individuals) { - if (instanceCheck(concept, individual)) - returnSet.add(individual); - } - return returnSet; - } - - public SortedSetTuple<Individual> doubleRetrieval(Description concept) - throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public SortedSetTuple<Individual> doubleRetrieval(Description concept, Description adc) - throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public boolean isSatisfiable() throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public SubsumptionHierarchy getSubsumptionHierarchy() - throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public void prepareDatatypePropertyHierarchy(Set<DatatypeProperty> allowedDatatypeProperties) throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public ObjectPropertyHierarchy getRoleHierarchy() throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public DatatypePropertyHierarchy getDatatypePropertyHierarchy() throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public Set<NamedClass> getConcepts(Individual i) throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public Description getDomain(ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public Description getDomain(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public Description getRange(ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public DataRange getRange(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public SortedSet<DatatypeProperty> getDatatypeProperties() throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public SortedSet<DatatypeProperty> getBooleanDatatypeProperties() throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public SortedSet<DatatypeProperty> getDoubleDatatypeProperties() throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public SortedSet<DatatypeProperty> getIntDatatypeProperties() throws ReasoningMethodUnsupportedException { - throw new ReasoningMethodUnsupportedException(); - } - - public abstract void releaseKB(); - - public Set<NamedClass> getInconsistentClasses() throws ReasoningMethodUnsupportedException{ - throw new ReasoningMethodUnsupportedException(); - } - -} Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerOld.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerOld.java 2008-11-10 16:53:59 UTC (rev 1503) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerOld.java 2008-11-10 18:09:19 UTC (rev 1504) @@ -34,7 +34,7 @@ import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectPropertyHierarchy; -import org.dllearner.core.owl.SubsumptionHierarchy; +import org.dllearner.core.owl.ClassHierarchy; import org.dllearner.reasoning.ReasonerType; import org.dllearner.utilities.datastructures.SortedSetTuple; @@ -69,7 +69,7 @@ // public SortedSet<Concept> getMoreGeneralConcepts(Concept concept) throws ReasoningMethodUnsupportedException; // public SortedSet<Concept> getMoreSpecialConcepts(Concept concept) throws ReasoningMethodUnsupportedException; - public SubsumptionHierarchy getSubsumptionHierarchy() throws ReasoningMethodUnsupportedException; + public ClassHierarchy getSubsumptionHierarchy() throws ReasoningMethodUnsupportedException; public ObjectPropertyHierarchy getRoleHierarchy() throws ReasoningMethodUnsupportedException; Deleted: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-11-10 16:53:59 UTC (rev 1503) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-11-10 18:09:19 UTC (rev 1504) @@ -1,748 +0,0 @@ -/** - * Copyright (C) 2007, 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.core; - -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.apache.log4j.Logger; -import org.dllearner.core.owl.Constant; -import org.dllearner.core.owl.DataRange; -import org.dllearner.core.owl.DatatypeProperty; -import org.dllearner.core.owl.DatatypePropertyHierarchy; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.Entity; -import org.dllearner.core.owl.Individual; -import org.dllearner.core.owl.NamedClass; -import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.core.owl.ObjectPropertyHierarchy; -import org.dllearner.core.owl.SubsumptionHierarchy; -import org.dllearner.reasoning.ReasonerType; -import org.dllearner.utilities.datastructures.SortedSetTuple; -import org.dllearner.utilities.owl.OWLVocabulary; - -/** - * The reasoning service is the interface to the used reasoner. Basically, - * it delegates all incoming reasoner request to the <code>Reasoner</code> - * object which has been specified in the constructor. However, it calculates - * some additional statistics about the time the reasoner needs to answer - * the query. - * - * @author Jens Lehmann - * - */ -@Deprecated -public class ReasoningService { - - public static Logger logger = Logger.getLogger(ReasoningService.class); - - // statistische Daten - private long instanceCheckReasoningTimeNs = 0; - private int nrOfInstanceChecks = 0; - private int nrOfMultiInstanceChecks = 0; - private long retrievalReasoningTimeNs = 0; - private int nrOfRetrievals = 0; - private long subsumptionReasoningTimeNs = 0; - private int nrOfSubsumptionChecks = 0; - private int nrOfMultiSubsumptionChecks = 0; - // private long subsumptionHierarchyTimeNs = 0; - private int nrOfSubsumptionHierarchyQueries = 0; - - // restliche Reasoning-Zeit - private long otherReasoningTimeNs = 0; - - // Zeit für alle Reasoningaufgabe (normalerweise länger als nur - // obige Sachen) - private long overallReasoningTimeNs = 0; - - // temporäre Variablen (ausgelagert wg. Performance und Vereinfachung) - private long reasoningStartTimeTmp; - private long reasoningDurationTmp; - - // Listenansicht - private List<NamedClass> atomicConceptsList; - private List<ObjectProperty> atomicRolesList; - - // private SortedSet<Concept> retrievalsSet = new TreeSet<Concept>(new ConceptComparator()); - - private ReasonerComponentOld reasoner; - - /** - * Constructs a reasoning service object. Note that you must not - * modify the underlying knowledge base of a reasoning service - * (if you do, you have to create a new reasoning service object). - * Further note, that the initialisation is lazy, e.g. you can - * feed the constructor with a non-initialised reasoner component. - * However, of course you need to make sure that the resoner component - * is initialised before the first reasoner query. - * - * @param reasoner - */ - public ReasoningService(ReasonerComponentOld reasoner) { - this.reasoner = reasoner; - - resetStatistics(); - } - - // zurücksetzen aller Statistiken (wenn z.B. vorher ein Satisfiability Check gemacht wird, - // der allerdings nicht zum eigentlichen Algorithmus gehört) - public void resetStatistics() { - instanceCheckReasoningTimeNs = 0; - nrOfInstanceChecks = 0; - retrievalReasoningTimeNs = 0; - nrOfRetrievals = 0; - subsumptionReasoningTimeNs = 0; - nrOfSubsumptionChecks = 0; - // subsumptionHierarchyTimeNs = 0; - nrOfSubsumptionHierarchyQueries = 0; - otherReasoningTimeNs = 0; - overallReasoningTimeNs = 0; - } - - public SortedSetTuple<Individual> doubleRetrieval(Description concept) { - reasoningStartTimeTmp = System.nanoTime(); - SortedSetTuple<Individual> result; - try { - result = reasoner.doubleRetrieval(concept); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; - otherReasoningTimeNs += reasoningDurationTmp; - overallReasoningTimeNs += reasoningDurationTmp; - return result; - } - - public SortedSetTuple<Individual> doubleRetrieval(Description concept, Description adc) { - reasoningStartTimeTmp = System.nanoTime(); - SortedSetTuple<Individual> result; - try { - result = reasoner.doubleRetrieval(concept, adc); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; - otherReasoningTimeNs += reasoningDurationTmp; - overallReasoningTimeNs += reasoningDurationTmp; - return result; - } - - // nachher wieder entfernen - // public static List<Concept> retrievals = new LinkedList<Concept>(); - - public SortedSet<Individual> retrieval(Description concept) { - // Test, ob tatsächlich keine doppelten Retrievals ausgeführt werden - // retrievals.add(concept); - //logger.debug("retrieval "+concept.toKBSyntaxString()); - - reasoningStartTimeTmp = System.nanoTime(); - SortedSet<Individual> result; - try { - result = reasoner.retrieval(concept); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - nrOfRetrievals++; - reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; - retrievalReasoningTimeNs += reasoningDurationTmp; - overallReasoningTimeNs += reasoningDurationTmp; - //logger.debug("retrieval done"); - return result; - } - - public boolean instanceCheck(Description concept, Individual s) { - //logger.debug("instanceCheck "+concept.toKBSyntaxString()); - reasoningStartTimeTmp = System.nanoTime(); - boolean result = false; - try { - result = reasoner.instanceCheck(concept, s); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - } - nrOfInstanceChecks++; - reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; - instanceCheckReasoningTimeNs += reasoningDurationTmp; - overallReasoningTimeNs += reasoningDurationTmp; - //logger.debug("instanceCheck done"); - return result; - } - - public SortedSet<Individual> instanceCheck(Description concept, Set<Individual> s) { - //logger.debug("instanceCheck "+concept.toKBSyntaxString()); - reasoningStartTimeTmp = System.nanoTime(); - SortedSet<Individual> result = null; - try { - result = reasoner.instanceCheck(concept, s); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - } - nrOfInstanceChecks+=s.size(); - nrOfMultiInstanceChecks++; - reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; - instanceCheckReasoningTimeNs += reasoningDurationTmp; - overallReasoningTimeNs += reasoningDurationTmp; - //logger.debug("instanceCheck done"); - return result; - } - - // c1 subsummiert c2 - public boolean subsumes(Description superConcept, Description subConcept) { - reasoningStartTimeTmp = System.nanoTime(); - boolean result = false; - try { - result = reasoner.subsumes(superConcept, subConcept); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - } - nrOfSubsumptionChecks++; - reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; - subsumptionReasoningTimeNs += reasoningDurationTmp; - overallReasoningTimeNs += reasoningDurationTmp; - return result; - } - - public Set<Description> subsumes(Set<Description> superConcepts, Description subConcept) { - reasoningStartTimeTmp = System.nanoTime(); - Set<Description> result = null; - try { - result = reasoner.subsumes(superConcepts, subConcept); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - } - nrOfSubsumptionChecks += superConcepts.size(); - nrOfMultiSubsumptionChecks++; - reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; - subsumptionReasoningTimeNs += reasoningDurationTmp; - overallReasoningTimeNs += reasoningDurationTmp; - return result; - } - - /* - // Problem: wie behandle ich Top und Bottom? - // TODO: schauen wie das in KAON2 gemacht wird - public SortedSet<Concept> getMoreGeneralConcepts(Concept concept) { - if(Config.useHierarchyReasonerBenchmarks) - reasoningStartTimeTmp = System.nanoTime(); - SortedSet<Concept> result; - try { - result = reasoner.getMoreGeneralConcepts(concept); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - if(Config.useHierarchyReasonerBenchmarks) { - nrOfSubsumptionHierarchyQueries++; - reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; - subsumptionHierarchyTimeNs += reasoningDurationTmp; - overallReasoningTimeNs += reasoningDurationTmp; - } - return result; - } - - public SortedSet<Concept> getMoreSpecialConcepts(Concept concept) { - if(Config.useHierarchyReasonerBenchmarks) - reasoningStartTimeTmp = System.nanoTime(); - SortedSet<Concept> result; - try { - result = reasoner.getMoreSpecialConcepts(concept); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - if(Config.useHierarchyReasonerBenchmarks) { - nrOfSubsumptionHierarchyQueries++; - reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; - subsumptionHierarchyTimeNs += reasoningDurationTmp; - overallReasoningTimeNs += reasoningDurationTmp; - } - return result; - } - */ - - /** - * Returns more general concepts in the subsumption hierarchy. - * - * @param concept Atomic concept, top, or bottom. - * @return A set of more general concepts. - */ - public SortedSet<Description> getMoreGeneralConcepts(Description concept) { - return getSubsumptionHierarchy().getMoreGeneralConcepts(concept); - } - - /** - * Returns more special concepts in the subsumption hierarchy. - * - * @param concept Atomic concept, top, or bottom. - * @return A set of more special concepts. - */ - public SortedSet<Description> getMoreSpecialConcepts(Description concept) { - return getSubsumptionHierarchy().getMoreSpecialConcepts(concept); - } - - /** - * Returns more general concepts in the subsumption hierarchy. - * - * @see ObjectPropertyHierarchy#getMoreGeneralRoles(ObjectProperty) - * @param role Atomic concept, top, or bottom. - * @return A set of more general concepts. - */ - public SortedSet<ObjectProperty> getMoreGeneralRoles(ObjectProperty role) { - return getRoleHierarchy().getMoreGeneralRoles(role); - } - - /** - * Returns more special concepts in the subsumption hierarchy. - * - * @see ObjectPropertyHierarchy#getMoreSpecialRoles(ObjectProperty) - * @param role Atomic concept, top, or bottom. - * @return A set of more special concepts. - */ - public SortedSet<ObjectProperty> getMoreSpecialRoles(ObjectProperty role) { - return getRoleHierarchy().getMoreSpecialRoles(role); - } - - /** - * @see ObjectPropertyHierarchy#getMostGeneralRoles() - * @return The most general roles. - */ - public TreeSet<ObjectProperty> getMostGeneralRoles() { - return getRoleHierarchy().getMostGeneralRoles(); - } - - /** - * @see ObjectPropertyHierarchy#getMostSpecialRoles() - * @return The most special roles. - */ - public TreeSet<ObjectProperty> getMostSpecialRoles() { - return getRoleHierarchy().getMostSpecialRoles(); - } - - /** - * Returns more general concepts in the subsumption hierarchy. - * - * @see ObjectPropertyHierarchy#getMoreGeneralRoles(ObjectProperty) - * @param role Atomic concept, top, or bottom. - * @return A set of more general concepts. - */ - public SortedSet<DatatypeProperty> getMoreGeneralDatatypeProperties(DatatypeProperty role) { - return getDatatypePropertyHierarchy().getMoreGeneralRoles(role); - } - - /** - * Returns more special concepts in the subsumption hierarchy. - * - * @see ObjectPropertyHierarchy#getMoreSpecialRoles(ObjectProperty) - * @param role Atomic concept, top, or bottom. - * @return A set of more special concepts. - */ - public SortedSet<DatatypeProperty> getMoreSpecialDatatypeProperties(DatatypeProperty role) { - return getDatatypePropertyHierarchy().getMoreSpecialRoles(role); - } - - /** - * @see ObjectPropertyHierarchy#getMostGeneralRoles() - * @return The most general roles. - */ - public TreeSet<DatatypeProperty> getMostGeneralDatatypeProperties() { - return getDatatypePropertyHierarchy().getMostGeneralRoles(); - } - - /** - * @see ObjectPropertyHierarchy#getMostSpecialRoles() - * @return The most special roles. - */ - public TreeSet<DatatypeProperty> getMostSpecialDatatypeProperties() { - return getDatatypePropertyHierarchy().getMostSpecialRoles(); - } - - public void prepareSubsumptionHierarchy() { - reasoner.prepareSubsumptionHierarchy(getNamedClasses()); - } - - public void prepareSubsumptionHierarchy(Set<NamedClass> allowedConcepts) { - reasoner.prepareSubsumptionHierarchy(allowedConcepts); - } - - public SubsumptionHierarchy getSubsumptionHierarchy() { - try { - if(reasoner.getSubsumptionHierarchy() == null){ - this.prepareSubsumptionHierarchy(); - } - - nrOfSubsumptionHierarchyQueries++; - return reasoner.getSubsumptionHierarchy(); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public void prepareRoleHierarchy() { - prepareRoleHierarchy(getObjectProperties()); - } - - public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { - try { - reasoner.prepareRoleHierarchy(allowedRoles); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - } - } - - public ObjectPropertyHierarchy getRoleHierarchy() { - try { - return reasoner.getRoleHierarchy(); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public void prepareDatatypePropertyHierarchy() { - prepareDatatypePropertyHierarchy(getDatatypeProperties()); - } - - public void prepareDatatypePropertyHierarchy(Set<DatatypeProperty> allowedRoles) { - try { - reasoner.prepareDatatypePropertyHierarchy(allowedRoles); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - } - } - - public DatatypePropertyHierarchy getDatatypePropertyHierarchy() { - try { - return reasoner.getDatatypePropertyHierarchy(); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public boolean isSatisfiable() { - reasoningStartTimeTmp = System.nanoTime(); - boolean result; - try { - result = reasoner.isSatisfiable(); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return false; - } - reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; - otherReasoningTimeNs += reasoningDurationTmp; - overallReasoningTimeNs += reasoningDurationTmp; - return result; - } - - public Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { - try { - return reasoner.getRelatedIndividuals(individual, objectProperty); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { - try { - return reasoner.getRelatedValues(individual, datatypeProperty); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public Set<Constant> getLabel(Entity entity) throws ReasoningMethodUnsupportedException { - try { - return reasoner.getLabel(entity); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - - public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) { - reasoningStartTimeTmp = System.nanoTime(); - Map<Individual, SortedSet<Individual>> result; - try { - result = reasoner.getRoleMembers(atomicRole); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; - otherReasoningTimeNs += reasoningDurationTmp; - overallReasoningTimeNs += reasoningDurationTmp; - return result; - } - - public boolean hasDatatypeSupport() { - return reasoner.hasDatatypeSupport(); - } - - public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty) { - try { - return reasoner.getDoubleDatatypeMembers(datatypeProperty); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public Map<Individual, SortedSet<Double>> getIntDatatypeMembers(DatatypeProperty datatypeProperty) { - try { - return reasoner.getDoubleDatatypeMembers(datatypeProperty); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public Map<Individual, SortedSet<Double>> getTrueDatatypeMembers(DatatypeProperty datatypeProperty) { - try { - return reasoner.getDoubleDatatypeMembers(datatypeProperty); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public Map<Individual, SortedSet<Double>> getFalseDatatypeMembers(DatatypeProperty datatypeProperty) { - try { - return reasoner.getDoubleDatatypeMembers(datatypeProperty); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public Set<NamedClass> getNamedClasses() { - return reasoner.getAtomicConcepts(); - } - - public Set<ObjectProperty> getObjectProperties() { - return reasoner.getAtomicRoles(); - } - - public SortedSet<DatatypeProperty> getDatatypeProperties() { - try { - return reasoner.getDatatypeProperties(); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public SortedSet<DatatypeProperty> getBooleanDatatypeProperties() { - try { - return reasoner.getBooleanDatatypeProperties(); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public SortedSet<DatatypeProperty> getIntDatatypeProperties() { - try { - return reasoner.getIntDatatypeProperties(); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public SortedSet<DatatypeProperty> getDoubleDatatypeProperties() { - try { - return reasoner.getDoubleDatatypeProperties(); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public SortedSet<Individual> getIndividuals() { - return reasoner.getIndividuals(); - } - - public Description getDomain(ObjectProperty objectProperty) { - try { - return reasoner.getDomain(objectProperty); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public Description getDomain(DatatypeProperty datatypeProperty) { - try { - return reasoner.getDomain(datatypeProperty); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public Description getRange(ObjectProperty objectProperty) { - try { - return reasoner.getRange(objectProperty); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public DataRange getRange(DatatypeProperty datatypeProperty) { - try { - return reasoner.getRange(datatypeProperty); - } catch (ReasoningMethodUnsupportedException e) { - handleExceptions(e); - return null; - } - } - - public ReasonerType getReasonerType() { - return reasoner.getReasonerType(); - } - - public List<NamedClass> getAtomicConceptsList() { - if(atomicConceptsList == null) - atomicConceptsList = new LinkedList<NamedClass>(getNamedClasses()); - return atomicConceptsList; - } - - public List<NamedClass> getAtomicConceptsList(boolean removeOWLThing) { - if(!removeOWLThing) { - return getAtomicConceptsList(); - }else { - List<NamedClass> l = new LinkedList<NamedClass>(); - for (NamedClass class1 : getAtomicConceptsList()) { - if(class1.compareTo(new NamedClass(OWLVocabulary.OWL_NOTHING)) == 0 || - class1.compareTo(new NamedClass(OWLVocabulary.OWL_THING)) == 0 ){ - ;//do nothing - }else{ - l.add(class1); - } - } - return l; - } - - } - - public List<ObjectProperty> getAtomicRolesList() { - if(atomicRolesList == null) - atomicRolesList = new LinkedList<ObjectProperty>(getObjectProperties()); - return atomicRolesList; - } - - public String getBaseURI() { - return reasoner.getBaseURI(); - } - - public Map<String, String> getPrefixes() { - return reasoner.getPrefixes(); - } - - public void releaseKB() { - reasoner.releaseKB(); - } - - public long getInstanceCheckReasoningTimeNs() { - return instance... [truncated message content] |