From: <jen...@us...> - 2008-11-10 09:54:53
|
Revision: 1499 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1499&view=rev Author: jenslehmann Date: 2008-11-10 09:54:48 +0000 (Mon, 10 Nov 2008) Log Message: ----------- started reasoner component redesign 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/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/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/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/ReasoningServiceFactory.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/ReasonerComponentOld.java trunk/src/dl-learner/org/dllearner/core/ReasonerNew.java trunk/src/dl-learner/org/dllearner/core/ReasonerOld.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java Removed Paths: ------------- 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/ReasoningService.java Property Changed: ---------------- trunk/src/dbpedia-navigator/ Property changes on: trunk/src/dbpedia-navigator ___________________________________________________________________ Modified: svn:ignore - temp .htaccess main.wsdl def0.xsd def1.xsd test.html test.php settings.ini Settings.php + temp .htaccess main.wsdl def0.xsd def1.xsd test.html test.php settings.ini Settings.php data Modified: trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java 2008-11-09 22:49:54 UTC (rev 1498) +++ trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java 2008-11-10 09:54:48 UTC (rev 1499) @@ -35,7 +35,7 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; -import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasonerComponentOld; 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 ReasonerComponent>> reasonerMapping = new TreeMap<String,Class<? extends ReasonerComponent>>(); + private static Map<String,Class<? extends ReasonerComponentOld>> reasonerMapping = new TreeMap<String,Class<? extends ReasonerComponentOld>>(); 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", ReasonerComponent.class); + componentTypeMapping.put("reasoner", ReasonerComponentOld.class); componentTypeMapping.put("problem", LearningProblem.class); componentTypeMapping.put("algorithm", LearningAlgorithm.class); @@ -123,7 +123,7 @@ return knowledgeSourceMapping.get(confString); } - public Class<? extends ReasonerComponent> getReasonerComponentClass(String confString) { + public Class<? extends ReasonerComponentOld> 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-09 22:49:54 UTC (rev 1498) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-11-10 09:54:48 UTC (rev 1499) @@ -56,7 +56,7 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.OntologyFormat; -import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasonerComponentOld; 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 ReasonerComponent rc; + private ReasonerComponentOld 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 ReasonerComponent> rcClass; + Class<? extends ReasonerComponentOld> rcClass; if(reasonerOption != null) { rcClass = confMapper.getReasonerComponentClass(reasonerOption.getStringValue()); if(rcClass == null) { @@ -856,7 +856,7 @@ return lp; } - public ReasonerComponent getReasonerComponent() { + public ReasonerComponentOld getReasonerComponent() { return rc; } @@ -889,8 +889,8 @@ * @return reasonerClass reasoner class */ @Deprecated - public static Class<? extends ReasonerComponent> getReasonerClass(ConfFileOption reasonerOption) { - Class<? extends ReasonerComponent> reasonerClass = null; + public static Class<? extends ReasonerComponentOld> getReasonerClass(ConfFileOption reasonerOption) { + Class<? extends ReasonerComponentOld> reasonerClass = null; if (reasonerOption == null || reasonerOption.getStringValue().equals("fastInstanceChecker")) reasonerClass = FastInstanceChecker.class; else if (reasonerOption.getStringValue().equals("owlAPI")) Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2008-11-09 22:49:54 UTC (rev 1498) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2008-11-10 09:54:48 UTC (rev 1499) @@ -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 ReasonerComponent>> reasonerComponents; + private static Collection<Class<? extends ReasonerComponentOld>> 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 ReasonerComponent>>(classComparator); + reasonerComponents = new TreeSet<Class<? extends ReasonerComponentOld>>(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 (ReasonerComponent.class.isAssignableFrom(component)) { - reasonerComponents.add((Class<? extends ReasonerComponent>) component); + } else if (ReasonerComponentOld.class.isAssignableFrom(component)) { + reasonerComponents.add((Class<? extends ReasonerComponentOld>) 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 ReasonerComponent> T reasoner(Class<T> reasoner, + public <T extends ReasonerComponentOld> 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 ReasonerComponent> T reasoner(Class<T> reasoner, + public <T extends ReasonerComponentOld> T reasoner(Class<T> reasoner, Set<KnowledgeSource> sources) { if (!reasonerComponents.contains(reasoner)) { System.err.println("Warning: reasoner component " + reasoner @@ -365,7 +365,7 @@ * @param reasoner A reasoner component. * @return The reasoning service encapsulating the reasoner. */ - public ReasoningService reasoningService(ReasonerComponent reasoner) { + public ReasoningService reasoningService(ReasonerComponentOld reasoner) { return new ReasoningService(reasoner); } @@ -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 ReasonerComponent>> getReasonerComponents() { - return new LinkedList<Class<? extends ReasonerComponent>>(reasonerComponents); + public List<Class<? extends ReasonerComponentOld>> getReasonerComponents() { + return new LinkedList<Class<? extends ReasonerComponentOld>>(reasonerComponents); } /** Deleted: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-11-09 22:49:54 UTC (rev 1498) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-11-10 09:54:48 UTC (rev 1499) @@ -1,142 +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.Map; -import java.util.Set; -import java.util.SortedSet; - -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.reasoning.ReasonerType; -import org.dllearner.utilities.datastructures.SortedSetTuple; - -/** - * Reasoner Interface. Lists all available reasoning methods. - * - * @author Jens Lehmann - * - */ -public interface Reasoner { - - public ReasonerType getReasonerType(); - - // Methode, die Subsumptionhierarchie initialisiert (sollte nur einmal - // pro erstelltem ReasoningService bzw. Reasoner aufgerufen werden) - // => erstellt auch vereinfachte Sichten auf Subsumptionhierarchie - // (siehe einfacher Traversal in Diplomarbeit) - public void prepareSubsumptionHierarchy(Set<NamedClass> allowedConcepts); - public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) throws ReasoningMethodUnsupportedException; - public void prepareDatatypePropertyHierarchy(Set<DatatypeProperty> allowedDatatypeProperties) throws ReasoningMethodUnsupportedException; - - public boolean subsumes(Description superConcept, Description subConcept) throws ReasoningMethodUnsupportedException; - - // mehrere subsumption checks - spart bei DIG Anfragen (nur die zweite Methode wird gebraucht) - public Set<Description> subsumes(Description superConcept, Set<Description> subConcepts) throws ReasoningMethodUnsupportedException; - public Set<Description> subsumes(Set<Description> superConcepts, Description subConcept) throws ReasoningMethodUnsupportedException; - - // liefert eine Menge paarweise nicht äquivalenter Konzepte zurück, die über dem Konzept in der - // Subsumption-Hierarchie stehen - // Methoden veraltet, da das jetzt von der SubsumptionHierarchy-Klasse geregelt wird - // public SortedSet<Concept> getMoreGeneralConcepts(Concept concept) throws ReasoningMethodUnsupportedException; - // public SortedSet<Concept> getMoreSpecialConcepts(Concept concept) throws ReasoningMethodUnsupportedException; - - public SubsumptionHierarchy getSubsumptionHierarchy() throws ReasoningMethodUnsupportedException; - - public ObjectPropertyHierarchy getRoleHierarchy() throws ReasoningMethodUnsupportedException; - - public DatatypePropertyHierarchy getDatatypePropertyHierarchy() throws ReasoningMethodUnsupportedException; - - public SortedSet<Individual> retrieval(Description concept) throws ReasoningMethodUnsupportedException; - - public Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException; - - public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; - - public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) throws ReasoningMethodUnsupportedException; - - public Map<Individual, SortedSet<Constant>> getDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; - - // annotations (not strictly reasoning methods) - // [OWL API supports only annotations specified in a given ontology, which - // is uncomfortable to handle when several ontologies are loaded] - public Set<Constant> getLabel(Entity entity) throws ReasoningMethodUnsupportedException; - - // some convenience methods - public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; - public Map<Individual, SortedSet<Boolean>> getBooleanDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; - public SortedSet<Individual> getTrueDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; - public SortedSet<Individual> getFalseDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; - - public boolean instanceCheck(Description concept, Individual individual) throws ReasoningMethodUnsupportedException; - - // mehrere instance checks für ein Konzept - spart bei DIG Anfragen - public SortedSet<Individual> instanceCheck(Description concept, Set<Individual> individuals) throws ReasoningMethodUnsupportedException; - - public SortedSetTuple<Individual> doubleRetrieval(Description concept) throws ReasoningMethodUnsupportedException; - - public SortedSetTuple<Individual> doubleRetrieval(Description concept, Description adc) throws ReasoningMethodUnsupportedException; - - public boolean isSatisfiable() throws ReasoningMethodUnsupportedException; - - // alle Konzepte, die i als Instanz haben - public Set<NamedClass> getConcepts(Individual i) throws ReasoningMethodUnsupportedException; - - public Set<NamedClass> getAtomicConcepts(); - - public Set<ObjectProperty> getAtomicRoles(); - - public String getBaseURI(); - - public Map<String, String> getPrefixes(); - - public Description getDomain(ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException; - - public Description getDomain(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; - - public Description getRange(ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException; - - public DataRange getRange(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; - - // currently, we do not require that datatype properties can be returned; - // the main reason is that DIG does not distinguish between datatype and - // object properties (of course one could implement it but it is not easy) - public SortedSet<DatatypeProperty> getDatatypeProperties() throws ReasoningMethodUnsupportedException; - - public SortedSet<DatatypeProperty> getBooleanDatatypeProperties() throws ReasoningMethodUnsupportedException; - - public SortedSet<DatatypeProperty> getDoubleDatatypeProperties() throws ReasoningMethodUnsupportedException; - - public SortedSet<DatatypeProperty> getIntDatatypeProperties() throws ReasoningMethodUnsupportedException; - - public SortedSet<Individual> getIndividuals(); - - public void releaseKB(); -} Deleted: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-11-09 22:49:54 UTC (rev 1498) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-11-10 09:54:48 UTC (rev 1499) @@ -1,303 +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 - * - */ -public abstract class ReasonerComponent extends Component implements Reasoner { - - protected Set<KnowledgeSource> sources; - - public ReasonerComponent(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(); - } - -} Copied: trunk/src/dl-learner/org/dllearner/core/ReasonerComponentOld.java (from rev 1498, trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponentOld.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponentOld.java 2008-11-10 09:54:48 UTC (rev 1499) @@ -0,0 +1,303 @@ +/** + * 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 + * + */ +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(); + } + +} Copied: trunk/src/dl-learner/org/dllearner/core/ReasonerNew.java (from rev 1498, trunk/src/dl-learner/org/dllearner/core/Reasoner.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerNew.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerNew.java 2008-11-10 09:54:48 UTC (rev 1499) @@ -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 ReasonerNew extends BaseReasoner, SchemaReasoner, IndividualReasoner { + +} Copied: trunk/src/dl-learner/org/dllearner/core/ReasonerOld.java (from rev 1498, trunk/src/dl-learner/org/dllearner/core/Reasoner.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerOld.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerOld.java 2008-11-10 09:54:48 UTC (rev 1499) @@ -0,0 +1,142 @@ +/** + * 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.Map; +import java.util.Set; +import java.util.SortedSet; + +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.reasoning.ReasonerType; +import org.dllearner.utilities.datastructures.SortedSetTuple; + +/** + * Reasoner Interface. Lists all available reasoning methods. + * + * @author Jens Lehmann + * + */ +public interface ReasonerOld { + + public ReasonerType getReasonerType(); + + // Methode, die Subsumptionhierarchie initialisiert (sollte nur einmal + // pro erstelltem ReasoningService bzw. Reasoner aufgerufen werden) + // => erstellt auch vereinfachte Sichten auf Subsumptionhierarchie + // (siehe einfacher Traversal in Diplomarbeit) + public void prepareSubsumptionHierarchy(Set<NamedClass> allowedConcepts); + public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) throws ReasoningMethodUnsupportedException; + public void prepareDatatypePropertyHierarchy(Set<DatatypeProperty> allowedDatatypeProperties) throws ReasoningMethodUnsupportedException; + + public boolean subsumes(Description superConcept, Description subConcept) throws ReasoningMethodUnsupportedException; + + // mehrere subsumption checks - spart bei DIG Anfragen (nur die zweite Methode wird gebraucht) + public Set<Description> subsumes(Description superConcept, Set<Description> subConcepts) throws ReasoningMethodUnsupportedException; + public Set<Description> subsumes(Set<Description> superConcepts, Description subConcept) throws ReasoningMethodUnsupportedException; + + // liefert eine Menge paarweise nicht äquivalenter Konzepte zurück, die über dem Konzept in der + // Subsumption-Hierarchie stehen + // Methoden veraltet, da das jetzt von der SubsumptionHierarchy-Klasse geregelt wird + // public SortedSet<Concept> getMoreGeneralConcepts(Concept concept) throws ReasoningMethodUnsupportedException; + // public SortedSet<Concept> getMoreSpecialConcepts(Concept concept) throws ReasoningMethodUnsupportedException; + + public SubsumptionHierarchy getSubsumptionHierarchy() throws ReasoningMethodUnsupportedException; + + public ObjectPropertyHierarchy getRoleHierarchy() throws ReasoningMethodUnsupportedException; + + public DatatypePropertyHierarchy getDatatypePropertyHierarchy() throws ReasoningMethodUnsupportedException; + + public SortedSet<Individual> retrieval(Description concept) throws ReasoningMethodUnsupportedException; + + public Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException; + + public Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + + public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) throws ReasoningMethodUnsupportedException; + + public Map<Individual, SortedSet<Constant>> getDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + + // annotations (not strictly reasoning methods) + // [OWL API supports only annotations specified in a given ontology, which + // is uncomfortable to handle when several ontologies are loaded] + public Set<Constant> getLabel(Entity entity) throws ReasoningMethodUnsupportedException; + + // some convenience methods + public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + public Map<Individual, SortedSet<Boolean>> getBooleanDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + public SortedSet<Individual> getTrueDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + public SortedSet<Individual> getFalseDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + + public boolean instanceCheck(Description concept, Individual individual) throws ReasoningMethodUnsupportedException; + + // mehrere instance checks für ein Konzept - spart bei DIG Anfragen + public SortedSet<Individual> instanceCheck(Description concept, Set<Individual> individuals) throws ReasoningMethodUnsupportedException; + + public SortedSetTuple<Individual> doubleRetrieval(Description concept) throws ReasoningMethodUnsupportedException; + + public SortedSetTuple<Individual> doubleRetrieval(Description concept, Description adc) throws ReasoningMethodUnsupportedException; + + public boolean isSatisfiable() throws ReasoningMethodUnsupportedException; + + // alle Konzepte, die i als Instanz haben + public Set<NamedClass> getConcepts(Individual i) throws ReasoningMethodUnsupportedException; + + public Set<NamedClass> getAtomicConcepts(); + + public Set<ObjectProperty> getAtomicRoles(); + + public String getBaseURI(); + + public Map<String, String> getPrefixes(); + + public Description getDomain(ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException; + + public Description getDomain(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + + public Description getRange(ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException; + + public DataRange getRange(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + + // currently, we do not require that datatype properties can be returned; + // the main reason is that DIG does not distinguish between datatype and + // object properties (of course one could implement it but it is not easy) + public SortedSet<DatatypeProperty> getDatatypeProperties() throws ReasoningMethodUnsupportedException; + + public SortedSet<DatatypeProperty> getBooleanDatatypeProperties() throws ReasoningMethodUnsupportedException; + + public SortedSet<DatatypeProperty> getDoubleDatatypeProperties() throws ReasoningMethodUnsupportedException; + + public SortedSet<DatatypeProperty> getIntDatatypeProperties() throws ReasoningMethodUnsupportedException; + + public SortedSet<Individual> getIndividuals(); + + public void releaseKB(); +} Deleted: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-11-09 22:49:54 UTC (rev 1498) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-11-10 09:54:48 UTC (rev 1499) @@ -1,747 +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 - * - */ -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 ReasonerComponent 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(ReasonerComponent 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... [truncated message content] |