From: <jen...@us...> - 2007-09-25 09:30:17
|
Revision: 151 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=151&view=rev Author: jenslehmann Date: 2007-09-25 02:30:13 -0700 (Tue, 25 Sep 2007) Log Message: ----------- continued building base structure Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/Component.java trunk/src/dl-learner/org/dllearner/core/ComponentManager.java trunk/src/dl-learner/org/dllearner/core/ConfigEntry.java trunk/src/dl-learner/org/dllearner/core/ConfigOption.java trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java trunk/src/dl-learner/org/dllearner/core/InvalidConfigOptionValueException.java trunk/src/dl-learner/org/dllearner/core/LearningAlgorithmNew.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLP.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java trunk/src/dl-learner/org/dllearner/core/ComponentTest.java trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java trunk/src/dl-learner/org/dllearner/kb/ trunk/src/dl-learner/org/dllearner/kb/OWLFile.java Removed Paths: ------------- trunk/Test.txt Deleted: trunk/Test.txt =================================================================== --- trunk/Test.txt 2007-09-23 17:17:56 UTC (rev 150) +++ trunk/Test.txt 2007-09-25 09:30:13 UTC (rev 151) @@ -1 +0,0 @@ -Test \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java 2007-09-25 09:30:13 UTC (rev 151) @@ -0,0 +1,28 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core; + +/** + * @author Jens Lehmann + * + */ +public class CommonConfigMappings { + +} Modified: trunk/src/dl-learner/org/dllearner/core/Component.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Component.java 2007-09-23 17:17:56 UTC (rev 150) +++ trunk/src/dl-learner/org/dllearner/core/Component.java 2007-09-25 09:30:13 UTC (rev 151) @@ -39,8 +39,8 @@ /** * Returns all configuration options supported by this component. */ - public static Collection<ConfigOption> createConfigOptions() { - return new LinkedList<ConfigOption>(); + public static Collection<ConfigOption<?>> createConfigOptions() { + return new LinkedList<ConfigOption<?>>(); } /** @@ -48,5 +48,5 @@ * * @param entry A configuration entry. */ - public abstract void applyConfigEntry(ConfigEntry entry); + public abstract <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException; } Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-09-23 17:17:56 UTC (rev 150) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-09-25 09:30:13 UTC (rev 151) @@ -72,6 +72,33 @@ return componentStrings; } + public KnowledgeSource knowledgeSource(Class<? extends KnowledgeSource> source) { + try { + Constructor<? extends KnowledgeSource> constructor = source.getConstructor(); + return constructor.newInstance(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + public LearningProblemNew learningProblem(Class<LearningProblemNew> lp, ReasonerComponent reasoner) { try { Constructor<LearningProblemNew> constructor = lp.getConstructor(ReasonerComponent.class); Added: trunk/src/dl-learner/org/dllearner/core/ComponentTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentTest.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/ComponentTest.java 2007-09-25 09:30:13 UTC (rev 151) @@ -0,0 +1,50 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core; + +import org.dllearner.kb.OWLFile; + +/** + * Test for component based design. + * + * @author Jens Lehmann + * + */ +public class ComponentTest { + + /** + * @param args + */ + public static void main(String[] args) { + + // get singleton instance of component manager + ComponentManager cm = ComponentManager.getInstance(); + + // create knowledge source + KnowledgeSource source = cm.knowledgeSource(OWLFile.class); + + // ... to be continued ... + + ReasonerComponent reasoner = new ReasonerComponent(); + ComponentManager.getInstance().learningProblem(LearningProblemNew.class, reasoner); + + } + +} Modified: trunk/src/dl-learner/org/dllearner/core/ConfigEntry.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ConfigEntry.java 2007-09-23 17:17:56 UTC (rev 150) +++ trunk/src/dl-learner/org/dllearner/core/ConfigEntry.java 2007-09-25 09:30:13 UTC (rev 151) @@ -25,14 +25,30 @@ * @author Jens Lehmann * */ -public class ConfigEntry { +public class ConfigEntry<T> { - public ConfigEntry(ConfigOption option, Object value) throws Exception { + private ConfigOption<T> option; + private T value; + + public ConfigEntry(ConfigOption<T> option, T value) throws InvalidConfigOptionValueException { if(!option.isValidValue(value)) { throw new InvalidConfigOptionValueException(option, value); } else { - + this.option = option; + this.value = value; } } + public ConfigOption<T> getOption() { + return option; + } + + public String getOptionName() { + return option.getName(); + } + + public T getValue() { + return value; + } + } Modified: trunk/src/dl-learner/org/dllearner/core/ConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ConfigOption.java 2007-09-23 17:17:56 UTC (rev 150) +++ trunk/src/dl-learner/org/dllearner/core/ConfigOption.java 2007-09-25 09:30:13 UTC (rev 151) @@ -26,7 +26,7 @@ * @author Jens Lehmann * */ -public abstract class ConfigOption { +public abstract class ConfigOption<T> { private String name; @@ -38,6 +38,6 @@ return name; } - public abstract boolean isValidValue(Object value); + public abstract boolean isValidValue(T value); } Modified: trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java 2007-09-23 17:17:56 UTC (rev 150) +++ trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java 2007-09-25 09:30:13 UTC (rev 151) @@ -26,7 +26,7 @@ * @author Jens Lehmann * */ -public class IntegerConfigOption extends ConfigOption { +public class IntegerConfigOption extends ConfigOption<Integer> { private int lowerLimit = Integer.MIN_VALUE; private int upperLimit = Integer.MAX_VALUE; @@ -38,7 +38,7 @@ /* (non-Javadoc) * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) */ - @Override + /* public boolean isValidValue(Object value) { if(!(value instanceof Integer)) return false; @@ -50,7 +50,19 @@ else return false; } + */ + /* (non-Javadoc) + * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) + */ + @Override + public boolean isValidValue(Integer value) { + if(value >= lowerLimit && value <= upperLimit) + return true; + else + return false; + } + /** * @return the The lowest possible value for this configuration option. */ @@ -79,4 +91,6 @@ this.upperLimit = upperLimit; } + + } Modified: trunk/src/dl-learner/org/dllearner/core/InvalidConfigOptionValueException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/InvalidConfigOptionValueException.java 2007-09-23 17:17:56 UTC (rev 150) +++ trunk/src/dl-learner/org/dllearner/core/InvalidConfigOptionValueException.java 2007-09-25 09:30:13 UTC (rev 151) @@ -27,7 +27,7 @@ private static final long serialVersionUID = 3286110428258072698L; - public InvalidConfigOptionValueException(ConfigOption option, Object value) { + public InvalidConfigOptionValueException(ConfigOption<?> option, Object value) { super("The value " + value + " is not valid for the configuration option " + option + "."); } Added: trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java 2007-09-25 09:30:13 UTC (rev 151) @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core; + +import java.net.URI; + +/** + * @author Jens Lehmann + * + */ +public abstract class KnowledgeSource extends Component { + + public abstract String toDIG(URI kbURI); + +} Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithmNew.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithmNew.java 2007-09-23 17:17:56 UTC (rev 150) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithmNew.java 2007-09-25 09:30:13 UTC (rev 151) @@ -23,15 +23,8 @@ * @author Jens Lehmann * */ -public class LearningAlgorithmNew extends Component { +public abstract class LearningAlgorithmNew extends Component { - /* (non-Javadoc) - * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.ConfigEntry) - */ - @Override - public void applyConfigEntry(ConfigEntry entry) { - // TODO Auto-generated method stub - } } Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2007-09-23 17:17:56 UTC (rev 150) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2007-09-25 09:30:13 UTC (rev 151) @@ -29,7 +29,7 @@ * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.ConfigEntry) */ @Override - public void applyConfigEntry(ConfigEntry entry) { + public <T> void applyConfigEntry(ConfigEntry<T> entry) { // TODO Auto-generated method stub } Modified: trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java 2007-09-23 17:17:56 UTC (rev 150) +++ trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java 2007-09-25 09:30:13 UTC (rev 151) @@ -29,7 +29,7 @@ * @author Jens Lehmann * */ -public class StringConfigOption extends ConfigOption { +public class StringConfigOption extends ConfigOption<String> { private Set<String> allowedValues; @@ -42,13 +42,8 @@ * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) */ @Override - public boolean isValidValue(Object value) { - if(!(value instanceof String)) - return false; - - String stringValue = (String) value; - - if(allowedValues.size() == 0 || allowedValues.contains(stringValue)) + public boolean isValidValue(String value) { + if(allowedValues.size() == 0 || allowedValues.contains(value)) return true; else return false; Added: trunk/src/dl-learner/org/dllearner/kb/OWLFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/OWLFile.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2007-09-25 09:30:13 UTC (rev 151) @@ -0,0 +1,81 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.kb; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.util.Collection; +import java.util.LinkedList; + +import org.dllearner.OntologyFileFormat; +import org.dllearner.core.ConfigEntry; +import org.dllearner.core.ConfigOption; +import org.dllearner.core.InvalidConfigOptionValueException; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.StringConfigOption; +import org.dllearner.reasoning.OWLAPIDIGConverter; + +/** + * @author Jens Lehmann + * + */ +public class OWLFile extends KnowledgeSource { + + private URL url; + + public static String getName() { + return "OWL file"; + } + + public static Collection<ConfigOption<?>> createConfigOptions() { + Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); + options.add(new StringConfigOption("url")); + return options; + } + + /* + * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.ConfigEntry) + */ + @Override + public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { + if (entry.getOptionName().equals("url")) { + String s = (String) entry.getValue(); + try { + url = new URL(s); + } catch (MalformedURLException e) { + // e.printStackTrace(); + throw new InvalidConfigOptionValueException(entry.getOption(), entry.getValue()); + } + } + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.KnowledgeSource#toDIG() + */ + @Override + public String toDIG(URI kbURI) { + // TODO: need some handling for cases where the URL was not set + return OWLAPIDIGConverter.getTellsString(url, OntologyFileFormat.RDF_XML, kbURI); + } + +} Modified: trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLP.java 2007-09-23 17:17:56 UTC (rev 150) +++ trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLP.java 2007-09-25 09:30:13 UTC (rev 151) @@ -19,10 +19,7 @@ */ package org.dllearner.learningproblems; -import java.util.Collection; - import org.dllearner.core.ConfigEntry; -import org.dllearner.core.ConfigOption; import org.dllearner.core.LearningProblemNew; /** @@ -35,17 +32,9 @@ * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.ConfigEntry) */ @Override - public void applyConfigEntry(ConfigEntry entry) { + public <T> void applyConfigEntry(ConfigEntry<T> entry) { // TODO Auto-generated method stub } - - /* (non-Javadoc) - * @see org.dllearner.core.Component#getConfigOptions() - */ - public static Collection<ConfigOption> getConfigOptions() { - // TODO: positive and negative examples - return null; - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |