From: <jen...@us...> - 2011-08-16 09:52:03
|
Revision: 3050 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3050&view=rev Author: jenslehmann Date: 2011-08-16 09:51:57 +0000 (Tue, 16 Aug 2011) Log Message: ----------- started separate component manager class for annotation based components Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java trunk/components-core/src/main/java/org/dllearner/core/config/ConfigOption.java trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/EnrichmentEvaluation.java Added Paths: ----------- trunk/scripts/src/main/java/org/dllearner/scripts/DocumentationHTMLGenerator.java Modified: trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 2011-08-16 08:08:04 UTC (rev 3049) +++ trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 2011-08-16 09:51:57 UTC (rev 3050) @@ -1,5 +1,5 @@ /** - * Copyright (C) 2007-2008, Jens Lehmann + * Copyright (C) 2007-2011, Jens Lehmann * * This file is part of DL-Learner. * @@ -43,6 +43,24 @@ import java.util.Map.Entry; import org.apache.log4j.Logger; +import org.dllearner.algorithms.DisjointClassesLearner; +import org.dllearner.algorithms.SimpleSubclassLearner; +import org.dllearner.algorithms.celoe.CELOE; +import org.dllearner.algorithms.properties.DataPropertyDomainAxiomLearner; +import org.dllearner.algorithms.properties.DataPropertyRangeAxiomLearner; +import org.dllearner.algorithms.properties.DisjointDataPropertyAxiomLearner; +import org.dllearner.algorithms.properties.DisjointObjectPropertyAxiomLearner; +import org.dllearner.algorithms.properties.EquivalentDataPropertyAxiomLearner; +import org.dllearner.algorithms.properties.EquivalentObjectPropertyAxiomLearner; +import org.dllearner.algorithms.properties.FunctionalDataPropertyAxiomLearner; +import org.dllearner.algorithms.properties.FunctionalObjectPropertyAxiomLearner; +import org.dllearner.algorithms.properties.InverseFunctionalObjectPropertyAxiomLearner; +import org.dllearner.algorithms.properties.ObjectPropertyDomainAxiomLearner; +import org.dllearner.algorithms.properties.ObjectPropertyRangeAxiomLearner; +import org.dllearner.algorithms.properties.SubDataPropertyOfAxiomLearner; +import org.dllearner.algorithms.properties.SubObjectPropertyOfAxiomLearner; +import org.dllearner.algorithms.properties.SymmetricObjectPropertyAxiomLearner; +import org.dllearner.algorithms.properties.TransitiveObjectPropertyAxiomLearner; import org.dllearner.core.options.ConfigEntry; import org.dllearner.core.options.ConfigOption; import org.dllearner.core.options.InvalidConfigOptionValueException; @@ -110,6 +128,7 @@ "org.dllearner.algorithms.isle.ISLE", "org.dllearner.algorithm.qtl.QTL" } )); + private static ComponentManager cm = null; // list of all configuration options of all components @@ -736,14 +755,4 @@ return list; } - /** - * Returns the name of a DL-Learner component. - * @param component - * @return Name of the component. - */ - public static String getName(Component component){ - ComponentAnn ann = component.getClass().getAnnotation(ComponentAnn.class); - return ann.name(); - } - } Modified: trunk/components-core/src/main/java/org/dllearner/core/config/ConfigOption.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/config/ConfigOption.java 2011-08-16 08:08:04 UTC (rev 3049) +++ trunk/components-core/src/main/java/org/dllearner/core/config/ConfigOption.java 2011-08-16 09:51:57 UTC (rev 3050) @@ -1,3 +1,22 @@ +/** + * 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.config; import java.lang.annotation.Retention; @@ -4,14 +23,12 @@ import java.lang.annotation.RetentionPolicy; /** - * Created by IntelliJ IDEA. - * User: Chris - * Date: 7/26/11 - * Time: 8:55 PM * - * This is an example annotation class allowing one to configure a field with a name, description, and corresponding property editor. - * - * Note: Only put this on Setters that take the actual object you want to end up with as the example expects it to be on the setter + * Annotation for all DL-Learner configuration options. + * + * @author Chris Shellenbarger + * @author Jens Lehmann + * @author Lorenz Bühmann */ @Retention(RetentionPolicy.RUNTIME) public @interface ConfigOption { Modified: trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java 2011-08-16 08:08:04 UTC (rev 3049) +++ trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java 2011-08-16 09:51:57 UTC (rev 3050) @@ -64,6 +64,7 @@ import org.dllearner.algorithms.properties.SymmetricObjectPropertyAxiomLearner; import org.dllearner.algorithms.properties.TransitiveObjectPropertyAxiomLearner; import org.dllearner.core.AbstractReasonerComponent; +import org.dllearner.core.AnnComponentManager; import org.dllearner.core.AxiomLearningAlgorithm; import org.dllearner.core.ComponentAnn; import org.dllearner.core.ComponentInitException; @@ -304,7 +305,7 @@ ConfigHelper.configure(learner, "maxExecutionTimeInSeconds", maxExecutionTimeInSeconds); learner.init(); - String algName = ComponentManager.getName(learner); + String algName = AnnComponentManager.getName(learner); System.out.print("Applying " + algName + " on " + resource + " ... "); long startTime = System.currentTimeMillis(); try { Added: trunk/scripts/src/main/java/org/dllearner/scripts/DocumentationHTMLGenerator.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/DocumentationHTMLGenerator.java (rev 0) +++ trunk/scripts/src/main/java/org/dllearner/scripts/DocumentationHTMLGenerator.java 2011-08-16 09:51:57 UTC (rev 3050) @@ -0,0 +1,77 @@ +/** + * 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.scripts; + +import java.io.File; +import java.util.Map; +import java.util.TreeMap; +import java.util.Map.Entry; + +import org.dllearner.core.AnnComponentManager; +import org.dllearner.core.Component; + +/** + * Script for generating documentation for all components, in particular + * their configuration options, in HTML format. The script is based on + * the new (as of 2011) annotation based component design. + * + * @author Jens Lehmann + * + */ +public class DocumentationHTMLGenerator { + + private AnnComponentManager cm; + + public DocumentationHTMLGenerator() { + cm = AnnComponentManager.getInstance(); + } + + public void writeConfigDocumentation(File file) { + Map<Class<? extends Component>, String> componentNames = cm.getComponentsNamed(); + TreeMap<String, Class<? extends Component>> componentNamesInv = new TreeMap<String, Class<? extends Component>>(); + + // create inverse, ordered map for displaying labels + for(Entry<Class<? extends Component>, String> entry : componentNames.entrySet()) { + componentNamesInv.put(entry.getValue(), entry.getKey()); + } + + StringBuffer sb = new StringBuffer(); + sb.append(getHeader()); + + + sb.append(getFooter()); + } + + private String getHeader() { + return "<html><head><title>DL-Learner components and configuration options</title></head><body>"; + } + + private String getFooter() { + return "</body>"; + } + + public static void main(String[] args) { + File file = new File("doc/configOptions.html"); + DocumentationHTMLGenerator dg = new DocumentationHTMLGenerator(); + dg.writeConfigDocumentation(file); + System.out.println("Done"); + } + +} Modified: trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/EnrichmentEvaluation.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/EnrichmentEvaluation.java 2011-08-16 08:08:04 UTC (rev 3049) +++ trunk/scripts/src/main/java/org/dllearner/scripts/evaluation/EnrichmentEvaluation.java 2011-08-16 09:51:57 UTC (rev 3050) @@ -59,6 +59,7 @@ import org.dllearner.algorithms.properties.ObjectPropertyRangeAxiomLearner; import org.dllearner.algorithms.properties.SymmetricObjectPropertyAxiomLearner; import org.dllearner.algorithms.properties.TransitiveObjectPropertyAxiomLearner; +import org.dllearner.core.AnnComponentManager; import org.dllearner.core.AxiomLearningAlgorithm; import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; @@ -227,7 +228,7 @@ learner.init(); // learner.setPropertyToDescribe(property); // learner.setMaxExecutionTimeInSeconds(10); - String algName = ComponentManager.getName(learner); + String algName = AnnComponentManager.getName(learner); System.out.println("Applying " + algName + " on " + property + " ... "); long startTime = System.currentTimeMillis(); boolean timeout = false; @@ -279,7 +280,7 @@ learner.init(); // learner.setPropertyToDescribe(property); // learner.setMaxExecutionTimeInSeconds(10); - String algName = ComponentManager.getName(learner); + String algName = AnnComponentManager.getName(learner); System.out.println("Applying " + algName + " on " + property + " ... "); long startTime = System.currentTimeMillis(); boolean timeout = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |