From: <jen...@us...> - 2008-09-22 14:51:04
|
Revision: 1236 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1236&view=rev Author: jenslehmann Date: 2008-09-22 14:50:35 +0000 (Mon, 22 Sep 2008) Log Message: ----------- - code improvements - string options with a fixed set of possible values now shown as combo boxes in GUI Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java Modified: trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -1,5 +1,5 @@ /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -21,27 +21,27 @@ /** + * A configuration option representing a boolean value. + * * @author Jens Lehmann * */ public class BooleanConfigOption extends ConfigOption<Boolean> { - - - public BooleanConfigOption(String name, String description, Boolean defaultValue, boolean mandatory, boolean requiresInit) { - super(name, description, defaultValue, mandatory, requiresInit); + public BooleanConfigOption(String name, String description) { + super(name, description); } - + public BooleanConfigOption(String name, String description, Boolean defaultValue) { super(name, description, defaultValue); - } - - public BooleanConfigOption(String name, String description) { - super(name, description); + } + + public BooleanConfigOption(String name, String description, Boolean defaultValue, boolean mandatory, boolean requiresInit) { + super(name, description, defaultValue, mandatory, requiresInit); - } + } /* (non-Javadoc) * @see org.dllearner.core.config.ConfigOption#getValueTypeAsJavaString() Modified: trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -102,10 +102,18 @@ this.requiresInit = requiresInit; } + /** + * + * @return The name of this option. + */ public String getName() { return name; } + /** + * + * @return The textual description of this option. + */ public String getDescription() { return description; } @@ -125,16 +133,20 @@ } /** - * says, if this option is mandatory for the component - * @return + * Specifies whether this option is mandatory for the component. + * (Mandatory means that this component cannot be initialised + * without setting a value for this option.) + * @return True if option is mandatory for component, false otherwise. */ public boolean isMandatory() { return mandatory; } /** - * says, if this option requires that the componnent is reinitialized with init() - * @return + * Specifies whether setting this option requires that the + * component or any components depending on this component + * need to be (re-)initialised. + * @return True if option requires init, false otherwise. */ public boolean requiresInit() { return requiresInit; @@ -161,6 +173,13 @@ */ public abstract boolean checkType(Object object); + /** + * Checks whether the value is valid, e.g. passing 1985 as + * integer value for an option, which requires values between + * 0 and 1, is not valid. + * @param value A value for the option. + * @return True if the value is valid and false otherwise. + */ public abstract boolean isValidValue(T value); public abstract String getValueTypeAsJavaString(); Modified: trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; @@ -42,7 +42,6 @@ import org.dllearner.learningproblems.PosNegInclusionLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; import org.dllearner.learningproblems.PosOnlyInclusionLP; -import org.dllearner.learningproblems.RoleLearning; import org.dllearner.reasoning.DIGReasoner; import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.reasoning.FastRetrievalReasoner; @@ -57,11 +56,10 @@ private ComponentFactory(){} /** -* @param filename pointer to the KB file on local file system * @return a component ready for initialization KBFile **/ -public static KBFile getKBFile(String filename) { -return KBFileConfigurator.getKBFile(filename); +public static KBFile getKBFile() { +return KBFileConfigurator.getKBFile(); } /** @@ -169,16 +167,6 @@ } /** -* @param positiveExamples positive examples -* @param negativeExamples negative examples -* @param reasoningService see ReasoningService -* @return a component ready for initialization RoleLearning -**/ -public static RoleLearning getRoleLearning(ReasoningService reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) { -return RoleLearningConfigurator.getRoleLearning(reasoningService, positiveExamples, negativeExamples); -} - -/** * @param learningProblem see LearningProblem * @param reasoningService see ReasoningService * @throws LearningProblemUnsupportedException see Modified: trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/Configurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; @@ -294,6 +294,15 @@ public String getStartClass() { return (String) ComponentManager.getInstance().getConfigOptionValue(dBpediaNavigationSuggestor, "startClass") ; } +/** +* forceRefinementLengthIncrease specifies whether nodes should be expanded until only longer refinements are reached. +* mandatory: false| reinit necessary: true +* default value: null +* @return boolean +**/ +public boolean getForceRefinementLengthIncrease() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(dBpediaNavigationSuggestor, "forceRefinementLengthIncrease") ; +} /** * @param writeSearchTree specifies whether to write a search tree. @@ -529,6 +538,15 @@ ComponentManager.getInstance().applyConfigEntry(dBpediaNavigationSuggestor, "startClass", startClass); reinitNecessary = true; } +/** +* @param forceRefinementLengthIncrease specifies whether nodes should be expanded until only longer refinements are reached. +* mandatory: false| reinit necessary: true +* default value: null +**/ +public void setForceRefinementLengthIncrease(boolean forceRefinementLengthIncrease) { +ComponentManager.getInstance().applyConfigEntry(dBpediaNavigationSuggestor, "forceRefinementLengthIncrease", forceRefinementLengthIncrease); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; @@ -277,6 +277,15 @@ return (Integer) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "guaranteeXgoodDescriptions") ; } /** +* maxClassDescriptionTests The maximum number of candidate hypothesis the algorithm is allowed to test (0 = no limit). The algorithm will stop afterwards. (The real number of tests can be slightly higher, because this criterion usually won't be checked after each single test.). +* mandatory: false| reinit necessary: true +* default value: 0 +* @return int +**/ +public int getMaxClassDescriptionTests() { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "maxClassDescriptionTests") ; +} +/** * logLevel determines the logLevel for this component, can be {TRACE, DEBUG, INFO}. * mandatory: false| reinit necessary: true * default value: DEBUG @@ -321,6 +330,15 @@ public String getStartClass() { return (String) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "startClass") ; } +/** +* forceRefinementLengthIncrease specifies whether nodes should be expanded until only longer refinements are reached. +* mandatory: false| reinit necessary: true +* default value: null +* @return boolean +**/ +public boolean getForceRefinementLengthIncrease() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "forceRefinementLengthIncrease") ; +} /** * @param writeSearchTree specifies whether to write a search tree. @@ -539,6 +557,15 @@ reinitNecessary = true; } /** +* @param maxClassDescriptionTests The maximum number of candidate hypothesis the algorithm is allowed to test (0 = no limit). The algorithm will stop afterwards. (The real number of tests can be slightly higher, because this criterion usually won't be checked after each single test.). +* mandatory: false| reinit necessary: true +* default value: 0 +**/ +public void setMaxClassDescriptionTests(int maxClassDescriptionTests) { +ComponentManager.getInstance().applyConfigEntry(exampleBasedROLComponent, "maxClassDescriptionTests", maxClassDescriptionTests); +reinitNecessary = true; +} +/** * @param logLevel determines the logLevel for this component, can be {TRACE, DEBUG, INFO}. * mandatory: false| reinit necessary: true * default value: DEBUG @@ -583,6 +610,15 @@ ComponentManager.getInstance().applyConfigEntry(exampleBasedROLComponent, "startClass", startClass); reinitNecessary = true; } +/** +* @param forceRefinementLengthIncrease specifies whether nodes should be expanded until only longer refinements are reached. +* mandatory: false| reinit necessary: true +* default value: null +**/ +public void setForceRefinementLengthIncrease(boolean forceRefinementLengthIncrease) { +ComponentManager.getInstance().applyConfigEntry(exampleBasedROLComponent, "forceRefinementLengthIncrease", forceRefinementLengthIncrease); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; @@ -61,6 +61,15 @@ public String getReasonerType() { return (String) ComponentManager.getInstance().getConfigOptionValue(fastInstanceChecker, "reasonerType") ; } +/** +* defaultNegation Whether to use default negation, i.e. an instance not being in a class means that it is in the negation of the class.. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getDefaultNegation() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fastInstanceChecker, "defaultNegation") ; +} /** * @param reasonerType FaCT++ or Pellet to dematerialize. @@ -71,6 +80,15 @@ ComponentManager.getInstance().applyConfigEntry(fastInstanceChecker, "reasonerType", reasonerType); reinitNecessary = true; } +/** +* @param defaultNegation Whether to use default negation, i.e. an instance not being in a class means that it is in the negation of the class.. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setDefaultNegation(boolean defaultNegation) { +ComponentManager.getInstance().applyConfigEntry(fastInstanceChecker, "defaultNegation", defaultNegation); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; @@ -43,25 +43,14 @@ } /** -* @param filename pointer to the KB file on local file system * @return KBFile **/ -public static KBFile getKBFile(String filename) { +public static KBFile getKBFile() { KBFile component = ComponentManager.getInstance().knowledgeSource(KBFile.class); -ComponentManager.getInstance().applyConfigEntry(component, "filename", filename); return component; } /** -* filename pointer to the KB file on local file system. -* mandatory: true| reinit necessary: true -* default value: null -* @return String -**/ -public String getFilename() { -return (String) ComponentManager.getInstance().getConfigOptionValue(kBFile, "filename") ; -} -/** * url URL pointer to the KB file. * mandatory: false| reinit necessary: true * default value: null @@ -72,15 +61,6 @@ } /** -* @param filename pointer to the KB file on local file system. -* mandatory: true| reinit necessary: true -* default value: null -**/ -public void setFilename(String filename) { -ComponentManager.getInstance().applyConfigEntry(kBFile, "filename", filename); -reinitNecessary = true; -} -/** * @param url URL pointer to the KB file. * mandatory: false| reinit necessary: true * default value: null Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegInclusionLPConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/SimpleSuggestionLearningAlgorithmConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -16,7 +16,7 @@ * 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.configurators; Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -23,6 +23,7 @@ import java.awt.event.ActionListener; import javax.swing.JButton; +import javax.swing.JComboBox; import javax.swing.JTextField; import org.dllearner.core.Component; @@ -45,6 +46,7 @@ private String value; private JTextField stringField; + private JComboBox comboBox; /** * Provides a widget for string options. @@ -62,6 +64,9 @@ // fire value changed event value = stringField.getText(); fireValueChanged(value); + } else if(e.getSource() == comboBox) { + value = (String) comboBox.getSelectedItem(); + fireValueChanged(value); } } @@ -76,18 +81,30 @@ value = ""; } - // text field for strings - stringField = new JTextField(35); - stringField.setText(value); - stringField.setToolTipText(configOption.getAllowedValuesDescription()); - - // set button (value is only updated when this button is pressed => - // would better without set) - setButton = new JButton("Set"); - setButton.addActionListener(this); - - add(stringField); - add(setButton); + StringConfigOption option = (StringConfigOption) configOption; + if(option.getAllowedValues().size() == 0) { + + // text field for strings + stringField = new JTextField(35); + stringField.setText(value); + stringField.setToolTipText(configOption.getAllowedValuesDescription()); + + // set button (value is only updated when this button is pressed => + // would better without set) + setButton = new JButton("Set"); + setButton.addActionListener(this); + + add(stringField); + add(setButton); + + // if there is a fixed set of strings available as options, we + // only offer those + } else { + comboBox = new JComboBox(option.getAllowedValues().toArray()); + comboBox.setSelectedItem(option.getDefaultValue()); + comboBox.addActionListener(this); + add(comboBox); + } } } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-09-22 08:04:33 UTC (rev 1235) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-09-22 14:50:35 UTC (rev 1236) @@ -35,6 +35,7 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningMethodUnsupportedException; +import org.dllearner.core.config.BooleanConfigOption; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; @@ -89,14 +90,15 @@ private static Logger logger = Logger.getLogger(FastInstanceChecker.class); - private boolean defaultNegation = true; - +// private boolean defaultNegation = true; + private FastInstanceCheckerConfigurator configurator; + @Override - public FastInstanceCheckerConfigurator getConfigurator (){ + public FastInstanceCheckerConfigurator getConfigurator() { return configurator; } - + private Set<NamedClass> atomicConcepts; private Set<ObjectProperty> atomicRoles; private SortedSet<DatatypeProperty> datatypeProperties; @@ -105,7 +107,7 @@ private SortedSet<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); private SortedSet<Individual> individuals; -// private ReasoningService rs; + // private ReasoningService rs; private OWLAPIReasoner rc; // we use sorted sets (map indices) here, because they have only log(n) @@ -125,22 +127,30 @@ private Map<DatatypeProperty, Map<Individual, SortedSet<Double>>> dd = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<Double>>>(); private Map<DatatypeProperty, Map<Individual, SortedSet<Integer>>> id = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<Integer>>>(); + /** + * Creates an instance of the fast instance checker. + * @param sources The knowledge sources used as input. + */ public FastInstanceChecker(Set<KnowledgeSource> sources) { super(sources); this.configurator = new FastInstanceCheckerConfigurator(this); } - + /** + * @return The options of this component. + */ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); - StringConfigOption type = new StringConfigOption("reasonerType", "FaCT++ or Pellet to dematerialize", "pellet", false, true); - type.setAllowedValues(new String[] {"fact", "pellet"}); + StringConfigOption type = new StringConfigOption("reasonerType", + "FaCT++ or Pellet to dematerialize", "pellet", false, true); + type.setAllowedValues(new String[] { "fact", "pellet" }); // closure option? see: // http://owlapi.svn.sourceforge.net/viewvc/owlapi/owl1_1/trunk/tutorial/src/main/java/uk/ac/manchester/owl/tutorial/examples/ClosureAxiomsExample.java?view=markup options.add(type); + options.add(new BooleanConfigOption("defaultNegation", "Whether to use default negation, i.e. an instance not being in a class means that it is in the negation of the class.", true, false, true)); return options; - } - + } + /* * (non-Javadoc) * @@ -150,10 +160,12 @@ public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { } + /** + * @return The name of this component. + */ public static String getName() { return "fast instance checker"; - } - + } /* * (non-Javadoc) @@ -162,7 +174,7 @@ */ @Override public void init() throws ComponentInitException { - //rc = new OWLAPIReasoner(sources); + // rc = new OWLAPIReasoner(sources); rc = ComponentFactory.getOWLAPIReasoner(sources); rc.getConfigurator().setReasonerType(configurator.getReasonerType()); rc.init(); @@ -176,7 +188,7 @@ atomicRoles = rc.getAtomicRoles(); individuals = rc.getIndividuals(); -// rs = new ReasoningService(rc); + // rs = new ReasoningService(rc); // TODO: some code taken from Helper.createFlatABox, but pasted here // because additional things need to @@ -185,46 +197,47 @@ long dematStartTime = System.currentTimeMillis(); logger.debug("dematerialising concepts"); - - for (NamedClass atomicConcept : rc.getAtomicConcepts()) { - + + for (NamedClass atomicConcept : rc.getAtomicConcepts()) { + SortedSet<Individual> pos = rc.retrieval(atomicConcept); classInstancesPos.put(atomicConcept, pos); - - if(defaultNegation) { - classInstancesNeg.put(atomicConcept, Helper.difference(individuals,pos)); + + if (configurator.getDefaultNegation()) { + classInstancesNeg.put(atomicConcept, Helper.difference(individuals, pos)); } else { - // Pellet needs approximately infinite time to answer negated queries - // on the carcinogenesis data set (and probably others), so we have to + // Pellet needs approximately infinite time to answer + // negated queries + // on the carcinogenesis data set (and probably others), so + // we have to // be careful here Negation negatedAtomicConcept = new Negation(atomicConcept); classInstancesNeg.put(atomicConcept, rc.retrieval(negatedAtomicConcept)); } - } logger.debug("dematerialising object properties"); - + for (ObjectProperty atomicRole : atomicRoles) { opPos.put(atomicRole, rc.getRoleMembers(atomicRole)); } logger.debug("dematerialising datatype properties"); - + for (DatatypeProperty dp : booleanDatatypeProperties) { bdPos.put(dp, rc.getTrueDatatypeMembers(dp)); bdNeg.put(dp, rc.getFalseDatatypeMembers(dp)); } - + for (DatatypeProperty dp : intDatatypeProperties) { id.put(dp, rc.getIntDatatypeMembers(dp)); - } - + } + for (DatatypeProperty dp : doubleDatatypeProperties) { dd.put(dp, rc.getDoubleDatatypeMembers(dp)); } - + long dematDuration = System.currentTimeMillis() - dematStartTime; logger.debug("TBox dematerialised in " + dematDuration + " ms"); @@ -237,9 +250,9 @@ @Override public boolean instanceCheck(Description description, Individual individual) throws ReasoningMethodUnsupportedException { - -// System.out.println(description + " " + individual); - + + // System.out.println(description + " " + individual); + if (description instanceof NamedClass) { return classInstancesPos.get((NamedClass) description).contains(individual); } else if (description instanceof Negation) { @@ -260,8 +273,9 @@ // the union, we return true List<Description> children = description.getChildren(); for (Description child : children) { - if (instanceCheck(child, individual)) + if (instanceCheck(child, individual)) { return true; + } } return false; } else if (description instanceof Intersection) { @@ -269,59 +283,67 @@ // the union, we return true List<Description> children = description.getChildren(); for (Description child : children) { - if (!instanceCheck(child, individual)) + if (!instanceCheck(child, individual)) { return false; + } } return true; } else if (description instanceof ObjectSomeRestriction) { ObjectPropertyExpression ope = ((ObjectSomeRestriction) description).getRole(); - if (!(ope instanceof ObjectProperty)) + if (!(ope instanceof ObjectProperty)) { throw new ReasoningMethodUnsupportedException("Instance check for description " + description + " unsupported. Inverse object properties not supported."); + } ObjectProperty op = (ObjectProperty) ope; Description child = description.getChild(0); Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); - ; + if (mapping == null) { logger.warn("Instance check of a description with an undefinied property (" + op + ")."); return false; } SortedSet<Individual> roleFillers = opPos.get(op).get(individual); - if (roleFillers == null) + if (roleFillers == null) { return false; + } for (Individual roleFiller : roleFillers) { - if (instanceCheck(child, roleFiller)) + if (instanceCheck(child, roleFiller)) { return true; + } } return false; } else if (description instanceof ObjectAllRestriction) { ObjectPropertyExpression ope = ((ObjectAllRestriction) description).getRole(); - if (!(ope instanceof ObjectProperty)) + if (!(ope instanceof ObjectProperty)) { throw new ReasoningMethodUnsupportedException("Instance check for description " + description + " unsupported. Inverse object properties not supported."); + } ObjectProperty op = (ObjectProperty) ope; Description child = description.getChild(0); Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); - ; + if (mapping == null) { logger.warn("Instance check of a description with an undefinied property (" + op + ")."); return true; } SortedSet<Individual> roleFillers = opPos.get(op).get(individual); - if (roleFillers == null) + if (roleFillers == null) { return true; + } for (Individual roleFiller : roleFillers) { - if (!instanceCheck(child, roleFiller)) + if (!instanceCheck(child, roleFiller)) { return false; + } } return true; } else if (description instanceof ObjectMinCardinalityRestriction) { ObjectPropertyExpression ope = ((ObjectCardinalityRestriction) description).getRole(); - if (!(ope instanceof ObjectProperty)) + if (!(ope instanceof ObjectProperty)) { throw new ReasoningMethodUnsupportedException("Instance check for description " + description + " unsupported. Inverse object properties not supported."); + } ObjectProperty op = (ObjectProperty) ope; Description child = description.getChild(0); Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); @@ -331,38 +353,44 @@ + ")."); return true; } - + int number = ((ObjectCardinalityRestriction) description).getNumber(); - int nrOfFillers = 0; - + int nrOfFillers = 0; + SortedSet<Individual> roleFillers = opPos.get(op).get(individual); // special case: there are always at least zero fillers - if(number == 0) + if (number == 0) { return true; + } // return false if there are none or not enough role fillers - if (roleFillers == null || roleFillers.size() < number) + if (roleFillers == null || roleFillers.size() < number) { return false; - + } + int index = 0; for (Individual roleFiller : roleFillers) { index++; if (instanceCheck(child, roleFiller)) { nrOfFillers++; - if(nrOfFillers == number) + if (nrOfFillers == number) { return true; - // earyl abort: e.g. >= 10 hasStructure.Methyl; - // if there are 11 fillers and 2 are not Methyl, the result is false + } + // earyl abort: e.g. >= 10 hasStructure.Methyl; + // if there are 11 fillers and 2 are not Methyl, the result + // is false } else { - if(roleFillers.size() - index < number) + if (roleFillers.size() - index < number) { return false; + } } } return false; } else if (description instanceof ObjectMaxCardinalityRestriction) { ObjectPropertyExpression ope = ((ObjectCardinalityRestriction) description).getRole(); - if (!(ope instanceof ObjectProperty)) + if (!(ope instanceof ObjectProperty)) { throw new ReasoningMethodUnsupportedException("Instance check for description " + description + " unsupported. Inverse object properties not supported."); + } ObjectProperty op = (ObjectProperty) ope; Description child = description.getChild(0); Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); @@ -372,38 +400,42 @@ + ")."); return true; } - + int number = ((ObjectCardinalityRestriction) description).getNumber(); - int nrOfFillers = 0; - + int nrOfFillers = 0; + SortedSet<Individual> roleFillers = opPos.get(op).get(individual); // return true if there are none or not enough role fillers - if (roleFillers == null || roleFillers.size() < number) + if (roleFillers == null || roleFillers.size() < number) { return true; - -// System.out.println(description + " " + individual); - + } + int index = 0; for (Individual roleFiller : roleFillers) { index++; if (instanceCheck(child, roleFiller)) { nrOfFillers++; - if(nrOfFillers > number) + if (nrOfFillers > number) { return false; - // earyl abort: e.g. <= 5 hasStructure.Methyl; - // if there are 6 fillers and 2 are not Methyl, the result is true + } + // early abort: e.g. <= 5 hasStructure.Methyl; + // if there are 6 fillers and 2 are not Methyl, the result + // is true } else { - if(roleFillers.size() - index <= number) + if (roleFillers.size() - index <= number) { return true; + } } } return true; } else if (description instanceof BooleanValueRestriction) { - DatatypeProperty dp = ((BooleanValueRestriction)description).getRestrictedPropertyExpresssion(); - boolean value = ((BooleanValueRestriction)description).getBooleanValue(); - - if(value) { - // check whether the individual is in the set of individuals mapped + DatatypeProperty dp = ((BooleanValueRestriction) description) + .getRestrictedPropertyExpresssion(); + boolean value = ((BooleanValueRestriction) description).getBooleanValue(); + + if (value) { + // check whether the individual is in the set of individuals + // mapped // to true by this datatype property return bdPos.get(dp).contains(individual); } else { @@ -414,23 +446,18 @@ DatatypeProperty dp = (DatatypeProperty) dsr.getRestrictedPropertyExpression(); DataRange dr = dsr.getDataRange(); SortedSet<Double> values = dd.get(dp).get(individual); - + // if there is no filler for this individual and property we // need to return false - if(values == null) + if (values == null) { return false; - - if(dr instanceof DoubleMaxValue) { - if(values.first() <= ((DoubleMaxValue)dr).getValue()) - return true; - else - return false; - } else if(dr instanceof DoubleMinValue) { - if(values.last() >= ((DoubleMinValue)dr).getValue()) - return true; - else - return false; } + + if (dr instanceof DoubleMaxValue) { + return (values.first() <= ((DoubleMaxValue) dr).getValue()); + } else if (dr instanceof DoubleMinValue) { + return (values.last() >= ((DoubleMinValue) dr).getValue()); + } } throw new ReasoningMethodUnsupportedException("Instance check for description " @@ -438,40 +465,46 @@ } @Override - public SortedSet<Individual> retrieval(Description concept) throws ReasoningMethodUnsupportedException { - if(concept instanceof NamedClass) - return classInstancesPos.get((NamedClass)concept); - else if(concept instanceof Negation && concept.getChild(0) instanceof NamedClass) - return classInstancesNeg.get((NamedClass)concept.getChild(0)); + public SortedSet<Individual> retrieval(Description concept) + throws ReasoningMethodUnsupportedException { + if (concept instanceof NamedClass) { + return classInstancesPos.get((NamedClass) concept); + } else if (concept instanceof Negation && concept.getChild(0) instanceof NamedClass) { + return classInstancesNeg.get((NamedClass) concept.getChild(0)); + } -// return rs.retrieval(concept); + // return rs.retrieval(concept); SortedSet<Individual> inds = new TreeSet<Individual>(); - for(Individual i : individuals) { - if(instanceCheck(concept,i)) + for (Individual i : individuals) { + if (instanceCheck(concept, i)) { inds.add(i); + } } return inds; - } - + } + /* * (non-Javadoc) * * @see org.dllearner.core.Reasoner#getAtomicConcepts() */ + @Override public Set<NamedClass> getAtomicConcepts() { return atomicConcepts; } @Override - public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers( + DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { return rc.getDoubleDatatypeMembers(datatypeProperty); } - + /* * (non-Javadoc) * * @see org.dllearner.core.Reasoner#getAtomicRoles() */ + @Override public Set<ObjectProperty> getAtomicRoles() { return atomicRoles; } @@ -501,6 +534,7 @@ * * @see org.dllearner.core.Reasoner#getIndividuals() */ + @Override public SortedSet<Individual> getIndividuals() { return individuals; } @@ -510,6 +544,7 @@ * * @see org.dllearner.core.Reasoner#getReasonerType() */ + @Override public ReasonerType getReasonerType() { return ReasonerType.FAST_INSTANCE_CHECKER; } @@ -519,6 +554,7 @@ * * @see org.dllearner.core.Reasoner#prepareSubsumptionHierarchy(java.util.Set) */ + @Override public void prepareSubsumptionHierarchy(Set<NamedClass> allowedConcepts) { rc.prepareSubsumptionHierarchy(allowedConcepts); } @@ -547,7 +583,7 @@ public DatatypePropertyHierarchy getDatatypePropertyHierarchy() { return rc.getDatatypePropertyHierarchy(); } - + @Override public boolean subsumes(Description superConcept, Description subConcept) { // Negation neg = new Negation(subConcept); @@ -561,9 +597,9 @@ * * @param args * No arguments supported. - * @throws ComponentInitException - * @throws ParseException - * @throws ReasoningMethodUnsupportedException + * @throws ComponentInitException Component cannot be initialised. + * @throws ParseException File cannot be parsed. + * @throws ReasoningMethodUnsupportedException Reasoning method not supported. */ public static void main(String[] args) throws ComponentInitException, ParseException, ReasoningMethodUnsupportedException { @@ -584,16 +620,22 @@ System.out.println(reasoner.instanceCheck(d, i)); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.dllearner.core.Reasoner#getBaseURI() */ + @Override public String getBaseURI() { return rc.getBaseURI(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.dllearner.core.Reasoner#getPrefixes() */ + @Override public Map<String, String> getPrefixes() { return rc.getPrefixes(); } @@ -602,38 +644,35 @@ public Description getDomain(ObjectProperty objectProperty) { return rc.getDomain(objectProperty); } - + @Override public Description getDomain(DatatypeProperty datatypeProperty) { return rc.getDomain(datatypeProperty); } - + @Override public Description getRange(ObjectProperty objectProperty) { return rc.getRange(objectProperty); } @Override - public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) { + public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) { return opPos.get(atomicRole); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.dllearner.core.ReasonerComponent#releaseKB() */ @Override public void releaseKB() { rc.releaseKB(); - } - - /*public void setReasonerType(String type){ - configurator.setReasonerType(type); - }*/ + } - @Override public boolean hasDatatypeSupport() { return true; } - + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |