From: <jen...@us...> - 2007-09-23 17:16:13
|
Revision: 149 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=149&view=rev Author: jenslehmann Date: 2007-09-23 10:16:08 -0700 (Sun, 23 Sep 2007) Log Message: ----------- continued implementing the new 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/learningproblems/DefinitionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLPThreeValued.java trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLPTwoValued.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithmNew.java trunk/src/dl-learner/org/dllearner/core/LearningProblemNew.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/learningproblems/LearningProblemNew.java Modified: trunk/src/dl-learner/org/dllearner/core/Component.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Component.java 2007-09-22 10:22:00 UTC (rev 148) +++ trunk/src/dl-learner/org/dllearner/core/Component.java 2007-09-23 17:16:08 UTC (rev 149) @@ -20,28 +20,33 @@ package org.dllearner.core; import java.util.Collection; +import java.util.LinkedList; /** * @author Jens Lehmann * */ -public interface Component { - +public abstract class Component { + /** * * @return The name of this component. */ - public String getName(); + public static String getName() { + return "unnamed component"; + } /** * Returns all configuration options supported by this component. */ - public Collection<ConfigOption> getConfigOptions(); + public static Collection<ConfigOption> createConfigOptions() { + return new LinkedList<ConfigOption>(); + } /** * Applies a configuration option to this component. * * @param entry A configuration entry. */ - public void applyConfigEntry(ConfigEntry entry); + public abstract void applyConfigEntry(ConfigEntry entry); } Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-09-22 10:22:00 UTC (rev 148) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-09-23 17:16:08 UTC (rev 149) @@ -19,10 +19,84 @@ */ package org.dllearner.core; +import java.io.BufferedReader; +import java.io.DataInputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.LinkedList; +import java.util.List; + /** + * Central manager class for DL-Learner. + * * @author Jens Lehmann * */ public class ComponentManager { + private static String componentsFile = "lib/components.ini"; + + private static ComponentManager cm = new ComponentManager(); + + private ComponentManager() { + + } + + public static ComponentManager getInstance() { + return cm; + } + + private static List<String> readComponentsFile() { + List<String> componentStrings = new LinkedList<String>(); + + try { + FileInputStream fstream = new FileInputStream(componentsFile); + + DataInputStream in = new DataInputStream(fstream); + BufferedReader br = new BufferedReader(new InputStreamReader(in)); + String line; + + while ((line = br.readLine()) != null) { + if(!(line.startsWith("#") || line.startsWith("//") || line.startsWith("%"))) + componentStrings.add(line); + } + + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + return componentStrings; + } + + public LearningProblemNew learningProblem(Class<LearningProblemNew> lp, ReasonerComponent reasoner) { + try { + Constructor<LearningProblemNew> constructor = lp.getConstructor(ReasonerComponent.class); + return constructor.newInstance(reasoner); + } 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 (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + } Added: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithmNew.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithmNew.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithmNew.java 2007-09-23 17:16:08 UTC (rev 149) @@ -0,0 +1,37 @@ +/** + * 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 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 + + } + +} Copied: trunk/src/dl-learner/org/dllearner/core/LearningProblemNew.java (from rev 148, trunk/src/dl-learner/org/dllearner/learningproblems/LearningProblemNew.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningProblemNew.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/LearningProblemNew.java 2007-09-23 17:16:08 UTC (rev 149) @@ -0,0 +1,31 @@ +/** + * 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; + +/** + * Marker interface for all learning problems (the "New" at the end of the name + * is temporary for the restructuring process). + * + * @author Jens Lehmann + * + */ +public abstract class LearningProblemNew extends Component { + +} Added: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2007-09-23 17:16:08 UTC (rev 149) @@ -0,0 +1,37 @@ +/** + * 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 ReasonerComponent 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/learningproblems/DefinitionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLP.java 2007-09-22 10:22:00 UTC (rev 148) +++ trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLP.java 2007-09-23 17:16:08 UTC (rev 149) @@ -21,19 +21,20 @@ import java.util.Collection; -import org.dllearner.core.Component; import org.dllearner.core.ConfigEntry; import org.dllearner.core.ConfigOption; +import org.dllearner.core.LearningProblemNew; /** * @author Jens Lehmann * */ -public abstract class DefinitionLP implements LearningProblemNew, Component { +public abstract class DefinitionLP extends LearningProblemNew { /* (non-Javadoc) * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.ConfigEntry) */ + @Override public void applyConfigEntry(ConfigEntry entry) { // TODO Auto-generated method stub @@ -42,17 +43,9 @@ /* (non-Javadoc) * @see org.dllearner.core.Component#getConfigOptions() */ - public Collection<ConfigOption> getConfigOptions() { - // TODO Auto-generated method stub + public static Collection<ConfigOption> getConfigOptions() { + // TODO: positive and negative examples return null; } - - /* (non-Javadoc) - * @see org.dllearner.core.Component#getName() - */ - public String getName() { - // TODO Auto-generated method stub - return null; - } } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLPThreeValued.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLPThreeValued.java 2007-09-22 10:22:00 UTC (rev 148) +++ trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLPThreeValued.java 2007-09-23 17:16:08 UTC (rev 149) @@ -19,17 +19,17 @@ */ package org.dllearner.learningproblems; -import java.util.Collection; - -import org.dllearner.core.ConfigEntry; -import org.dllearner.core.ConfigOption; - /** * @author Jens Lehmann * */ public class DefinitionLPThreeValued extends DefinitionLP { + /* (non-Javadoc) + * @see org.dllearner.core.Component#getName() + */ + public static String getName() { + return "two valued definition learning problem"; + } - } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLPTwoValued.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLPTwoValued.java 2007-09-22 10:22:00 UTC (rev 148) +++ trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLPTwoValued.java 2007-09-23 17:16:08 UTC (rev 149) @@ -25,6 +25,11 @@ */ public class DefinitionLPTwoValued extends DefinitionLP { + /* (non-Javadoc) + * @see org.dllearner.core.Component#getName() + */ + public static String getName() { + return "two valued definition learning problem"; + } - } Deleted: trunk/src/dl-learner/org/dllearner/learningproblems/LearningProblemNew.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/LearningProblemNew.java 2007-09-22 10:22:00 UTC (rev 148) +++ trunk/src/dl-learner/org/dllearner/learningproblems/LearningProblemNew.java 2007-09-23 17:16:08 UTC (rev 149) @@ -1,31 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.learningproblems; - -/** - * Marker interface for all learning problems (the "New" at the end of the name - * is temporary for the restructuring process). - * - * @author Jens Lehmann - * - */ -public interface LearningProblemNew { - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |