From: <jen...@us...> - 2008-11-10 11:00:35
|
Revision: 1500 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1500&view=rev Author: jenslehmann Date: 2008-11-10 11:00:23 +0000 (Mon, 10 Nov 2008) Log Message: ----------- - reasoner component redesign continued - SVN is now *broken*, please don't update if you want everything to work properly Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/ComponentManager.java trunk/src/dl-learner/org/dllearner/core/LearningProblem.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponentOld.java trunk/src/dl-learner/org/dllearner/core/ReasonerOld.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/examples/KRKModular.java trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java trunk/src/dl-learner/org/dllearner/gui/InitWorker.java trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.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/learningproblems/PosNegLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyInclusionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyLP.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/scripts/ConfigJavaGenerator.java trunk/src/dl-learner/org/dllearner/scripts/PaperStatistics.java trunk/src/dl-learner/org/dllearner/scripts/Sample.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java trunk/src/dl-learner/org/dllearner/server/ClientState.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/test/junit/RefinementOperatorTests.java trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnOWLFile.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparqlold.java trunk/src/dl-learner/org/dllearner/utilities/owl/OntologyCloser.java trunk/src/dl-learner/org/dllearner/utilities/owl/OntologyCloserOWLAPI.java trunk/src/dl-learner/org/dllearner/utilities/owl/ReasoningServiceFactory.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/BaseReasoner.java trunk/src/dl-learner/org/dllearner/core/IndividualReasoner.java trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/core/ReasonerNew.java Modified: trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java 2008-11-10 09:54:48 UTC (rev 1499) +++ trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -35,7 +35,7 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; -import org.dllearner.core.ReasonerComponentOld; +import org.dllearner.core.ReasonerComponent; import org.dllearner.kb.OWLFile; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.learningproblems.PosNegDefinitionLP; @@ -58,7 +58,7 @@ // mappings between component classes and their names in conf files private static Map<String,Class<? extends KnowledgeSource>> knowledgeSourceMapping = new TreeMap<String,Class<? extends KnowledgeSource>>(); - private static Map<String,Class<? extends ReasonerComponentOld>> reasonerMapping = new TreeMap<String,Class<? extends ReasonerComponentOld>>(); + private static Map<String,Class<? extends ReasonerComponent>> reasonerMapping = new TreeMap<String,Class<? extends ReasonerComponent>>(); private static Map<String,Class<? extends LearningProblem>> learningProblemMapping = new TreeMap<String,Class<? extends LearningProblem>>(); private static Map<String,Class<? extends LearningAlgorithm>> learningAlgorithmMapping = new TreeMap<String,Class<? extends LearningAlgorithm>>(); private static TreeMap<String,Class<? extends Component>> componentMapping = new TreeMap<String,Class<? extends Component>>(); @@ -108,7 +108,7 @@ private static void buildKeys() { // edit this part manually componentTypeMapping.put("import", KnowledgeSource.class); - componentTypeMapping.put("reasoner", ReasonerComponentOld.class); + componentTypeMapping.put("reasoner", ReasonerComponent.class); componentTypeMapping.put("problem", LearningProblem.class); componentTypeMapping.put("algorithm", LearningAlgorithm.class); @@ -123,7 +123,7 @@ return knowledgeSourceMapping.get(confString); } - public Class<? extends ReasonerComponentOld> getReasonerComponentClass(String confString) { + public Class<? extends ReasonerComponent> getReasonerComponentClass(String confString) { return reasonerMapping.get(confString); } Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-11-10 09:54:48 UTC (rev 1499) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -56,7 +56,7 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.OntologyFormat; -import org.dllearner.core.ReasonerComponentOld; +import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; import org.dllearner.core.config.BooleanConfigOption; @@ -113,7 +113,7 @@ private LearningAlgorithm la; private LearningProblem lp; private ReasoningService rs; - private ReasonerComponentOld rc; + private ReasonerComponent rc; /** * Entry point for CLI interface. @@ -245,7 +245,7 @@ // step 2: detect used reasoner Monitor rsMonitor = JamonMonitorLogger.getTimeMonitor(Start.class, "initReasoningService").start(); ConfFileOption reasonerOption = parser.getConfOptionsByName("reasoner"); - Class<? extends ReasonerComponentOld> rcClass; + Class<? extends ReasonerComponent> rcClass; if(reasonerOption != null) { rcClass = confMapper.getReasonerComponentClass(reasonerOption.getStringValue()); if(rcClass == null) { @@ -856,7 +856,7 @@ return lp; } - public ReasonerComponentOld getReasonerComponent() { + public ReasonerComponent getReasonerComponent() { return rc; } @@ -889,8 +889,8 @@ * @return reasonerClass reasoner class */ @Deprecated - public static Class<? extends ReasonerComponentOld> getReasonerClass(ConfFileOption reasonerOption) { - Class<? extends ReasonerComponentOld> reasonerClass = null; + public static Class<? extends ReasonerComponent> getReasonerClass(ConfFileOption reasonerOption) { + Class<? extends ReasonerComponent> reasonerClass = null; if (reasonerOption == null || reasonerOption.getStringValue().equals("fastInstanceChecker")) reasonerClass = FastInstanceChecker.class; else if (reasonerOption.getStringValue().equals("owlAPI")) Added: trunk/src/dl-learner/org/dllearner/core/BaseReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/BaseReasoner.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/BaseReasoner.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2007-2008, 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.Map; +import java.util.Set; +import java.util.SortedSet; + +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectProperty; + +/** + * Contains the following reasoning/query operations: + * <ul> + * <li>queries for elements contained in the knowledge base (classes, properties, ...)</li> + * <li>basic reasoning requests related to the knowledge base as a whole (e.g. consistency)</li> + * </ul> + * + * @author Jens Lehmann + * + */ +public interface BaseReasoner { + + /** + * Gets all named classes in the knowledge base, e.g. Person, City, Car. + * @return All named classes in KB. + */ + public Set<NamedClass> getNamedClasses(); + + /** + * Gets all object properties in the knowledge base, e.g. hasChild, isCapitalOf, hasEngine. + * @return All object properties in KB. + */ + public Set<ObjectProperty> getObjectProperties(); + + /** + * Gets all individuals in the knowledge base, e.g. Eric, London, Car829. + * @return All individuals in KB. + */ + public SortedSet<Individual> getIndividuals(); + + /** + * Returns the base URI of the knowledge base. If several knowledge sources are + * used, we only pick one of their base URIs. + * @return The base URI, e.g. http://dbpedia.org/resource/. + */ + public String getBaseURI(); + + /** + * Returns the prefixes used in the knowledge base, e.g. foaf for + * foaf: <http://xmlns.com/foaf/0.1/>. If several knowledge sources are used, + * their prefixes are merged. (In case a prefix is defined twice with different + * values, we pick one of those.) + * @return The prefix mapping. + */ + public Map<String, String> getPrefixes(); + +} Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2008-11-10 09:54:48 UTC (rev 1499) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -71,7 +71,7 @@ // these variables are valid for the complete lifetime of a DL-Learner session private static Collection<Class<? extends Component>> components; private static Collection<Class<? extends KnowledgeSource>> knowledgeSources; - private static Collection<Class<? extends ReasonerComponentOld>> reasonerComponents; + private static Collection<Class<? extends ReasonerComponent>> reasonerComponents; private static Collection<Class<? extends LearningProblem>> learningProblems; private static Collection<Class<? extends LearningAlgorithm>> learningAlgorithms; // you can either use the components.ini file or directly specify the classes to use @@ -111,7 +111,7 @@ // component list components = new TreeSet<Class<? extends Component>>(classComparator); knowledgeSources = new TreeSet<Class<? extends KnowledgeSource>>(classComparator); - reasonerComponents = new TreeSet<Class<? extends ReasonerComponentOld>>(classComparator); + reasonerComponents = new TreeSet<Class<? extends ReasonerComponent>>(classComparator); learningProblems = new TreeSet<Class<? extends LearningProblem>>(classComparator); learningAlgorithms = new TreeSet<Class<? extends LearningAlgorithm>>(classComparator); algorithmProblemsMapping = new TreeMap<Class<? extends LearningAlgorithm>, Collection<Class<? extends LearningProblem>>>( @@ -126,8 +126,8 @@ if (KnowledgeSource.class.isAssignableFrom(component)) { knowledgeSources.add((Class<? extends KnowledgeSource>) component); - } else if (ReasonerComponentOld.class.isAssignableFrom(component)) { - reasonerComponents.add((Class<? extends ReasonerComponentOld>) component); + } else if (ReasonerComponent.class.isAssignableFrom(component)) { + reasonerComponents.add((Class<? extends ReasonerComponent>) component); } else if (LearningProblem.class.isAssignableFrom(component)) { learningProblems.add((Class<? extends LearningProblem>) component); } else if (LearningAlgorithm.class.isAssignableFrom(component)) { @@ -324,7 +324,7 @@ * @param source A knowledge source. * @return A reasoner component. */ - public <T extends ReasonerComponentOld> T reasoner(Class<T> reasoner, + public <T extends ReasonerComponent> T reasoner(Class<T> reasoner, KnowledgeSource source) { Set<KnowledgeSource> sources = new HashSet<KnowledgeSource>(); sources.add(source); @@ -340,7 +340,7 @@ * @param sources A set of knowledge sources. * @return A reasoner component. */ - public <T extends ReasonerComponentOld> T reasoner(Class<T> reasoner, + public <T extends ReasonerComponent> T reasoner(Class<T> reasoner, Set<KnowledgeSource> sources) { if (!reasonerComponents.contains(reasoner)) { System.err.println("Warning: reasoner component " + reasoner @@ -365,9 +365,9 @@ * @param reasoner A reasoner component. * @return The reasoning service encapsulating the reasoner. */ - public ReasoningService reasoningService(ReasonerComponentOld reasoner) { - return new ReasoningService(reasoner); - } +// public ReasoningService reasoningService(ReasonerComponent reasoner) { +// return new ReasoningService(reasoner); +// } /** * Factory method for creating a learning problem component. @@ -376,13 +376,13 @@ * @param reasoner A reasoning service object. * @return A learning problem component. */ - public <T extends LearningProblem> T learningProblem(Class<T> lpClass, ReasoningService reasoner) { + public <T extends LearningProblem> T learningProblem(Class<T> lpClass, ReasonerComponent reasoner) { if (!learningProblems.contains(lpClass)) { System.err.println("Warning: learning problem " + lpClass + " is not a registered learning problem component."); } - T lp = invokeConstructor(lpClass, new Class[] { ReasoningService.class }, + T lp = invokeConstructor(lpClass, new Class[] { ReasonerComponent.class }, new Object[] { reasoner }); pool.registerComponent(lp); return lp; @@ -399,7 +399,7 @@ * @throws LearningProblemUnsupportedException Thrown when the learning problem and * the learning algorithm are not compatible. */ - public <T extends LearningAlgorithm> T learningAlgorithm(Class<T> laClass, LearningProblem lp, ReasoningService rs) throws LearningProblemUnsupportedException { + public <T extends LearningAlgorithm> T learningAlgorithm(Class<T> laClass, LearningProblem lp, ReasonerComponent rs) throws LearningProblemUnsupportedException { if (!learningAlgorithms.contains(laClass)) { System.err.println("Warning: learning algorithm " + laClass + " is not a registered learning algorithm component."); @@ -423,7 +423,7 @@ // return null; } - T la = invokeConstructor(laClass, new Class[] { constructorArgument, ReasoningService.class }, new Object[] { lp, rs }); + T la = invokeConstructor(laClass, new Class[] { constructorArgument, ReasonerComponent.class }, new Object[] { lp, rs }); pool.registerComponent(la); return la; } @@ -659,8 +659,8 @@ * @return the components A list of reasoner component classes available in this * instance of <code>ComponentManager</code>. */ - public List<Class<? extends ReasonerComponentOld>> getReasonerComponents() { - return new LinkedList<Class<? extends ReasonerComponentOld>>(reasonerComponents); + public List<Class<? extends ReasonerComponent>> getReasonerComponents() { + return new LinkedList<Class<? extends ReasonerComponent>>(reasonerComponents); } /** Added: trunk/src/dl-learner/org/dllearner/core/IndividualReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/IndividualReasoner.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/IndividualReasoner.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2007-2008, 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; + +/** + * Reasoning requests/queries related to individuals in the knowledge base. + * + * @author Jens Lehmann + * + */ +public interface IndividualReasoner { + +} Modified: trunk/src/dl-learner/org/dllearner/core/LearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningProblem.java 2008-11-10 09:54:48 UTC (rev 1499) +++ trunk/src/dl-learner/org/dllearner/core/LearningProblem.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -46,17 +46,17 @@ * Implementations of learning problems can use this class * variable to perform reasoner operations. */ - protected ReasoningService reasoningService; + protected ReasonerComponent reasoner; /** * Constructs a learning problem using a reasoning service for * querying the background knowledge. It can be used for * evaluating solution candidates. - * @param reasoningService The reasoning service used as + * @param reasoner The reasoning service used as * background knowledge. */ - public LearningProblem(ReasoningService reasoningService) { - this.reasoningService = reasoningService; + public LearningProblem(ReasonerComponent reasoner) { + this.reasoner = reasoner; } /** @@ -65,10 +65,10 @@ * Implementations, which do not only use the provided reasoning * service class variable, must make sure that a call to this method * indeed changes the reasoning service. - * @param reasoningService New reasoning service. + * @param reasoner New reasoning service. */ - public void changeReasoningService(ReasoningService reasoningService) { - this.reasoningService = reasoningService; + public void changeReasoningService(ReasonerComponent reasoner) { + this.reasoner = reasoner; } /** Copied: trunk/src/dl-learner/org/dllearner/core/Reasoner.java (from rev 1499, trunk/src/dl-learner/org/dllearner/core/ReasonerNew.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2007-2008, 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; + +/** + * List of available reasoning/query methods. + * + * @author Jens Lehmann + * + */ +public interface Reasoner extends BaseReasoner, SchemaReasoner, IndividualReasoner { + +} Added: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -0,0 +1,934 @@ +/** + * Copyright (C) 2007-2008, 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.LinkedList; +import java.util.List; +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.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; + +/** + * Abstract component representing a reasoner. Only a few reasoning operations + * are guaranteed to be implemented by the underlying reasoner, while a + * {@link ReasoningMethodUnsupportedException} is thrown for all other methods. + * In addition to calling the actual implementations of reasoning operations, + * the class also collects statistical information, which can be queried. + * + * @author Jens Lehmann + * + */ +public abstract class ReasonerComponent extends Component implements Reasoner { + + public static Logger logger = Logger.getLogger(ReasonerComponent.class); + + // statistical data for particular reasoning operations + 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 int nrOfSubsumptionHierarchyQueries = 0; + + // rest of reasoning time + private long otherReasoningTimeNs = 0; + + // time for all reasoning requests (usually longer than the sum of all + // above) + private long overallReasoningTimeNs = 0; + + // temporary variables (moved here for performance reasons) + private long reasoningStartTimeTmp; + private long reasoningDurationTmp; + + // list view + private List<NamedClass> atomicConceptsList; + private List<ObjectProperty> atomicRolesList; + + // hierarchies (they are computed the first time they are needed) + private SubsumptionHierarchy subsumptionHierarchy; + private ObjectPropertyHierarchy roleHierarchy; + private DatatypePropertyHierarchy datatypePropertyHierarchy; + + /** + * The underlying knowledge sources. + */ + protected Set<KnowledgeSource> sources; + + /** + * Constructs a new reasoner component. + * + * @param sources + * The underlying knowledge sources. + */ + public ReasonerComponent(Set<KnowledgeSource> sources) { + this.sources = sources; + } + + /** + * Gets the knowledge sources used by this reasoner. + * + * @return The underlying knowledge 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; + } + + /** + * Gets the type of the underlying reasoner. Although rarely necessary, + * applications can use this to adapt their behaviour to the reasoner. + * + * @return The reasoner type. + */ + public abstract ReasonerType getReasonerType(); + + /** + * Reset all statistics. Usually, you do not need to call this. However, if + * you e.g. perform benchmarks of learning algorithms and performing + * reasoning operations, such as a consistency check, before starting the + * algorithm, you can use this method to reset all statistical values. + */ + public void resetStatistics() { + instanceCheckReasoningTimeNs = 0; + nrOfInstanceChecks = 0; + retrievalReasoningTimeNs = 0; + nrOfRetrievals = 0; + subsumptionReasoningTimeNs = 0; + nrOfSubsumptionChecks = 0; + // subsumptionHierarchyTimeNs = 0; + nrOfSubsumptionHierarchyQueries = 0; + otherReasoningTimeNs = 0; + overallReasoningTimeNs = 0; + } + + /** + * 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. + */ + public abstract void releaseKB(); + + // we cannot expect callers of reasoning methods to reliably recover if + // certain reasoning methods are not implemented by the backend; we also + // should not require callers to build catch clauses each time they make + // a reasoner request => for this reasoner, we throw a runtime exception + // here + private void handleExceptions(ReasoningMethodUnsupportedException e) { + e.printStackTrace(); + throw new RuntimeException("Reasoning method not supported.", e); + } + + @Override + public boolean subsumes(Description superClass, Description subClass) { + reasoningStartTimeTmp = System.nanoTime(); + boolean result = false; + try { + result = subsumesImpl(superClass, subClass); + } 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 = subsumesImpl(superConcepts, subConcept); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + } + nrOfSubsumptionChecks += superConcepts.size(); + nrOfMultiSubsumptionChecks++; + 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) { + reasoningStartTimeTmp = System.nanoTime(); + SortedSetTuple<Individual> result; + try { + result = doubleRetrievalImpl(concept, adc); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; + otherReasoningTimeNs += reasoningDurationTmp; + overallReasoningTimeNs += reasoningDurationTmp; + return result; + } + + public SortedSet<Individual> retrieval(Description concept) { + reasoningStartTimeTmp = System.nanoTime(); + SortedSet<Individual> result; + try { + result = retrievalImpl(concept); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + nrOfRetrievals++; + reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; + retrievalReasoningTimeNs += reasoningDurationTmp; + overallReasoningTimeNs += reasoningDurationTmp; + return result; + } + + public boolean instanceCheck(Description concept, Individual s) { + reasoningStartTimeTmp = System.nanoTime(); + boolean result = false; + try { + result = instanceCheckImpl(concept, s); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + } + nrOfInstanceChecks++; + reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; + instanceCheckReasoningTimeNs += reasoningDurationTmp; + overallReasoningTimeNs += reasoningDurationTmp; + 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 = instanceCheckImpl(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; + } + + /** + * 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(); + } + + protected void 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); + } + } + return subsumptionHierarchy; + } + + protected void prepareRoleHierarchy() throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException( + "Object property hierarchy creation not supported by this reasoner."); + } + + public ObjectPropertyHierarchy getRoleHierarchy() { + if (roleHierarchy == null) { + try { + prepareRoleHierarchy(); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + } + } + return roleHierarchy; + } + + protected void prepareDatatypePropertyHierarchy() throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException( + "Datatype property hierarchy creation not supported by this reasoner."); + } + + public DatatypePropertyHierarchy getDatatypePropertyHierarchy() { + if (datatypePropertyHierarchy == null) { + try { + prepareDatatypePropertyHierarchy(); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + } + } + return datatypePropertyHierarchy; + } + + public boolean isSatisfiable() { + reasoningStartTimeTmp = System.nanoTime(); + boolean result; + try { + result = isSatisfiableImpl(); + } 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 getRelatedIndividualsImpl(individual, objectProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) + throws ReasoningMethodUnsupportedException { + try { + return getRelatedValuesImpl(individual, datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Set<Constant> getLabel(Entity entity) throws ReasoningMethodUnsupportedException { + try { + return getLabelImpl(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 = getRoleMembersImpl(atomicRole); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; + otherReasoningTimeNs += reasoningDurationTmp; + overallReasoningTimeNs += reasoningDurationTmp; + return result; + } + + public abstract boolean hasDatatypeSupport(); + + public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers( + DatatypeProperty datatypeProperty) { + try { + return getDoubleDatatypeMembersImpl(datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Map<Individual, SortedSet<Integer>> getIntDatatypeMembers( + DatatypeProperty datatypeProperty) { + try { + return getIntDatatypeMembersImpl(datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public SortedSet<Individual> getTrueDatatypeMembers(DatatypeProperty datatypeProperty) { + try { + return getTrueDatatypeMembersImpl(datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public SortedSet<Individual> getFalseDatatypeMembers(DatatypeProperty datatypeProperty) { + try { + return getFalseDatatypeMembersImpl(datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public SortedSet<DatatypeProperty> getDatatypeProperties() { + try { + return getDatatypePropertiesImpl(); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public SortedSet<DatatypeProperty> getBooleanDatatypeProperties() { + try { + return getBooleanDatatypePropertiesImpl(); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public SortedSet<DatatypeProperty> getIntDatatypeProperties() { + try { + return getIntDatatypePropertiesImpl(); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public SortedSet<DatatypeProperty> getDoubleDatatypeProperties() { + try { + return getDoubleDatatypePropertiesImpl(); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Description getDomain(ObjectProperty objectProperty) { + try { + return getDomainImpl(objectProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Description getDomain(DatatypeProperty datatypeProperty) { + try { + return getDomainImpl(datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Description getRange(ObjectProperty objectProperty) { + try { + return getRangeImpl(objectProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public DataRange getRange(DatatypeProperty datatypeProperty) { + try { + return getRangeImpl(datatypeProperty); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + 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 long getInstanceCheckReasoningTimeNs() { + return instanceCheckReasoningTimeNs; + } + + public long getRetrievalReasoningTimeNs() { + return retrievalReasoningTimeNs; + } + + public int getNrOfInstanceChecks() { + return nrOfInstanceChecks; + } + + public int getNrOfRetrievals() { + return nrOfRetrievals; + } + + public int getNrOfSubsumptionChecks() { + return nrOfSubsumptionChecks; + } + + public long getSubsumptionReasoningTimeNs() { + return subsumptionReasoningTimeNs; + } + + /* + * public long getSubsumptionHierarchyTimeNs() { return + * subsumptionHierarchyTimeNs; } + */ + public int getNrOfSubsumptionHierarchyQueries() { + return nrOfSubsumptionHierarchyQueries; + } + + public long getOverallReasoningTimeNs() { + return overallReasoningTimeNs; + } + + public long getTimePerRetrievalNs() { + return retrievalReasoningTimeNs / nrOfRetrievals; + } + + public long getTimePerInstanceCheckNs() { + return instanceCheckReasoningTimeNs / nrOfInstanceChecks; + } + + public long getTimePerSubsumptionCheckNs() { + return subsumptionReasoningTimeNs / nrOfSubsumptionChecks; + } + + public int getNrOfMultiSubsumptionChecks() { + return nrOfMultiSubsumptionChecks; + } + + public int getNrOfMultiInstanceChecks() { + 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(); + } + + public Set<Constant> getRelatedValuesImpl(Individual individual, + DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Set<Constant> getLabelImpl(Entity entity) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Map<Individual, SortedSet<Individual>> getRoleMembersImpl(ObjectProperty atomicRole) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Map<Individual, SortedSet<Constant>> getDatatypeMembersImpl( + DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + // convenience method to get int value mappings of a datatype property + public Map<Individual, SortedSet<Integer>> getIntDatatypeMembersImpl( + DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembersImpl(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>> getDoubleDatatypeMembersImpl( + DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembersImpl(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>> getBooleanDatatypeMembersImpl( + DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembersImpl(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> getTrueDatatypeMembersImpl(DatatypeProperty datatypeProperty) + throws ReasoningMethodUnsupportedException { + Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembersImpl(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> getFalseDatatypeMembersImpl(DatatypeProperty datatypeProperty) + throws ReasoningMethodUnsupportedException { + Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembersImpl(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 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)) + 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(); + } + + public boolean isSatisfiableImpl() throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public SubsumptionHierarchy getSubsumptionHierarchyImpl() + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public void prepareRoleHierarchyImpl(Set<ObjectProperty> allowedRoles) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public void prepareDatatypePropertyHierarchyImpl(Set<DatatypeProperty> allowedDatatypeProperties) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public ObjectPropertyHierarchy getRoleHierarchyImpl() + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public DatatypePropertyHierarchy getDatatypePropertyHierarchyImpl() + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Set<NamedClass> getConceptsImpl(Individual i) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Description getDomainImpl(ObjectProperty objectProperty) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Description getDomainImpl(DatatypeProperty datatypeProperty) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Description getRangeImpl(ObjectProperty objectProperty) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public DataRange getRangeImpl(DatatypeProperty datatypeProperty) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public SortedSet<DatatypeProperty> getDatatypePropertiesImpl() + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public SortedSet<DatatypeProperty> getBooleanDatatypePropertiesImpl() + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public SortedSet<DatatypeProperty> getDoubleDatatypePropertiesImpl() + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public SortedSet<DatatypeProperty> getIntDatatypePropertiesImpl() + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Set<NamedClass> getInconsistentClassesImpl() throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + +} Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponentOld.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponentOld.java 2008-11-10 09:54:48 UTC (rev 1499) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponentOld.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -46,6 +46,7 @@ * @author Jens Lehmann * */ +@Deprecated public abstract class ReasonerComponentOld extends Component implements ReasonerOld { protected Set<KnowledgeSource> sources; Deleted: trunk/src/dl-learner/org/dllearner/core/ReasonerNew.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerNew.java 2008-11-10 09:54:48 UTC (rev 1499) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerNew.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -1,30 +0,0 @@ -/** - * Copyright (C) 2007-2008, 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; - -/** - * List of available reasoning/query methods. - * - * @author Jens Lehmann - * - */ -public interface ReasonerNew extends BaseReasoner, SchemaReasoner, IndividualReasoner { - -} Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerOld.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerOld.java 2008-11-10 09:54:48 UTC (rev 1499) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerOld.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -44,6 +44,7 @@ * @author Jens Lehmann * */ +@Deprecated public interface ReasonerOld { public ReasonerType getReasonerType(); Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-11-10 09:54:48 UTC (rev 1499) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -53,6 +53,7 @@ * @author Jens Lehmann * */ +@Deprecated public class ReasoningService { public static Logger logger = Logger.getLogger(ReasoningService.class); Added: trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2007-2008, 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.Set; + +import org.dllearner.core.owl.Description; + +/** + * Reasoning requests related to the schema of the knowledge base. + * + * @author Jens Lehmann + * + */ +public interface SchemaReasoner { + + public boolean subsumes(Description superConcept, Description subConcept); + + public Set<Description> subsumes(Description superConcept, Set<Description> subConcepts); + + public Set<Description> subsumes(Set<Description> superConcepts, Description subConcept); + +} Modified: trunk/src/dl-learner/org/dllearner/examples/KRKModular.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/KRKModular.java 2008-11-10 09:54:48 UTC (rev 1499) +++ trunk/src/dl-learner/org/dllearner/examples/KRKModular.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -21,7 +21,7 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; -import org.dllearner.core.ReasonerComponentOld; +import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; import org.dllearner.core.configurators.ComponentFactory; import org.dllearner.core.owl.ClassAssertionAxiom; @@ -85,12 +85,12 @@ static HashMap<String, SortedSet<Individual>> classToInd = new HashMap<String, SortedSet<Individual>>(); static HashMap<Individual, String> indToClass = new HashMap<Individual, String>(); - static Set<ReasonerComponentOld> allReasoners = new HashSet<ReasonerComponentOld>(); + static Set<ReasonerComponent> allReasoners = new HashSet<ReasonerComponent>(); static int negativeExamplesAdded = 200; // static LinkedList<String> words; public KB kb; - public ReasonerComponentOld reasoner; + public ReasonerComponent reasoner; //public FastInstanceChecker fic; @@ -254,19 +254,19 @@ try { Set<KnowledgeSource> sources = new HashSet<KnowledgeSource>(); sources.add(new KBFile(kb)); - ReasonerComponentOld r = new FastInstanceChecker(sources); + ReasonerComponent r = new FastInstanceChecker(sources); r.init(); - ReasoningService rs = new ReasoningService(r); +// ReasoningService rs = new ReasoningService(r); //cm.learningProblem(lpClass, reasoner) - LearningProblem lp = new PosNegDefinitionLP(rs); + LearningProblem lp = new PosNegDefinitionLP(r); //cm.getConfigOptionValue(lp, ""); cm.applyConfigEntry(lp, "positiveExamples",pos); cm.applyConfigEntry(lp, "negativeExamples",neg); lp.init(); - la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, rs); + la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, r); SortedSet<String> ignoredConcepts = getIgnoredConcepts(pos, neg); cm.applyConfigEntry(la,"useAllConstructor",false); @@ -470,7 +470,7 @@ SortedSet<Individual> ret = new TreeSet<Individual>(); try{ - for (ReasonerComponentOld onereasoner : allReasoners) { + for (ReasonerComponent onereasoner : allReasoners) { ret.addAll(onereasoner.retrieval(d)); } Modified: trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-11-10 09:54:48 UTC (rev 1499) +++ trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-11-10 11:00:23 UTC (rev 1500) @@ -34,7 +34,7 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; -import org.dllearner.core.ReasonerComponentOld; +import org.dllearner.core.ReasonerComponent; /** * Class displaying a component (and its options). @@ -102,7 +102,7 @@ selectableComponents = new LinkedList<Class<? extends Component>>(); if (panelClass == KnowledgeSource.class) { selectableComponents.addAll(config.getComponentManager().getKnowledgeSources()); - } else if (panelClass == Reasone... [truncated message content] |