From: <jen...@us...> - 2011-03-17 11:25:05
|
Revision: 2725 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2725&view=rev Author: jenslehmann Date: 2011-03-17 11:24:56 +0000 (Thu, 17 Mar 2011) Log Message: ----------- refactored learning algorithm class to (officially) allow algorithms learning SPARQL queries and fuzzy expressions Modified Paths: -------------- trunk/autosparql/src/main/resources/log4j.properties trunk/components-core/src/main/java/org/dllearner/algorithms/BruteForceLearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/RandomGuesser.java trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELLearningAlgorithmDisjunctive.java trunk/components-core/src/main/java/org/dllearner/algorithms/gp/GP.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/ISLE.java trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/OCEL.java trunk/components-core/src/main/java/org/dllearner/algorithms/refinement/ROLearner.java trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java trunk/components-core/src/main/java/org/dllearner/core/LearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/core/LearningProblemUnsupportedException.java trunk/components-core/src/main/java/org/dllearner/core/options/CommonConfigOptions.java trunk/components-core/src/main/java/org/dllearner/utilities/components/ComponentCombo.java trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnConfiguration.java trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnOWLFileConfiguration.java trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java trunk/components-core/src/test/java/org/dllearner/test/ClassCastExceptionTest.java trunk/components-core/src/test/java/org/dllearner/test/ComponentTest.java trunk/components-core/src/test/java/org/dllearner/test/SworeTest.java trunk/interfaces/src/main/java/org/dllearner/cli/ConfMapper.java trunk/interfaces/src/main/java/org/dllearner/cli/DocumentationGenerator.java trunk/interfaces/src/main/java/org/dllearner/cli/Start.java trunk/interfaces/src/main/java/org/dllearner/gui/ComponentPanel.java trunk/interfaces/src/main/java/org/dllearner/gui/Config.java trunk/interfaces/src/main/java/org/dllearner/gui/ConfigSave.java trunk/interfaces/src/main/java/org/dllearner/gui/MiniGUI.java trunk/interfaces/src/main/java/org/dllearner/gui/StartGUI.java trunk/interfaces/src/main/java/org/dllearner/server/ClientState.java trunk/interfaces/src/main/java/org/dllearner/server/DLLearnerWS.java trunk/interfaces/src/test/java/org/dllearner/test/junit/ReasonerTests.java trunk/protege/src/main/java/org/dllearner/tools/protege/Manager.java trunk/scripts/src/main/java/org/dllearner/examples/KRKModular.java trunk/scripts/src/main/java/org/dllearner/scripts/ConfigJavaGenerator.java trunk/scripts/src/main/java/org/dllearner/scripts/CrossValidation.java trunk/scripts/src/main/java/org/dllearner/scripts/NestedCrossValidation.java trunk/scripts/src/main/java/org/dllearner/scripts/Sample.java trunk/scripts/src/main/java/org/dllearner/scripts/SemanticBibleComparison.java trunk/scripts/src/main/java/org/dllearner/scripts/tiger/TestIterativeLearning.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/core/AbstractCELA.java trunk/components-core/src/main/java/org/dllearner/core/ClassExpressionLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/core/FuzzyClassExpressionLearningAlgorithm.java trunk/components-core/src/main/java/org/dllearner/core/SparqlQueryLearningAlgorithm.java Modified: trunk/autosparql/src/main/resources/log4j.properties =================================================================== --- trunk/autosparql/src/main/resources/log4j.properties 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/autosparql/src/main/resources/log4j.properties 2011-03-17 11:24:56 UTC (rev 2725) @@ -25,7 +25,7 @@ # appenders are the output-targets defined above # loglevels: trace, debug, info, warn, error, fatal # -log4j.rootLogger=debug, stdout, file +log4j.rootLogger=debug, stdout ### set log levels - for more verbose logging change 'info' to 'debug' ### @@ -34,6 +34,6 @@ log4j.category.org.dllearner.autosparql.server=INFO ####SparqlQueryGenerator -log4j.category.org.dllearner.sparqlquerygenerator=DEBUG +log4j.category.org.dllearner.sparqlquerygenerator=INFO Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/BruteForceLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/BruteForceLearner.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/BruteForceLearner.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -26,7 +26,7 @@ import java.util.List; import java.util.Map; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.BruteForceLearnerConfigurator; @@ -57,7 +57,7 @@ * @author Jens Lehmann * */ -public class BruteForceLearner extends LearningAlgorithm { +public class BruteForceLearner extends AbstractCELA { private BruteForceLearnerConfigurator configurator; @Override Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/RandomGuesser.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/RandomGuesser.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/RandomGuesser.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -25,7 +25,7 @@ import org.apache.log4j.Logger; import org.dllearner.algorithms.gp.GPUtilities; import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.Score; @@ -48,7 +48,7 @@ * @author Jens Lehmann * */ -public class RandomGuesser extends LearningAlgorithm { +public class RandomGuesser extends AbstractCELA { private RandomGuesserConfigurator configurator; @Override Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -33,7 +33,7 @@ import org.apache.log4j.Logger; import org.dllearner.core.ComponentInitException; import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.CELOEConfigurator; @@ -75,7 +75,7 @@ * @author Jens Lehmann * */ -public class CELOE extends LearningAlgorithm { +public class CELOE extends AbstractCELA { private static Logger logger = Logger.getLogger(CELOE.class); private CELOEConfigurator configurator; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELLearningAlgorithm.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELLearningAlgorithm.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELLearningAlgorithm.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -27,7 +27,7 @@ import org.apache.log4j.Logger; import org.dllearner.core.ComponentInitException; import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.Configurator; @@ -51,7 +51,7 @@ * @author Jens Lehmann * */ -public class ELLearningAlgorithm extends LearningAlgorithm { +public class ELLearningAlgorithm extends AbstractCELA { private static Logger logger = Logger.getLogger(ELLearningAlgorithm.class); private ELLearningAlgorithmConfigurator configurator; @@ -65,7 +65,7 @@ private long treeStartTime; // a set with limited size (currently the ordering is defined in the class itself) - private EvaluatedDescriptionSet bestEvaluatedDescriptions = new EvaluatedDescriptionSet(LearningAlgorithm.MAX_NR_OF_RESULTS); + private EvaluatedDescriptionSet bestEvaluatedDescriptions = new EvaluatedDescriptionSet(AbstractCELA.MAX_NR_OF_RESULTS); private SearchTreeNode startNode; private ELHeuristic heuristic; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELLearningAlgorithmDisjunctive.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELLearningAlgorithmDisjunctive.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/el/ELLearningAlgorithmDisjunctive.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -30,7 +30,7 @@ import org.apache.log4j.Logger; import org.dllearner.core.ComponentInitException; import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.Configurator; @@ -83,7 +83,7 @@ * @author Jens Lehmann * */ -public class ELLearningAlgorithmDisjunctive extends LearningAlgorithm { +public class ELLearningAlgorithmDisjunctive extends AbstractCELA { private static Logger logger = Logger.getLogger(ELLearningAlgorithmDisjunctive.class); private ELLearningAlgorithmDisjunctiveConfigurator configurator; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/gp/GP.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/gp/GP.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/gp/GP.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -30,7 +30,7 @@ import java.util.Map.Entry; import org.dllearner.algorithms.hybridgp.Psi; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.GPConfigurator; @@ -55,7 +55,7 @@ * @author Jens Lehmann * */ -public class GP extends LearningAlgorithm { +public class GP extends AbstractCELA { private GPConfigurator configurator; @Override Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/ISLE.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/ISLE.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/ISLE.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -34,7 +34,7 @@ import org.dllearner.algorithms.celoe.OENode; import org.dllearner.core.ComponentInitException; import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.ISLEConfigurator; @@ -71,7 +71,7 @@ * @author Jens Lehmann * */ -public class ISLE extends LearningAlgorithm { +public class ISLE extends AbstractCELA { private static Logger logger = Logger.getLogger(CELOE.class); private ISLEConfigurator configurator; Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/OCEL.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/OCEL.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/ocel/OCEL.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -30,7 +30,7 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.dllearner.core.ComponentInitException; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.OCELConfigurator; @@ -81,7 +81,7 @@ * @author Jens Lehmann * */ -public class OCEL extends LearningAlgorithm { +public class OCEL extends AbstractCELA { private OCELConfigurator configurator; @Override Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/refinement/ROLearner.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/refinement/ROLearner.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -14,7 +14,7 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.ROLearnerConfigurator; @@ -42,7 +42,7 @@ import org.dllearner.utilities.owl.ConceptTransformation; import org.dllearner.utilities.owl.EvaluatedDescriptionPosNegComparator; -public class ROLearner extends LearningAlgorithm { +public class ROLearner extends AbstractCELA { private ROLearnerConfigurator configurator; @Override @@ -51,7 +51,7 @@ } private static Logger logger = Logger - .getLogger(LearningAlgorithm.class); + .getLogger(AbstractCELA.class); private String logLevel = CommonConfigOptions.logLevelDefault; Copied: trunk/components-core/src/main/java/org/dllearner/core/AbstractCELA.java (from rev 2724, trunk/components-core/src/main/java/org/dllearner/core/LearningAlgorithm.java) =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/AbstractCELA.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/core/AbstractCELA.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -0,0 +1,305 @@ +/** + * Copyright (C) 2007-2011, 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.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.TreeSet; + +import org.dllearner.core.owl.Description; +import org.dllearner.utilities.datastructures.DescriptionSubsumptionTree; +import org.dllearner.utilities.owl.ConceptTransformation; + +/** + * Abstract superclass of all class expression learning algorithm implementations. + * Includes support for anytime learning algorithms and resumable + * learning algorithms. Provides methods for filtering the best + * descriptions found by the algorithm. As results of the algorithm, + * you can either get only descriptions or evaluated descriptions. + * Evaluated descriptions have information about accuracy and + * example coverage associated with them. However, retrieving those + * may require addition reasoner queries, because the learning + * algorithms usually use but do not necessarily store this information. + * + * @author Jens Lehmann + * + */ +public abstract class AbstractCELA extends Component { + + /** + * The learning problem variable, which must be used by + * all learning algorithm implementations. + */ + protected LearningProblem learningProblem; + + /** + * The reasoning service variable, which must be used by + * all learning algorithm implementations. + */ + protected ReasonerComponent reasoner; + + /** + * Each learning algorithm gets a learning problem and + * a reasoner as input. + * @param learningProblem The learning problem to solve. + * @param reasoningService The reasoner connecting to the + * underlying knowledge base. + */ + public AbstractCELA(LearningProblem learningProblem, ReasonerComponent reasoningService) { + this.learningProblem = learningProblem; + this.reasoner = reasoningService; + } + + /** + * Call this when you want to change the learning problem, but + * leave everything else as is. Method can be used to apply + * a configured algorithm to different learning problems. + * Implementations, which do not only use the provided learning + * algorithm variable, must make sure that a call to this method + * indeed changes the learning problem. + * @param learningProblem The new learning problem. + */ + public void changeLearningProblem(LearningProblem learningProblem) { + this.learningProblem = learningProblem; + } + + /** + * Call this when you want to change the reasoning service, but + * leave everything else as is. Method can be used to use + * a configured algorithm with different reasoners. + * 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 The new reasoning service. + */ + public void changeReasonerComponent(ReasonerComponent reasoningService) { + this.reasoner = reasoningService; + } + + /** + * This is the maximum number of results, which the learning + * algorithms are asked to store. (Note, that algorithms are not + * required to store any results except the best one, so this limit + * is used to limit the performance cost for those which + * choose to store results.) + */ + public static final int MAX_NR_OF_RESULTS = 100; + + /** + * Starts the algorithm. It runs until paused, stopped, or + * a termination criterion has been reached. + */ + public abstract void start(); + + /** + * Pauses the algorithm (not all algorithms need to implement + * this operation). + */ + public void pause() { }; + + /** + * Resumes the algorithm (not all algorithms need to implement + * this operation). You can use this method to continue + * an algorithm run even after a termination criterion has been + * reached. It will run until paused, stopped, or terminated + * again. + */ + public void resume() { }; + + /** + * Stops the algorithm gracefully. A stopped algorithm cannot be resumed anymore. + * Use this method for cleanup and freeing memory. + */ + public abstract void stop(); + + /** + * Returns whether the learning algorithm is running. Implementation + * should use a boolean status variable in their implementations of + * the start and resume methods. + * @return True if the algorithm is running, false otherwise. + */ + public abstract boolean isRunning(); + + /** + * Every algorithm must be able to return the score of the + * best solution found. + * + * @return Best score. + */ +// @Deprecated +// public abstract Score getSolutionScore(); + + /** + * @see #getCurrentlyBestEvaluatedDescription() + * @return The best class description found by the learning algorithm so far. + */ + public abstract Description getCurrentlyBestDescription(); + + /** + * @see #getCurrentlyBestEvaluatedDescriptions() + * @return The best class descriptions found by the learning algorithm so far. + */ + public List<Description> getCurrentlyBestDescriptions() { + List<Description> ds = new LinkedList<Description>(); + ds.add(getCurrentlyBestDescription()); + return ds; + } + + /** + * @see #getCurrentlyBestEvaluatedDescriptions(int) + * @param nrOfDescriptions Limit for the number or returned descriptions. + * @return The best class descriptions found by the learning algorithm so far. + */ + public synchronized List<Description> getCurrentlyBestDescriptions(int nrOfDescriptions) { + return getCurrentlyBestDescriptions(nrOfDescriptions, false); + } + + /** + * @see #getCurrentlyBestEvaluatedDescriptions(int,double,boolean) + * @param nrOfDescriptions Limit for the number or returned descriptions. + * @param filterNonMinimalDescriptions Remove non-minimal descriptions (e.g. those which can be shortened + * to an equivalent concept) from the returned set. + * @return The best class descriptions found by the learning algorithm so far. + */ + public synchronized List<Description> getCurrentlyBestDescriptions(int nrOfDescriptions, boolean filterNonMinimalDescriptions) { + List<Description> currentlyBest = getCurrentlyBestDescriptions(); + List<Description> returnList = new LinkedList<Description>(); + for(Description ed : currentlyBest) { + if(returnList.size() >= nrOfDescriptions) { + return returnList; + } + + if(!filterNonMinimalDescriptions || ConceptTransformation.isDescriptionMinimal(ed)) { + returnList.add(ed); + } + + } + return returnList; + } + + /** + * Returns the best descriptions obtained so far. + * @return Best class description found so far. + */ + public abstract EvaluatedDescription getCurrentlyBestEvaluatedDescription(); + + /** + * Returns a sorted set of the best descriptions found so far. We + * assume that they are ordered such that the best ones come in + * last. (In Java, iterators traverse a SortedSet in ascending order.) + * @return Best class descriptions found so far. + */ + public TreeSet<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions() { + TreeSet<EvaluatedDescription> ds = new TreeSet<EvaluatedDescription>(); + ds.add(getCurrentlyBestEvaluatedDescription()); + return ds; + } + + /** + * Returns a filtered list of currently best class descriptions. + * + * @param nrOfDescriptions Maximum number of restrictions. Use Integer.MAX_VALUE + * if you do not want this filter to be active. + * + * @param accuracyThreshold Minimum accuracy. All class descriptions with lower + * accuracy are disregarded. Specify a value between 0.0 and 1.0. Use 0.0 if + * you do not want this filter to be active. + * + * @param filterNonMinimalDescriptions If true, non-minimal descriptions are + * filtered, e.g. ALL r.TOP (being equivalent to TOP), male AND male (can be + * shortened to male). Currently, non-minimal descriptions are just skipped, + * i.e. they are completely omitted from the return list. Later, implementation + * might be changed to return shortened versions of those descriptions. + * + * @return A list of currently best class descriptions. + */ + public synchronized List<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions(int nrOfDescriptions, double accuracyThreshold, boolean filterNonMinimalDescriptions) { + TreeSet<? extends EvaluatedDescription> currentlyBest = getCurrentlyBestEvaluatedDescriptions(); + List<EvaluatedDescription> returnList = new LinkedList<EvaluatedDescription>(); + for(EvaluatedDescription ed : currentlyBest.descendingSet()) { + // once we hit a description with a below threshold accuracy, we simply return + // because learning algorithms are advised to order descriptions by accuracy, + // so we won't find any concept with higher accuracy in the remaining list +// if(ed.getAccuracy() < accuracyThreshold) { + if(ed.getAccuracy() < accuracyThreshold) { + return returnList; + } + + // return if we have sufficiently many descriptions + if(returnList.size() >= nrOfDescriptions) { + return returnList; + } + + if(!filterNonMinimalDescriptions || ConceptTransformation.isDescriptionMinimal(ed.getDescription())) { + // before we add the description we replace EXISTS r.TOP with + // EXISTS r.range(r) if range(r) is atomic + // (we need to clone, otherwise we change descriptions which could + // be in the search of the learning algorith, which leads to + // unpredictable behaviour) + Description d = ed.getDescription().clone(); + + //commented out because reasoner is called. leads in swing applications sometimes to exceptions +// ConceptTransformation.replaceRange(d, reasoner); + ed.setDescription(d); + + returnList.add(ed); + } + + } + return returnList; + } + + /** + * Return the best currently found concepts up to some maximum + * count (no minimality filter used). + * @param nrOfDescriptions Maximum number of descriptions returned. + * @return Return value is getCurrentlyBestDescriptions(nrOfDescriptions, 0.0, false). + */ + public synchronized List<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions(int nrOfDescriptions) { + return getCurrentlyBestEvaluatedDescriptions(nrOfDescriptions, 0.0, false); + } + + /** + * Returns a fraction of class descriptions with sufficiently high accuracy. + * @param accuracyThreshold Only return solutions with this accuracy or higher. + * @return Return value is getCurrentlyBestDescriptions(Integer.MAX_VALUE, accuracyThreshold, false). + */ + public synchronized List<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions(double accuracyThreshold) { + return getCurrentlyBestEvaluatedDescriptions(Integer.MAX_VALUE, accuracyThreshold, false); + } + + public synchronized List<? extends EvaluatedDescription> getCurrentlyBestMostGeneralEvaluatedDescriptions() { + List<? extends EvaluatedDescription> l = getCurrentlyBestEvaluatedDescriptions(getCurrentlyBestEvaluatedDescriptions().last().getAccuracy()); + DescriptionSubsumptionTree t = new DescriptionSubsumptionTree(reasoner); + t.insert(l); + return t.getMostGeneralDescriptions(true); + } + + /** + * Returns all learning problems supported by this component. This can be used to indicate that, e.g. + * an algorithm is only suitable for positive only learning. + * @return All classes implementing learning problems, which are supported by this learning algorithm. + */ + public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() { + return new LinkedList<Class<? extends LearningProblem>>(); + } + +} Added: trunk/components-core/src/main/java/org/dllearner/core/ClassExpressionLearningAlgorithm.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/ClassExpressionLearningAlgorithm.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/core/ClassExpressionLearningAlgorithm.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2007-2011, 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; + +/** + * Basic interface for algorithms learning OWL/DL class expressions. + * + * @author Jens Lehmann + * + */ +public interface ClassExpressionLearningAlgorithm extends LearningAlgorithm { + +} Modified: trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -72,7 +72,7 @@ private static Collection<Class<? extends KnowledgeSource>> knowledgeSources; private static Collection<Class<? extends ReasonerComponent>> reasonerComponents; private static Collection<Class<? extends LearningProblem>> learningProblems; - private static Collection<Class<? extends LearningAlgorithm>> learningAlgorithms; + private static Collection<Class<? extends AbstractCELA>> learningAlgorithms; // you can either use the components.ini file or directly specify the classes to use @Deprecated private static String componentsFile = "org/dllearner/components.ini"; @@ -111,8 +111,8 @@ private static Map<Class<? extends Component>, String> componentNames; private static Map<Class<? extends Component>, List<ConfigOption<?>>> componentOptions; private static Map<Class<? extends Component>, Map<String, ConfigOption<?>>> componentOptionsByName; - private static Map<Class<? extends LearningAlgorithm>, Collection<Class<? extends LearningProblem>>> algorithmProblemsMapping; - private static Map<Class<? extends LearningProblem>, Collection<Class<? extends LearningAlgorithm>>> problemAlgorithmsMapping; + private static Map<Class<? extends AbstractCELA>, Collection<Class<? extends LearningProblem>>> algorithmProblemsMapping; + private static Map<Class<? extends LearningProblem>, Collection<Class<? extends AbstractCELA>>> problemAlgorithmsMapping; // list of default values of config options // private static Map<ConfigOption<?>,Object> configOptionDefaults; @@ -143,8 +143,8 @@ knowledgeSources = new TreeSet<Class<? extends KnowledgeSource>>(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>>>( + learningAlgorithms = new TreeSet<Class<? extends AbstractCELA>>(classComparator); + algorithmProblemsMapping = new TreeMap<Class<? extends AbstractCELA>, Collection<Class<? extends LearningProblem>>>( classComparator); // create classes from strings @@ -160,8 +160,8 @@ reasonerComponents.add((Class<? extends ReasonerComponent>) component); } else if (LearningProblem.class.isAssignableFrom(component)) { learningProblems.add((Class<? extends LearningProblem>) component); - } else if (LearningAlgorithm.class.isAssignableFrom(component)) { - Class<? extends LearningAlgorithm> learningAlgorithmClass = (Class<? extends LearningAlgorithm>) component; + } else if (AbstractCELA.class.isAssignableFrom(component)) { + Class<? extends AbstractCELA> learningAlgorithmClass = (Class<? extends AbstractCELA>) component; learningAlgorithms.add(learningAlgorithmClass); Collection<Class<? extends LearningProblem>> problems = (Collection<Class<? extends LearningProblem>>) invokeStaticMethod( learningAlgorithmClass, "supportedLearningProblems"); @@ -447,7 +447,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, ReasonerComponent rs) throws LearningProblemUnsupportedException { + public <T extends AbstractCELA> 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."); @@ -661,9 +661,9 @@ * @param learningProblem A learning problem type. * @return The set of learning algorithms applicable for this learning problem. */ - public List<Class<? extends LearningAlgorithm>> getApplicableLearningAlgorithms(Class<? extends LearningProblem> learningProblem) { - List<Class<? extends LearningAlgorithm>> algorithms = new LinkedList<Class<? extends LearningAlgorithm>>(); - for(Entry<Class<? extends LearningProblem>,Collection<Class<? extends LearningAlgorithm>>> entry : problemAlgorithmsMapping.entrySet()) { + public List<Class<? extends AbstractCELA>> getApplicableLearningAlgorithms(Class<? extends LearningProblem> learningProblem) { + List<Class<? extends AbstractCELA>> algorithms = new LinkedList<Class<? extends AbstractCELA>>(); + for(Entry<Class<? extends LearningProblem>,Collection<Class<? extends AbstractCELA>>> entry : problemAlgorithmsMapping.entrySet()) { Class<? extends LearningProblem> prob = entry.getKey(); if(prob.isAssignableFrom(learningProblem)) { algorithms.addAll(entry.getValue()); @@ -679,8 +679,8 @@ * @return the components A list of learning algorithm classes available in this * instance of <code>ComponentManager</code>. */ - public List<Class<? extends LearningAlgorithm>> getLearningAlgorithms() { - return new LinkedList<Class<? extends LearningAlgorithm>>(learningAlgorithms); + public List<Class<? extends AbstractCELA>> getLearningAlgorithms() { + return new LinkedList<Class<? extends AbstractCELA>>(learningAlgorithms); } @@ -696,11 +696,11 @@ * Retuns a list of all instanciated and registered LearningAlgorithm * @return Currently active learning algorithms. */ - public List<LearningAlgorithm> getLiveLearningAlgorithms(){ - List<LearningAlgorithm> list = new ArrayList<LearningAlgorithm>(); + public List<AbstractCELA> getLiveLearningAlgorithms(){ + List<AbstractCELA> list = new ArrayList<AbstractCELA>(); for (Component component : cm.getLiveComponents()) { - if(component instanceof LearningAlgorithm){ - list.add((LearningAlgorithm) component); + if(component instanceof AbstractCELA){ + list.add((AbstractCELA) component); } } Added: trunk/components-core/src/main/java/org/dllearner/core/FuzzyClassExpressionLearningAlgorithm.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/FuzzyClassExpressionLearningAlgorithm.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/core/FuzzyClassExpressionLearningAlgorithm.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2007-2011, 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; + +/** + * Basic interface for algorithms learning fuzzy OWL/DL class expressions. + * + * @author Jens Lehmann + * + */ +public interface FuzzyClassExpressionLearningAlgorithm extends LearningAlgorithm { + +} Modified: trunk/components-core/src/main/java/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/LearningAlgorithm.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/core/LearningAlgorithm.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -1,5 +1,5 @@ /** - * Copyright (C) 2007-2008, Jens Lehmann + * Copyright (C) 2007-2011, Jens Lehmann * * This file is part of DL-Learner. * @@ -19,287 +19,12 @@ */ package org.dllearner.core; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; -import java.util.TreeSet; - -import org.dllearner.core.owl.Description; -import org.dllearner.utilities.datastructures.DescriptionSubsumptionTree; -import org.dllearner.utilities.owl.ConceptTransformation; - /** - * Abstract superclass of all learning algorithm implementations. - * Includes support for anytime learning algorithms and resumable - * learning algorithms. Provides methods for filtering the best - * descriptions found by the algorithm. As results of the algorithm, - * you can either get only descriptions or evaluated descriptions. - * Evaluated descriptions have information about accuracy and - * example coverage associated with them. However, retrieving those - * may require addition reasoner queries, because the learning - * algorithms usually use but do not necessarily store this information. + * Basic interface for all DL-Learner learning algorithms. * * @author Jens Lehmann * */ -public abstract class LearningAlgorithm extends Component { +public interface LearningAlgorithm { - /** - * The learning problem variable, which must be used by - * all learning algorithm implementations. - */ - protected LearningProblem learningProblem; - - /** - * The reasoning service variable, which must be used by - * all learning algorithm implementations. - */ - protected ReasonerComponent reasoner; - - /** - * Each learning algorithm gets a learning problem and - * a reasoner as input. - * @param learningProblem The learning problem to solve. - * @param reasoningService The reasoner connecting to the - * underlying knowledge base. - */ - public LearningAlgorithm(LearningProblem learningProblem, ReasonerComponent reasoningService) { - this.learningProblem = learningProblem; - this.reasoner = reasoningService; - } - - /** - * Call this when you want to change the learning problem, but - * leave everything else as is. Method can be used to apply - * a configured algorithm to different learning problems. - * Implementations, which do not only use the provided learning - * algorithm variable, must make sure that a call to this method - * indeed changes the learning problem. - * @param learningProblem The new learning problem. - */ - public void changeLearningProblem(LearningProblem learningProblem) { - this.learningProblem = learningProblem; - } - - /** - * Call this when you want to change the reasoning service, but - * leave everything else as is. Method can be used to use - * a configured algorithm with different reasoners. - * 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 The new reasoning service. - */ - public void changeReasonerComponent(ReasonerComponent reasoningService) { - this.reasoner = reasoningService; - } - - /** - * This is the maximum number of results, which the learning - * algorithms are asked to store. (Note, that algorithms are not - * required to store any results except the best one, so this limit - * is used to limit the performance cost for those which - * choose to store results.) - */ - public static final int MAX_NR_OF_RESULTS = 100; - - /** - * Starts the algorithm. It runs until paused, stopped, or - * a termination criterion has been reached. - */ - public abstract void start(); - - /** - * Pauses the algorithm (not all algorithms need to implement - * this operation). - */ - public void pause() { }; - - /** - * Resumes the algorithm (not all algorithms need to implement - * this operation). You can use this method to continue - * an algorithm run even after a termination criterion has been - * reached. It will run until paused, stopped, or terminated - * again. - */ - public void resume() { }; - - /** - * Stops the algorithm gracefully. A stopped algorithm cannot be resumed anymore. - * Use this method for cleanup and freeing memory. - */ - public abstract void stop(); - - /** - * Returns whether the learning algorithm is running. Implementation - * should use a boolean status variable in their implementations of - * the start and resume methods. - * @return True if the algorithm is running, false otherwise. - */ - public abstract boolean isRunning(); - - /** - * Every algorithm must be able to return the score of the - * best solution found. - * - * @return Best score. - */ -// @Deprecated -// public abstract Score getSolutionScore(); - - /** - * @see #getCurrentlyBestEvaluatedDescription() - * @return The best class description found by the learning algorithm so far. - */ - public abstract Description getCurrentlyBestDescription(); - - /** - * @see #getCurrentlyBestEvaluatedDescriptions() - * @return The best class descriptions found by the learning algorithm so far. - */ - public List<Description> getCurrentlyBestDescriptions() { - List<Description> ds = new LinkedList<Description>(); - ds.add(getCurrentlyBestDescription()); - return ds; - } - - /** - * @see #getCurrentlyBestEvaluatedDescriptions(int) - * @param nrOfDescriptions Limit for the number or returned descriptions. - * @return The best class descriptions found by the learning algorithm so far. - */ - public synchronized List<Description> getCurrentlyBestDescriptions(int nrOfDescriptions) { - return getCurrentlyBestDescriptions(nrOfDescriptions, false); - } - - /** - * @see #getCurrentlyBestEvaluatedDescriptions(int,double,boolean) - * @param nrOfDescriptions Limit for the number or returned descriptions. - * @param filterNonMinimalDescriptions Remove non-minimal descriptions (e.g. those which can be shortened - * to an equivalent concept) from the returned set. - * @return The best class descriptions found by the learning algorithm so far. - */ - public synchronized List<Description> getCurrentlyBestDescriptions(int nrOfDescriptions, boolean filterNonMinimalDescriptions) { - List<Description> currentlyBest = getCurrentlyBestDescriptions(); - List<Description> returnList = new LinkedList<Description>(); - for(Description ed : currentlyBest) { - if(returnList.size() >= nrOfDescriptions) { - return returnList; - } - - if(!filterNonMinimalDescriptions || ConceptTransformation.isDescriptionMinimal(ed)) { - returnList.add(ed); - } - - } - return returnList; - } - - /** - * Returns the best descriptions obtained so far. - * @return Best class description found so far. - */ - public abstract EvaluatedDescription getCurrentlyBestEvaluatedDescription(); - - /** - * Returns a sorted set of the best descriptions found so far. We - * assume that they are ordered such that the best ones come in - * last. (In Java, iterators traverse a SortedSet in ascending order.) - * @return Best class descriptions found so far. - */ - public TreeSet<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions() { - TreeSet<EvaluatedDescription> ds = new TreeSet<EvaluatedDescription>(); - ds.add(getCurrentlyBestEvaluatedDescription()); - return ds; - } - - /** - * Returns a filtered list of currently best class descriptions. - * - * @param nrOfDescriptions Maximum number of restrictions. Use Integer.MAX_VALUE - * if you do not want this filter to be active. - * - * @param accuracyThreshold Minimum accuracy. All class descriptions with lower - * accuracy are disregarded. Specify a value between 0.0 and 1.0. Use 0.0 if - * you do not want this filter to be active. - * - * @param filterNonMinimalDescriptions If true, non-minimal descriptions are - * filtered, e.g. ALL r.TOP (being equivalent to TOP), male AND male (can be - * shortened to male). Currently, non-minimal descriptions are just skipped, - * i.e. they are completely omitted from the return list. Later, implementation - * might be changed to return shortened versions of those descriptions. - * - * @return A list of currently best class descriptions. - */ - public synchronized List<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions(int nrOfDescriptions, double accuracyThreshold, boolean filterNonMinimalDescriptions) { - TreeSet<? extends EvaluatedDescription> currentlyBest = getCurrentlyBestEvaluatedDescriptions(); - List<EvaluatedDescription> returnList = new LinkedList<EvaluatedDescription>(); - for(EvaluatedDescription ed : currentlyBest.descendingSet()) { - // once we hit a description with a below threshold accuracy, we simply return - // because learning algorithms are advised to order descriptions by accuracy, - // so we won't find any concept with higher accuracy in the remaining list -// if(ed.getAccuracy() < accuracyThreshold) { - if(ed.getAccuracy() < accuracyThreshold) { - return returnList; - } - - // return if we have sufficiently many descriptions - if(returnList.size() >= nrOfDescriptions) { - return returnList; - } - - if(!filterNonMinimalDescriptions || ConceptTransformation.isDescriptionMinimal(ed.getDescription())) { - // before we add the description we replace EXISTS r.TOP with - // EXISTS r.range(r) if range(r) is atomic - // (we need to clone, otherwise we change descriptions which could - // be in the search of the learning algorith, which leads to - // unpredictable behaviour) - Description d = ed.getDescription().clone(); - - //commented out because reasoner is called. leads in swing applications sometimes to exceptions -// ConceptTransformation.replaceRange(d, reasoner); - ed.setDescription(d); - - returnList.add(ed); - } - - } - return returnList; - } - - /** - * Return the best currently found concepts up to some maximum - * count (no minimality filter used). - * @param nrOfDescriptions Maximum number of descriptions returned. - * @return Return value is getCurrentlyBestDescriptions(nrOfDescriptions, 0.0, false). - */ - public synchronized List<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions(int nrOfDescriptions) { - return getCurrentlyBestEvaluatedDescriptions(nrOfDescriptions, 0.0, false); - } - - /** - * Returns a fraction of class descriptions with sufficiently high accuracy. - * @param accuracyThreshold Only return solutions with this accuracy or higher. - * @return Return value is getCurrentlyBestDescriptions(Integer.MAX_VALUE, accuracyThreshold, false). - */ - public synchronized List<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions(double accuracyThreshold) { - return getCurrentlyBestEvaluatedDescriptions(Integer.MAX_VALUE, accuracyThreshold, false); - } - - public synchronized List<? extends EvaluatedDescription> getCurrentlyBestMostGeneralEvaluatedDescriptions() { - List<? extends EvaluatedDescription> l = getCurrentlyBestEvaluatedDescriptions(getCurrentlyBestEvaluatedDescriptions().last().getAccuracy()); - DescriptionSubsumptionTree t = new DescriptionSubsumptionTree(reasoner); - t.insert(l); - return t.getMostGeneralDescriptions(true); - } - - /** - * Returns all learning problems supported by this component. This can be used to indicate that, e.g. - * an algorithm is only suitable for positive only learning. - * @return All classes implementing learning problems, which are supported by this learning algorithm. - */ - public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() { - return new LinkedList<Class<? extends LearningProblem>>(); - } - } Modified: trunk/components-core/src/main/java/org/dllearner/core/LearningProblemUnsupportedException.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/LearningProblemUnsupportedException.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/core/LearningProblemUnsupportedException.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -33,12 +33,12 @@ private static final long serialVersionUID = 177919265073997460L; - public LearningProblemUnsupportedException(Class<? extends LearningProblem> problemClass, Class<? extends LearningAlgorithm> algorithmClass) { + public LearningProblemUnsupportedException(Class<? extends LearningProblem> problemClass, Class<? extends AbstractCELA> algorithmClass) { super("Warning: No suitable constructor registered for algorithm " + algorithmClass.getName() + " and problem " + problemClass.getClass().getName() + "."); } - public LearningProblemUnsupportedException(Class<? extends LearningProblem> problemClass, Class<? extends LearningAlgorithm> algorithmClass, Collection<Class<? extends LearningProblem>> supportedProblems) { + public LearningProblemUnsupportedException(Class<? extends LearningProblem> problemClass, Class<? extends AbstractCELA> algorithmClass, Collection<Class<? extends LearningProblem>> supportedProblems) { super("Warning: No suitable constructor registered for algorithm " + algorithmClass.getName() + " and problem " + problemClass.getClass().getName() + ". Registered constructors for " + algorithmClass.getName() + ": " Added: trunk/components-core/src/main/java/org/dllearner/core/SparqlQueryLearningAlgorithm.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/SparqlQueryLearningAlgorithm.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/core/SparqlQueryLearningAlgorithm.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2007-2011, 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; + +/** + * Basic interface for algorithms learning SPARQL queries. + * + * @author Jens Lehmann + * + */ +public interface SparqlQueryLearningAlgorithm extends LearningAlgorithm { + +} Modified: trunk/components-core/src/main/java/org/dllearner/core/options/CommonConfigOptions.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/options/CommonConfigOptions.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/core/options/CommonConfigOptions.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -19,7 +19,7 @@ */ package org.dllearner.core.options; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; @@ -193,7 +193,7 @@ public static IntegerConfigOption maxNrOfResults(int defaultValue) { IntegerConfigOption opt = new IntegerConfigOption("maxNrOfResults", "Sets the maximum number of results one is interested in. (Setting this to a lower value may increase performance as the learning algorithm has to store/evaluate/beautify less descriptions).", defaultValue); opt.setLowerLimit(1); - opt.setUpperLimit(LearningAlgorithm.MAX_NR_OF_RESULTS); + opt.setUpperLimit(AbstractCELA.MAX_NR_OF_RESULTS); return opt; } Modified: trunk/components-core/src/main/java/org/dllearner/utilities/components/ComponentCombo.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/components/ComponentCombo.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/utilities/components/ComponentCombo.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -27,7 +27,7 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasonerComponent; @@ -50,7 +50,7 @@ private Set<KnowledgeSource> sources; private ReasonerComponent reasoner; private LearningProblem problem; - private LearningAlgorithm algorithm; + private AbstractCELA algorithm; /** * Builds a component combination object from the specified components. @@ -59,7 +59,7 @@ * @param problem A learning problem. * @param algorithm A learning algorithm. */ - public ComponentCombo(KnowledgeSource source, ReasonerComponent reasoner, LearningProblem problem, LearningAlgorithm algorithm) { + public ComponentCombo(KnowledgeSource source, ReasonerComponent reasoner, LearningProblem problem, AbstractCELA algorithm) { this(getSourceSet(source), reasoner, problem, algorithm); } @@ -70,7 +70,7 @@ * @param problem A learning problem. * @param algorithm A learning algorithm. */ - public ComponentCombo(Set<KnowledgeSource> sources, ReasonerComponent reasoner, LearningProblem problem, LearningAlgorithm algorithm) { + public ComponentCombo(Set<KnowledgeSource> sources, ReasonerComponent reasoner, LearningProblem problem, AbstractCELA algorithm) { this.sources = sources; this.reasoner = reasoner; this.problem = problem; @@ -144,7 +144,7 @@ /** * @return the algorithm */ - public LearningAlgorithm getAlgorithm() { + public AbstractCELA getAlgorithm() { return algorithm; } Modified: trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnConfiguration.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnConfiguration.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnConfiguration.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -5,7 +5,7 @@ import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; @@ -28,7 +28,7 @@ public boolean replaceSearchTree = true; - public void applyConfigEntries(ComponentManager cm, KnowledgeSource ks, LearningProblem lp, ReasonerComponent rs, LearningAlgorithm la) { + public void applyConfigEntries(ComponentManager cm, KnowledgeSource ks, LearningProblem lp, ReasonerComponent rs, AbstractCELA la) { try { // LEARNINGALGORITHM Modified: trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnOWLFileConfiguration.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnOWLFileConfiguration.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnOWLFileConfiguration.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -4,7 +4,7 @@ import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; @@ -22,7 +22,7 @@ } @Override - public void applyConfigEntries(ComponentManager cm, KnowledgeSource ks, LearningProblem lp, ReasonerComponent rs, LearningAlgorithm la) { + public void applyConfigEntries(ComponentManager cm, KnowledgeSource ks, LearningProblem lp, ReasonerComponent rs, AbstractCELA la) { try { super.applyConfigEntries(cm, ks, lp, rs, la); // KNOWLEDGESOURCE Modified: trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/main/java/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -2,7 +2,7 @@ import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.kb.sparql.Cache; @@ -24,7 +24,7 @@ @Override - public void applyConfigEntries(ComponentManager cm, KnowledgeSource ks, LearningProblem lp, ReasonerComponent rs, LearningAlgorithm la) { + public void applyConfigEntries(ComponentManager cm, KnowledgeSource ks, LearningProblem lp, ReasonerComponent rs, AbstractCELA la) { try { super.applyConfigEntries(cm, ks, lp, rs, la); // KNOWLEDGESOURCE Modified: trunk/components-core/src/test/java/org/dllearner/test/ClassCastExceptionTest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/test/ClassCastExceptionTest.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/test/java/org/dllearner/test/ClassCastExceptionTest.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -8,7 +8,7 @@ import org.dllearner.core.ComponentManager; import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.KnowledgeSource; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasonerComponent; @@ -47,7 +47,7 @@ lp.init(); // create the learning algorithm - LearningAlgorithm la = null; + AbstractCELA la = null; try { la = cm.learningAlgorithm(CELOE.class, lp, reasoner); cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", 2); Modified: trunk/components-core/src/test/java/org/dllearner/test/ComponentTest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/test/ComponentTest.java 2011-03-16 21:14:14 UTC (rev 2724) +++ trunk/components-core/src/test/java/org/dllearner/test/ComponentTest.java 2011-03-17 11:24:56 UTC (rev 2725) @@ -28,7 +28,7 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; -import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.AbstractCELA; import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasonerComponent; @@ -78,7 +78,7 @@ lp.init(); // create the learning algorithm - LearningAlgorithm la = null; + AbstractCELA la = null; try { la = cm.learningAlgorithm(OCEL.class, lp, reasoner); la.init(); Modified: trunk/components-core/src/test/java/org/dllearner/test/SworeTest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/test... [truncated message content] |