You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(120) |
Sep
(36) |
Oct
(116) |
Nov
(17) |
Dec
(44) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(143) |
Feb
(192) |
Mar
(74) |
Apr
(84) |
May
(105) |
Jun
(64) |
Jul
(49) |
Aug
(120) |
Sep
(159) |
Oct
(156) |
Nov
(51) |
Dec
(28) |
2009 |
Jan
(17) |
Feb
(55) |
Mar
(33) |
Apr
(57) |
May
(54) |
Jun
(28) |
Jul
(6) |
Aug
(16) |
Sep
(38) |
Oct
(30) |
Nov
(26) |
Dec
(52) |
2010 |
Jan
(7) |
Feb
(91) |
Mar
(65) |
Apr
(2) |
May
(14) |
Jun
(25) |
Jul
(38) |
Aug
(48) |
Sep
(80) |
Oct
(70) |
Nov
(75) |
Dec
(77) |
2011 |
Jan
(68) |
Feb
(53) |
Mar
(51) |
Apr
(35) |
May
(65) |
Jun
(101) |
Jul
(29) |
Aug
(230) |
Sep
(95) |
Oct
(49) |
Nov
(110) |
Dec
(63) |
2012 |
Jan
(41) |
Feb
(42) |
Mar
(25) |
Apr
(46) |
May
(51) |
Jun
(44) |
Jul
(45) |
Aug
(29) |
Sep
(12) |
Oct
(9) |
Nov
(17) |
Dec
(2) |
2013 |
Jan
(12) |
Feb
(14) |
Mar
(7) |
Apr
(16) |
May
(54) |
Jun
(27) |
Jul
(11) |
Aug
(5) |
Sep
(85) |
Oct
(27) |
Nov
(37) |
Dec
(32) |
2014 |
Jan
(8) |
Feb
(29) |
Mar
(5) |
Apr
(3) |
May
(22) |
Jun
(3) |
Jul
(4) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <ku...@us...> - 2008-09-08 12:38:58
|
Revision: 1175 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1175&view=rev Author: kurzum Date: 2008-09-08 12:38:52 +0000 (Mon, 08 Sep 2008) Log Message: ----------- fixed newsample class Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/NewSample.java Modified: trunk/src/dl-learner/org/dllearner/scripts/NewSample.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/NewSample.java 2008-09-08 12:37:27 UTC (rev 1174) +++ trunk/src/dl-learner/org/dllearner/scripts/NewSample.java 2008-09-08 12:38:52 UTC (rev 1175) @@ -35,7 +35,7 @@ import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasoningService; -import org.dllearner.core.configuration.Configurator; +import org.dllearner.core.configurators.ComponentFactory; import org.dllearner.kb.OWLFile; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.reasoning.FastInstanceChecker; @@ -117,33 +117,33 @@ //KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); String fileURL = new File(owlFile).toURI().toString(); - OWLFile ks = Configurator.getOWLFile(cm, fileURL); + OWLFile ks = ComponentFactory.getOWLFile( fileURL); // reasoner - FastInstanceChecker f = Configurator.getFastInstanceChecker(cm, ks); + FastInstanceChecker f = ComponentFactory.getFastInstanceChecker( ks); ReasoningService rs = cm.reasoningService(f); // learning problem - PosNegDefinitionLP lp = Configurator.getPosNegDefinitionLP(cm, rs, posExamples, negExamples); + PosNegDefinitionLP lp = ComponentFactory.getPosNegDefinitionLP( rs, posExamples, negExamples); // learning algorithm - ExampleBasedROLComponent la = Configurator.getExampleBasedROLComponent(cm, lp, rs); + ExampleBasedROLComponent la = ComponentFactory.getExampleBasedROLComponent( lp, rs); //OPTIONAL PARAMETERS - la.getConfigurator().setUseAllConstructor(cm, false); - la.getConfigurator().setUseExistsConstructor(cm, true); - la.getConfigurator().setUseCardinalityRestrictions(cm, false); - la.getConfigurator().setUseExistsConstructor(cm, true); - la.getConfigurator().setUseNegation(cm, false); - la.getConfigurator().setWriteSearchTree(cm, false); - la.getConfigurator().setSearchTreeFile(cm, "log/searchTree.txt"); - la.getConfigurator().setReplaceSearchTree(cm, true); - la.getConfigurator().setNoisePercentage(cm, 0.0); + la.getConfigurator().setUseAllConstructor( false); + la.getConfigurator().setUseExistsConstructor(true); + la.getConfigurator().setUseCardinalityRestrictions(false); + la.getConfigurator().setUseExistsConstructor(true); + la.getConfigurator().setUseNegation(false); + la.getConfigurator().setWriteSearchTree(false); + la.getConfigurator().setSearchTreeFile("log/searchTree.txt"); + la.getConfigurator().setReplaceSearchTree(true); + la.getConfigurator().setNoisePercentage(0.0); SortedSet<String> ignore = new TreeSet<String>(); ignore.add("http://example.com/foo#car"); - la.getConfigurator().setIgnoredConcepts(cm, ignore); + la.getConfigurator().setIgnoredConcepts(ignore); // all components need to be initialised before they can be used This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-09-08 12:37:31
|
Revision: 1174 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1174&view=rev Author: jenslehmann Date: 2008-09-08 12:37:27 +0000 (Mon, 08 Sep 2008) Log Message: ----------- "about" and "quick tutorial" GUI windows Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/AboutWindow.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java Modified: trunk/src/dl-learner/org/dllearner/gui/AboutWindow.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/AboutWindow.java 2008-09-08 11:45:09 UTC (rev 1173) +++ trunk/src/dl-learner/org/dllearner/gui/AboutWindow.java 2008-09-08 12:37:27 UTC (rev 1174) @@ -1,12 +1,25 @@ package org.dllearner.gui; +import java.net.URL; + +import javax.swing.ImageIcon; import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTextPane; +import javax.swing.text.BadLocationException; +import javax.swing.text.Style; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyleContext; +import javax.swing.text.StyledDocument; +import org.dllearner.Info; + /** * Window displaying some information about DL-Learner and DL-Learner GUI. * * @author Jens Lehmann - * + * */ public class AboutWindow extends JFrame { @@ -14,19 +27,112 @@ public AboutWindow() { setTitle("About"); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setLocationByPlatform(true); - setSize(300, 300); + setSize(400, 400); + + URL imgURL = AboutWindow.class.getResource("dl-learner.gif"); - // display icon + String html = "<html><p align=\"center\"><img src=\""+imgURL+"\" alt=\"DL-Learner logo\"/></p>"; + html += "<p align=\"center\"><i>DL-Learner</i><br />Build " + Info.build + "</p>"; + html += "<br /><p align=\"center\"><i>License</i><br />GNU General Public License Version 3</p>"; + html += "<br /><p align=\"center\"><i>Homepage</i><br /><a href=\"http://dl-learner.org\">http://dl-learner.org</a></p>"; + html += "<br /><p align=\"center\"><i>DL-Learner GUI developers</i><br />"; + html += "Jens Lehmann<br />Tilo Hielscher</p>"; + html += "<br /><p align=\"center\"><i>DL-Learner contributors in general</i><br />"; + html += "Jens Lehmann<br />"; + html += " Sebastian Hellmann (SPARQL component and more)<br />"; + html += "Sebastian Knappe (DBpedia Navigator)<br />"; + html += "Tilo Hielscher (DL-Learner GUI)<br />"; + html += "Lorenz Bühmann (ORE Tool)<br />"; + html += "Maria Moritz, Vu Duc Minh (OntoWiki plugin)<br />"; + html += "Christian Kötteritzsch (Protégé 4 plugin)<br />"; + html += "Collette Hagert (DB to OWL converter)</p>"; + html += "</html>"; - // display build version + JLabel label = new JLabel(html); +// label.setFont(new Font("Serif", Font.PLAIN, 14)); - // display authors of GUI + add(label); - // display DL-Learner contributors - +// SimpleAttributeSet bold = new SimpleAttributeSet(); +// StyleConstants.setBold(bold, true); +// StyleConstants.setAlignment(bold, StyleConstants.ALIGN_CENTER); +// +// JTextPane textPane = new JTextPane(); +// StyledDocument doc = textPane.getStyledDocument(); +// +// +// textPane.setText("DL-Learner"); +// doc.setParagraphAttributes(0, doc.getLength(), bold, false); +// add(textPane); +// +// + + // Put the editor pane in a scroll pane. +// JTextPane textPane = createTextPane(); + JScrollPane editorScrollPane = new JScrollPane(label); + editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); +// editorScrollPane.setPreferredSize(new Dimension(250, 145)); +// editorScrollPane.setMinimumSize(new Dimension(10, 10)); + + add(editorScrollPane); + setVisible(true); } + + @SuppressWarnings("unused") + private JTextPane createTextPane() { + String[] initString = { " ", "DL-Learner ", "Build " + Info.build, + "DL-Learner GUI developers:", "Jens Lehmann\nTilo Hielscher\n" }; + + String[] initStyles = { "icon", "bold", "regular", "italic", "regular" }; + + JTextPane textPane = new JTextPane(); +// textPane.setSize(300, 200); + textPane.setEditable(false); + StyledDocument doc = textPane.getStyledDocument(); + addStylesToDocument(doc); + + try { + for (int i = 0; i < initString.length; i++) { + doc.insertString(doc.getLength(), initString[i] + "\n", doc.getStyle(initStyles[i])); + } + } catch (BadLocationException ble) { + System.err.println("Couldn't insert initial text into text pane."); + } + + return textPane; + } + + protected void addStylesToDocument(StyledDocument doc) { + Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); + + Style regular = doc.addStyle("regular", def); +// StyleConstants.setFontFamily(def, "SansSerif"); + + Style s = doc.addStyle("italic", regular); + StyleConstants.setItalic(s, true); + + s = doc.addStyle("bold", regular); + StyleConstants.setAlignment(s, StyleConstants.ALIGN_RIGHT); + StyleConstants.setBold(s, true); + + s = doc.addStyle("icon", regular); + StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER); + ImageIcon pigIcon = createImageIcon("dl-learner.gif", "DL-Learner logo"); + StyleConstants.setIcon(s, pigIcon); + } + + protected static ImageIcon createImageIcon(String path, String description) { + URL imgURL = AboutWindow.class.getResource(path); + if (imgURL != null) { + return new ImageIcon(imgURL, description); + } else { + System.err.println("Couldn't find file: " + path); + return null; + } + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-08 11:45:09 UTC (rev 1173) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-08 12:37:27 UTC (rev 1174) @@ -66,7 +66,7 @@ private JMenuItem exitItem = new JMenuItem("Exit"); private JMenu menuHelp = new JMenu("Help"); private JMenuItem aboutItem = new JMenuItem("About"); - private JMenuItem tutorialItem = new JMenuItem("Tutorial"); + private JMenuItem tutorialItem = new JMenuItem("Quick Tutorial"); public StartGUI() { this(null); @@ -153,6 +153,22 @@ if (args.length > 0) file = new File(args[args.length - 1]); + // force platform look and feel + try { + UIManager.setLookAndFeel( +// "com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + UIManager.getSystemLookAndFeelClassName()); + // TODO: currently everything is in bold on Linux (and Win?) + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (UnsupportedLookAndFeelException e) { + e.printStackTrace(); + } + new StartGUI(file); } Modified: trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java 2008-09-08 11:45:09 UTC (rev 1173) +++ trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java 2008-09-08 12:37:27 UTC (rev 1174) @@ -1,6 +1,26 @@ +/** + * Copyright (C) 2007-2008, 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.gui; import javax.swing.JFrame; +import javax.swing.JLabel; /** * Window displaying a tutorial for the DL-Learner GUI. @@ -14,11 +34,28 @@ public TutorialWindow() { setTitle("Quick Tutorial"); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setLocationByPlatform(true); setSize(300, 500); // display tutorial text + String text = "<html><h2>Quick Tutorial</h2><p align=\"justify\">DL-Learner has a component" + + " based design to make it easier to extend and use. There are four " + + "components corresponding to the tabs you see: knowledge source, " + + "reasoner, learning problem, and learning algorithm. There are various " + + "components available of each type (selectable at the top of each tab). " + + "Each component has configuration options associated with it (middle of the" + + " tab, scrollable), which you can use to specify the settings for the component.</p>" + + "<br /><p align=\"justify\">In order to create a learning problem, " + + "you have to choose and configure all four types of components." + + " The run tab plays a special role: It is used to start the learning algorithm" + + " and display statistical information.</p>" + + "<br /><p><i>Further references:</i><br />" + + "Homepage: <a href=\"http://dl-learner.org\">http://dl-learner.org</a><br />" + + "DL-Learner Architecture: <a href=\"http://dl-learner.org/wiki/Architecture\">http://dl-learner.org/wiki/Architecture</a>" + + "</p><br /><p>Please send questions to le...@in....</p></html>"; + JLabel label = new JLabel(text); + add(label); setVisible(true); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-08 11:45:13
|
Revision: 1173 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1173&view=rev Author: kurzum Date: 2008-09-08 11:45:09 +0000 (Mon, 08 Sep 2008) Log Message: ----------- intermediate commit Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/kb/OWLAPIOntology.java trunk/src/dl-learner/org/dllearner/kb/OWLFile.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/configurators/ 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/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/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/PosNegInclusionLPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.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/SparqlKnowledgeSourceConfigurator.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/core/configuration/ Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-08 09:24:41 UTC (rev 1172) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-08 11:45:09 UTC (rev 1173) @@ -44,7 +44,7 @@ import org.dllearner.core.config.IntegerConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringConfigOption; -import org.dllearner.core.configuration.ExampleBasedROLComponentConfigurator; +import org.dllearner.core.configurators.ExampleBasedROLComponentConfigurator; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; Added: trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java 2008-09-08 11:45:09 UTC (rev 1173) @@ -0,0 +1,88 @@ +/** + * Copyright (C) 2007-2008, 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.configurators; + +import org.dllearner.algorithms.BruteForceLearner; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasoningService; + +/** +* automatically generated, do not edit manually +**/ +public class BruteForceLearnerConfigurator { + +private boolean reinitNecessary = false; +private BruteForceLearner BruteForceLearner; + +public BruteForceLearnerConfigurator (BruteForceLearner BruteForceLearner){ +this.BruteForceLearner = BruteForceLearner; +} + +/** +**/ +public static BruteForceLearner getBruteForceLearner (LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException{ +BruteForceLearner component = ComponentManager.getInstance().learningAlgorithm(BruteForceLearner.class, learningProblem, reasoningService ); +return component; +} + +/** +* option name: maxLength +* maximum length of generated concepts +* default value: 7 +**/ +public int getMaxLength ( ) { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(BruteForceLearner, "maxLength") ; +} +/** +* option name: returnType +* Specifies the type which the solution has to belong to (if already) known. This means we inform the learning algorithm that the solution is a subclass of this type. +* default value: null +**/ +public String getReturnType ( ) { +return (String) ComponentManager.getInstance().getConfigOptionValue(BruteForceLearner, "returnType") ; +} + +/** +* option name: maxLength +* maximum length of generated concepts +* default value: 7 +**/ +public void setMaxLength ( int maxLength) { +ComponentManager.getInstance().applyConfigEntry(BruteForceLearner, "maxLength", maxLength); +reinitNecessary = true; +} +/** +* option name: returnType +* Specifies the type which the solution has to belong to (if already) known. This means we inform the learning algorithm that the solution is a subclass of this type. +* default value: null +**/ +public void setReturnType ( String returnType) { +ComponentManager.getInstance().applyConfigEntry(BruteForceLearner, "returnType", returnType); +reinitNecessary = true; +} + +public boolean isReinitNecessary(){ +return reinitNecessary; +} + + +} Added: trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2008-09-08 11:45:09 UTC (rev 1173) @@ -0,0 +1,172 @@ +/** + * Copyright (C) 2007-2008, 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.configurators; + +import java.util.Set; +import org.dllearner.algorithms.BruteForceLearner; +import org.dllearner.algorithms.DBpediaNavigationSuggestor; +import org.dllearner.algorithms.RandomGuesser; +import org.dllearner.algorithms.gp.GP; +import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; +import org.dllearner.algorithms.refinement.ROLearner; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.configurators.BruteForceLearnerConfigurator; +import org.dllearner.core.configurators.DBpediaNavigationSuggestorConfigurator; +import org.dllearner.core.configurators.DIGReasonerConfigurator; +import org.dllearner.core.configurators.ExampleBasedROLComponentConfigurator; +import org.dllearner.core.configurators.FastInstanceCheckerConfigurator; +import org.dllearner.core.configurators.FastRetrievalReasonerConfigurator; +import org.dllearner.core.configurators.GPConfigurator; +import org.dllearner.core.configurators.KBFileConfigurator; +import org.dllearner.core.configurators.OWLAPIReasonerConfigurator; +import org.dllearner.core.configurators.OWLFileConfigurator; +import org.dllearner.core.configurators.PosNegDefinitionLPConfigurator; +import org.dllearner.core.configurators.PosNegInclusionLPConfigurator; +import org.dllearner.core.configurators.PosOnlyDefinitionLPConfigurator; +import org.dllearner.core.configurators.ROLearnerConfigurator; +import org.dllearner.core.configurators.RandomGuesserConfigurator; +import org.dllearner.core.configurators.SparqlKnowledgeSourceConfigurator; +import org.dllearner.kb.KBFile; +import org.dllearner.kb.OWLFile; +import org.dllearner.kb.sparql.SparqlKnowledgeSource; +import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.learningproblems.PosNegInclusionLP; +import org.dllearner.learningproblems.PosOnlyDefinitionLP; +import org.dllearner.reasoning.DIGReasoner; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.reasoning.FastRetrievalReasoner; +import org.dllearner.reasoning.OWLAPIReasoner; + +/** +* automatically generated, do not edit manually +**/ +public class ComponentFactory { + +/** +* @param filename pointer to the KB file on local file system +**/ +public static KBFile getKBFile (String filename ) { +return KBFileConfigurator.getKBFile(filename); +} + +/** +* @param url URL pointing to the OWL file +**/ +public static OWLFile getOWLFile (String url ) { +return OWLFileConfigurator.getOWLFile(url); +} + +/** +* @param instances relevant instances e.g. positive and negative examples in a learning problem +**/ +public static SparqlKnowledgeSource getSparqlKnowledgeSource (Set<String> instances ) { +return SparqlKnowledgeSourceConfigurator.getSparqlKnowledgeSource(instances); +} + +/** +**/ +public static DIGReasoner getDIGReasoner (KnowledgeSource knowledgeSource ) { +return DIGReasonerConfigurator.getDIGReasoner(knowledgeSource); +} + +/** +**/ +public static FastInstanceChecker getFastInstanceChecker (KnowledgeSource knowledgeSource ) { +return FastInstanceCheckerConfigurator.getFastInstanceChecker(knowledgeSource); +} + +/** +**/ +public static FastRetrievalReasoner getFastRetrievalReasoner (KnowledgeSource knowledgeSource ) { +return FastRetrievalReasonerConfigurator.getFastRetrievalReasoner(knowledgeSource); +} + +/** +**/ +public static OWLAPIReasoner getOWLAPIReasoner (KnowledgeSource knowledgeSource ) { +return OWLAPIReasonerConfigurator.getOWLAPIReasoner(knowledgeSource); +} + +/** +* @param positiveExamples positive examples +* @param negativeExamples negative examples +**/ +public static PosNegDefinitionLP getPosNegDefinitionLP (ReasoningService reasoningService, Set<String> positiveExamples, Set<String> negativeExamples ) { +return PosNegDefinitionLPConfigurator.getPosNegDefinitionLP(reasoningService, positiveExamples, negativeExamples); +} + +/** +* @param positiveExamples positive examples +* @param negativeExamples negative examples +**/ +public static PosNegInclusionLP getPosNegInclusionLP (ReasoningService reasoningService, Set<String> positiveExamples, Set<String> negativeExamples ) { +return PosNegInclusionLPConfigurator.getPosNegInclusionLP(reasoningService, positiveExamples, negativeExamples); +} + +/** +* @param positiveExamples positive examples +**/ +public static PosOnlyDefinitionLP getPosOnlyDefinitionLP (ReasoningService reasoningService, Set<String> positiveExamples ) { +return PosOnlyDefinitionLPConfigurator.getPosOnlyDefinitionLP(reasoningService, positiveExamples); +} + +/** +**/ +public static BruteForceLearner getBruteForceLearner (LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException { +return BruteForceLearnerConfigurator.getBruteForceLearner(learningProblem, reasoningService); +} + +/** +**/ +public static DBpediaNavigationSuggestor getDBpediaNavigationSuggestor (LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException { +return DBpediaNavigationSuggestorConfigurator.getDBpediaNavigationSuggestor(learningProblem, reasoningService); +} + +/** +**/ +public static RandomGuesser getRandomGuesser (LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException { +return RandomGuesserConfigurator.getRandomGuesser(learningProblem, reasoningService); +} + +/** +**/ +public static GP getGP (LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException { +return GPConfigurator.getGP(learningProblem, reasoningService); +} + +/** +**/ +public static ExampleBasedROLComponent getExampleBasedROLComponent (LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException { +return ExampleBasedROLComponentConfigurator.getExampleBasedROLComponent(learningProblem, reasoningService); +} + +/** +**/ +public static ROLearner getROLearner (LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException { +return ROLearnerConfigurator.getROLearner(learningProblem, reasoningService); +} + + +} Added: trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configurators/DBpediaNavigationSuggestorConfigurator.java 2008-09-08 11:45:09 UTC (rev 1173) @@ -0,0 +1,501 @@ +/** + * Copyright (C) 2007-2008, 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.configurators; + +import java.util.Set; +import org.dllearner.algorithms.DBpediaNavigationSuggestor; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasoningService; + +/** +* automatically generated, do not edit manually +**/ +public class DBpediaNavigationSuggestorConfigurator { + +private boolean reinitNecessary = false; +private DBpediaNavigationSuggestor DBpediaNavigationSuggestor; + +public DBpediaNavigationSuggestorConfigurator (DBpediaNavigationSuggestor DBpediaNavigationSuggestor){ +this.DBpediaNavigationSuggestor = DBpediaNavigationSuggestor; +} + +/** +**/ +public static DBpediaNavigationSuggestor getDBpediaNavigationSuggestor (LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException{ +DBpediaNavigationSuggestor component = ComponentManager.getInstance().learningAlgorithm(DBpediaNavigationSuggestor.class, learningProblem, reasoningService ); +return component; +} + +/** +* option name: writeSearchTree +* specifies whether to write a search tree +* default value: false +**/ +public boolean getWriteSearchTree ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "writeSearchTree") ; +} +/** +* option name: searchTreeFile +* file to use for the search tree +* default value: log/searchTree.txt +**/ +public String getSearchTreeFile ( ) { +return (String) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "searchTreeFile") ; +} +/** +* option name: replaceSearchTree +* specifies whether to replace the search tree in the log file after each run or append the new search tree +* default value: false +**/ +public boolean getReplaceSearchTree ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "replaceSearchTree") ; +} +/** +* option name: heuristic +* specifiy the heuristic to use +* default value: lexicographic +**/ +public String getHeuristic ( ) { +return (String) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "heuristic") ; +} +/** +* option name: applyAllFilter +* usage of equivalence ALL R.C AND ALL R.D = ALL R.(C AND D) +* default value: true +**/ +public boolean getApplyAllFilter ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "applyAllFilter") ; +} +/** +* option name: applyExistsFilter +* usage of equivalence EXISTS R.C OR EXISTS R.D = EXISTS R.(C OR D) +* default value: true +**/ +public boolean getApplyExistsFilter ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "applyExistsFilter") ; +} +/** +* option name: useTooWeakList +* try to filter out too weak concepts without sending them to the reasoner +* default value: true +**/ +public boolean getUseTooWeakList ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "useTooWeakList") ; +} +/** +* option name: useOverlyGeneralList +* try to find overly general concept without sending them to the reasoner +* default value: true +**/ +public boolean getUseOverlyGeneralList ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "useOverlyGeneralList") ; +} +/** +* option name: useShortConceptConstruction +* shorten concept to see whether they already exist +* default value: true +**/ +public boolean getUseShortConceptConstruction ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "useShortConceptConstruction") ; +} +/** +* option name: horizontalExpansionFactor +* horizontal expansion factor (see publication for description) +* default value: 0.6 +**/ +public double getHorizontalExpansionFactor ( ) { +return (Double) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "horizontalExpansionFactor") ; +} +/** +* option name: improveSubsumptionHierarchy +* simplify subsumption hierarchy to reduce search space (see publication for description) +* default value: true +**/ +public boolean getImproveSubsumptionHierarchy ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "improveSubsumptionHierarchy") ; +} +/** +* option name: allowedConcepts +* concepts the algorithm is allowed to use +* default value: null +**/ +@SuppressWarnings("unchecked") +public Set<String> getAllowedConcepts ( ) { +return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "allowedConcepts") ; +} +/** +* option name: ignoredConcepts +* concepts the algorithm must ignore +* default value: null +**/ +@SuppressWarnings("unchecked") +public Set<String> getIgnoredConcepts ( ) { +return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "ignoredConcepts") ; +} +/** +* option name: allowedRoles +* roles the algorithm is allowed to use +* default value: null +**/ +@SuppressWarnings("unchecked") +public Set<String> getAllowedRoles ( ) { +return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "allowedRoles") ; +} +/** +* option name: ignoredRoles +* roles the algorithm must ignore +* default value: null +**/ +@SuppressWarnings("unchecked") +public Set<String> getIgnoredRoles ( ) { +return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "ignoredRoles") ; +} +/** +* option name: useAllConstructor +* specifies whether the universal concept constructor is used in the learning algorithm +* default value: true +**/ +public boolean getUseAllConstructor ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "useAllConstructor") ; +} +/** +* option name: useExistsConstructor +* specifies whether the existential concept constructor is used in the learning algorithm +* default value: true +**/ +public boolean getUseExistsConstructor ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "useExistsConstructor") ; +} +/** +* option name: useCardinalityRestrictions +* specifies whether CardinalityRestrictions is used in the learning algorithm +* default value: true +**/ +public boolean getUseCardinalityRestrictions ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "useCardinalityRestrictions") ; +} +/** +* option name: useNegation +* specifies whether negation is used in the learning algorothm +* default value: true +**/ +public boolean getUseNegation ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "useNegation") ; +} +/** +* option name: useBooleanDatatypes +* specifies whether boolean datatypes are used in the learning algorothm +* default value: true +**/ +public boolean getUseBooleanDatatypes ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "useBooleanDatatypes") ; +} +/** +* option name: maxExecutionTimeInSeconds +* algorithm will stop after specified seconds +* default value: 0 +**/ +public int getMaxExecutionTimeInSeconds ( ) { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "maxExecutionTimeInSeconds") ; +} +/** +* option name: minExecutionTimeInSeconds +* algorithm will run at least specified seconds +* default value: 0 +**/ +public int getMinExecutionTimeInSeconds ( ) { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "minExecutionTimeInSeconds") ; +} +/** +* option name: guaranteeXgoodDescriptions +* algorithm will run until X good (100%) concept descritpions are found +* default value: 1 +**/ +public int getGuaranteeXgoodDescriptions ( ) { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "guaranteeXgoodDescriptions") ; +} +/** +* option name: logLevel +* determines the logLevel for this component, can be {TRACE, DEBUG, INFO} +* default value: DEBUG +**/ +public String getLogLevel ( ) { +return (String) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "logLevel") ; +} +/** +* option name: noisePercentage +* the (approximated) percentage of noise within the examples +* default value: 0.0 +**/ +public double getNoisePercentage ( ) { +return (Double) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "noisePercentage") ; +} +/** +* option name: startClass +* the named class which should be used to start the algorithm (GUI: needs a widget for selecting a class) +* default value: null +**/ +public String getStartClass ( ) { +return (String) ComponentManager.getInstance().getConfigOptionValue(DBpediaNavigationSuggestor, "startClass") ; +} + +/** +* option name: writeSearchTree +* specifies whether to write a search tree +* default value: false +**/ +public void setWriteSearchTree ( boolean writeSearchTree) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "writeSearchTree", writeSearchTree); +reinitNecessary = true; +} +/** +* option name: searchTreeFile +* file to use for the search tree +* default value: log/searchTree.txt +**/ +public void setSearchTreeFile ( String searchTreeFile) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "searchTreeFile", searchTreeFile); +reinitNecessary = true; +} +/** +* option name: replaceSearchTree +* specifies whether to replace the search tree in the log file after each run or append the new search tree +* default value: false +**/ +public void setReplaceSearchTree ( boolean replaceSearchTree) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "replaceSearchTree", replaceSearchTree); +reinitNecessary = true; +} +/** +* option name: heuristic +* specifiy the heuristic to use +* default value: lexicographic +**/ +public void setHeuristic ( String heuristic) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "heuristic", heuristic); +reinitNecessary = true; +} +/** +* option name: applyAllFilter +* usage of equivalence ALL R.C AND ALL R.D = ALL R.(C AND D) +* default value: true +**/ +public void setApplyAllFilter ( boolean applyAllFilter) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "applyAllFilter", applyAllFilter); +reinitNecessary = true; +} +/** +* option name: applyExistsFilter +* usage of equivalence EXISTS R.C OR EXISTS R.D = EXISTS R.(C OR D) +* default value: true +**/ +public void setApplyExistsFilter ( boolean applyExistsFilter) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "applyExistsFilter", applyExistsFilter); +reinitNecessary = true; +} +/** +* option name: useTooWeakList +* try to filter out too weak concepts without sending them to the reasoner +* default value: true +**/ +public void setUseTooWeakList ( boolean useTooWeakList) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "useTooWeakList", useTooWeakList); +reinitNecessary = true; +} +/** +* option name: useOverlyGeneralList +* try to find overly general concept without sending them to the reasoner +* default value: true +**/ +public void setUseOverlyGeneralList ( boolean useOverlyGeneralList) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "useOverlyGeneralList", useOverlyGeneralList); +reinitNecessary = true; +} +/** +* option name: useShortConceptConstruction +* shorten concept to see whether they already exist +* default value: true +**/ +public void setUseShortConceptConstruction ( boolean useShortConceptConstruction) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "useShortConceptConstruction", useShortConceptConstruction); +reinitNecessary = true; +} +/** +* option name: horizontalExpansionFactor +* horizontal expansion factor (see publication for description) +* default value: 0.6 +**/ +public void setHorizontalExpansionFactor ( double horizontalExpansionFactor) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "horizontalExpansionFactor", horizontalExpansionFactor); +reinitNecessary = true; +} +/** +* option name: improveSubsumptionHierarchy +* simplify subsumption hierarchy to reduce search space (see publication for description) +* default value: true +**/ +public void setImproveSubsumptionHierarchy ( boolean improveSubsumptionHierarchy) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "improveSubsumptionHierarchy", improveSubsumptionHierarchy); +reinitNecessary = true; +} +/** +* option name: allowedConcepts +* concepts the algorithm is allowed to use +* default value: null +**/ +public void setAllowedConcepts ( Set<String> allowedConcepts) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "allowedConcepts", allowedConcepts); +reinitNecessary = true; +} +/** +* option name: ignoredConcepts +* concepts the algorithm must ignore +* default value: null +**/ +public void setIgnoredConcepts ( Set<String> ignoredConcepts) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "ignoredConcepts", ignoredConcepts); +reinitNecessary = true; +} +/** +* option name: allowedRoles +* roles the algorithm is allowed to use +* default value: null +**/ +public void setAllowedRoles ( Set<String> allowedRoles) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "allowedRoles", allowedRoles); +reinitNecessary = true; +} +/** +* option name: ignoredRoles +* roles the algorithm must ignore +* default value: null +**/ +public void setIgnoredRoles ( Set<String> ignoredRoles) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "ignoredRoles", ignoredRoles); +reinitNecessary = true; +} +/** +* option name: useAllConstructor +* specifies whether the universal concept constructor is used in the learning algorithm +* default value: true +**/ +public void setUseAllConstructor ( boolean useAllConstructor) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "useAllConstructor", useAllConstructor); +reinitNecessary = true; +} +/** +* option name: useExistsConstructor +* specifies whether the existential concept constructor is used in the learning algorithm +* default value: true +**/ +public void setUseExistsConstructor ( boolean useExistsConstructor) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "useExistsConstructor", useExistsConstructor); +reinitNecessary = true; +} +/** +* option name: useCardinalityRestrictions +* specifies whether CardinalityRestrictions is used in the learning algorithm +* default value: true +**/ +public void setUseCardinalityRestrictions ( boolean useCardinalityRestrictions) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "useCardinalityRestrictions", useCardinalityRestrictions); +reinitNecessary = true; +} +/** +* option name: useNegation +* specifies whether negation is used in the learning algorothm +* default value: true +**/ +public void setUseNegation ( boolean useNegation) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "useNegation", useNegation); +reinitNecessary = true; +} +/** +* option name: useBooleanDatatypes +* specifies whether boolean datatypes are used in the learning algorothm +* default value: true +**/ +public void setUseBooleanDatatypes ( boolean useBooleanDatatypes) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "useBooleanDatatypes", useBooleanDatatypes); +reinitNecessary = true; +} +/** +* option name: maxExecutionTimeInSeconds +* algorithm will stop after specified seconds +* default value: 0 +**/ +public void setMaxExecutionTimeInSeconds ( int maxExecutionTimeInSeconds) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "maxExecutionTimeInSeconds", maxExecutionTimeInSeconds); +reinitNecessary = true; +} +/** +* option name: minExecutionTimeInSeconds +* algorithm will run at least specified seconds +* default value: 0 +**/ +public void setMinExecutionTimeInSeconds ( int minExecutionTimeInSeconds) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "minExecutionTimeInSeconds", minExecutionTimeInSeconds); +reinitNecessary = true; +} +/** +* option name: guaranteeXgoodDescriptions +* algorithm will run until X good (100%) concept descritpions are found +* default value: 1 +**/ +public void setGuaranteeXgoodDescriptions ( int guaranteeXgoodDescriptions) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "guaranteeXgoodDescriptions", guaranteeXgoodDescriptions); +reinitNecessary = true; +} +/** +* option name: logLevel +* determines the logLevel for this component, can be {TRACE, DEBUG, INFO} +* default value: DEBUG +**/ +public void setLogLevel ( String logLevel) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "logLevel", logLevel); +reinitNecessary = true; +} +/** +* option name: noisePercentage +* the (approximated) percentage of noise within the examples +* default value: 0.0 +**/ +public void setNoisePercentage ( double noisePercentage) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "noisePercentage", noisePercentage); +reinitNecessary = true; +} +/** +* option name: startClass +* the named class which should be used to start the algorithm (GUI: needs a widget for selecting a class) +* default value: null +**/ +public void setStartClass ( String startClass) { +ComponentManager.getInstance().applyConfigEntry(DBpediaNavigationSuggestor, "startClass", startClass); +reinitNecessary = true; +} + +public boolean isReinitNecessary(){ +return reinitNecessary; +} + + +} Added: trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java 2008-09-08 11:45:09 UTC (rev 1173) @@ -0,0 +1,103 @@ +/** + * Copyright (C) 2007-2008, 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.configurators; + +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.reasoning.DIGReasoner; + +/** +* automatically generated, do not edit manually +**/ +public class DIGReasonerConfigurator { + +private boolean reinitNecessary = false; +private DIGReasoner DIGReasoner; + +public DIGReasonerConfigurator (DIGReasoner DIGReasoner){ +this.DIGReasoner = DIGReasoner; +} + +/** +**/ +public static DIGReasoner getDIGReasoner (KnowledgeSource knowledgeSource ) { +DIGReasoner component = ComponentManager.getInstance().reasoner(DIGReasoner.class, knowledgeSource ); +return component; +} + +/** +* option name: reasonerUrl +* URL of the DIG reasoner +* default value: null +**/ +public String getReasonerUrl ( ) { +return (String) ComponentManager.getInstance().getConfigOptionValue(DIGReasoner, "reasonerUrl") ; +} +/** +* option name: writeDIGProtocol +* specifies whether or not to write a protocoll of send and received DIG requests +* default value: false +**/ +public boolean getWriteDIGProtocol ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(DIGReasoner, "writeDIGProtocol") ; +} +/** +* option name: digProtocolFile +* the file to store the DIG protocol +* default value: log/digProtocol.txt +**/ +public String getDigProtocolFile ( ) { +return (String) ComponentManager.getInstance().getConfigOptionValue(DIGReasoner, "digProtocolFile") ; +} + +/** +* option name: reasonerUrl +* URL of the DIG reasoner +* default value: null +**/ +public void setReasonerUrl ( String reasonerUrl) { +ComponentManager.getInstance().applyConfigEntry(DIGReasoner, "reasonerUrl", reasonerUrl); +reinitNecessary = true; +} +/** +* option name: writeDIGProtocol +* specifies whether or not to write a protocoll of send and received DIG requests +* default value: false +**/ +public void setWriteDIGProtocol ( boolean writeDIGProtocol) { +ComponentManager.getInstance().applyConfigEntry(DIGReasoner, "writeDIGProtocol", writeDIGProtocol); +reinitNecessary = true; +} +/** +* option name: digProtocolFile +* the file to store the DIG protocol +* default value: log/digProtocol.txt +**/ +public void setDigProtocolFile ( String digProtocolFile) { +ComponentManager.getInstance().applyConfigEntry(DIGReasoner, "digProtocolFile", digProtocolFile); +reinitNecessary = true; +} + +public boolean isReinitNecessary(){ +return reinitNecessary; +} + + +} Added: trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2008-09-08 11:45:09 UTC (rev 1173) @@ -0,0 +1,552 @@ +/** + * Copyright (C) 2007-2008, 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.configurators; + +import java.util.Set; +import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasoningService; + +/** +* automatically generated, do not edit manually +**/ +public class ExampleBasedROLComponentConfigurator { + +private boolean reinitNecessary = false; +private ExampleBasedROLComponent ExampleBasedROLComponent; + +public ExampleBasedROLComponentConfigurator (ExampleBasedROLComponent ExampleBasedROLComponent){ +this.ExampleBasedROLComponent = ExampleBasedROLComponent; +} + +/** +**/ +public static ExampleBasedROLComponent getExampleBasedROLComponent (LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException{ +ExampleBasedROLComponent component = ComponentManager.getInstance().learningAlgorithm(ExampleBasedROLComponent.class, learningProblem, reasoningService ); +return component; +} + +/** +* option name: writeSearchTree +* specifies whether to write a search tree +* default value: false +**/ +public boolean getWriteSearchTree ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "writeSearchTree") ; +} +/** +* option name: searchTreeFile +* file to use for the search tree +* default value: log/searchTree.txt +**/ +public String getSearchTreeFile ( ) { +return (String) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "searchTreeFile") ; +} +/** +* option name: replaceSearchTree +* specifies whether to replace the search tree in the log file after each run or append the new search tree +* default value: false +**/ +public boolean getReplaceSearchTree ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "replaceSearchTree") ; +} +/** +* option name: heuristic +* specifiy the heuristic to use +* default value: lexicographic +**/ +public String getHeuristic ( ) { +return (String) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "heuristic") ; +} +/** +* option name: applyAllFilter +* usage of equivalence ALL R.C AND ALL R.D = ALL R.(C AND D) +* default value: true +**/ +public boolean getApplyAllFilter ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "applyAllFilter") ; +} +/** +* option name: applyExistsFilter +* usage of equivalence EXISTS R.C OR EXISTS R.D = EXISTS R.(C OR D) +* default value: true +**/ +public boolean getApplyExistsFilter ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "applyExistsFilter") ; +} +/** +* option name: useTooWeakList +* try to filter out too weak concepts without sending them to the reasoner +* default value: true +**/ +public boolean getUseTooWeakList ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "useTooWeakList") ; +} +/** +* option name: useOverlyGeneralList +* try to find overly general concept without sending them to the reasoner +* default value: true +**/ +public boolean getUseOverlyGeneralList ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "useOverlyGeneralList") ; +} +/** +* option name: useShortConceptConstruction +* shorten concept to see whether they already exist +* default value: true +**/ +public boolean getUseShortConceptConstruction ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "useShortConceptConstruction") ; +} +/** +* option name: horizontalExpansionFactor +* horizontal expansion factor (see publication for description) +* default value: 0.6 +**/ +public double getHorizontalExpansionFactor ( ) { +return (Double) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "horizontalExpansionFactor") ; +} +/** +* option name: improveSubsumptionHierarchy +* simplify subsumption hierarchy to reduce search space (see publication for description) +* default value: true +**/ +public boolean getImproveSubsumptionHierarchy ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "improveSubsumptionHierarchy") ; +} +/** +* option name: allowedConcepts +* concepts the algorithm is allowed to use +* default value: null +**/ +@SuppressWarnings("unchecked") +public Set<String> getAllowedConcepts ( ) { +return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "allowedConcepts") ; +} +/** +* option name: ignoredConcepts +* concepts the algorithm must ignore +* default value: null +**/ +@SuppressWarnings("unchecked") +public Set<String> getIgnoredConcepts ( ) { +return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "ignoredConcepts") ; +} +/** +* option name: allowedRoles +* roles the algorithm is allowed to use +* default value: null +**/ +@SuppressWarnings("unchecked") +public Set<String> getAllowedRoles ( ) { +return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "allowedRoles") ; +} +/** +* option name: ignoredRoles +* roles the algorithm must ignore +* default value: null +**/ +@SuppressWarnings("unchecked") +public Set<String> getIgnoredRoles ( ) { +return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "ignoredRoles") ; +} +/** +* option name: useAllConstructor +* specifies whether the universal concept constructor is used in the learning algorithm +* default value: true +**/ +public boolean getUseAllConstructor ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "useAllConstructor") ; +} +/** +* option name: useExistsConstructor +* specifies whether the existential concept constructor is used in the learning algorithm +* default value: true +**/ +public boolean getUseExistsConstructor ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "useExistsConstructor") ; +} +/** +* option name: useCardinalityRestrictions +* specifies whether CardinalityRestrictions is used in the learning algorithm +* default value: true +**/ +public boolean getUseCardinalityRestrictions ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "useCardinalityRestrictions") ; +} +/** +* option name: useNegation +* specifies whether negation is used in the learning algorothm +* default value: true +**/ +public boolean getUseNegation ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "useNegation") ; +} +/** +* option name: useBooleanDatatypes +* specifies whether boolean datatypes are used in the learning algorothm +* default value: true +**/ +public boolean getUseBooleanDatatypes ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "useBooleanDatatypes") ; +} +/** +* option name: useDoubleDatatypes +* specifies whether boolean datatypes are used in the learning algorothm +* default value: true +**/ +public boolean getUseDoubleDatatypes ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "useDoubleDatatypes") ; +} +/** +* option name: maxExecutionTimeInSeconds +* algorithm will stop after specified seconds +* default value: 0 +**/ +public int getMaxExecutionTimeInSeconds ( ) { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "maxExecutionTimeInSeconds") ; +} +/** +* option name: minExecutionTimeInSeconds +* algorithm will run at least specified seconds +* default value: 0 +**/ +public int getMinExecutionTimeInSeconds ( ) { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "minExecutionTimeInSeconds") ; +} +/** +* option name: guaranteeXgoodDescriptions +* algorithm will run until X good (100%) concept descritpions are found +* default value: 1 +**/ +public int getGuaranteeXgoodDescriptions ( ) { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "guaranteeXgoodDescriptions") ; +} +/** +* option name: logLevel +* determines the logLevel for this component, can be {TRACE, DEBUG, INFO} +* default value: DEBUG +**/ +public String getLogLevel ( ) { +return (String) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "logLevel") ; +} +/** +* option name: usePropernessChecks +* specifies whether to check for equivalence (i.e. discard equivalent refinements) +* default value: false +**/ +public boolean getUsePropernessChecks ( ) { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "usePropernessChecks") ; +} +/** +* option name: maxPosOnlyExpansion +* specifies how often a node in the search tree of a posonly learning problem needs to be expanded before it is considered as solution candidate +* default value: 4 +**/ +public int getMaxPosOnlyExpansion ( ) { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "maxPosOnlyExpansion") ; +} +/** +* option name: noisePercentage +* the (approximated) percentage of noise within the examples +* default value: 0.0 +**/ +public double getNoisePercentage ( ) { +return (Double) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "noisePercentage") ; +} +/** +* option name: startClass +* the named class which should be used to start the algorithm (GUI: needs a widget for selecting a class) +* default value: null +**/ +public String getStartClass ( ) { +return (String) ComponentManager.getInstance().getConfigOptionValue(ExampleBasedROLComponent, "startClass") ; +} + +/** +* option name: writeSearchTree +* specifies whether to write a search tree +* default value: false +**/ +public void setWriteSearchTree ( boolean writeSearchTree) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "writeSearchTree", writeSearchTree); +reinitNecessary = true; +} +/** +* option name: searchTreeFile +* file to use for the search tree +* default value: log/searchTree.txt +**/ +public void setSearchTreeFile ( String searchTreeFile) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "searchTreeFile", searchTreeFile); +reinitNecessary = true; +} +/** +* option name: replaceSearchTree +* specifies whether to replace the search tree in the log file after each run or append the new search tree +* default value: false +**/ +public void setReplaceSearchTree ( boolean replaceSearchTree) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "replaceSearchTree", replaceSearchTree); +reinitNecessary = true; +} +/** +* option name: heuristic +* specifiy the heuristic to use +* default value: lexicographic +**/ +public void setHeuristic ( String heuristic) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "heuristic", heuristic); +reinitNecessary = true; +} +/** +* option name: applyAllFilter +* usage of equivalence ALL R.C AND ALL R.D = ALL R.(C AND D) +* default value: true +**/ +public void setApplyAllFilter ( boolean applyAllFilter) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "applyAllFilter", applyAllFilter); +reinitNecessary = true; +} +/** +* option name: applyExistsFilter +* usage of equivalence EXISTS R.C OR EXISTS R.D = EXISTS R.(C OR D) +* default value: true +**/ +public void setApplyExistsFilter ( boolean applyExistsFilter) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "applyExistsFilter", applyExistsFilter); +reinitNecessary = true; +} +/** +* option name: useTooWeakList +* try to filter out too weak concepts without sending them to the reasoner +* default value: true +**/ +public void setUseTooWeakList ( boolean useTooWeakList) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "useTooWeakList", useTooWeakList); +reinitNecessary = true; +} +/** +* option name: useOverlyGeneralList +* try to find overly general concept without sending them to the reasoner +* default value: true +**/ +public void setUseOverlyGeneralList ( boolean useOverlyGeneralList) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "useOverlyGeneralList", useOverlyGeneralList); +reinitNecessary = true; +} +/** +* option name: useShortConceptConstruction +* shorten concept to see whether they already exist +* default value: true +**/ +public void setUseShortConceptConstruction ( boolean useShortConceptConstruction) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "useShortConceptConstruction", useShortConceptConstruction); +reinitNecessary = true; +} +/** +* option name: horizontalExpansionFactor +* horizontal expansion factor (see publication for description) +* default value: 0.6 +**/ +public void setHorizontalExpansionFactor ( double horizontalExpansionFactor) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "horizontalExpansionFactor", horizontalExpansionFactor); +reinitNecessary = true; +} +/** +* option name: improveSubsumptionHierarchy +* simplify subsumption hierarchy to reduce search space (see publication for description) +* default value: true +**/ +public void setImproveSubsumptionHierarchy ( boolean improveSubsumptionHierarchy) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "improveSubsumptionHierarchy", improveSubsumptionHierarchy); +reinitNecessary = true; +} +/** +* option name: allowedConcepts +* concepts the algorithm is allowed to use +* default value: null +**/ +public void setAllowedConcepts ( Set<String> allowedConcepts) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "allowedConcepts", allowedConcepts); +reinitNecessary = true; +} +/** +* option name: ignoredConcepts +* concepts the algorithm must ignore +* default value: null +**/ +public void setIgnoredConcepts ( Set<String> ignoredConcepts) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "ignoredConcepts", ignoredConcepts); +reinitNecessary = true; +} +/** +* option name: allowedRoles +* roles the algorithm is allowed to use +* default value: null +**/ +public void setAllowedRoles ( Set<String> allowedRoles) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "allowedRoles", allowedRoles); +reinitNecessary = true; +} +/** +* option name: ignoredRoles +* roles the algorithm must ignore +* default value: null +**/ +public void setIgnoredRoles ( Set<String> ignoredRoles) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "ignoredRoles", ignoredRoles); +reinitNecessary = true; +} +/** +* option name: useAllConstructor +* specifies whether the universal concept constructor is used in the learning algorithm +* default value: true +**/ +public void setUseAllConstructor ( boolean useAllConstructor) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "useAllConstructor", useAllConstructor); +reinitNecessary = true; +} +/** +* option name: useExistsConstructor +* specifies whether the existential concept constructor is used in the learning algorithm +* default value: true +**/ +public void setUseExistsConstructor ( boolean useExistsConstructor) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "useExistsConstructor", useExistsConstructor); +reinitNecessary = true; +} +/** +* option name: useCardinalityRestrictions +* specifies whether CardinalityRestrictions is used in the learning algorithm +* default value: true +**/ +public void setUseCardinalityRestrictions ( boolean useCardinalityRestrictions) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "useCardinalityRestrictions", useCardinalityRestrictions); +reinitNecessary = true; +} +/** +* option name: useNegation +* specifies whether negation is used in the learning algorothm +* default value: true +**/ +public void setUseNegation ( boolean useNegation) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "useNegation", useNegation); +reinitNecessary = true; +} +/** +* option name: useBooleanDatatypes +* specifies whether boolean datatypes are used in the learning algorothm +* default value: true +**/ +public void setUseBooleanDatatypes ( boolean useBooleanDatatypes) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "useBooleanDatatypes", useBooleanDatatypes); +reinitNecessary = true; +} +/** +* option name: useDoubleDatatypes +* specifies whether boolean datatypes are used in the learning algorothm +* default value: true +**/ +public void setUseDoubleDatatypes ( boolean useDoubleDatatypes) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "useDoubleDatatypes", useDoubleDatatypes); +reinitNecessary = true; +} +/** +* option name: maxExecutionTimeInSeconds +* algorithm will stop after specified seconds +* default value: 0 +**/ +public void setMaxExecutionTimeInSeconds ( int maxExecutionTimeInSeconds) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "maxExecutionTimeInSeconds", maxExecutionTimeInSeconds); +reinitNecessary = true; +} +/** +* option name: minExecutionTimeInSeconds +* algorithm will run at least specified seconds +* default value: 0 +**/ +public void setMinExecutionTimeInSeconds ( int minExecutionTimeInSeconds) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "minExecutionTimeInSeconds", minExecutionTimeInSeconds); +reinitNecessary = true; +} +/** +* option name: guaranteeXgoodDescriptions +* algorithm will run until X good (100%) concept descritpions are found +* default value: 1 +**/ +public void setGuaranteeXgoodDescriptions ( int guaranteeXgoodDescriptions) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "guaranteeXgoodDescriptions", guaranteeXgoodDescriptions); +reinitNecessary = true; +} +/** +* option name: logLevel +* determines the logLevel for this component, can be {TRACE, DEBUG, INFO} +* default value: DEBUG +**/ +public void setLogLevel ( String logLevel) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "logLevel", logLevel); +reinitNecessary = true; +} +/** +* option name: usePropernessChecks +* specifies whether to check for equivalence (i.e. discard equivalent refinements) +* default value: false +**/ +public void setUsePropernessChecks ( boolean usePropernessChecks) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "usePropernessChecks", usePropernessChecks); +reinitNecessary = true; +} +/** +* option name: maxPosOnlyExpansion +* specifies how often a node in the search tree of a posonly learning problem needs to be expanded before it is considered as solution candidate +* default value: 4 +**/ +public void setMaxPosOnlyExpansion ( int maxPosOnlyExpansion) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "maxPosOnlyExpansion", maxPosOnlyExpansion); +reinitNecessary = true; +} +/** +* option name: noisePercentage +* the (approximated) percentage of noise within the examples +* default value: 0.0 +**/ +public void setNoisePercentage ( double noisePercentage) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "noisePercentage", noisePercentage); +reinitNecessary = true; +} +/** +* option name: startClass +* the named class which should be used to start the algorithm (GUI: needs a widget for selecting a class) +* default value: null +**/ +public void setStartClass ( String startClass) { +ComponentManager.getInstance().applyConfigEntry(ExampleBasedROLComponent, "startClass", startClass); +reinitNecessary = true; +} + +public boolean isReinitNecessary(){ +return reinitNecessary; +} + + +} Added: trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2008-09-08 11:45:09 UTC (rev 1173) @@ -0,0 +1,69 @@ +/** + * Copyright (C) 2007-2008, 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.configurators; + +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.reasoning.FastInstanceChecker; + +/** +* automatically generated, do not edit manually +**/ +public class FastInstanceCheckerConfigurator { + +private boolean reinitNecessary = false; +private FastInstanceChecker FastInstanceChecker; + +public FastInstanceCheckerConfigurator (FastInstanceChecker FastInstanceChecker){ +this.FastInstanceChecker = FastInstanceChecker; +} + +/** +**/ +public static FastInstanceChecker getFastInstanceChecker (KnowledgeSource knowledgeSource ) { +FastInstance... [truncated message content] |
From: <jen...@us...> - 2008-09-08 09:24:46
|
Revision: 1172 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1172&view=rev Author: jenslehmann Date: 2008-09-08 09:24:41 +0000 (Mon, 08 Sep 2008) Log Message: ----------- Some changes and documentation for component config options. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/kb/OWLFile.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyLP.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -36,7 +36,6 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.IntegerConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; -import org.dllearner.core.config.ConfigOption.Tags; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; @@ -92,7 +91,7 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); - options.add(new IntegerConfigOption("maxLength", "maximum length of generated concepts", 7, Tags.NORMAL)); + options.add(new IntegerConfigOption("maxLength", "maximum length of generated concepts", 7)); options.add(CommonConfigOptions.getReturnType()); return options; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -36,7 +36,6 @@ import org.dllearner.core.config.DoubleConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringConfigOption; -import org.dllearner.core.config.ConfigOption.Tags; import org.dllearner.core.owl.Description; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegLP; @@ -120,7 +119,7 @@ options.add(CommonConfigOptions.guaranteeXgoodDescriptions()); options.add(CommonConfigOptions.getLogLevel()); //TODO make a commonconfig Option out of this - DoubleConfigOption noisePercentage = new DoubleConfigOption("noisePercentage", "the (approximated) percentage of noise within the examples",0.0,Tags.NORMAL); + DoubleConfigOption noisePercentage = new DoubleConfigOption("noisePercentage", "the (approximated) percentage of noise within the examples",0.0); noisePercentage.setLowerLimit(0); noisePercentage.setUpperLimit(100); options.add(noisePercentage); Modified: trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -34,7 +34,6 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.IntegerConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; -import org.dllearner.core.config.ConfigOption.Tags; import org.dllearner.core.owl.Description; public class RandomGuesser extends LearningAlgorithm { @@ -66,8 +65,8 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); - options.add(new IntegerConfigOption("numberOfTrees", "number of randomly generated concepts/trees", 5, Tags.NORMAL)); - options.add(new IntegerConfigOption("maxDepth", "maximum depth of generated concepts/trees", 5, Tags.NORMAL)); + options.add(new IntegerConfigOption("numberOfTrees", "number of randomly generated concepts/trees", 5)); + options.add(new IntegerConfigOption("maxDepth", "maximum depth of generated concepts/trees", 5)); return options; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -44,7 +44,6 @@ import org.dllearner.core.config.IntegerConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringConfigOption; -import org.dllearner.core.config.ConfigOption.Tags; import org.dllearner.core.configuration.ExampleBasedROLComponentConfigurator; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.NamedClass; @@ -204,10 +203,10 @@ options.add(CommonConfigOptions.minExecutionTimeInSeconds()); options.add(CommonConfigOptions.guaranteeXgoodDescriptions()); options.add(CommonConfigOptions.getLogLevel()); - options.add(new BooleanConfigOption("usePropernessChecks", "specifies whether to check for equivalence (i.e. discard equivalent refinements)",usePropernessChecksDefault,Tags.NORMAL)); + options.add(new BooleanConfigOption("usePropernessChecks", "specifies whether to check for equivalence (i.e. discard equivalent refinements)",usePropernessChecksDefault)); options.add(new IntegerConfigOption("maxPosOnlyExpansion", "specifies how often a node in the search tree of a posonly learning problem needs to be expanded before it is" + - " considered as solution candidate",maxPosOnlyExpansionDefault,Tags.NORMAL)); - DoubleConfigOption noisePercentage = new DoubleConfigOption("noisePercentage", "the (approximated) percentage of noise within the examples",noisePercentageDefault,Tags.NORMAL); + " considered as solution candidate",maxPosOnlyExpansionDefault)); + DoubleConfigOption noisePercentage = new DoubleConfigOption("noisePercentage", "the (approximated) percentage of noise within the examples",noisePercentageDefault); noisePercentage.setLowerLimit(0); noisePercentage.setUpperLimit(100); options.add(noisePercentage); Modified: trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -26,13 +26,6 @@ */ public class BooleanConfigOption extends ConfigOption<Boolean> { - - - public BooleanConfigOption(String name, String description, Boolean defaultValue, Tags... tags) { - super(name, description, defaultValue, tags); - - } - public BooleanConfigOption(String name, String description, Boolean defaultValue) { super(name, description, defaultValue); Modified: trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -19,7 +19,6 @@ */ package org.dllearner.core.config; -import org.dllearner.core.config.ConfigOption.Tags; /** @@ -59,7 +58,7 @@ } public static DoubleConfigOption getPercentPerLenghtUnitOption(double defaultValue) { - DoubleConfigOption option = new DoubleConfigOption("percentPerLenghtUnit", "describes the reduction in classification accuracy in percent one is willing to accept for reducing the length of the concept by one", defaultValue, Tags.NORMAL); + DoubleConfigOption option = new DoubleConfigOption("percentPerLenghtUnit", "describes the reduction in classification accuracy in percent one is willing to accept for reducing the length of the concept by one", defaultValue); option.setLowerLimit(0.0); option.setUpperLimit(1.0); return option; Modified: trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -1,5 +1,5 @@ /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -29,57 +29,79 @@ * Note: Currently, handling the type of a configuration option is not * straightforward to implement, because Java Generics information is erased at * runtime. This will be fixed in Java 7, in particular JSR 308, which is due at - * approx. the end of 2008. + * approx. the beginning of 2009. * + * @param <T> The type of the config option, e.g. Integer, String etc. * @author Jens Lehmann * */ public abstract class ConfigOption<T> { + /** + * Name of this option. + */ protected String name; + /** + * A short description explaining the effect of this option. + */ protected String description; + /** + * The default value of this option. + */ protected T defaultValue; - public enum Tags {NORMAL, MANDATORY, REINIT} + /** + * Specifies whether this option is mandatory for a component, + * e.g. if a value other than the default value needs to be given. + */ + protected boolean mandatory = false; - protected boolean mandatory = false; - protected boolean reinitNecessary = false; + /** + * Specifies whether a change of the value of the option requires + * running the init method of the component again. For some options + * (e.g. url of an OWL file component) a new run of init is needed, + * while others can be changed without the need to re-init the + * component. + */ + protected boolean requiresInit = false; + /** + * Calls this(name, description, null, false, true). + * @param name Name of config option. + * @param description Explanation of option. + */ public ConfigOption(String name, String description) { - this(name, description, null); + this(name, description, null, false, true); } - public ConfigOption(String name, String description, T defaultValue, Tags ...tags ) { + /** + * Calls this(name, description, defaultValue, false, true). + * @param name Name of config option. + * @param description Explanation of option. + * @param defaultValue Standard value of option. + */ + public ConfigOption(String name, String description, T defaultValue) { + this(name, description, defaultValue, false, true); + } + + /** + * Constructs a component configuration option. + * @param name Name of config option. + * @param description Explanation of option. + * @param defaultValue Standard value of option. + * @param mandatory Specifies whether assigning a value to the option is required. + * @param requiresInit Says whether init() has to be called again when the option is changed. + */ + public ConfigOption(String name, String description, T defaultValue, boolean mandatory, boolean requiresInit) { this.name = name; this.description = description; this.defaultValue = defaultValue; - boolean normal = false; - for(Tags t:tags){ - if (t.equals(Tags.NORMAL)){ - normal =true; - } - } - for(Tags t:tags){ - if(normal){ - ;//DO Nothing - } - else if (t.equals(Tags.MANDATORY)){ - this.mandatory = true; - } else if (t.equals(Tags.REINIT)){ - this.reinitNecessary = true; - } - } - + this.mandatory = mandatory; + this.requiresInit = requiresInit; } - public ConfigOption(String name, String description, T defaultValue ) { - this.name = name; - this.description = description; - this.defaultValue = defaultValue; - } - public String getName() { return name; } @@ -114,8 +136,8 @@ * says, if this option requires that the componnent is reinitialized with init() * @return */ - public boolean isReinitNecessary() { - return reinitNecessary; + public boolean requiresInit() { + return requiresInit; } /** @@ -146,7 +168,27 @@ return getClass().toString(); } + /** + * @param defaultValue the defaultValue to set + */ + public void setDefaultValue(T defaultValue) { + this.defaultValue = defaultValue; + } + + /** + * @param mandatory the mandatory to set + */ + public void setMandatory(boolean mandatory) { + this.mandatory = mandatory; + } + /** + * @param requiresInit the requiresInit to set + */ + public void setRequiresInit(boolean requiresInit) { + this.requiresInit = requiresInit; + } + @Override public String toString() { return "option name: " + name + "\ndescription: " + description + "\nvalues: " Modified: trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -32,14 +32,6 @@ private double lowerLimit = Double.MIN_VALUE; private double upperLimit = Double.MAX_VALUE; - - - - public DoubleConfigOption(String name, String description, Double defaultValue, Tags... tags) { - super(name, description, defaultValue, tags); - - } - public DoubleConfigOption(String name, String description, Double defaultValue) { super(name, description, defaultValue); Modified: trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -32,13 +32,6 @@ private int lowerLimit = Integer.MIN_VALUE; private int upperLimit = Integer.MAX_VALUE; - - - public IntegerConfigOption(String name, String description, Integer defaultValue, Tags... tags) { - super(name, description, defaultValue, tags); - - } - public IntegerConfigOption(String name, String description, Integer defaultValue) { super(name, description, defaultValue); Modified: trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -34,23 +34,18 @@ private Set<String> allowedValues = new TreeSet<String>(); - - - - - public StringConfigOption(String name, String description, String defaultValue, Tags... tags) { - super(name, description, defaultValue, tags); + public StringConfigOption(String name, String description) { + super(name, description); - } - + } + public StringConfigOption(String name, String description, String defaultValue) { super(name, description, defaultValue); } - public StringConfigOption(String name, String description) { - super(name, description); - + public StringConfigOption(String name, String description, String defaultValue, boolean mandatory, boolean requiresInit) { + super(name, description, defaultValue, mandatory, requiresInit); } /* (non-Javadoc) Modified: trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -1,5 +1,5 @@ /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -31,22 +31,19 @@ */ public class StringSetConfigOption extends ConfigOption<Set<String>> { - - - public StringSetConfigOption(String name, String description, Set<String> defaultValue, Tags... tags) { - super(name, description, defaultValue, tags); + public StringSetConfigOption(String name, String description) { + super(name, description); - } - + } + public StringSetConfigOption(String name, String description, Set<String> defaultValue) { super(name, description, defaultValue); } - public StringSetConfigOption(String name, String description) { - super(name, description); - - } + public StringSetConfigOption(String name, String description, Set<String> 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/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -33,7 +33,6 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringConfigOption; -import org.dllearner.core.config.ConfigOption.Tags; import org.dllearner.core.configuration.KBFileConfigurator; import org.dllearner.core.owl.KB; import org.dllearner.parser.KBParser; @@ -93,8 +92,8 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); - options.add(new StringConfigOption("filename", "pointer to the KB file on local file system",null, Tags.MANDATORY, Tags.REINIT)); - options.add(new StringConfigOption("url", "URL pointer to the KB file",null, Tags.REINIT)); + options.add(new StringConfigOption("filename", "pointer to the KB file on local file system",null, true, true)); + options.add(new StringConfigOption("url", "URL pointer to the KB file",null, false, true)); return options; } Modified: trunk/src/dl-learner/org/dllearner/kb/OWLFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -33,7 +33,6 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringConfigOption; -import org.dllearner.core.config.ConfigOption.Tags; import org.dllearner.core.configuration.OWLFileConfigurator; import org.dllearner.core.owl.KB; import org.dllearner.reasoning.OWLAPIDIGConverter; @@ -61,7 +60,7 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); - options.add(new StringConfigOption("url", "URL pointing to the OWL file", null, Tags.MANDATORY )); + options.add(new StringConfigOption("url", "URL pointing to the OWL file", null, true, false)); return options; } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -45,7 +45,6 @@ import org.dllearner.core.config.StringConfigOption; import org.dllearner.core.config.StringSetConfigOption; import org.dllearner.core.config.StringTupleListConfigOption; -import org.dllearner.core.config.ConfigOption.Tags; import org.dllearner.core.configuration.SparqlKnowledgeSourceConfigurator; import org.dllearner.core.owl.KB; import org.dllearner.kb.aquisitors.SparqlTupleAquisitor; @@ -164,9 +163,9 @@ // Endpoint")); options .add(new StringSetConfigOption("instances", - "relevant instances e.g. positive and negative examples in a learning problem",null,Tags.MANDATORY)); + "relevant instances e.g. positive and negative examples in a learning problem",null,true,false)); options.add(new IntegerConfigOption("recursionDepth", - "recursion depth of KB fragment selection", 1, Tags.NORMAL)); + "recursion depth of KB fragment selection", 1)); options.add(new StringConfigOption("predefinedFilter", "the mode of the SPARQL Filter, use one of YAGO,SKOS,YAGOSKOS , YAGOSPECIALHIERARCHY, TEST")); options.add(new StringConfigOption("predefinedEndpoint", @@ -192,17 +191,17 @@ "Specifies whether the extracted NTriples are converted to RDF and deleted.", true)); options.add(new BooleanConfigOption("useLits", - "use Literals in SPARQL query", true, Tags.NORMAL)); + "use Literals in SPARQL query", true)); options .add(new BooleanConfigOption( "getAllSuperClasses", "If true then all superclasses are retrieved until the most general class (owl:Thing) is reached.", - true, Tags.NORMAL)); + true)); //options.add(new BooleanConfigOption("learnDomain", // "learns the Domain for a Role")); options.add(new BooleanConfigOption("useCache", - "If true a Cache is used",true, Tags.NORMAL)); + "If true a Cache is used",true)); //options.add(new BooleanConfigOption("learnRange", // "learns the Range for a Role")); //options.add(new StringConfigOption("role", Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -34,7 +34,6 @@ import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringConfigOption; import org.dllearner.core.config.StringSetConfigOption; -import org.dllearner.core.config.ConfigOption.Tags; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.utilities.Helper; @@ -86,13 +85,13 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); options.add(new StringSetConfigOption("positiveExamples", - "positive examples",null, Tags.MANDATORY)); + "positive examples",null, true, false)); options.add(new StringSetConfigOption("negativeExamples", - "negative examples",null, Tags.MANDATORY)); + "negative examples",null, true, false)); options.add(new BooleanConfigOption("useRetrievalForClassficiation", - "Specifies whether to use retrieval or instance checks for testing a concept.", false, Tags.NORMAL)); + "Specifies whether to use retrieval or instance checks for testing a concept.", false)); options.add(CommonConfigOptions.getPercentPerLenghtUnitOption(0.05)); - StringConfigOption multiInstanceChecks = new StringConfigOption("useMultiInstanceChecks", "See UseMultiInstanceChecks enum.","twoChecks",Tags.NORMAL); + StringConfigOption multiInstanceChecks = new StringConfigOption("useMultiInstanceChecks", "See UseMultiInstanceChecks enum.","twoChecks"); multiInstanceChecks.setAllowedValues(new String[] {"never", "twoChecks", "oneCheck"}); options.add(multiInstanceChecks); return options; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyLP.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyLP.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -31,7 +31,6 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringSetConfigOption; -import org.dllearner.core.config.ConfigOption.Tags; import org.dllearner.core.owl.Individual; /** @@ -66,7 +65,7 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); options.add(new StringSetConfigOption("positiveExamples", - "positive examples", null, Tags.MANDATORY)); + "positive examples", null, true, false)); return options; } Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -44,7 +44,6 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringConfigOption; -import org.dllearner.core.config.ConfigOption.Tags; import org.dllearner.core.configuration.OWLAPIReasonerConfigurator; import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.Datatype; @@ -152,7 +151,7 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); - StringConfigOption type = new StringConfigOption("reasonerType", "FaCT++ or Pellet, which means \"pellet\" or \"fact\"", "pellet", Tags.NORMAL); + StringConfigOption type = new StringConfigOption("reasonerType", "FaCT++ or Pellet, which means \"pellet\" or \"fact\"", "pellet"); 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 Modified: trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -195,7 +195,7 @@ imports.addAll(option.getJavaImports()); vars.add(fillVariableDefTemplate(optionName, type, defaultValue)); - setters.add(fillSetterTemplate(className, comment, optionName, type, option.isReinitNecessary())); + setters.add(fillSetterTemplate(className, comment, optionName, type, option.requiresInit())); getters.add(fillGetterTemplate(comment, optionName, type)); // System.out.println(option); // componentOptions.get(component)) { Modified: trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java 2008-09-05 14:53:16 UTC (rev 1171) +++ trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java 2008-09-08 09:24:41 UTC (rev 1172) @@ -82,6 +82,7 @@ ignore.add("./examples/sparql/SKOSTEST_local.conf"); // Out of Memory Error ignore.add("./examples/sparql/scrobble.conf"); // HTTP 502 Proxy Error ignore.add("./examples/family-benchmark/Cousin.conf"); // Out of Memory Error + ignore.add("./examples/sparql/SilentBobWorking2.conf"); // Out of Memory Error for (String path : confFiles.keySet()) { for (String file : confFiles.get(path)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-05 14:53:23
|
Revision: 1171 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1171&view=rev Author: kurzum Date: 2008-09-05 14:53:16 +0000 (Fri, 05 Sep 2008) Log Message: ----------- finished java interface for some components Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java trunk/src/dl-learner/org/dllearner/core/configuration/Configurator.java trunk/src/dl-learner/org/dllearner/core/configuration/FastInstanceCheckerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/OWLFileConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/SparqlKnowledgeSourceConfigurator.java trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyLP.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java trunk/src/dl-learner/org/dllearner/scripts/NewSample.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnOWLFile.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/configuration/BruteForceLearnerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/DBpediaNavigationSuggestorConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/DIGReasonerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/ExampleBasedROLComponentConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/FastRetrievalReasonerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/GPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/KBFileConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/OWLAPIReasonerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/PosNegDefinitionLPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/PosNegInclusionLPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/PosOnlyDefinitionLPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/ROLearnerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/RandomGuesserConfigurator.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-09-05 12:24:05 UTC (rev 1170) +++ trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-09-05 14:53:16 UTC (rev 1171) @@ -36,16 +36,17 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.IntegerConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.config.ConfigOption.Tags; +import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Intersection; -import org.dllearner.core.owl.Union; -import org.dllearner.core.owl.ObjectAllRestriction; import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Negation; import org.dllearner.core.owl.Nothing; -import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.ObjectAllRestriction; +import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectSomeRestriction; -import org.dllearner.core.owl.Negation; -import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.Thing; +import org.dllearner.core.owl.Union; /** * A brute force learning algorithm. @@ -64,6 +65,7 @@ private Description bestDefinition; private Score bestScore; + //changing this wont have any effect any more private Integer maxLength = 7; private String returnType; @@ -90,7 +92,7 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); - options.add(new IntegerConfigOption("maxLength", "maximum length of generated concepts")); + options.add(new IntegerConfigOption("maxLength", "maximum length of generated concepts", 7, Tags.NORMAL)); options.add(CommonConfigOptions.getReturnType()); return options; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-09-05 12:24:05 UTC (rev 1170) +++ trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-09-05 14:53:16 UTC (rev 1171) @@ -36,6 +36,7 @@ import org.dllearner.core.config.DoubleConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringConfigOption; +import org.dllearner.core.config.ConfigOption.Tags; import org.dllearner.core.owl.Description; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegLP; @@ -118,7 +119,8 @@ options.add(CommonConfigOptions.minExecutionTimeInSeconds()); options.add(CommonConfigOptions.guaranteeXgoodDescriptions()); options.add(CommonConfigOptions.getLogLevel()); - DoubleConfigOption noisePercentage = new DoubleConfigOption("noisePercentage", "the (approximated) percentage of noise within the examples"); + //TODO make a commonconfig Option out of this + DoubleConfigOption noisePercentage = new DoubleConfigOption("noisePercentage", "the (approximated) percentage of noise within the examples",0.0,Tags.NORMAL); noisePercentage.setLowerLimit(0); noisePercentage.setUpperLimit(100); options.add(noisePercentage); Modified: trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-09-05 12:24:05 UTC (rev 1170) +++ trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-09-05 14:53:16 UTC (rev 1171) @@ -23,8 +23,8 @@ import java.util.LinkedList; import org.apache.log4j.Logger; +import org.dllearner.algorithms.gp.GPUtilities; import org.dllearner.algorithms.gp.Program; -import org.dllearner.algorithms.gp.GPUtilities; import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; @@ -34,6 +34,7 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.IntegerConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.config.ConfigOption.Tags; import org.dllearner.core.owl.Description; public class RandomGuesser extends LearningAlgorithm { @@ -65,8 +66,8 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); - options.add(new IntegerConfigOption("numberOfTrees", "number of randomly generated concepts/trees")); - options.add(new IntegerConfigOption("maxDepth", "maximum depth of generated concepts/trees")); + options.add(new IntegerConfigOption("numberOfTrees", "number of randomly generated concepts/trees", 5, Tags.NORMAL)); + options.add(new IntegerConfigOption("maxDepth", "maximum depth of generated concepts/trees", 5, Tags.NORMAL)); return options; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-05 12:24:05 UTC (rev 1170) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-05 14:53:16 UTC (rev 1171) @@ -44,16 +44,18 @@ import org.dllearner.core.config.IntegerConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringConfigOption; +import org.dllearner.core.config.ConfigOption.Tags; +import org.dllearner.core.configuration.ExampleBasedROLComponentConfigurator; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; import org.dllearner.learningproblems.PosOnlyLP; +import org.dllearner.reasoning.ReasonerType; import org.dllearner.refinementoperators.RhoDRDown; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; -import org.dllearner.reasoning.ReasonerType; /** * The DL-Learner learning algorithm component for the example @@ -91,6 +93,13 @@ private ReasoningService rs; private LearningProblem learningProblem; + private ExampleBasedROLComponentConfigurator configurator; + public ExampleBasedROLComponentConfigurator getConfigurator(){ + return configurator; + } + + + // configuration options private boolean writeSearchTree; private File searchTreeFile; @@ -116,10 +125,15 @@ private boolean useNegation = CommonConfigOptions.useNegationDefault; private boolean useBooleanDatatypes = CommonConfigOptions.useBooleanDatatypesDefault; private boolean useDoubleDatatypes = CommonConfigOptions.useDoubleDatatypesDefault; - private double noisePercentage = 0.0; + private static double noisePercentageDefault = 0.0; + private double noisePercentage = noisePercentageDefault; private NamedClass startClass = null; - private boolean usePropernessChecks = false; - private int maxPosOnlyExpansion = 4; + //refactor this + private static boolean usePropernessChecksDefault = false; + private boolean usePropernessChecks = usePropernessChecksDefault; + // refactor this + private static int maxPosOnlyExpansionDefault = 4; + private int maxPosOnlyExpansion = maxPosOnlyExpansionDefault; //extended Options //in seconds private int maxExecutionTimeInSeconds = CommonConfigOptions.maxExecutionTimeInSecondsDefault; @@ -141,11 +155,13 @@ public ExampleBasedROLComponent(PosNegLP learningProblem, ReasoningService rs) { this.learningProblem = learningProblem; this.rs = rs; + this.configurator = new ExampleBasedROLComponentConfigurator(this); } public ExampleBasedROLComponent(PosOnlyDefinitionLP learningProblem, ReasoningService rs) { this.learningProblem = learningProblem; this.rs = rs; + this.configurator = new ExampleBasedROLComponentConfigurator(this); } public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() { @@ -188,10 +204,10 @@ options.add(CommonConfigOptions.minExecutionTimeInSeconds()); options.add(CommonConfigOptions.guaranteeXgoodDescriptions()); options.add(CommonConfigOptions.getLogLevel()); - options.add(new BooleanConfigOption("usePropernessChecks", "specifies whether to check for equivalence (i.e. discard equivalent refinements)")); + options.add(new BooleanConfigOption("usePropernessChecks", "specifies whether to check for equivalence (i.e. discard equivalent refinements)",usePropernessChecksDefault,Tags.NORMAL)); options.add(new IntegerConfigOption("maxPosOnlyExpansion", "specifies how often a node in the search tree of a posonly learning problem needs to be expanded before it is" + - " considered as solution candidate")); - DoubleConfigOption noisePercentage = new DoubleConfigOption("noisePercentage", "the (approximated) percentage of noise within the examples"); + " considered as solution candidate",maxPosOnlyExpansionDefault,Tags.NORMAL)); + DoubleConfigOption noisePercentage = new DoubleConfigOption("noisePercentage", "the (approximated) percentage of noise within the examples",noisePercentageDefault,Tags.NORMAL); noisePercentage.setLowerLimit(0); noisePercentage.setUpperLimit(100); options.add(noisePercentage); Modified: trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2008-09-05 12:24:05 UTC (rev 1170) +++ trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2008-09-05 14:53:16 UTC (rev 1171) @@ -19,7 +19,9 @@ */ package org.dllearner.core.config; +import org.dllearner.core.config.ConfigOption.Tags; + /** * Contains methods for creating common configuration options, i.e. options * which are or may be of use for several components. @@ -57,7 +59,7 @@ } public static DoubleConfigOption getPercentPerLenghtUnitOption(double defaultValue) { - DoubleConfigOption option = new DoubleConfigOption("percentPerLenghtUnit", "describes the reduction in classification accuracy in percent one is willing to accept for reducing the length of the concept by one", defaultValue); + DoubleConfigOption option = new DoubleConfigOption("percentPerLenghtUnit", "describes the reduction in classification accuracy in percent one is willing to accept for reducing the length of the concept by one", defaultValue, Tags.NORMAL); option.setLowerLimit(0.0); option.setUpperLimit(1.0); return option; @@ -112,7 +114,7 @@ } public static BooleanConfigOption useDoubleDatatypes() { - return new BooleanConfigOption("useBooleanDatatypes", "specifies whether boolean datatypes are used in the learning algorothm",useDoubleDatatypesDefault); + return new BooleanConfigOption("useDoubleDatatypes", "specifies whether boolean datatypes are used in the learning algorothm",useDoubleDatatypesDefault); } public static IntegerConfigOption maxExecutionTimeInSeconds() { Modified: trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-09-05 12:24:05 UTC (rev 1170) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-09-05 14:53:16 UTC (rev 1171) @@ -152,6 +152,14 @@ return "option name: " + name + "\ndescription: " + description + "\nvalues: " + getAllowedValuesDescription() + "\ndefault value: " + defaultValue + "\n"; } + + public String getJavaDocString() { + String line = "* option name: " + name + "\n"; + line += "* " + description + "\n"; + //line += "* allowed values: "+ getAllowedValuesDescription() + "\n"; + line += "* default value: " + defaultValue + "\n"; + return line; + } /** * Get a formatted value to put into configuration file. Modified: trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java 2008-09-05 12:24:05 UTC (rev 1170) +++ trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java 2008-09-05 14:53:16 UTC (rev 1171) @@ -19,7 +19,6 @@ */ package org.dllearner.core.config; -import org.dllearner.core.config.ConfigOption.Tags; /** * Represents a configuration option with values of type value. Similar to the Modified: trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java 2008-09-05 12:24:05 UTC (rev 1170) +++ trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java 2008-09-05 14:53:16 UTC (rev 1171) @@ -19,7 +19,6 @@ */ package org.dllearner.core.config; -import org.dllearner.core.config.ConfigOption.Tags; /** * A configuration option, which allows values of type integer. A minimum and Modified: trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java 2008-09-05 12:24:05 UTC (rev 1170) +++ trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java 2008-09-05 14:53:16 UTC (rev 1171) @@ -23,8 +23,6 @@ import java.util.Set; import java.util.TreeSet; -import org.dllearner.core.config.ConfigOption.Tags; - /** * A configuration option, which allows values of type String. Optionally a set * of allowed strings can be set. By default all strings are allowed. Added: trunk/src/dl-learner/org/dllearner/core/configuration/BruteForceLearnerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configuration/BruteForceLearnerConfigurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configuration/BruteForceLearnerConfigurator.java 2008-09-05 14:53:16 UTC (rev 1171) @@ -0,0 +1,102 @@ +/** + * Copyright (C) 2007-2008, 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.configuration; + +import org.dllearner.algorithms.BruteForceLearner; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.configuration.Configurator; + +/** +* automatically generated, do not edit manually +**/ +@SuppressWarnings("unused") +public class BruteForceLearnerConfigurator extends Configurator { + +private boolean reinitNecessary = false; +private BruteForceLearner BruteForceLearner; +private int maxLength = 7; +private String returnType = null; + +public BruteForceLearnerConfigurator (BruteForceLearner BruteForceLearner){ +this.BruteForceLearner = BruteForceLearner; +} + +/** +**/ +public static BruteForceLearner getBruteForceLearner (ComponentManager cm, LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException{ +BruteForceLearner component = cm.learningAlgorithm(BruteForceLearner.class, learningProblem, reasoningService ); +return component; +} + +@SuppressWarnings({ "unchecked" }) +public <T> void applyConfigEntry(ConfigEntry<T> entry){ +String optionName = entry.getOptionName(); +if(false){//empty block +}else if (optionName.equals("maxLength")){ +maxLength = (Integer) entry.getValue(); +}else if (optionName.equals("returnType")){ +returnType = (String) entry.getValue(); +} +} + +/** +* option name: maxLength +* maximum length of generated concepts +* default value: 7 +**/ +public int getMaxLength ( ) { +return this.maxLength; +} +/** +* option name: returnType +* Specifies the type which the solution has to belong to (if already) known. This means we inform the learning algorithm that the solution is a subclass of this type. +* default value: null +**/ +public String getReturnType ( ) { +return this.returnType; +} + +/** +* option name: maxLength +* maximum length of generated concepts +* default value: 7 +**/ +public void setMaxLength ( ComponentManager cm, int maxLength) { +cm.applyConfigEntry(BruteForceLearner, "maxLength", maxLength); +} +/** +* option name: returnType +* Specifies the type which the solution has to belong to (if already) known. This means we inform the learning algorithm that the solution is a subclass of this type. +* default value: null +**/ +public void setReturnType ( ComponentManager cm, String returnType) { +cm.applyConfigEntry(BruteForceLearner, "returnType", returnType); +} + +public boolean isReinitNecessary(){ +return reinitNecessary; +} + + +} Modified: trunk/src/dl-learner/org/dllearner/core/configuration/Configurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configuration/Configurator.java 2008-09-05 12:24:05 UTC (rev 1170) +++ trunk/src/dl-learner/org/dllearner/core/configuration/Configurator.java 2008-09-05 14:53:16 UTC (rev 1171) @@ -18,44 +18,156 @@ **/ package org.dllearner.core.configuration; + import java.util.Set; +import org.dllearner.algorithms.BruteForceLearner; +import org.dllearner.algorithms.DBpediaNavigationSuggestor; +import org.dllearner.algorithms.RandomGuesser; +import org.dllearner.algorithms.gp.GP; +import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; +import org.dllearner.algorithms.refinement.ROLearner; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; -import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasoningService; +import org.dllearner.core.configuration.BruteForceLearnerConfigurator; +import org.dllearner.core.configuration.DBpediaNavigationSuggestorConfigurator; +import org.dllearner.core.configuration.DIGReasonerConfigurator; +import org.dllearner.core.configuration.ExampleBasedROLComponentConfigurator; import org.dllearner.core.configuration.FastInstanceCheckerConfigurator; +import org.dllearner.core.configuration.FastRetrievalReasonerConfigurator; +import org.dllearner.core.configuration.GPConfigurator; +import org.dllearner.core.configuration.KBFileConfigurator; +import org.dllearner.core.configuration.OWLAPIReasonerConfigurator; import org.dllearner.core.configuration.OWLFileConfigurator; +import org.dllearner.core.configuration.PosNegDefinitionLPConfigurator; +import org.dllearner.core.configuration.PosNegInclusionLPConfigurator; +import org.dllearner.core.configuration.PosOnlyDefinitionLPConfigurator; +import org.dllearner.core.configuration.ROLearnerConfigurator; +import org.dllearner.core.configuration.RandomGuesserConfigurator; import org.dllearner.core.configuration.SparqlKnowledgeSourceConfigurator; +import org.dllearner.kb.KBFile; import org.dllearner.kb.OWLFile; import org.dllearner.kb.sparql.SparqlKnowledgeSource; +import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.learningproblems.PosNegInclusionLP; +import org.dllearner.learningproblems.PosOnlyDefinitionLP; +import org.dllearner.reasoning.DIGReasoner; import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.reasoning.FastRetrievalReasoner; +import org.dllearner.reasoning.OWLAPIReasoner; /** * automatically generated, do not edit manually **/ +@SuppressWarnings("unused") public class Configurator { /** -* url: URL pointing to the OWL file +* @param filename pointer to the KB file on local file system **/ -public static OWLFile getOWLFile (ComponentManager cm, String url ) { +public static KBFile getKBFile (ComponentManager cm, String filename ) { +return KBFileConfigurator.getKBFile(cm, filename); +} + +/** +* @param url URL pointing to the OWL file +**/ +public static OWLFile getOWLFile (ComponentManager cm, String url ) { return OWLFileConfigurator.getOWLFile(cm, url); } /** -* instances: relevant instances e.g. positive and negative examples in a learning problem +* @param instances relevant instances e.g. positive and negative examples in a learning problem **/ -public static SparqlKnowledgeSource getSparqlKnowledgeSource (ComponentManager cm, Set<String> instances ) { +public static SparqlKnowledgeSource getSparqlKnowledgeSource (ComponentManager cm, Set<String> instances ) { return SparqlKnowledgeSourceConfigurator.getSparqlKnowledgeSource(cm, instances); } /** **/ -public static FastInstanceChecker getFastInstanceChecker (ComponentManager cm, KnowledgeSource knowledgeSource ) { +public static DIGReasoner getDIGReasoner (ComponentManager cm, KnowledgeSource knowledgeSource ) { +return DIGReasonerConfigurator.getDIGReasoner(cm, knowledgeSource); +} + +/** +**/ +public static FastInstanceChecker getFastInstanceChecker (ComponentManager cm, KnowledgeSource knowledgeSource ) { return FastInstanceCheckerConfigurator.getFastInstanceChecker(cm, knowledgeSource); } +/** +**/ +public static FastRetrievalReasoner getFastRetrievalReasoner (ComponentManager cm, KnowledgeSource knowledgeSource ) { +return FastRetrievalReasonerConfigurator.getFastRetrievalReasoner(cm, knowledgeSource); +} +/** +**/ +public static OWLAPIReasoner getOWLAPIReasoner (ComponentManager cm, KnowledgeSource knowledgeSource ) { +return OWLAPIReasonerConfigurator.getOWLAPIReasoner(cm, knowledgeSource); } + +/** +* @param positiveExamples positive examples +* @param negativeExamples negative examples +**/ +public static PosNegDefinitionLP getPosNegDefinitionLP (ComponentManager cm, ReasoningService reasoningService, Set<String> positiveExamples, Set<String> negativeExamples ) { +return PosNegDefinitionLPConfigurator.getPosNegDefinitionLP(cm, reasoningService, positiveExamples, negativeExamples); +} + +/** +* @param positiveExamples positive examples +* @param negativeExamples negative examples +**/ +public static PosNegInclusionLP getPosNegInclusionLP (ComponentManager cm, ReasoningService reasoningService, Set<String> positiveExamples, Set<String> negativeExamples ) { +return PosNegInclusionLPConfigurator.getPosNegInclusionLP(cm, reasoningService, positiveExamples, negativeExamples); +} + +/** +* @param positiveExamples positive examples +**/ +public static PosOnlyDefinitionLP getPosOnlyDefinitionLP (ComponentManager cm, ReasoningService reasoningService, Set<String> positiveExamples ) { +return PosOnlyDefinitionLPConfigurator.getPosOnlyDefinitionLP(cm, reasoningService, positiveExamples); +} + +/** +**/ +public static BruteForceLearner getBruteForceLearner (ComponentManager cm, LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException { +return BruteForceLearnerConfigurator.getBruteForceLearner(cm, learningProblem, reasoningService); +} + +/** +**/ +public static DBpediaNavigationSuggestor getDBpediaNavigationSuggestor (ComponentManager cm, LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException { +return DBpediaNavigationSuggestorConfigurator.getDBpediaNavigationSuggestor(cm, learningProblem, reasoningService); +} + +/** +**/ +public static RandomGuesser getRandomGuesser (ComponentManager cm, LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException { +return RandomGuesserConfigurator.getRandomGuesser(cm, learningProblem, reasoningService); +} + +/** +**/ +public static GP getGP (ComponentManager cm, LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException { +return GPConfigurator.getGP(cm, learningProblem, reasoningService); +} + +/** +**/ +public static ExampleBasedROLComponent getExampleBasedROLComponent (ComponentManager cm, LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException { +return ExampleBasedROLComponentConfigurator.getExampleBasedROLComponent(cm, learningProblem, reasoningService); +} + +/** +**/ +public static ROLearner getROLearner (ComponentManager cm, LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException { +return ROLearnerConfigurator.getROLearner(cm, learningProblem, reasoningService); +} + + +} Added: trunk/src/dl-learner/org/dllearner/core/configuration/DBpediaNavigationSuggestorConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configuration/DBpediaNavigationSuggestorConfigurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configuration/DBpediaNavigationSuggestorConfigurator.java 2008-09-05 14:53:16 UTC (rev 1171) @@ -0,0 +1,559 @@ +/** + * Copyright (C) 2007-2008, 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.configuration; + +import java.util.Set; +import org.dllearner.algorithms.DBpediaNavigationSuggestor; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.configuration.Configurator; + +/** +* automatically generated, do not edit manually +**/ +@SuppressWarnings("unused") +public class DBpediaNavigationSuggestorConfigurator extends Configurator { + +private boolean reinitNecessary = false; +private DBpediaNavigationSuggestor DBpediaNavigationSuggestor; +private boolean writeSearchTree = false; +private String searchTreeFile = "log/searchTree.txt"; +private boolean replaceSearchTree = false; +private String heuristic = "lexicographic"; +private boolean applyAllFilter = true; +private boolean applyExistsFilter = true; +private boolean useTooWeakList = true; +private boolean useOverlyGeneralList = true; +private boolean useShortConceptConstruction = true; +private double horizontalExpansionFactor = 0.6; +private boolean improveSubsumptionHierarchy = true; +private Set<String> allowedConcepts = null; +private Set<String> ignoredConcepts = null; +private Set<String> allowedRoles = null; +private Set<String> ignoredRoles = null; +private boolean useAllConstructor = true; +private boolean useExistsConstructor = true; +private boolean useCardinalityRestrictions = true; +private boolean useNegation = true; +private boolean useBooleanDatatypes = true; +private int maxExecutionTimeInSeconds = 0; +private int minExecutionTimeInSeconds = 0; +private int guaranteeXgoodDescriptions = 1; +private String logLevel = "DEBUG"; +private double noisePercentage = 0.0; +private String startClass = null; + +public DBpediaNavigationSuggestorConfigurator (DBpediaNavigationSuggestor DBpediaNavigationSuggestor){ +this.DBpediaNavigationSuggestor = DBpediaNavigationSuggestor; +} + +/** +**/ +public static DBpediaNavigationSuggestor getDBpediaNavigationSuggestor (ComponentManager cm, LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException{ +DBpediaNavigationSuggestor component = cm.learningAlgorithm(DBpediaNavigationSuggestor.class, learningProblem, reasoningService ); +return component; +} + +@SuppressWarnings({ "unchecked" }) +public <T> void applyConfigEntry(ConfigEntry<T> entry){ +String optionName = entry.getOptionName(); +if(false){//empty block +}else if (optionName.equals("writeSearchTree")){ +writeSearchTree = (Boolean) entry.getValue(); +}else if (optionName.equals("searchTreeFile")){ +searchTreeFile = (String) entry.getValue(); +}else if (optionName.equals("replaceSearchTree")){ +replaceSearchTree = (Boolean) entry.getValue(); +}else if (optionName.equals("heuristic")){ +heuristic = (String) entry.getValue(); +}else if (optionName.equals("applyAllFilter")){ +applyAllFilter = (Boolean) entry.getValue(); +}else if (optionName.equals("applyExistsFilter")){ +applyExistsFilter = (Boolean) entry.getValue(); +}else if (optionName.equals("useTooWeakList")){ +useTooWeakList = (Boolean) entry.getValue(); +}else if (optionName.equals("useOverlyGeneralList")){ +useOverlyGeneralList = (Boolean) entry.getValue(); +}else if (optionName.equals("useShortConceptConstruction")){ +useShortConceptConstruction = (Boolean) entry.getValue(); +}else if (optionName.equals("horizontalExpansionFactor")){ +horizontalExpansionFactor = (Double) entry.getValue(); +}else if (optionName.equals("improveSubsumptionHierarchy")){ +improveSubsumptionHierarchy = (Boolean) entry.getValue(); +}else if (optionName.equals("allowedConcepts")){ +allowedConcepts = (Set<String>) entry.getValue(); +}else if (optionName.equals("ignoredConcepts")){ +ignoredConcepts = (Set<String>) entry.getValue(); +}else if (optionName.equals("allowedRoles")){ +allowedRoles = (Set<String>) entry.getValue(); +}else if (optionName.equals("ignoredRoles")){ +ignoredRoles = (Set<String>) entry.getValue(); +}else if (optionName.equals("useAllConstructor")){ +useAllConstructor = (Boolean) entry.getValue(); +}else if (optionName.equals("useExistsConstructor")){ +useExistsConstructor = (Boolean) entry.getValue(); +}else if (optionName.equals("useCardinalityRestrictions")){ +useCardinalityRestrictions = (Boolean) entry.getValue(); +}else if (optionName.equals("useNegation")){ +useNegation = (Boolean) entry.getValue(); +}else if (optionName.equals("useBooleanDatatypes")){ +useBooleanDatatypes = (Boolean) entry.getValue(); +}else if (optionName.equals("maxExecutionTimeInSeconds")){ +maxExecutionTimeInSeconds = (Integer) entry.getValue(); +}else if (optionName.equals("minExecutionTimeInSeconds")){ +minExecutionTimeInSeconds = (Integer) entry.getValue(); +}else if (optionName.equals("guaranteeXgoodDescriptions")){ +guaranteeXgoodDescriptions = (Integer) entry.getValue(); +}else if (optionName.equals("logLevel")){ +logLevel = (String) entry.getValue(); +}else if (optionName.equals("noisePercentage")){ +noisePercentage = (Double) entry.getValue(); +}else if (optionName.equals("startClass")){ +startClass = (String) entry.getValue(); +} +} + +/** +* option name: writeSearchTree +* specifies whether to write a search tree +* default value: false +**/ +public boolean getWriteSearchTree ( ) { +return this.writeSearchTree; +} +/** +* option name: searchTreeFile +* file to use for the search tree +* default value: log/searchTree.txt +**/ +public String getSearchTreeFile ( ) { +return this.searchTreeFile; +} +/** +* option name: replaceSearchTree +* specifies whether to replace the search tree in the log file after each run or append the new search tree +* default value: false +**/ +public boolean getReplaceSearchTree ( ) { +return this.replaceSearchTree; +} +/** +* option name: heuristic +* specifiy the heuristic to use +* default value: lexicographic +**/ +public String getHeuristic ( ) { +return this.heuristic; +} +/** +* option name: applyAllFilter +* usage of equivalence ALL R.C AND ALL R.D = ALL R.(C AND D) +* default value: true +**/ +public boolean getApplyAllFilter ( ) { +return this.applyAllFilter; +} +/** +* option name: applyExistsFilter +* usage of equivalence EXISTS R.C OR EXISTS R.D = EXISTS R.(C OR D) +* default value: true +**/ +public boolean getApplyExistsFilter ( ) { +return this.applyExistsFilter; +} +/** +* option name: useTooWeakList +* try to filter out too weak concepts without sending them to the reasoner +* default value: true +**/ +public boolean getUseTooWeakList ( ) { +return this.useTooWeakList; +} +/** +* option name: useOverlyGeneralList +* try to find overly general concept without sending them to the reasoner +* default value: true +**/ +public boolean getUseOverlyGeneralList ( ) { +return this.useOverlyGeneralList; +} +/** +* option name: useShortConceptConstruction +* shorten concept to see whether they already exist +* default value: true +**/ +public boolean getUseShortConceptConstruction ( ) { +return this.useShortConceptConstruction; +} +/** +* option name: horizontalExpansionFactor +* horizontal expansion factor (see publication for description) +* default value: 0.6 +**/ +public double getHorizontalExpansionFactor ( ) { +return this.horizontalExpansionFactor; +} +/** +* option name: improveSubsumptionHierarchy +* simplify subsumption hierarchy to reduce search space (see publication for description) +* default value: true +**/ +public boolean getImproveSubsumptionHierarchy ( ) { +return this.improveSubsumptionHierarchy; +} +/** +* option name: allowedConcepts +* concepts the algorithm is allowed to use +* default value: null +**/ +public Set<String> getAllowedConcepts ( ) { +return this.allowedConcepts; +} +/** +* option name: ignoredConcepts +* concepts the algorithm must ignore +* default value: null +**/ +public Set<String> getIgnoredConcepts ( ) { +return this.ignoredConcepts; +} +/** +* option name: allowedRoles +* roles the algorithm is allowed to use +* default value: null +**/ +public Set<String> getAllowedRoles ( ) { +return this.allowedRoles; +} +/** +* option name: ignoredRoles +* roles the algorithm must ignore +* default value: null +**/ +public Set<String> getIgnoredRoles ( ) { +return this.ignoredRoles; +} +/** +* option name: useAllConstructor +* specifies whether the universal concept constructor is used in the learning algorithm +* default value: true +**/ +public boolean getUseAllConstructor ( ) { +return this.useAllConstructor; +} +/** +* option name: useExistsConstructor +* specifies whether the existential concept constructor is used in the learning algorithm +* default value: true +**/ +public boolean getUseExistsConstructor ( ) { +return this.useExistsConstructor; +} +/** +* option name: useCardinalityRestrictions +* specifies whether CardinalityRestrictions is used in the learning algorithm +* default value: true +**/ +public boolean getUseCardinalityRestrictions ( ) { +return this.useCardinalityRestrictions; +} +/** +* option name: useNegation +* specifies whether negation is used in the learning algorothm +* default value: true +**/ +public boolean getUseNegation ( ) { +return this.useNegation; +} +/** +* option name: useBooleanDatatypes +* specifies whether boolean datatypes are used in the learning algorothm +* default value: true +**/ +public boolean getUseBooleanDatatypes ( ) { +return this.useBooleanDatatypes; +} +/** +* option name: maxExecutionTimeInSeconds +* algorithm will stop after specified seconds +* default value: 0 +**/ +public int getMaxExecutionTimeInSeconds ( ) { +return this.maxExecutionTimeInSeconds; +} +/** +* option name: minExecutionTimeInSeconds +* algorithm will run at least specified seconds +* default value: 0 +**/ +public int getMinExecutionTimeInSeconds ( ) { +return this.minExecutionTimeInSeconds; +} +/** +* option name: guaranteeXgoodDescriptions +* algorithm will run until X good (100%) concept descritpions are found +* default value: 1 +**/ +public int getGuaranteeXgoodDescriptions ( ) { +return this.guaranteeXgoodDescriptions; +} +/** +* option name: logLevel +* determines the logLevel for this component, can be {TRACE, DEBUG, INFO} +* default value: DEBUG +**/ +public String getLogLevel ( ) { +return this.logLevel; +} +/** +* option name: noisePercentage +* the (approximated) percentage of noise within the examples +* default value: 0.0 +**/ +public double getNoisePercentage ( ) { +return this.noisePercentage; +} +/** +* option name: startClass +* the named class which should be used to start the algorithm (GUI: needs a widget for selecting a class) +* default value: null +**/ +public String getStartClass ( ) { +return this.startClass; +} + +/** +* option name: writeSearchTree +* specifies whether to write a search tree +* default value: false +**/ +public void setWriteSearchTree ( ComponentManager cm, boolean writeSearchTree) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "writeSearchTree", writeSearchTree); +} +/** +* option name: searchTreeFile +* file to use for the search tree +* default value: log/searchTree.txt +**/ +public void setSearchTreeFile ( ComponentManager cm, String searchTreeFile) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "searchTreeFile", searchTreeFile); +} +/** +* option name: replaceSearchTree +* specifies whether to replace the search tree in the log file after each run or append the new search tree +* default value: false +**/ +public void setReplaceSearchTree ( ComponentManager cm, boolean replaceSearchTree) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "replaceSearchTree", replaceSearchTree); +} +/** +* option name: heuristic +* specifiy the heuristic to use +* default value: lexicographic +**/ +public void setHeuristic ( ComponentManager cm, String heuristic) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "heuristic", heuristic); +} +/** +* option name: applyAllFilter +* usage of equivalence ALL R.C AND ALL R.D = ALL R.(C AND D) +* default value: true +**/ +public void setApplyAllFilter ( ComponentManager cm, boolean applyAllFilter) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "applyAllFilter", applyAllFilter); +} +/** +* option name: applyExistsFilter +* usage of equivalence EXISTS R.C OR EXISTS R.D = EXISTS R.(C OR D) +* default value: true +**/ +public void setApplyExistsFilter ( ComponentManager cm, boolean applyExistsFilter) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "applyExistsFilter", applyExistsFilter); +} +/** +* option name: useTooWeakList +* try to filter out too weak concepts without sending them to the reasoner +* default value: true +**/ +public void setUseTooWeakList ( ComponentManager cm, boolean useTooWeakList) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "useTooWeakList", useTooWeakList); +} +/** +* option name: useOverlyGeneralList +* try to find overly general concept without sending them to the reasoner +* default value: true +**/ +public void setUseOverlyGeneralList ( ComponentManager cm, boolean useOverlyGeneralList) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "useOverlyGeneralList", useOverlyGeneralList); +} +/** +* option name: useShortConceptConstruction +* shorten concept to see whether they already exist +* default value: true +**/ +public void setUseShortConceptConstruction ( ComponentManager cm, boolean useShortConceptConstruction) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "useShortConceptConstruction", useShortConceptConstruction); +} +/** +* option name: horizontalExpansionFactor +* horizontal expansion factor (see publication for description) +* default value: 0.6 +**/ +public void setHorizontalExpansionFactor ( ComponentManager cm, double horizontalExpansionFactor) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "horizontalExpansionFactor", horizontalExpansionFactor); +} +/** +* option name: improveSubsumptionHierarchy +* simplify subsumption hierarchy to reduce search space (see publication for description) +* default value: true +**/ +public void setImproveSubsumptionHierarchy ( ComponentManager cm, boolean improveSubsumptionHierarchy) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "improveSubsumptionHierarchy", improveSubsumptionHierarchy); +} +/** +* option name: allowedConcepts +* concepts the algorithm is allowed to use +* default value: null +**/ +public void setAllowedConcepts ( ComponentManager cm, Set<String> allowedConcepts) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "allowedConcepts", allowedConcepts); +} +/** +* option name: ignoredConcepts +* concepts the algorithm must ignore +* default value: null +**/ +public void setIgnoredConcepts ( ComponentManager cm, Set<String> ignoredConcepts) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "ignoredConcepts", ignoredConcepts); +} +/** +* option name: allowedRoles +* roles the algorithm is allowed to use +* default value: null +**/ +public void setAllowedRoles ( ComponentManager cm, Set<String> allowedRoles) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "allowedRoles", allowedRoles); +} +/** +* option name: ignoredRoles +* roles the algorithm must ignore +* default value: null +**/ +public void setIgnoredRoles ( ComponentManager cm, Set<String> ignoredRoles) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "ignoredRoles", ignoredRoles); +} +/** +* option name: useAllConstructor +* specifies whether the universal concept constructor is used in the learning algorithm +* default value: true +**/ +public void setUseAllConstructor ( ComponentManager cm, boolean useAllConstructor) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "useAllConstructor", useAllConstructor); +} +/** +* option name: useExistsConstructor +* specifies whether the existential concept constructor is used in the learning algorithm +* default value: true +**/ +public void setUseExistsConstructor ( ComponentManager cm, boolean useExistsConstructor) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "useExistsConstructor", useExistsConstructor); +} +/** +* option name: useCardinalityRestrictions +* specifies whether CardinalityRestrictions is used in the learning algorithm +* default value: true +**/ +public void setUseCardinalityRestrictions ( ComponentManager cm, boolean useCardinalityRestrictions) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "useCardinalityRestrictions", useCardinalityRestrictions); +} +/** +* option name: useNegation +* specifies whether negation is used in the learning algorothm +* default value: true +**/ +public void setUseNegation ( ComponentManager cm, boolean useNegation) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "useNegation", useNegation); +} +/** +* option name: useBooleanDatatypes +* specifies whether boolean datatypes are used in the learning algorothm +* default value: true +**/ +public void setUseBooleanDatatypes ( ComponentManager cm, boolean useBooleanDatatypes) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "useBooleanDatatypes", useBooleanDatatypes); +} +/** +* option name: maxExecutionTimeInSeconds +* algorithm will stop after specified seconds +* default value: 0 +**/ +public void setMaxExecutionTimeInSeconds ( ComponentManager cm, int maxExecutionTimeInSeconds) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "maxExecutionTimeInSeconds", maxExecutionTimeInSeconds); +} +/** +* option name: minExecutionTimeInSeconds +* algorithm will run at least specified seconds +* default value: 0 +**/ +public void setMinExecutionTimeInSeconds ( ComponentManager cm, int minExecutionTimeInSeconds) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "minExecutionTimeInSeconds", minExecutionTimeInSeconds); +} +/** +* option name: guaranteeXgoodDescriptions +* algorithm will run until X good (100%) concept descritpions are found +* default value: 1 +**/ +public void setGuaranteeXgoodDescriptions ( ComponentManager cm, int guaranteeXgoodDescriptions) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "guaranteeXgoodDescriptions", guaranteeXgoodDescriptions); +} +/** +* option name: logLevel +* determines the logLevel for this component, can be {TRACE, DEBUG, INFO} +* default value: DEBUG +**/ +public void setLogLevel ( ComponentManager cm, String logLevel) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "logLevel", logLevel); +} +/** +* option name: noisePercentage +* the (approximated) percentage of noise within the examples +* default value: 0.0 +**/ +public void setNoisePercentage ( ComponentManager cm, double noisePercentage) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "noisePercentage", noisePercentage); +} +/** +* option name: startClass +* the named class which should be used to start the algorithm (GUI: needs a widget for selecting a class) +* default value: null +**/ +public void setStartClass ( ComponentManager cm, String startClass) { +cm.applyConfigEntry(DBpediaNavigationSuggestor, "startClass", startClass); +} + +public boolean isReinitNecessary(){ +return reinitNecessary; +} + + +} Added: trunk/src/dl-learner/org/dllearner/core/configuration/DIGReasonerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configuration/DIGReasonerConfigurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configuration/DIGReasonerConfigurator.java 2008-09-05 14:53:16 UTC (rev 1171) @@ -0,0 +1,119 @@ +/** + * Copyright (C) 2007-2008, 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.configuration; + +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.configuration.Configurator; +import org.dllearner.reasoning.DIGReasoner; + +/** +* automatically generated, do not edit manually +**/ +@SuppressWarnings("unused") +public class DIGReasonerConfigurator extends Configurator { + +private boolean reinitNecessary = false; +private DIGReasoner DIGReasoner; +private String reasonerUrl = null; +private boolean writeDIGProtocol = false; +private String digProtocolFile = "log/digProtocol.txt"; + +public DIGReasonerConfigurator (DIGReasoner DIGReasoner){ +this.DIGReasoner = DIGReasoner; +} + +/** +**/ +public static DIGReasoner getDIGReasoner (ComponentManager cm, KnowledgeSource knowledgeSource ) { +DIGReasoner component = cm.reasoner(DIGReasoner.class, knowledgeSource ); +return component; +} + +@SuppressWarnings({ "unchecked" }) +public <T> void applyConfigEntry(ConfigEntry<T> entry){ +String optionName = entry.getOptionName(); +if(false){//empty block +}else if (optionName.equals("reasonerUrl")){ +reasonerUrl = (String) entry.getValue(); +}else if (optionName.equals("writeDIGProtocol")){ +writeDIGProtocol = (Boolean) entry.getValue(); +}else if (optionName.equals("digProtocolFile")){ +digProtocolFile = (String) entry.getValue(); +} +} + +/** +* option name: reasonerUrl +* URL of the DIG reasoner +* default value: null +**/ +public String getReasonerUrl ( ) { +return this.reasonerUrl; +} +/** +* option name: writeDIGProtocol +* specifies whether or not to write a protocoll of send and received DIG requests +* default value: false +**/ +public boolean getWriteDIGProtocol ( ) { +return this.writeDIGProtocol; +} +/** +* option name: digProtocolFile +* the file to store the DIG protocol +* default value: log/digProtocol.txt +**/ +public String getDigProtocolFile ( ) { +return this.digProtocolFile; +} + +/** +* option name: reasonerUrl +* URL of the DIG reasoner +* default value: null +**/ +public void setReasonerUrl ( ComponentManager cm, String reasonerUrl) { +cm.applyConfigEntry(DIGReasoner, "reasonerUrl", reasonerUrl); +} +/** +* option name: writeDIGProtocol +* specifies whether or not to write a protocoll of send and received DIG requests +* default value: false +**/ +public void setWriteDIGProtocol ( ComponentManager cm, boolean writeDIGProtocol) { +cm.applyConfigEntry(DIGReasoner, "writeDIGProtocol", writeDIGProtocol); +} +/** +* option name: digProtocolFile +* the file to store the DIG protocol +* default value: log/digProtocol.txt +**/ +public void setDigProtocolFile ( ComponentManager cm, String digProtocolFile) { +cm.applyConfigEntry(DIGReasoner, "digProtocolFile", digProtocolFile); +} + +public boolean isReinitNecessary(){ +return reinitNecessary; +} + + +} Added: trunk/src/dl-learner/org/dllearner/core/configuration/ExampleBasedROLComponentConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configuration/ExampleBasedROLComponentConfigurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configuration/ExampleBasedROLComponentConfigurator.java 2008-09-05 14:53:16 UTC (rev 1171) @@ -0,0 +1,616 @@ +/** + * Copyright (C) 2007-2008, 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.configuration; + +import java.util.Set; +import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.configuration.Configurator; + +/** +* automatically generated, do not edit manually +**/ +@SuppressWarnings("unused") +public class ExampleBasedROLComponentConfigurator extends Configurator { + +private boolean reinitNecessary = false; +private ExampleBasedROLComponent ExampleBasedROLComponent; +private boolean writeSearchTree = false; +private String searchTreeFile = "log/searchTree.txt"; +private boolean replaceSearchTree = false; +private String heuristic = "lexicographic"; +private boolean applyAllFilter = true; +private boolean applyExistsFilter = true; +private boolean useTooWeakList = true; +private boolean useOverlyGeneralList = true; +private boolean useShortConceptConstruction = true; +private double horizontalExpansionFactor = 0.6; +private boolean improveSubsumptionHierarchy = true; +private Set<String> allowedConcepts = null; +private Set<String> ignoredConcepts = null; +private Set<String> allowedRoles = null; +private Set<String> ignoredRoles = null; +private boolean useAllConstructor = true; +private boolean useExistsConstructor = true; +private boolean useCardinalityRestrictions = true; +private boolean useNegation = true; +private boolean useBooleanDatatypes = true; +private boolean useDoubleDatatypes = true; +private int maxExecutionTimeInSeconds = 0; +private int minExecutionTimeInSeconds = 0; +private int guaranteeXgoodDescriptions = 1; +private String logLevel = "DEBUG"; +private boolean usePropernessChecks = false; +private int maxPosOnlyExpansion = 4; +private double noisePercentage = 0.0; +private String startClass = null; + +public ExampleBasedROLComponentConfigurator (ExampleBasedROLComponent ExampleBasedROLComponent){ +this.ExampleBasedROLComponent = ExampleBasedROLComponent; +} + +/** +**/ +public static ExampleBasedROLComponent getExampleBasedROLComponent (ComponentManager cm, LearningProblem learningProblem, ReasoningService reasoningService ) throws LearningProblemUnsupportedException{ +ExampleBasedROLComponent component = cm.learningAlgorithm(ExampleBasedROLComponent.class, learningProblem, reasoningService ); +return component; +} + +@SuppressWarnings({ "unchecked" }) +public <T> void applyConfigEntry(ConfigEntry<T> entry){ +String optionName = entry.getOptionName(); +if(false){//empty block +}else if (optionName.equals("writeSearchTree")){ +writeSearchTree = (Boolean) entry.getValue(); +}else if (optionName.equals("searchTreeFile")){ +searchTreeFile = (String) entry.getValue(); +}else if (optionName.equals("replaceSearchTree")){ +replaceSearchTree = (Boolean) entry.getValue(); +}else if (optionName.equals("heuristic")){ +heuristic = (String) entry.getValue(); +}else if (optionName.equals("applyAllFilter")){ +applyAllFilter = (Boolean) entry.getValue(); +}else if (optionName.equals("applyExistsFilter")){ +applyExistsFilter = (Boolean) entry.getValue(); +}else if (optionName.equals("useTooWeakList")){ +useTooWeakList = (Boolean) entry.getValue(); +}else if (optionName.equals("useOverlyGeneralList")){ +useOverlyGeneralList = (Boolean) entry.getValue(); +}else if (optionName.equals("useShortConceptConstruction")){ +useShortConceptConstruction = (Boolean) entry.getValue(); +}else if (optionName.equals("horizontalExpansionFactor")){ +horizontalExpansionFactor = (Double) entry.getValue(); +}else if (optionName.equals("improveSubsumptionHierarchy")){ +improveSubsumptionHierarchy = (Boolean) entry.getValue(); +}else if (optionName.equals("allowedConcepts")){ +allowedConcepts = (Set<String>) entry.getValue(); +}else if (optionName.equals("ignoredConcepts")){ +ignoredConcepts = (Set<String>) entry.getValue(); +}else if (optionName.equals("allowedRoles")){ +allowedRoles = (Set<String>) entry.getValue(); +}else if (optionName.equals("ignoredRoles")){ +ignoredRoles = (Set<String>) entry.getValue(); +}else if (optionName.equals("useAllConstructor")){ +useAllConstructor = (Boolean) entry.getValue(); +}else if (optionName.equals("useExistsConstructor")){ +useExistsConstructor = (Boolean) entry.getValue(); +}else if (optionName.equals("useCardinalityRestrictions")){ +useCardinalityRestrictions = (Boolean) entry.getValue(); +}else if (optionName.equals("useNegation")){ +useNegation = (Boolean) entry.getValue(); +}else if (optionName.equals("useBooleanDatatypes")){ +useBooleanDatatypes = (Boolean) entry.getValue(); +}else if (optionName.equals("useDoubleDatatypes")){ +useDoubleDatatypes = (Boolean) entry.getValue(); +}else if (optionName.equals("maxExecutionTimeInSeconds")){ +maxExecutionTimeInSeconds = (Integer) entry.getValue(); +}else if (optionName.equals("minExecutionTimeInSeconds")){ +minExecutionTimeInSeconds = (Integer) entry.getValue(); +}else if (optionName.equals("guaranteeXgoodDescriptions")){ +guaranteeXgoodDescriptions = (Integer) entry.getValue(); +}else if (optionName.equals("logLevel")){ +logLevel = (String) entry.getValue(); +}else if (optionName.equals("usePropernessChecks")){ +usePropernessChecks = (Boolean) entry.getValue(); +}else if (optionName.equals("maxPosOnlyExpansion")){ +maxPosOnlyExpansion = (Integer) entry.getValue(); +}else if (optionName.equals("noisePercentage")){ +noisePercentage = (Double) entry.getValue(); +}else if (optionName.equals("startClass")){ +startClass = (String) entry.getValue(); +} +} + +/** +* option name: writeSearchTree +* specifies whether to write a search tree +* default value: false +**/ +public boolean getWriteSearchTree ( ) { +return this.writeSearchTree; +} +/** +* option name: searchTreeFile +* file to use for the search tree +* default value: log/searchTree.txt +**/ +public String getSearchTreeFile ( ) { +return this.searchTreeFile; +} +/** +* option name: replaceSearchTree +* specifies whether to replace the search tree in the log file after each run or append the new search tree +* default value: false +**/ +public boolean getReplaceSearchTree ( ) { +return this.replaceSearchTree; +} +/** +* option name: heuristic +* specifiy the heuristic to use +* default value: lexicographic +**/ +public String getHeuristic ( ) { +return this.heuristic; +} +/** +* option name: applyAllFi... [truncated message content] |
From: <ku...@us...> - 2008-09-05 12:24:08
|
Revision: 1170 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1170&view=rev Author: kurzum Date: 2008-09-05 12:24:05 +0000 (Fri, 05 Sep 2008) Log Message: ----------- java interface Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/configuration/Configurator.java trunk/src/dl-learner/org/dllearner/core/configuration/OWLFileConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/SparqlKnowledgeSourceConfigurator.java trunk/src/dl-learner/org/dllearner/kb/OWLFile.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java trunk/src/dl-learner/org/dllearner/scripts/Sample.java trunk/src/dl-learner/org/dllearner/utilities/Files.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/configuration/FastInstanceCheckerConfigurator.java trunk/src/dl-learner/org/dllearner/scripts/NewSample.java Modified: trunk/src/dl-learner/org/dllearner/core/configuration/Configurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configuration/Configurator.java 2008-09-03 19:29:41 UTC (rev 1169) +++ trunk/src/dl-learner/org/dllearner/core/configuration/Configurator.java 2008-09-05 12:24:05 UTC (rev 1170) @@ -18,31 +18,44 @@ **/ package org.dllearner.core.configuration; - import java.util.Set; import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.configuration.FastInstanceCheckerConfigurator; import org.dllearner.core.configuration.OWLFileConfigurator; import org.dllearner.core.configuration.SparqlKnowledgeSourceConfigurator; import org.dllearner.kb.OWLFile; import org.dllearner.kb.sparql.SparqlKnowledgeSource; +import org.dllearner.reasoning.FastInstanceChecker; /** * automatically generated, do not edit manually **/ -public class Configurator { +public class Configurator { /** -URL pointing to the OWL file +* url: URL pointing to the OWL file **/ public static OWLFile getOWLFile (ComponentManager cm, String url ) { -return OWLFileConfigurator.getOWLFile(cm, url); +return OWLFileConfigurator.getOWLFile(cm, url); } /** -relevant instances e.g. positive and negative examples in a learning problem +* instances: relevant instances e.g. positive and negative examples in a learning problem **/ public static SparqlKnowledgeSource getSparqlKnowledgeSource (ComponentManager cm, Set<String> instances ) { -return SparqlKnowledgeSourceConfigurator.getSparqlKnowledgeSource(cm, instances); +return SparqlKnowledgeSourceConfigurator.getSparqlKnowledgeSource(cm, instances); } +/** +**/ +public static FastInstanceChecker getFastInstanceChecker (ComponentManager cm, KnowledgeSource knowledgeSource ) { +return FastInstanceCheckerConfigurator.getFastInstanceChecker(cm, knowledgeSource); } + + +} Added: trunk/src/dl-learner/org/dllearner/core/configuration/FastInstanceCheckerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configuration/FastInstanceCheckerConfigurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configuration/FastInstanceCheckerConfigurator.java 2008-09-05 12:24:05 UTC (rev 1170) @@ -0,0 +1,68 @@ +/** + * Copyright (C) 2007-2008, 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.configuration; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.configuration.Configurator; +import org.dllearner.reasoning.FastInstanceChecker; + +/** +* automatically generated, do not edit manually +**/ +public class FastInstanceCheckerConfigurator extends Configurator { + +FastInstanceChecker FastInstanceChecker; +private String reasonerType = "pellet"; + +public FastInstanceCheckerConfigurator (FastInstanceChecker FastInstanceChecker){ +this.FastInstanceChecker = FastInstanceChecker; +} + +/** +**/ +public static FastInstanceChecker getFastInstanceChecker (ComponentManager cm, KnowledgeSource knowledgeSource ) { +FastInstanceChecker component = cm.reasoner(FastInstanceChecker.class, knowledgeSource ); +return component; +} + +@SuppressWarnings({ "unchecked" }) +public <T> void applyConfigEntry(ConfigEntry<T> entry){ +String optionName = entry.getOptionName(); +if(false){//empty block +}else if (optionName.equals("reasonerType")){ +reasonerType = (String) entry.getValue(); +} +} + +/** +reasonerType : FaCT++ or Pellet to dematerialize**/ +public String getReasonerType ( ) { +return this.reasonerType; +} + +/** +reasonerType : FaCT++ or Pellet to dematerialize**/ +public void setReasonerType ( ComponentManager cm, String reasonerType) { +cm.applyConfigEntry(FastInstanceChecker, "reasonerType", reasonerType); +} + + +} Modified: trunk/src/dl-learner/org/dllearner/core/configuration/OWLFileConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configuration/OWLFileConfigurator.java 2008-09-03 19:29:41 UTC (rev 1169) +++ trunk/src/dl-learner/org/dllearner/core/configuration/OWLFileConfigurator.java 2008-09-05 12:24:05 UTC (rev 1170) @@ -18,13 +18,11 @@ **/ package org.dllearner.core.configuration; - import org.dllearner.core.ComponentManager; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.configuration.Configurator; import org.dllearner.kb.OWLFile; - /** * automatically generated, do not edit manually **/ @@ -33,49 +31,39 @@ OWLFile OWLFile; private String url = null; +public OWLFileConfigurator (OWLFile OWLFile){ +this.OWLFile = OWLFile; +} /** -URL pointing to the OWL file +* url: URL pointing to the OWL file **/ -public void setMandatoryOptions (String url ) { -this.url = url; -} -/** -URL pointing to the OWL file -**/ public static OWLFile getOWLFile (ComponentManager cm, String url ) { -OWLFile component = cm.knowledgeSource(OWLFile.class); +OWLFile component = cm.knowledgeSource(OWLFile.class ); cm.applyConfigEntry(component, "url", url); return component; } - @SuppressWarnings({ "unchecked" }) public <T> void applyConfigEntry(ConfigEntry<T> entry){ String optionName = entry.getOptionName(); -if (optionName.equals(url)){ +if(false){//empty block +}else if (optionName.equals("url")){ url = (String) entry.getValue(); } } - /** -* URL pointing to the OWL file -**/ -public void setUrl (String url) { -this.url = url; +url : URL pointing to the OWL file**/ +public String getUrl ( ) { +return this.url; } - - /** -* URL pointing to the OWL file -* -**/ -public String getUrl ( ) { -return this.url; +url : URL pointing to the OWL file**/ +public void setUrl ( ComponentManager cm, String url) { +cm.applyConfigEntry(OWLFile, "url", url); } - } Modified: trunk/src/dl-learner/org/dllearner/core/configuration/SparqlKnowledgeSourceConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configuration/SparqlKnowledgeSourceConfigurator.java 2008-09-03 19:29:41 UTC (rev 1169) +++ trunk/src/dl-learner/org/dllearner/core/configuration/SparqlKnowledgeSourceConfigurator.java 2008-09-05 12:24:05 UTC (rev 1170) @@ -18,7 +18,6 @@ **/ package org.dllearner.core.configuration; - import java.util.List; import java.util.Set; import org.dllearner.core.ComponentManager; @@ -27,7 +26,6 @@ import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.utilities.datastructures.StringTuple; - /** * automatically generated, do not edit manually **/ @@ -59,440 +57,315 @@ private Set<String> defaultGraphURIs = null; private Set<String> namedGraphURIs = null; +public SparqlKnowledgeSourceConfigurator (SparqlKnowledgeSource SparqlKnowledgeSource){ +this.SparqlKnowledgeSource = SparqlKnowledgeSource; +} /** -relevant instances e.g. positive and negative examples in a learning problem +* instances: relevant instances e.g. positive and negative examples in a learning problem **/ -public void setMandatoryOptions (Set<String> instances ) { -this.instances = instances; -} -/** -relevant instances e.g. positive and negative examples in a learning problem -**/ public static SparqlKnowledgeSource getSparqlKnowledgeSource (ComponentManager cm, Set<String> instances ) { -SparqlKnowledgeSource component = cm.knowledgeSource(SparqlKnowledgeSource.class); +SparqlKnowledgeSource component = cm.knowledgeSource(SparqlKnowledgeSource.class ); cm.applyConfigEntry(component, "instances", instances); return component; } - @SuppressWarnings({ "unchecked" }) public <T> void applyConfigEntry(ConfigEntry<T> entry){ String optionName = entry.getOptionName(); -if (optionName.equals(url)){ +if(false){//empty block +}else if (optionName.equals("url")){ url = (String) entry.getValue(); -}else if (optionName.equals(cacheDir)){ +}else if (optionName.equals("cacheDir")){ cacheDir = (String) entry.getValue(); -}else if (optionName.equals(instances)){ +}else if (optionName.equals("instances")){ instances = (Set<String>) entry.getValue(); -}else if (optionName.equals(recursionDepth)){ +}else if (optionName.equals("recursionDepth")){ recursionDepth = (Integer) entry.getValue(); -}else if (optionName.equals(predefinedFilter)){ +}else if (optionName.equals("predefinedFilter")){ predefinedFilter = (String) entry.getValue(); -}else if (optionName.equals(predefinedEndpoint)){ +}else if (optionName.equals("predefinedEndpoint")){ predefinedEndpoint = (String) entry.getValue(); -}else if (optionName.equals(predefinedManipulator)){ +}else if (optionName.equals("predefinedManipulator")){ predefinedManipulator = (String) entry.getValue(); -}else if (optionName.equals(predList)){ +}else if (optionName.equals("predList")){ predList = (Set<String>) entry.getValue(); -}else if (optionName.equals(objList)){ +}else if (optionName.equals("objList")){ objList = (Set<String>) entry.getValue(); -}else if (optionName.equals(classList)){ +}else if (optionName.equals("classList")){ classList = (Set<String>) entry.getValue(); -}else if (optionName.equals(format)){ +}else if (optionName.equals("format")){ format = (String) entry.getValue(); -}else if (optionName.equals(dumpToFile)){ +}else if (optionName.equals("dumpToFile")){ dumpToFile = (Boolean) entry.getValue(); -}else if (optionName.equals(convertNT2RDF)){ +}else if (optionName.equals("convertNT2RDF")){ convertNT2RDF = (Boolean) entry.getValue(); -}else if (optionName.equals(useLits)){ +}else if (optionName.equals("useLits")){ useLits = (Boolean) entry.getValue(); -}else if (optionName.equals(getAllSuperClasses)){ +}else if (optionName.equals("getAllSuperClasses")){ getAllSuperClasses = (Boolean) entry.getValue(); -}else if (optionName.equals(useCache)){ +}else if (optionName.equals("useCache")){ useCache = (Boolean) entry.getValue(); -}else if (optionName.equals(replacePredicate)){ +}else if (optionName.equals("replacePredicate")){ replacePredicate = (List<StringTuple>) entry.getValue(); -}else if (optionName.equals(replaceObject)){ +}else if (optionName.equals("replaceObject")){ replaceObject = (List<StringTuple>) entry.getValue(); -}else if (optionName.equals(breakSuperClassRetrievalAfter)){ +}else if (optionName.equals("breakSuperClassRetrievalAfter")){ breakSuperClassRetrievalAfter = (Integer) entry.getValue(); -}else if (optionName.equals(closeAfterRecursion)){ +}else if (optionName.equals("closeAfterRecursion")){ closeAfterRecursion = (Boolean) entry.getValue(); -}else if (optionName.equals(getPropertyInformation)){ +}else if (optionName.equals("getPropertyInformation")){ getPropertyInformation = (Boolean) entry.getValue(); -}else if (optionName.equals(verbosity)){ +}else if (optionName.equals("verbosity")){ verbosity = (String) entry.getValue(); -}else if (optionName.equals(defaultGraphURIs)){ +}else if (optionName.equals("defaultGraphURIs")){ defaultGraphURIs = (Set<String>) entry.getValue(); -}else if (optionName.equals(namedGraphURIs)){ +}else if (optionName.equals("namedGraphURIs")){ namedGraphURIs = (Set<String>) entry.getValue(); } } - /** -* URL of SPARQL Endpoint -**/ -public void setUrl (String url) { -this.url = url; +url : URL of SPARQL Endpoint**/ +public String getUrl ( ) { +return this.url; } - /** -* dir of cache -**/ -public void setCacheDir (String cacheDir) { -this.cacheDir = cacheDir; +cacheDir : dir of cache**/ +public String getCacheDir ( ) { +return this.cacheDir; } - /** -* relevant instances e.g. positive and negative examples in a learning problem -**/ -public void setInstances (Set<String> instances) { -this.instances = instances; +instances : relevant instances e.g. positive and negative examples in a learning problem**/ +public Set<String> getInstances ( ) { +return this.instances; } - /** -* recursion depth of KB fragment selection -**/ -public void setRecursionDepth (int recursionDepth) { -this.recursionDepth = recursionDepth; +recursionDepth : recursion depth of KB fragment selection**/ +public int getRecursionDepth ( ) { +return this.recursionDepth; } - /** -* the mode of the SPARQL Filter, use one of YAGO,SKOS,YAGOSKOS , YAGOSPECIALHIERARCHY, TEST -**/ -public void setPredefinedFilter (String predefinedFilter) { -this.predefinedFilter = predefinedFilter; +predefinedFilter : the mode of the SPARQL Filter, use one of YAGO,SKOS,YAGOSKOS , YAGOSPECIALHIERARCHY, TEST**/ +public String getPredefinedFilter ( ) { +return this.predefinedFilter; } - /** -* the mode of the SPARQL Filter, use one of DBPEDIA, LOCAL, GOVTRACK, REVYU, MYOPENLINK, FACTBOOK -**/ -public void setPredefinedEndpoint (String predefinedEndpoint) { -this.predefinedEndpoint = predefinedEndpoint; +predefinedEndpoint : the mode of the SPARQL Filter, use one of DBPEDIA, LOCAL, GOVTRACK, REVYU, MYOPENLINK, FACTBOOK**/ +public String getPredefinedEndpoint ( ) { +return this.predefinedEndpoint; } - /** -* the mode of the Manipulator, use one of STANDARD, DBPEDIA-NAVIGATOR -**/ -public void setPredefinedManipulator (String predefinedManipulator) { -this.predefinedManipulator = predefinedManipulator; +predefinedManipulator : the mode of the Manipulator, use one of STANDARD, DBPEDIA-NAVIGATOR**/ +public String getPredefinedManipulator ( ) { +return this.predefinedManipulator; } - /** -* list of all ignored roles -**/ -public void setPredList (Set<String> predList) { -this.predList = predList; +predList : list of all ignored roles**/ +public Set<String> getPredList ( ) { +return this.predList; } - /** -* list of all ignored objects -**/ -public void setObjList (Set<String> objList) { -this.objList = objList; +objList : list of all ignored objects**/ +public Set<String> getObjList ( ) { +return this.objList; } - /** -* list of all ignored classes -**/ -public void setClassList (Set<String> classList) { -this.classList = classList; +classList : list of all ignored classes**/ +public Set<String> getClassList ( ) { +return this.classList; } - /** -* N-TRIPLES or KB format -**/ -public void setFormat (String format) { -this.format = format; +format : N-TRIPLES or KB format**/ +public String getFormat ( ) { +return this.format; } - /** -* Specifies whether the extracted ontology is written to a file or not. -**/ -public void setDumpToFile (boolean dumpToFile) { -this.dumpToFile = dumpToFile; +dumpToFile : Specifies whether the extracted ontology is written to a file or not.**/ +public boolean getDumpToFile ( ) { +return this.dumpToFile; } - /** -* Specifies whether the extracted NTriples are converted to RDF and deleted. -**/ -public void setConvertNT2RDF (boolean convertNT2RDF) { -this.convertNT2RDF = convertNT2RDF; +convertNT2RDF : Specifies whether the extracted NTriples are converted to RDF and deleted.**/ +public boolean getConvertNT2RDF ( ) { +return this.convertNT2RDF; } - /** -* use Literals in SPARQL query -**/ -public void setUseLits (boolean useLits) { -this.useLits = useLits; +useLits : use Literals in SPARQL query**/ +public boolean getUseLits ( ) { +return this.useLits; } - /** -* If true then all superclasses are retrieved until the most general class (owl:Thing) is reached. -**/ -public void setGetAllSuperClasses (boolean getAllSuperClasses) { -this.getAllSuperClasses = getAllSuperClasses; +getAllSuperClasses : If true then all superclasses are retrieved until the most general class (owl:Thing) is reached.**/ +public boolean getGetAllSuperClasses ( ) { +return this.getAllSuperClasses; } - /** -* If true a Cache is used -**/ -public void setUseCache (boolean useCache) { -this.useCache = useCache; +useCache : If true a Cache is used**/ +public boolean getUseCache ( ) { +return this.useCache; } - /** -* rule for replacing predicates -**/ -public void setReplacePredicate (List<StringTuple> replacePredicate) { -this.replacePredicate = replacePredicate; +replacePredicate : rule for replacing predicates**/ +public List<StringTuple> getReplacePredicate ( ) { +return this.replacePredicate; } - /** -* rule for replacing predicates -**/ -public void setReplaceObject (List<StringTuple> replaceObject) { -this.replaceObject = replaceObject; +replaceObject : rule for replacing predicates**/ +public List<StringTuple> getReplaceObject ( ) { +return this.replaceObject; } - /** -* stops a cyclic hierarchy after specified number of classes -**/ -public void setBreakSuperClassRetrievalAfter (int breakSuperClassRetrievalAfter) { -this.breakSuperClassRetrievalAfter = breakSuperClassRetrievalAfter; +breakSuperClassRetrievalAfter : stops a cyclic hierarchy after specified number of classes**/ +public int getBreakSuperClassRetrievalAfter ( ) { +return this.breakSuperClassRetrievalAfter; } - /** -* gets all classes for all instances -**/ -public void setCloseAfterRecursion (boolean closeAfterRecursion) { -this.closeAfterRecursion = closeAfterRecursion; +closeAfterRecursion : gets all classes for all instances**/ +public boolean getCloseAfterRecursion ( ) { +return this.closeAfterRecursion; } - /** -* gets all types for extracted ObjectProperties -**/ -public void setGetPropertyInformation (boolean getPropertyInformation) { -this.getPropertyInformation = getPropertyInformation; +getPropertyInformation : gets all types for extracted ObjectProperties**/ +public boolean getGetPropertyInformation ( ) { +return this.getPropertyInformation; } - /** -* control verbosity of output for this component -**/ -public void setVerbosity (String verbosity) { -this.verbosity = verbosity; +verbosity : control verbosity of output for this component**/ +public String getVerbosity ( ) { +return this.verbosity; } - /** -* a list of all default Graph URIs -**/ -public void setDefaultGraphURIs (Set<String> defaultGraphURIs) { -this.defaultGraphURIs = defaultGraphURIs; +defaultGraphURIs : a list of all default Graph URIs**/ +public Set<String> getDefaultGraphURIs ( ) { +return this.defaultGraphURIs; } - /** -* a list of all named Graph URIs -**/ -public void setNamedGraphURIs (Set<String> namedGraphURIs) { -this.namedGraphURIs = namedGraphURIs; +namedGraphURIs : a list of all named Graph URIs**/ +public Set<String> getNamedGraphURIs ( ) { +return this.namedGraphURIs; } - - /** -* URL of SPARQL Endpoint -* -**/ -public String getUrl ( ) { -return this.url; +url : URL of SPARQL Endpoint**/ +public void setUrl ( ComponentManager cm, String url) { +cm.applyConfigEntry(SparqlKnowledgeSource, "url", url); } - /** -* dir of cache -* -**/ -public String getCacheDir ( ) { -return this.cacheDir; +cacheDir : dir of cache**/ +public void setCacheDir ( ComponentManager cm, String cacheDir) { +cm.applyConfigEntry(SparqlKnowledgeSource, "cacheDir", cacheDir); } - /** -* relevant instances e.g. positive and negative examples in a learning problem -* -**/ -public Set<String> getInstances ( ) { -return this.instances; +instances : relevant instances e.g. positive and negative examples in a learning problem**/ +public void setInstances ( ComponentManager cm, Set<String> instances) { +cm.applyConfigEntry(SparqlKnowledgeSource, "instances", instances); } - /** -* recursion depth of KB fragment selection -* -**/ -public int getRecursionDepth ( ) { -return this.recursionDepth; +recursionDepth : recursion depth of KB fragment selection**/ +public void setRecursionDepth ( ComponentManager cm, int recursionDepth) { +cm.applyConfigEntry(SparqlKnowledgeSource, "recursionDepth", recursionDepth); } - /** -* the mode of the SPARQL Filter, use one of YAGO,SKOS,YAGOSKOS , YAGOSPECIALHIERARCHY, TEST -* -**/ -public String getPredefinedFilter ( ) { -return this.predefinedFilter; +predefinedFilter : the mode of the SPARQL Filter, use one of YAGO,SKOS,YAGOSKOS , YAGOSPECIALHIERARCHY, TEST**/ +public void setPredefinedFilter ( ComponentManager cm, String predefinedFilter) { +cm.applyConfigEntry(SparqlKnowledgeSource, "predefinedFilter", predefinedFilter); } - /** -* the mode of the SPARQL Filter, use one of DBPEDIA, LOCAL, GOVTRACK, REVYU, MYOPENLINK, FACTBOOK -* -**/ -public String getPredefinedEndpoint ( ) { -return this.predefinedEndpoint; +predefinedEndpoint : the mode of the SPARQL Filter, use one of DBPEDIA, LOCAL, GOVTRACK, REVYU, MYOPENLINK, FACTBOOK**/ +public void setPredefinedEndpoint ( ComponentManager cm, String predefinedEndpoint) { +cm.applyConfigEntry(SparqlKnowledgeSource, "predefinedEndpoint", predefinedEndpoint); } - /** -* the mode of the Manipulator, use one of STANDARD, DBPEDIA-NAVIGATOR -* -**/ -public String getPredefinedManipulator ( ) { -return this.predefinedManipulator; +predefinedManipulator : the mode of the Manipulator, use one of STANDARD, DBPEDIA-NAVIGATOR**/ +public void setPredefinedManipulator ( ComponentManager cm, String predefinedManipulator) { +cm.applyConfigEntry(SparqlKnowledgeSource, "predefinedManipulator", predefinedManipulator); } - /** -* list of all ignored roles -* -**/ -public Set<String> getPredList ( ) { -return this.predList; +predList : list of all ignored roles**/ +public void setPredList ( ComponentManager cm, Set<String> predList) { +cm.applyConfigEntry(SparqlKnowledgeSource, "predList", predList); } - /** -* list of all ignored objects -* -**/ -public Set<String> getObjList ( ) { -return this.objList; +objList : list of all ignored objects**/ +public void setObjList ( ComponentManager cm, Set<String> objList) { +cm.applyConfigEntry(SparqlKnowledgeSource, "objList", objList); } - /** -* list of all ignored classes -* -**/ -public Set<String> getClassList ( ) { -return this.classList; +classList : list of all ignored classes**/ +public void setClassList ( ComponentManager cm, Set<String> classList) { +cm.applyConfigEntry(SparqlKnowledgeSource, "classList", classList); } - /** -* N-TRIPLES or KB format -* -**/ -public String getFormat ( ) { -return this.format; +format : N-TRIPLES or KB format**/ +public void setFormat ( ComponentManager cm, String format) { +cm.applyConfigEntry(SparqlKnowledgeSource, "format", format); } - /** -* Specifies whether the extracted ontology is written to a file or not. -* -**/ -public boolean getDumpToFile ( ) { -return this.dumpToFile; +dumpToFile : Specifies whether the extracted ontology is written to a file or not.**/ +public void setDumpToFile ( ComponentManager cm, boolean dumpToFile) { +cm.applyConfigEntry(SparqlKnowledgeSource, "dumpToFile", dumpToFile); } - /** -* Specifies whether the extracted NTriples are converted to RDF and deleted. -* -**/ -public boolean getConvertNT2RDF ( ) { -return this.convertNT2RDF; +convertNT2RDF : Specifies whether the extracted NTriples are converted to RDF and deleted.**/ +public void setConvertNT2RDF ( ComponentManager cm, boolean convertNT2RDF) { +cm.applyConfigEntry(SparqlKnowledgeSource, "convertNT2RDF", convertNT2RDF); } - /** -* use Literals in SPARQL query -* -**/ -public boolean getUseLits ( ) { -return this.useLits; +useLits : use Literals in SPARQL query**/ +public void setUseLits ( ComponentManager cm, boolean useLits) { +cm.applyConfigEntry(SparqlKnowledgeSource, "useLits", useLits); } - /** -* If true then all superclasses are retrieved until the most general class (owl:Thing) is reached. -* -**/ -public boolean getGetAllSuperClasses ( ) { -return this.getAllSuperClasses; +getAllSuperClasses : If true then all superclasses are retrieved until the most general class (owl:Thing) is reached.**/ +public void setGetAllSuperClasses ( ComponentManager cm, boolean getAllSuperClasses) { +cm.applyConfigEntry(SparqlKnowledgeSource, "getAllSuperClasses", getAllSuperClasses); } - /** -* If true a Cache is used -* -**/ -public boolean getUseCache ( ) { -return this.useCache; +useCache : If true a Cache is used**/ +public void setUseCache ( ComponentManager cm, boolean useCache) { +cm.applyConfigEntry(SparqlKnowledgeSource, "useCache", useCache); } - /** -* rule for replacing predicates -* -**/ -public List<StringTuple> getReplacePredicate ( ) { -return this.replacePredicate; +replacePredicate : rule for replacing predicates**/ +public void setReplacePredicate ( ComponentManager cm, List<StringTuple> replacePredicate) { +cm.applyConfigEntry(SparqlKnowledgeSource, "replacePredicate", replacePredicate); } - /** -* rule for replacing predicates -* -**/ -public List<StringTuple> getReplaceObject ( ) { -return this.replaceObject; +replaceObject : rule for replacing predicates**/ +public void setReplaceObject ( ComponentManager cm, List<StringTuple> replaceObject) { +cm.applyConfigEntry(SparqlKnowledgeSource, "replaceObject", replaceObject); } - /** -* stops a cyclic hierarchy after specified number of classes -* -**/ -public int getBreakSuperClassRetrievalAfter ( ) { -return this.breakSuperClassRetrievalAfter; +breakSuperClassRetrievalAfter : stops a cyclic hierarchy after specified number of classes**/ +public void setBreakSuperClassRetrievalAfter ( ComponentManager cm, int breakSuperClassRetrievalAfter) { +cm.applyConfigEntry(SparqlKnowledgeSource, "breakSuperClassRetrievalAfter", breakSuperClassRetrievalAfter); } - /** -* gets all classes for all instances -* -**/ -public boolean getCloseAfterRecursion ( ) { -return this.closeAfterRecursion; +closeAfterRecursion : gets all classes for all instances**/ +public void setCloseAfterRecursion ( ComponentManager cm, boolean closeAfterRecursion) { +cm.applyConfigEntry(SparqlKnowledgeSource, "closeAfterRecursion", closeAfterRecursion); } - /** -* gets all types for extracted ObjectProperties -* -**/ -public boolean getGetPropertyInformation ( ) { -return this.getPropertyInformation; +getPropertyInformation : gets all types for extracted ObjectProperties**/ +public void setGetPropertyInformation ( ComponentManager cm, boolean getPropertyInformation) { +cm.applyConfigEntry(SparqlKnowledgeSource, "getPropertyInformation", getPropertyInformation); } - /** -* control verbosity of output for this component -* -**/ -public String getVerbosity ( ) { -return this.verbosity; +verbosity : control verbosity of output for this component**/ +public void setVerbosity ( ComponentManager cm, String verbosity) { +cm.applyConfigEntry(SparqlKnowledgeSource, "verbosity", verbosity); } - /** -* a list of all default Graph URIs -* -**/ -public Set<String> getDefaultGraphURIs ( ) { -return this.defaultGraphURIs; +defaultGraphURIs : a list of all default Graph URIs**/ +public void setDefaultGraphURIs ( ComponentManager cm, Set<String> defaultGraphURIs) { +cm.applyConfigEntry(SparqlKnowledgeSource, "defaultGraphURIs", defaultGraphURIs); } - /** -* a list of all named Graph URIs -* -**/ -public Set<String> getNamedGraphURIs ( ) { -return this.namedGraphURIs; +namedGraphURIs : a list of all named Graph URIs**/ +public void setNamedGraphURIs ( ComponentManager cm, Set<String> namedGraphURIs) { +cm.applyConfigEntry(SparqlKnowledgeSource, "namedGraphURIs", namedGraphURIs); } - } Modified: trunk/src/dl-learner/org/dllearner/kb/OWLFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2008-09-03 19:29:41 UTC (rev 1169) +++ trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2008-09-05 12:24:05 UTC (rev 1170) @@ -45,7 +45,7 @@ public class OWLFile extends KnowledgeSource { private URL url; - private OWLFileConfigurator configurator = new OWLFileConfigurator(); + private OWLFileConfigurator configurator ; public OWLFileConfigurator getOWLFileConfigurator(){ return configurator; } @@ -54,6 +54,9 @@ return "OWL file"; } + public OWLFile(){ + configurator = new OWLFileConfigurator(this); + } public static Collection<ConfigOption<?>> createConfigOptions() { @@ -67,19 +70,24 @@ */ @Override public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { + configurator.applyConfigEntry(entry); + + //postprocessing if (entry.getOptionName().equals("url")) { - String s = (String) entry.getValue(); try { - url = new URL(s); - // File f = new File(url.toURI()); - //if(!f.canRead()) - // throw new InvalidConfigOptionValueException(entry.getOption(), entry.getValue()); + url = new URL(configurator.getUrl()); } catch (MalformedURLException e) { - throw new InvalidConfigOptionValueException(entry.getOption(), entry.getValue(),"malformed URL " + s); - } //catch (URISyntaxException e) { - // TODO Auto-generated catch block - //e.printStackTrace(); - //} + throw new InvalidConfigOptionValueException(entry.getOption(), entry.getValue(),"malformed URL " + configurator.getUrl()); + } + +// File f = new File(url.toURI()); +//if(!f.canRead()) +// throw new InvalidConfigOptionValueException(entry.getOption(), entry.getValue()); +// String s = (String) entry.getValue(); +//catch (URISyntaxException e) { +//e.printStackTrace(); +//} + } } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-03 19:29:41 UTC (rev 1169) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-05 12:24:05 UTC (rev 1170) @@ -46,7 +46,6 @@ import org.dllearner.core.config.StringSetConfigOption; import org.dllearner.core.config.StringTupleListConfigOption; import org.dllearner.core.config.ConfigOption.Tags; -import org.dllearner.core.configuration.OWLFileConfigurator; import org.dllearner.core.configuration.SparqlKnowledgeSourceConfigurator; import org.dllearner.core.owl.KB; import org.dllearner.kb.aquisitors.SparqlTupleAquisitor; @@ -85,11 +84,16 @@ static final boolean debugUseImprovedTupleAquisitor = debug && false; //switches tupleaquisitor static final boolean debugExitAfterExtraction = debug && false; //switches sysex und rdf generation - private SparqlKnowledgeSourceConfigurator configurator = new SparqlKnowledgeSourceConfigurator(); + private SparqlKnowledgeSourceConfigurator configurator; + public SparqlKnowledgeSourceConfigurator getSparqlKnowledgeSourceConfigurator(){ return configurator; } +/*public SparqlKnowledgeSource (){ + this.configurator = new SparqlKnowledgeSourceConfigurator(this); + } +*/ private boolean useCache=true; // ConfigOptions public URL url; Modified: trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2008-09-03 19:29:41 UTC (rev 1169) +++ trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2008-09-05 12:24:05 UTC (rev 1170) @@ -20,13 +20,23 @@ package org.dllearner.scripts; import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; +import org.apache.commons.collections.map.LinkedMap; +import org.dllearner.core.Component; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningService; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.configuration.Configurator; @@ -51,256 +61,361 @@ private static final String TEMPLATE_DIR = "doc/template/"; - private static final String CLASSADDITION = "Configurator"; + private static final String CONFIGURATOR = "Configurator"; private static final SortedSet<String> configuratorImports = new TreeSet<String>(); - private static final SortedSet<String> configuratorMethods = new TreeSet<String>(); + private static final List<String> configuratorMethods = new ArrayList<String>(); + + Class<? extends Component> component; + String className; + String componentType; + List<String> body = new ArrayList<String>(); + List<String> vars = new ArrayList<String>(); + List<String> setters = new ArrayList<String>(); + List<String> getters = new ArrayList<String>(); + SortedSet<String> imports = new TreeSet<String>(); + Map<String,String> additionalMandatoryVars = new LinkedHashMap<String, String>(); + Map<String,String> mandatoryVars = new LinkedHashMap<String, String>(); + Map<String,String> varMap = new LinkedHashMap<String, String>(); + + List<ConfigOption<?>> mandatoryOptions = new LinkedList<ConfigOption<?>>(); + /** * @param args */ public static void main(String[] args) { + Files.backupDirectory(TARGET_DIR); + //System.exit(0); Files.deleteDir(TARGET_DIR); - + ComponentManager cm = ComponentManager.getInstance(); configuratorImports.add(ComponentManager.class.getCanonicalName()); - + configuratorImports.add(KnowledgeSource.class.getCanonicalName()); + configuratorImports.add(ReasonerComponent.class.getCanonicalName()); + configuratorImports.add(ReasoningService.class.getCanonicalName()); + configuratorImports.add(LearningProblem.class.getCanonicalName()); + configuratorImports.add(LearningAlgorithm.class.getCanonicalName()); for (Class<? extends KnowledgeSource> component : cm .getKnowledgeSources()) { String componentType = "knowledgeSource"; + + if (component.getSimpleName().equalsIgnoreCase( "OWLFile")) { configuratorImports.add(component.getCanonicalName()); - configuratorImports.add("org.dllearner.core.configuration."+component.getSimpleName()+CLASSADDITION); - make (component, componentType); + configuratorImports.add("org.dllearner.core.configuration."+component.getSimpleName()+CONFIGURATOR); + ConfigJavaGenerator c = new ConfigJavaGenerator(component, componentType); + + c.makeSubclasses(); + }if (component.getSimpleName().equalsIgnoreCase( "SparqlKnowledgeSource")) { configuratorImports.add(component.getCanonicalName()); - configuratorImports.add("org.dllearner.core.configuration."+component.getSimpleName()+CLASSADDITION); - make (component, componentType); + configuratorImports.add("org.dllearner.core.configuration."+component.getSimpleName()+CONFIGURATOR); + ConfigJavaGenerator c = new ConfigJavaGenerator(component, componentType); + c.makeSubclasses(); } } + for (Class<? extends ReasonerComponent> component : cm.getReasonerComponents()) { + + + if (component.getSimpleName().equalsIgnoreCase( + "FastInstanceChecker")) { + configuratorImports.add(component.getCanonicalName()); + configuratorImports.add("org.dllearner.core.configuration."+component.getSimpleName()+CONFIGURATOR); + + ConfigJavaGenerator c = new ConfigJavaGenerator(component, "reasoner"); + c.imports.add("org.dllearner.core.KnowledgeSource"); + c.additionalMandatoryVars.put("KnowledgeSource knowledgeSource","knowledgeSource"); + c.makeSubclasses(); + + } + + + } + + makeConfiguratorSuperClass(); System.out.println("Done"); } - public static void makeConfiguratorSuperClass(){ - StringBuffer current = new StringBuffer(); - current.append(HEADER+"\n"); - current.append("package org.dllearner.core.configuration;\n\n"); - for (String string : configuratorImports) { - current.append("import "+string+";\n"); - } - current.append("\n"+getClassComment()); - current.append("public class "+CLASSADDITION+" {\n\n"); - for (String string : configuratorMethods) { - current.append(string+"\n"); - } - current.append("}\n"); - Files.createFile(new File(TARGET_DIR + "/" + CLASSADDITION + ".java"), current.toString()); - } - - public static void make(Class<? extends KnowledgeSource> component, String componentType){ - StringBuffer current = new StringBuffer(); - StringBuffer vars = new StringBuffer(); - StringBuffer setters = new StringBuffer(); - StringBuffer getters = new StringBuffer(); - SortedSet<String> imports = new TreeSet<String>(); - String className = component.getSimpleName(); - List<ConfigOption<?>> mandatoryOptions = new LinkedList<ConfigOption<?>>(); - + public ConfigJavaGenerator (Class<? extends Component> component, String componentType){ + className = component.getSimpleName(); + this.component = component; + this.componentType = componentType; imports.add(component.getCanonicalName()); imports.add(ComponentManager.class.getCanonicalName()); imports.add(Configurator.class.getCanonicalName()); imports.add(ConfigEntry.class.getCanonicalName()); + + vars.add(className+" "+className+";\n"); + + } + + public void makeSubclasses(){ + + + //imports.add("import "+ConfigOption.class.getCanonicalName()+";"); + //vars.put(key, value) + //vars.add(className+" "+ className+";\n"); - vars.append(className+" "+ className+";\n"); - current.append(HEADER + "\n"); - current.append("package org.dllearner.core.configuration;\n\n"); for (ConfigOption<?> option : ComponentManager .getConfigOptions(component)) { + + String type = option.getValueTypeAsJavaString(); + String optionName = option.getName(); + String defaultValue = option.getDefaultValueInJava(); + String comment = option.getDescription(); + if(option.isMandatory()){ + mandatoryVars.put(type + " " + optionName , optionName); mandatoryOptions.add(option); configuratorImports.addAll(option.getJavaImports()); - } + } imports.addAll(option.getJavaImports()); - vars.append(getVarDef(option)); - setters.append(getSetter(option)); - getters.append(getGetter(option)); + vars.add(fillVariableDefTemplate(optionName, type, defaultValue)); + setters.add(fillSetterTemplate(className, comment, optionName, type)); + getters.add(fillGetterTemplate(comment, optionName, type)); // System.out.println(option); // componentOptions.get(component)) { } - for (String string : imports) { - current.append("import "+string+";\n"); - } - current.append("\n\n"); - current.append(getClassDefinition(className)); - current.append(vars); - current.append("\n\n"); - current.append(getMandatoryFunctions(className, componentType, mandatoryOptions)); - current.append("\n\n"); - current.append(makeApplyConfigEntry(ComponentManager.getConfigOptions(component))); - current.append("\n\n"); - current.append(setters+"\n\n"+getters+"\n\n"); - current.append("}\n"); - configuratorMethods.add(getSuperClassFunction(className, componentType, mandatoryOptions)); + + + body.add(expandCollection(vars, "", "", 0)); + body.add(fillConstructorTemplate(className)); + + body.add(makeGetInstanceForSubclass(className, componentType, + getAllCommentsForOptionList(mandatoryOptions))); + + body.add(makeApplyConfigEntryForOptionList(ComponentManager.getConfigOptions(component))); + + body.add(expandCollection(getters, "", "", 0)); + body.add(expandCollection(setters, "", "", 0)); + String ret = fillClassTemplate( + "org.dllearner.core.configuration", + expandCollection(imports, "import ", ";\n", 0), + className+CONFIGURATOR, + CONFIGURATOR, + expandCollection(body, "", "\n", 0) ); + + + + + + //configuratorMethods.add((className, componentType, mandatoryOptions)); + Files.createFile(new File(TARGET_DIR + "/" + className - + CLASSADDITION + ".java"), current.toString()); + + CONFIGURATOR + ".java"), ret); + + configuratorMethods.add( + makeSuperConfiguratorMethods( + className, + componentType, + getAllCommentsForOptionList(mandatoryOptions))); } - private static String getConstructor(String className){ - return ""; - } - public static String makeApplyConfigEntry(List<ConfigOption<?>> options){ + + public static String makeApplyConfigEntryForOptionList(List<ConfigOption<?>> options){ String ret ="@SuppressWarnings({ \"unchecked\" })\n" + "public <T> void applyConfigEntry(ConfigEntry<T> entry){\n"; ret+="String optionName = entry.getOptionName();\n"; //ret+="ConfigOption<T> option = entry.getOption();\n"; - if(!options.isEmpty()){ - ConfigOption<?> first = options.remove(0); - ret+="if (optionName.equals("+first.getName()+")){\n" + - ""+first.getName()+" = ("+rightType(first.getValueTypeAsJavaString())+") " + - " entry.getValue();\n"; - } + ret+="if(false){//empty block \n}"; + for (ConfigOption<?> option : options) { - ret+="}else if (optionName.equals("+option.getName()+")){\n"; + ret+="else if (optionName.equals(\""+option.getName()+"\")){\n"; ret+=""+option.getName()+" = ("+rightType(option.getValueTypeAsJavaString())+") " + - " entry.getValue();\n"; + " entry.getValue();\n}"; } - ret+="}\n}\n"; + ret+="\n}\n"; return ret; } - public static String rightType(String type){ - if(type.equals("int"))return "Integer"; - else if(type.equals("boolean"))return "Boolean"; - else return type; + + private static String getAllCommentsForOptionList(List<ConfigOption<?>> options){ + String ret = ""; + for (ConfigOption<?> option : options) { + ret+="* "+option.getName()+": "+option.getDescription()+"\n"; + } + return fillJavaDocComment(ret); } - private static String getMandatoryFunctionComment(List<ConfigOption<?>> options){ - String ret = "/**\n"; - for (ConfigOption<?> option : options) { - ret+=option.getDescription()+"\n"; + private String makeGetInstanceForSubclass(String className, String componentType, + String comments){ + Map<String, String> parametersWithType = new LinkedHashMap<String,String>(); + Map<String, String> parametersNoType = new LinkedHashMap<String,String>(); + String applyConf = ""; + parametersWithType.put("ComponentManager cm", "cm"); + parametersNoType.put(className+".class", className+".class"); + for (String s : additionalMandatoryVars.keySet()) { + parametersWithType.put(s, additionalMandatoryVars.get(s)); + parametersNoType.put(s, additionalMandatoryVars.get(s)); } - ret+="**/\n"; + for (String s : mandatoryVars.keySet()) { + parametersWithType.put(s, mandatoryVars.get(s)); + applyConf += fillApplyConfigEntry("component", mandatoryVars.get(s))+""; + } + + String parWithType = expandCollection(parametersWithType.keySet(), "", ", ", 2); + + String par = expandCollection(parametersNoType.values(), "", ", ", 2); + + //TODO + String ret = comments; + ret += "public static "+className+" get"+className+" ("+parWithType+" ) {\n"; + ret += className+" component = cm."+componentType+"(" +par+" );\n"; + ret += applyConf; + + ret+="return component;\n}\n"; return ret; } - private static String getMandatoryFunctions(String className, String componentType, List<ConfigOption<?>> options){ - String mandParametersWithType = getMandatoryParameters(options, true); - //String mandParametersNoType = getMandatoryParameters(options, false); - String mandFunctionBody = mandatoryFunctionBody(options); - String ret= getMandatoryFunctionComment(options); - ret += "public void setMandatoryOptions ("+mandParametersWithType+" ) {\n" + - ""+mandFunctionBody+"}\n"; + private String makeSuperConfiguratorMethods( + String className, String componentType, String comments){ - ret+= getMandatoryFunctionComment(options); - ret+= "public static "+className+" get"+className+" (ComponentManager cm, "+mandParametersWithType+" ) {\n" + - className+" component = cm."+componentType+"("+className+".class);\n"; - for (ConfigOption<?> option : options) { - ret+="cm.applyConfigEntry(component, \""+option.getName()+"\", "+option.getName()+");\n"; + Map<String, String> parametersWithType = new LinkedHashMap<String,String>(); + Map<String, String> parametersNoType = new LinkedHashMap<String,String>(); + String applyConf = ""; + parametersWithType.put("ComponentManager cm", "cm"); + parametersNoType.put(className+".class", className+".class"); + for (String s : additionalMandatoryVars.keySet()) { + parametersWithType.put(s, additionalMandatoryVars.get(s)); + parametersNoType.put(s, additionalMandatoryVars.get(s)); } + for (String s : mandatoryVars.keySet()) { + parametersWithType.put(s, mandatoryVars.get(s)); + applyConf += fillApplyConfigEntry("component", mandatoryVars.get(s))+""; + } - ret+="return component;\n}\n"; + String parWithType = expandCollection(parametersWithType.keySet(), "", ", ", 2); + + String par = expandCollection(parametersWithType.values(), "", ", ", 2); + + String ret = comments; + ret += "public static "+className+" get"+className+" ("+parWithType+" ) {\n" + + "return "+ className+CONFIGURATOR+".get"+className+"("+par+");\n}\n"; return ret; } - private static String getSuperClassFunction(String className, String componentType, List<ConfigOption<?>> options){ - String mandParametersWithType = getMandatoryParameters(options, true); - String mandParametersNoType = getMandatoryParameters(options, false); - //String mandFunctionBody = mandatoryFunctionBody(options); - String ret = getMandatoryFunctionComment(options); - ret += "public static "+className+" get"+className+" (ComponentManager cm, "+mandParametersWithType+" ) {\n" + - "return "+ className+CLASSADDITION+".get"+className+"(cm, "+mandParametersNoType+");\n}\n"; - return ret; + public static void makeConfiguratorSuperClass(){ + String ret= + fillClassTemplate( + "org.dllearner.core.configuration", + expandCollection(configuratorImports, "import ", ";\n",0), + CONFIGURATOR, + "", + expandCollection(configuratorMethods, "", "\n", 0) + ); + + + Files.createFile(new File(TARGET_DIR + "/" + CONFIGURATOR + ".java"), ret); } - public static String getMandatoryParameters (List<ConfigOption<?>> options, boolean includeType){ - if(options.isEmpty())return ""; - String ret = ""; - String type = ""; - for (ConfigOption<?> option : options) { - type = (includeType)?option.getValueTypeAsJavaString():""; - ret += type + " " + option.getName()+", "; - } - ret = ret.substring(0,ret.length()-2); - return ret; + + + private static String fillApplyConfigEntry(String className, String optionName){ + return "cm.applyConfigEntry("+className+", \""+optionName+"\", "+optionName+");\n"; } - private static String mandatoryFunctionBody(List<ConfigOption<?>> options){ - String ret = ""; - for (ConfigOption<?> option : options) { - ret += "this."+option.getName()+" = "+option.getName()+";\n"; - } - return ret; + private static String fillConstructorTemplate(String className){ + return "public "+className+CONFIGURATOR+" ("+className+" "+className+"){\n" + + "this."+className+" = "+className+";\n" + + "}\n"; } - private static String getVarDef(ConfigOption<?> option) { - return "private " + option.getValueTypeAsJavaString() + " " - + option.getName() + " = " + option.getDefaultValueInJava() + private static String fillVariableDefTemplate(String optionName, String type, String defaultValue) { + return "private " + type + " " + + optionName + " = " + defaultValue + ";\n"; } + + private static String fillJavaDocComment(String lines){ + return "/**\n"+lines+"**/\n"; + } - private static String getSetter(ConfigOption<?> option) { - String s = option.getName().substring(0, 1); - s = s.toUpperCase() + option.getName().substring(1); - String comment = "/**\n" + - "* "+option.getDescription()+"\n" + - "**/\n"; + + + private static String fillGetterTemplate( String comment, String optionName, String type) { + String ret = fillJavaDocComment (optionName+" : "+comment); + ret+= "public "+type+" get" + capitalize(optionName) + " ( ) {\n"; + ret+= "return this." + optionName+";\n"; + ret+= "}\n"; + return ret; + } + private static String fillSetterTemplate(String className, String comment, String optionName, String type ){ + String ret = fillJavaDocComment (optionName+" : "+comment); + ret += "public void set" + capitalize(optionName); + ret += " ( ComponentManager cm, " + type +" "+ optionName+") {\n"; + ret += fillApplyConfigEntry(className, optionName); + ret += "}\n" ; + return ret; + } + + + + private static String fillClassTemplate(String Package, String imports, String className, String Extends, String body){ + String ret = HEADER +"\n"; + ret += "package "+Package+";\n"; + ret += imports+"\n"; + ret += fillJavaDocComment("* automatically generated, do not edit manually\n"); + ret += "public class "+className+" "+((Extends.length()>0)?"extends "+Extends:"")+" {\n\n"; + ret += body+"\n"; + ret +="}\n"; + return ret; - return comment + "public void set" + s + " (" + option.getValueTypeAsJavaString() - + " "+option.getName()+") {\n" + - "this." + option.getName()+" = "+ option.getName()+ - ";\n" + - "}\n\n"; - } - private static String getGetter(ConfigOption<?> option) { - String s = option.getName().substring(0, 1); - s = s.toUpperCase() + option.getName().substring(1); - String comment = "/**\n" + - "* "+option.getDescription()+"\n" + - "* \n" + - "**/\n"; + + + private static String expandCollection (Collection<String> col, String before, String after, int removeChars){ + if(col.isEmpty())return ""; + String ret =""; + for (String string : col) { + ret+= before+string+after; + } + + if(removeChars==0){ + return ret; + }else { + return ret.substring(0, ret.length()-removeChars); + } + } - return comment + "public "+option.getValueTypeAsJavaString()+" get" + s + " ( ) {\n" + - "return this." + option.getName()+";\n" + - "}\n\n"; - + + + private static String capitalize(String s){ + String tmp = s.substring(0, 1); + return tmp.toUpperCase() + s.substring(1); } - - private static String getClassDefinition(String className) { - String ret = getClassComment() - + "public class " + className + CLASSADDITION + " extends Configurator {\n" + "\n"; - return ret; + + public static String rightType(String type){ + if(type.equals("int"))return "Integer"; + else if(type.equals("boolean"))return "Boolean"; + else return type; + } - private static String getClassComment(){ - return "" + "/**\n" - + "* automatically generated, do not edit manually\n" + "**/\n"; - } - private static String getHeader() { try { return Files.readFile(new File(HEADER_FILE)); Added: trunk/src/dl-learner/org/dllearner/scripts/NewSample.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/NewSample.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/NewSample.java 2008-09-05 12:24:05 UTC (rev 1170) @@ -0,0 +1,160 @@ +/** + * Copyright (C) 2007-2008, 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.io.IOException; +import java.text.DecimalFormat; +import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.FileAppender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.SimpleLayout; +import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.configuration.Configurator; +import org.dllearner.kb.OWLFile; +import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.utilities.Files; + +import com.jamonapi.MonitorFactory; + +/** + * Sample script showing how to use DL-Learner. Provides an entry point for tool + * developers. + * + * @author Sebastian Hellmann + * @author Jens Lehmann + * + */ +public class NewSample { + + private static Logger logger = Logger.getRootLogger(); + private static DecimalFormat df = new DecimalFormat(); + + public static void main(String[] args) throws IOException, ComponentInitException, + LearningProblemUnsupportedException { + + // create logger (configure this to your needs) + SimpleLayout layout = new SimpleLayout(); + FileAppender fileAppender = new FileAppender(layout, "log/sample_log.txt", false); + + ConsoleAppender consoleAppender = new ConsoleAppender(layout); + logger.removeAllAppenders(); + logger.addAppender(consoleAppender); + logger.addAppender(fileAppender); + logger.setLevel(Level.DEBUG); + + // OWL file containing background knowledge + String owlFile = "examples/trains/trains.owl"; + + // examples + SortedSet<String> posExamples = new TreeSet<String>(); + posExamples.add("http://example.com/foo#east1"); + posExamples.add("http://example.com/foo#east2"); + posExamples.add("http://example.com/foo#east3"); + posExamples.add("http://example.com/foo#east4"); + posExamples.add("http://example.com/foo#east5"); + + SortedSet<String> negExamples = new TreeSet<String>(); + negExamples.add("http://example.com/foo#west6"); + negExamples.add("http://example.com/foo#west7"); + negExamples.add("http://example.com/foo#west8"); + negExamples.add("http://example.com/foo#west9"); + negExamples.add("http://example.com/foo#west10"); + + List<EvaluatedDescription> results = learn(owlFile, posExamples, negExamples, 5); + int x = 0; + for (EvaluatedDescription ed : results) { + System.out.println("solution: " + x); + System.out.println(" description: \t" + + ed.getDescription().toManchesterSyntaxString(null, null)); + System.out.println(" accuracy: \t" + df.format(ed.getAccuracy() * 100) + "%"); + System.out.println(); + x++; + } + + Files.createFile(new File("log/jamon_sample.html"), MonitorFactory.getReport()); + } + + public static List<EvaluatedDescription> learn(String owlFile, SortedSet<String> posExamples, + SortedSet<String> negExamples, int maxNrOfResults) throws ComponentInitException, + LearningProblemUnsupportedException { + + logger.info("Start Learning with"); + logger.info("positive examples: \t" + posExamples.size()); + logger.info("negative examples: \t" + negExamples.size()); + + // the component manager is the central object to create + // and configure components + ComponentManager cm = ComponentManager.getInstance(); + + // knowledge source + //KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); + + String fileURL = new File(owlFile).toURI().toString(); + OWLFile ks = Configurator.getOWLFile(cm, fileURL); + + + // reasoner + ReasonerComponent r = cm.reasoner(FastInstanceChecker.class, ks); + ReasoningService rs = cm.reasoningService(r); + + + // learning problem + LearningProblem lp = cm.learningProblem(PosNegDefinitionLP.class, rs); + cm.applyConfigEntry(lp, "positiveExamples", posExamples); + cm.applyConfigEntry(lp, "negativeExamples", negExamples); + + // learning algorithm + LearningAlgorithm la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, rs); + cm.applyConfigEntry(la, "useAllConstructor", false); + cm.applyConfigEntry(la, "useExistsConstructor", true); + cm.applyConfigEntry(la, "useCardinalityRestrictions", false); + cm.applyConfigEntry(la, "useNegation", false); + cm.applyConfigEntry(la, "writeSearchTree", false); + cm.applyConfigEntry(la, "searchTreeFile", "log/searchTree.txt"); + cm.applyConfigEntry(la, "replaceSearchTree", true); + cm.applyConfigEntry(la, "noisePercentage", 0.0); + + // all components need to be initialised before they can be used + ks.init(); + r.init(); + lp.init(); + la.init(); + + // start learning algorithm + logger.debug("start learning"); + la.start(); + + return la.getCurrentlyBestEvaluatedDescriptions(maxNrOfResults); + } + +} Modified: trunk/src/dl-learner/org/dllearner/scripts/Sample.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/Sample.java 2008-09-03 19:29:41 UTC (rev 1169) +++ trunk/src/dl-learner/org/dllearner/scripts/Sample.java 2008-09-05 12:24:05 UTC (rev 1170) @@ -33,13 +33,11 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; -import org.dllearner.core.configuration.Configurator; import org.dllearner.kb.OWLFile; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.reasoning.FastInstanceChecker; @@ -121,9 +119,10 @@ //KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); String fileURL = new File(owlFile).toURI().toString(); - OWLFile ks = Configurator.getOWLFile(cm, fileURL); - //cm.applyConfigEntry(ks, "url", fileURL); - + OWLFile ks = cm.knowledgeSource(OWLFile.class); + cm.applyConfigEntry(ks, "url", fileURL); + + // reasoner ReasonerComponent r = cm.reasoner(FastInstanceChecker.class, ks); ReasoningService rs = cm.reasoningService(r); Modified: trunk/src/dl-learner/org/dllearner/utilities/Files.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Files.java 2008-09-03 19:29:41 UTC (rev 1169) +++ trunk/src/dl-learner/org/dllearner/utilities/Files.java 2008-09-05 12:24:05 UTC (rev 1170) @@ -156,5 +156,30 @@ Files.deleteFile(new File(dir+File.separator+files[i])); } } + + public static void backupDirect... [truncated message content] |
From: <ku...@us...> - 2008-09-03 19:29:57
|
Revision: 1169 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1169&view=rev Author: kurzum Date: 2008-09-03 19:29:41 +0000 (Wed, 03 Sep 2008) Log Message: ----------- started implementing genering java interface Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/Component.java 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/config/DoubleConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java trunk/src/dl-learner/org/dllearner/kb/OWLFile.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlEndpoint.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/scripts/AutoDetectFilter.java trunk/src/dl-learner/org/dllearner/scripts/Sample.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java trunk/src/dl-learner/org/dllearner/utilities/Files.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnOWLFile.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/configuration/ trunk/src/dl-learner/org/dllearner/core/configuration/Configurator.java trunk/src/dl-learner/org/dllearner/core/configuration/OWLFileConfigurator.java trunk/src/dl-learner/org/dllearner/core/configuration/SparqlKnowledgeSourceConfigurator.java trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java Modified: trunk/src/dl-learner/org/dllearner/core/Component.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Component.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/core/Component.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -24,6 +24,7 @@ import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.DoubleConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; /** @@ -34,6 +35,12 @@ */ public abstract class Component { +//protected Configurator configurator; + + //public Configurator<? extends Configurator> getConfigurator(){ + //return configurator; + //} + /** * Returns the name of this component. By default, "unnamed * component" is returned, but all implementations of components Modified: trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -19,20 +19,38 @@ */ package org.dllearner.core.config; + /** * @author Jens Lehmann * */ public class BooleanConfigOption extends ConfigOption<Boolean> { + + + public BooleanConfigOption(String name, String description, Boolean defaultValue, Tags... tags) { + super(name, description, defaultValue, tags); + + } + + 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) { - super(name, description, defaultValue); + /* (non-Javadoc) + * @see org.dllearner.core.config.ConfigOption#getValueTypeAsJavaString() + */ + @Override + public String getValueTypeAsJavaString(){ + return "boolean"; } - + /* * (non-Javadoc) * Modified: trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -19,6 +19,9 @@ */ package org.dllearner.core.config; +import java.util.SortedSet; +import java.util.TreeSet; + /** * This class represents a configuration option (without a value for the * option). @@ -38,16 +41,44 @@ protected String description; protected T defaultValue; + + public enum Tags {NORMAL, MANDATORY, REINIT} + + protected boolean mandatory = false; + protected boolean reinitNecessary = false; public ConfigOption(String name, String description) { this(name, description, null); } - - public ConfigOption(String name, String description, T defaultValue) { + + public ConfigOption(String name, String description, T defaultValue, Tags ...tags ) { this.name = name; this.description = description; this.defaultValue = defaultValue; + boolean normal = false; + for(Tags t:tags){ + if (t.equals(Tags.NORMAL)){ + normal =true; + } + } + for(Tags t:tags){ + if(normal){ + ;//DO Nothing + } + else if (t.equals(Tags.MANDATORY)){ + this.mandatory = true; + } else if (t.equals(Tags.REINIT)){ + this.reinitNecessary = true; + } + } + } + + public ConfigOption(String name, String description, T defaultValue ) { + this.name = name; + this.description = description; + this.defaultValue = defaultValue; + } public String getName() { return name; @@ -63,6 +94,37 @@ public T getDefaultValue() { return defaultValue; } + + /** + * @return the defaultValue + */ + public String getDefaultValueInJava() { + return defaultValue+""; + } + + /** + * says, if this option is mandatory for the component + * @return + */ + public boolean isMandatory() { + return mandatory; + } + + /** + * says, if this option requires that the componnent is reinitialized with init() + * @return + */ + public boolean isReinitNecessary() { + return reinitNecessary; + } + + /** + * gets java imports + * @return + */ + public SortedSet<String> getJavaImports() { + return new TreeSet<String>(); + } /** * Checks whether the object has the correct type to be used as a value for @@ -76,6 +138,8 @@ public abstract boolean checkType(Object object); public abstract boolean isValidValue(T value); + + public abstract String getValueTypeAsJavaString(); //TODO maybe change the function getClass in the options to get simpleName public String getAllowedValuesDescription() { Modified: trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -19,6 +19,8 @@ */ package org.dllearner.core.config; +import org.dllearner.core.config.ConfigOption.Tags; + /** * Represents a configuration option with values of type value. Similar to the * integer option a minimum and a maximum value can specified. @@ -31,14 +33,32 @@ private double lowerLimit = Double.MIN_VALUE; private double upperLimit = Double.MAX_VALUE; + + + + public DoubleConfigOption(String name, String description, Double defaultValue, Tags... tags) { + super(name, description, defaultValue, tags); + + } + + public DoubleConfigOption(String name, String description, Double defaultValue) { + super(name, description, defaultValue); + + } + public DoubleConfigOption(String name, String description) { super(name, description); + } - public DoubleConfigOption(String name, String description, double defaultValue) { - super(name, description, defaultValue); + /* (non-Javadoc) + * @see org.dllearner.core.config.ConfigOption#getValueTypeAsJavaString() + */ + @Override + public String getValueTypeAsJavaString(){ + return "double"; } - + /* * (non-Javadoc) * Modified: trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -19,6 +19,8 @@ */ package org.dllearner.core.config; +import org.dllearner.core.config.ConfigOption.Tags; + /** * A configuration option, which allows values of type integer. A minimum and * maximum value of the argument can optionally be specified. @@ -31,14 +33,31 @@ private int lowerLimit = Integer.MIN_VALUE; private int upperLimit = Integer.MAX_VALUE; + + + public IntegerConfigOption(String name, String description, Integer defaultValue, Tags... tags) { + super(name, description, defaultValue, tags); + + } + + public IntegerConfigOption(String name, String description, Integer defaultValue) { + super(name, description, defaultValue); + + } + public IntegerConfigOption(String name, String description) { super(name, description); + } - public IntegerConfigOption(String name, String description, int defaultValue) { - super(name, description, defaultValue); + /* (non-Javadoc) + * @see org.dllearner.core.config.ConfigOption#getValueTypeAsJavaString() + */ + @Override + public String getValueTypeAsJavaString(){ + return "int"; } - + /* * (non-Javadoc) * Modified: trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -23,6 +23,8 @@ import java.util.Set; import java.util.TreeSet; +import org.dllearner.core.config.ConfigOption.Tags; + /** * A configuration option, which allows values of type String. Optionally a set * of allowed strings can be set. By default all strings are allowed. @@ -32,16 +34,43 @@ */ public class StringConfigOption extends ConfigOption<String> { - private Set<String> allowedValues = new TreeSet<String>();; + private Set<String> allowedValues = new TreeSet<String>(); - public StringConfigOption(String name, String description) { - super(name, description); + + + + + public StringConfigOption(String name, String description, String defaultValue, Tags... tags) { + super(name, description, defaultValue, tags); + } public StringConfigOption(String name, String description, String defaultValue) { super(name, description, defaultValue); + } + public StringConfigOption(String name, String description) { + super(name, description); + + } + + /* (non-Javadoc) + * @see org.dllearner.core.config.ConfigOption#getDefaultValue() + */ + @Override + public String getDefaultValueInJava() { + return (defaultValue == null)?null:"\""+defaultValue+"\""; + } + + /* (non-Javadoc) + * @see org.dllearner.core.config.ConfigOption#getValueTypeAsJavaString() + */ + @Override + public String getValueTypeAsJavaString(){ + return "String"; + } + /* * (non-Javadoc) * Modified: trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -20,6 +20,8 @@ package org.dllearner.core.config; import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; /** * A set of strings. @@ -29,10 +31,42 @@ */ public class StringSetConfigOption extends ConfigOption<Set<String>> { + + + public StringSetConfigOption(String name, String description, Set<String> defaultValue, Tags... tags) { + super(name, description, defaultValue, tags); + + } + + public StringSetConfigOption(String name, String description, Set<String> defaultValue) { + super(name, description, defaultValue); + + } + public StringSetConfigOption(String name, String description) { super(name, description); + } + /* (non-Javadoc) + * @see org.dllearner.core.config.ConfigOption#getValueTypeAsJavaString() + */ + @Override + public String getValueTypeAsJavaString(){ + return "Set<String>"; + } + + /* (non-Javadoc) + * @see org.dllearner.core.config.ConfigOption#getJavaImports() + */ + @Override + public SortedSet<String> getJavaImports() { + SortedSet<String> ret = new TreeSet<String>(); + ret.add("java.util.Set"); + return ret; + + } + /* * (non-Javadoc) * Modified: trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -20,6 +20,8 @@ package org.dllearner.core.config; import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; import org.dllearner.utilities.datastructures.StringTuple; @@ -40,6 +42,25 @@ super(name, description, defaultValue); } + /* (non-Javadoc) + * @see org.dllearner.core.config.ConfigOption#getValueTypeAsJavaString() + */ + @Override + public String getValueTypeAsJavaString(){ + return "List<StringTuple>"; + } + + /* (non-Javadoc) + * @see org.dllearner.core.config.ConfigOption#getJavaImports() + */ + @Override + public SortedSet<String> getJavaImports() { + SortedSet<String> ret = new TreeSet<String>(); + ret.add("java.util.List"); + ret.add("org.dllearner.utilities.datastructures.StringTuple"); + return ret; + } + /* * (non-Javadoc) * Added: trunk/src/dl-learner/org/dllearner/core/configuration/Configurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configuration/Configurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configuration/Configurator.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2007-2008, 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.configuration; + +import java.util.Set; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.configuration.OWLFileConfigurator; +import org.dllearner.core.configuration.SparqlKnowledgeSourceConfigurator; +import org.dllearner.kb.OWLFile; +import org.dllearner.kb.sparql.SparqlKnowledgeSource; + +/** +* automatically generated, do not edit manually +**/ +public class Configurator { + +/** +URL pointing to the OWL file +**/ +public static OWLFile getOWLFile (ComponentManager cm, String url ) { +return OWLFileConfigurator.getOWLFile(cm, url); +} + +/** +relevant instances e.g. positive and negative examples in a learning problem +**/ +public static SparqlKnowledgeSource getSparqlKnowledgeSource (ComponentManager cm, Set<String> instances ) { +return SparqlKnowledgeSourceConfigurator.getSparqlKnowledgeSource(cm, instances); +} + +} Added: trunk/src/dl-learner/org/dllearner/core/configuration/OWLFileConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configuration/OWLFileConfigurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configuration/OWLFileConfigurator.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -0,0 +1,81 @@ +/** + * Copyright (C) 2007-2008, 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.configuration; + +import org.dllearner.core.ComponentManager; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.configuration.Configurator; +import org.dllearner.kb.OWLFile; + + +/** +* automatically generated, do not edit manually +**/ +public class OWLFileConfigurator extends Configurator { + +OWLFile OWLFile; +private String url = null; + + +/** +URL pointing to the OWL file +**/ +public void setMandatoryOptions (String url ) { +this.url = url; +} +/** +URL pointing to the OWL file +**/ +public static OWLFile getOWLFile (ComponentManager cm, String url ) { +OWLFile component = cm.knowledgeSource(OWLFile.class); +cm.applyConfigEntry(component, "url", url); +return component; +} + + +@SuppressWarnings({ "unchecked" }) +public <T> void applyConfigEntry(ConfigEntry<T> entry){ +String optionName = entry.getOptionName(); +if (optionName.equals(url)){ +url = (String) entry.getValue(); +} +} + + +/** +* URL pointing to the OWL file +**/ +public void setUrl (String url) { +this.url = url; +} + + + +/** +* URL pointing to the OWL file +* +**/ +public String getUrl ( ) { +return this.url; +} + + + +} Added: trunk/src/dl-learner/org/dllearner/core/configuration/SparqlKnowledgeSourceConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configuration/SparqlKnowledgeSourceConfigurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configuration/SparqlKnowledgeSourceConfigurator.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -0,0 +1,498 @@ +/** + * Copyright (C) 2007-2008, 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.configuration; + +import java.util.List; +import java.util.Set; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.configuration.Configurator; +import org.dllearner.kb.sparql.SparqlKnowledgeSource; +import org.dllearner.utilities.datastructures.StringTuple; + + +/** +* automatically generated, do not edit manually +**/ +public class SparqlKnowledgeSourceConfigurator extends Configurator { + +SparqlKnowledgeSource SparqlKnowledgeSource; +private String url = null; +private String cacheDir = null; +private Set<String> instances = null; +private int recursionDepth = 1; +private String predefinedFilter = null; +private String predefinedEndpoint = null; +private String predefinedManipulator = null; +private Set<String> predList = null; +private Set<String> objList = null; +private Set<String> classList = null; +private String format = "N-TRIPLES"; +private boolean dumpToFile = true; +private boolean convertNT2RDF = true; +private boolean useLits = true; +private boolean getAllSuperClasses = true; +private boolean useCache = true; +private List<StringTuple> replacePredicate = null; +private List<StringTuple> replaceObject = null; +private int breakSuperClassRetrievalAfter = 1000; +private boolean closeAfterRecursion = true; +private boolean getPropertyInformation = false; +private String verbosity = "warning"; +private Set<String> defaultGraphURIs = null; +private Set<String> namedGraphURIs = null; + + +/** +relevant instances e.g. positive and negative examples in a learning problem +**/ +public void setMandatoryOptions (Set<String> instances ) { +this.instances = instances; +} +/** +relevant instances e.g. positive and negative examples in a learning problem +**/ +public static SparqlKnowledgeSource getSparqlKnowledgeSource (ComponentManager cm, Set<String> instances ) { +SparqlKnowledgeSource component = cm.knowledgeSource(SparqlKnowledgeSource.class); +cm.applyConfigEntry(component, "instances", instances); +return component; +} + + +@SuppressWarnings({ "unchecked" }) +public <T> void applyConfigEntry(ConfigEntry<T> entry){ +String optionName = entry.getOptionName(); +if (optionName.equals(url)){ +url = (String) entry.getValue(); +}else if (optionName.equals(cacheDir)){ +cacheDir = (String) entry.getValue(); +}else if (optionName.equals(instances)){ +instances = (Set<String>) entry.getValue(); +}else if (optionName.equals(recursionDepth)){ +recursionDepth = (Integer) entry.getValue(); +}else if (optionName.equals(predefinedFilter)){ +predefinedFilter = (String) entry.getValue(); +}else if (optionName.equals(predefinedEndpoint)){ +predefinedEndpoint = (String) entry.getValue(); +}else if (optionName.equals(predefinedManipulator)){ +predefinedManipulator = (String) entry.getValue(); +}else if (optionName.equals(predList)){ +predList = (Set<String>) entry.getValue(); +}else if (optionName.equals(objList)){ +objList = (Set<String>) entry.getValue(); +}else if (optionName.equals(classList)){ +classList = (Set<String>) entry.getValue(); +}else if (optionName.equals(format)){ +format = (String) entry.getValue(); +}else if (optionName.equals(dumpToFile)){ +dumpToFile = (Boolean) entry.getValue(); +}else if (optionName.equals(convertNT2RDF)){ +convertNT2RDF = (Boolean) entry.getValue(); +}else if (optionName.equals(useLits)){ +useLits = (Boolean) entry.getValue(); +}else if (optionName.equals(getAllSuperClasses)){ +getAllSuperClasses = (Boolean) entry.getValue(); +}else if (optionName.equals(useCache)){ +useCache = (Boolean) entry.getValue(); +}else if (optionName.equals(replacePredicate)){ +replacePredicate = (List<StringTuple>) entry.getValue(); +}else if (optionName.equals(replaceObject)){ +replaceObject = (List<StringTuple>) entry.getValue(); +}else if (optionName.equals(breakSuperClassRetrievalAfter)){ +breakSuperClassRetrievalAfter = (Integer) entry.getValue(); +}else if (optionName.equals(closeAfterRecursion)){ +closeAfterRecursion = (Boolean) entry.getValue(); +}else if (optionName.equals(getPropertyInformation)){ +getPropertyInformation = (Boolean) entry.getValue(); +}else if (optionName.equals(verbosity)){ +verbosity = (String) entry.getValue(); +}else if (optionName.equals(defaultGraphURIs)){ +defaultGraphURIs = (Set<String>) entry.getValue(); +}else if (optionName.equals(namedGraphURIs)){ +namedGraphURIs = (Set<String>) entry.getValue(); +} +} + + +/** +* URL of SPARQL Endpoint +**/ +public void setUrl (String url) { +this.url = url; +} + +/** +* dir of cache +**/ +public void setCacheDir (String cacheDir) { +this.cacheDir = cacheDir; +} + +/** +* relevant instances e.g. positive and negative examples in a learning problem +**/ +public void setInstances (Set<String> instances) { +this.instances = instances; +} + +/** +* recursion depth of KB fragment selection +**/ +public void setRecursionDepth (int recursionDepth) { +this.recursionDepth = recursionDepth; +} + +/** +* the mode of the SPARQL Filter, use one of YAGO,SKOS,YAGOSKOS , YAGOSPECIALHIERARCHY, TEST +**/ +public void setPredefinedFilter (String predefinedFilter) { +this.predefinedFilter = predefinedFilter; +} + +/** +* the mode of the SPARQL Filter, use one of DBPEDIA, LOCAL, GOVTRACK, REVYU, MYOPENLINK, FACTBOOK +**/ +public void setPredefinedEndpoint (String predefinedEndpoint) { +this.predefinedEndpoint = predefinedEndpoint; +} + +/** +* the mode of the Manipulator, use one of STANDARD, DBPEDIA-NAVIGATOR +**/ +public void setPredefinedManipulator (String predefinedManipulator) { +this.predefinedManipulator = predefinedManipulator; +} + +/** +* list of all ignored roles +**/ +public void setPredList (Set<String> predList) { +this.predList = predList; +} + +/** +* list of all ignored objects +**/ +public void setObjList (Set<String> objList) { +this.objList = objList; +} + +/** +* list of all ignored classes +**/ +public void setClassList (Set<String> classList) { +this.classList = classList; +} + +/** +* N-TRIPLES or KB format +**/ +public void setFormat (String format) { +this.format = format; +} + +/** +* Specifies whether the extracted ontology is written to a file or not. +**/ +public void setDumpToFile (boolean dumpToFile) { +this.dumpToFile = dumpToFile; +} + +/** +* Specifies whether the extracted NTriples are converted to RDF and deleted. +**/ +public void setConvertNT2RDF (boolean convertNT2RDF) { +this.convertNT2RDF = convertNT2RDF; +} + +/** +* use Literals in SPARQL query +**/ +public void setUseLits (boolean useLits) { +this.useLits = useLits; +} + +/** +* If true then all superclasses are retrieved until the most general class (owl:Thing) is reached. +**/ +public void setGetAllSuperClasses (boolean getAllSuperClasses) { +this.getAllSuperClasses = getAllSuperClasses; +} + +/** +* If true a Cache is used +**/ +public void setUseCache (boolean useCache) { +this.useCache = useCache; +} + +/** +* rule for replacing predicates +**/ +public void setReplacePredicate (List<StringTuple> replacePredicate) { +this.replacePredicate = replacePredicate; +} + +/** +* rule for replacing predicates +**/ +public void setReplaceObject (List<StringTuple> replaceObject) { +this.replaceObject = replaceObject; +} + +/** +* stops a cyclic hierarchy after specified number of classes +**/ +public void setBreakSuperClassRetrievalAfter (int breakSuperClassRetrievalAfter) { +this.breakSuperClassRetrievalAfter = breakSuperClassRetrievalAfter; +} + +/** +* gets all classes for all instances +**/ +public void setCloseAfterRecursion (boolean closeAfterRecursion) { +this.closeAfterRecursion = closeAfterRecursion; +} + +/** +* gets all types for extracted ObjectProperties +**/ +public void setGetPropertyInformation (boolean getPropertyInformation) { +this.getPropertyInformation = getPropertyInformation; +} + +/** +* control verbosity of output for this component +**/ +public void setVerbosity (String verbosity) { +this.verbosity = verbosity; +} + +/** +* a list of all default Graph URIs +**/ +public void setDefaultGraphURIs (Set<String> defaultGraphURIs) { +this.defaultGraphURIs = defaultGraphURIs; +} + +/** +* a list of all named Graph URIs +**/ +public void setNamedGraphURIs (Set<String> namedGraphURIs) { +this.namedGraphURIs = namedGraphURIs; +} + + + +/** +* URL of SPARQL Endpoint +* +**/ +public String getUrl ( ) { +return this.url; +} + +/** +* dir of cache +* +**/ +public String getCacheDir ( ) { +return this.cacheDir; +} + +/** +* relevant instances e.g. positive and negative examples in a learning problem +* +**/ +public Set<String> getInstances ( ) { +return this.instances; +} + +/** +* recursion depth of KB fragment selection +* +**/ +public int getRecursionDepth ( ) { +return this.recursionDepth; +} + +/** +* the mode of the SPARQL Filter, use one of YAGO,SKOS,YAGOSKOS , YAGOSPECIALHIERARCHY, TEST +* +**/ +public String getPredefinedFilter ( ) { +return this.predefinedFilter; +} + +/** +* the mode of the SPARQL Filter, use one of DBPEDIA, LOCAL, GOVTRACK, REVYU, MYOPENLINK, FACTBOOK +* +**/ +public String getPredefinedEndpoint ( ) { +return this.predefinedEndpoint; +} + +/** +* the mode of the Manipulator, use one of STANDARD, DBPEDIA-NAVIGATOR +* +**/ +public String getPredefinedManipulator ( ) { +return this.predefinedManipulator; +} + +/** +* list of all ignored roles +* +**/ +public Set<String> getPredList ( ) { +return this.predList; +} + +/** +* list of all ignored objects +* +**/ +public Set<String> getObjList ( ) { +return this.objList; +} + +/** +* list of all ignored classes +* +**/ +public Set<String> getClassList ( ) { +return this.classList; +} + +/** +* N-TRIPLES or KB format +* +**/ +public String getFormat ( ) { +return this.format; +} + +/** +* Specifies whether the extracted ontology is written to a file or not. +* +**/ +public boolean getDumpToFile ( ) { +return this.dumpToFile; +} + +/** +* Specifies whether the extracted NTriples are converted to RDF and deleted. +* +**/ +public boolean getConvertNT2RDF ( ) { +return this.convertNT2RDF; +} + +/** +* use Literals in SPARQL query +* +**/ +public boolean getUseLits ( ) { +return this.useLits; +} + +/** +* If true then all superclasses are retrieved until the most general class (owl:Thing) is reached. +* +**/ +public boolean getGetAllSuperClasses ( ) { +return this.getAllSuperClasses; +} + +/** +* If true a Cache is used +* +**/ +public boolean getUseCache ( ) { +return this.useCache; +} + +/** +* rule for replacing predicates +* +**/ +public List<StringTuple> getReplacePredicate ( ) { +return this.replacePredicate; +} + +/** +* rule for replacing predicates +* +**/ +public List<StringTuple> getReplaceObject ( ) { +return this.replaceObject; +} + +/** +* stops a cyclic hierarchy after specified number of classes +* +**/ +public int getBreakSuperClassRetrievalAfter ( ) { +return this.breakSuperClassRetrievalAfter; +} + +/** +* gets all classes for all instances +* +**/ +public boolean getCloseAfterRecursion ( ) { +return this.closeAfterRecursion; +} + +/** +* gets all types for extracted ObjectProperties +* +**/ +public boolean getGetPropertyInformation ( ) { +return this.getPropertyInformation; +} + +/** +* control verbosity of output for this component +* +**/ +public String getVerbosity ( ) { +return this.verbosity; +} + +/** +* a list of all default Graph URIs +* +**/ +public Set<String> getDefaultGraphURIs ( ) { +return this.defaultGraphURIs; +} + +/** +* a list of all named Graph URIs +* +**/ +public Set<String> getNamedGraphURIs ( ) { +return this.namedGraphURIs; +} + + + +} Modified: trunk/src/dl-learner/org/dllearner/kb/OWLFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -33,6 +33,8 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringConfigOption; +import org.dllearner.core.config.ConfigOption.Tags; +import org.dllearner.core.configuration.OWLFileConfigurator; import org.dllearner.core.owl.KB; import org.dllearner.reasoning.OWLAPIDIGConverter; @@ -43,6 +45,10 @@ public class OWLFile extends KnowledgeSource { private URL url; + private OWLFileConfigurator configurator = new OWLFileConfigurator(); + public OWLFileConfigurator getOWLFileConfigurator(){ + return configurator; + } public static String getName() { return "OWL file"; @@ -52,7 +58,7 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); - options.add(new StringConfigOption("url", "URL pointing to the OWL file")); + options.add(new StringConfigOption("url", "URL pointing to the OWL file", null, Tags.MANDATORY )); return options; } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlEndpoint.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlEndpoint.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlEndpoint.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -72,27 +72,8 @@ public String toString(){ return getHTTPRequest(); } - /*public static SparqlEndpoint getEndpointByNumber(int i) { - - switch (i) { - case 0:break; - //should not be filled - case 1: - return dbpediaEndpoint(); - case 2: - return localJoseki(); - case 3: - return govTrack(); - case 4: - return revyu(); - case 5: - return myopenlink(); - case 6: - return worldFactBook(); - } - return null; - }*/ + public static SparqlEndpoint getEndpointByName(String name) { name = name.toUpperCase(); Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -45,6 +45,9 @@ import org.dllearner.core.config.StringConfigOption; import org.dllearner.core.config.StringSetConfigOption; import org.dllearner.core.config.StringTupleListConfigOption; +import org.dllearner.core.config.ConfigOption.Tags; +import org.dllearner.core.configuration.OWLFileConfigurator; +import org.dllearner.core.configuration.SparqlKnowledgeSourceConfigurator; import org.dllearner.core.owl.KB; import org.dllearner.kb.aquisitors.SparqlTupleAquisitor; import org.dllearner.kb.aquisitors.SparqlTupleAquisitorImproved; @@ -76,14 +79,16 @@ public class SparqlKnowledgeSource extends KnowledgeSource { - //DEFAULTS - static int recursionDepthDefault = 1; //RBC static final boolean debug = false; static final boolean debugUseImprovedTupleAquisitor = debug && false; //switches tupleaquisitor static final boolean debugExitAfterExtraction = debug && false; //switches sysex und rdf generation + private SparqlKnowledgeSourceConfigurator configurator = new SparqlKnowledgeSourceConfigurator(); + public SparqlKnowledgeSourceConfigurator getSparqlKnowledgeSourceConfigurator(){ + return configurator; + } private boolean useCache=true; // ConfigOptions @@ -91,7 +96,7 @@ // String host; private Set<String> instances = new HashSet<String>();; private URL dumpFile; - private int recursionDepth = recursionDepthDefault; + private int recursionDepth = 1; private String predefinedFilter = null; private String predefinedEndpoint = null; private String predefinedManipulator = null; @@ -155,9 +160,9 @@ // Endpoint")); options .add(new StringSetConfigOption("instances", - "relevant instances e.g. positive and negative examples in a learning problem")); + "relevant instances e.g. positive and negative examples in a learning problem",null,Tags.MANDATORY)); options.add(new IntegerConfigOption("recursionDepth", - "recursion depth of KB fragment selection", recursionDepthDefault)); + "recursion depth of KB fragment selection", 1, Tags.NORMAL)); options.add(new StringConfigOption("predefinedFilter", "the mode of the SPARQL Filter, use one of YAGO,SKOS,YAGOSKOS , YAGOSPECIALHIERARCHY, TEST")); options.add(new StringConfigOption("predefinedEndpoint", @@ -183,34 +188,34 @@ "Specifies whether the extracted NTriples are converted to RDF and deleted.", true)); options.add(new BooleanConfigOption("useLits", - "use Literals in SPARQL query")); + "use Literals in SPARQL query", true, Tags.NORMAL)); options .add(new BooleanConfigOption( "getAllSuperClasses", "If true then all superclasses are retrieved until the most general class (owl:Thing) is reached.", - true)); + true, Tags.NORMAL)); - options.add(new BooleanConfigOption("learnDomain", - "learns the Domain for a Role")); + //options.add(new BooleanConfigOption("learnDomain", + // "learns the Domain for a Role")); options.add(new BooleanConfigOption("useCache", - "If true a Cache is used")); - options.add(new BooleanConfigOption("learnRange", - "learns the Range for a Role")); - options.add(new StringConfigOption("role", - "role to learn Domain/Range from")); - options.add(new StringTupleListConfigOption("example", "example")); + "If true a Cache is used",true, Tags.NORMAL)); + //options.add(new BooleanConfigOption("learnRange", + // "learns the Range for a Role")); + //options.add(new StringConfigOption("role", + // "role to learn Domain/Range from")); + //options.add(new StringTupleListConfigOption("example", "example")); options.add(new StringTupleListConfigOption("replacePredicate", "rule for replacing predicates")); options.add(new StringTupleListConfigOption("replaceObject", "rule for replacing predicates")); options.add(new IntegerConfigOption("breakSuperClassRetrievalAfter", - "stops a cyclic hierarchy after specified number of classes")); - options.add(new IntegerConfigOption( - "numberOfInstancesUsedForRoleLearning", "")); + "stops a cyclic hierarchy after specified number of classes", 1000)); + //options.add(new IntegerConfigOption( + // "numberOfInstancesUsedForRoleLearning", "")); options.add(new BooleanConfigOption("closeAfterRecursion", - "gets all classes for all instances")); + "gets all classes for all instances", true)); options.add(new BooleanConfigOption("getPropertyInformation", - "gets all types for extracted ObjectProperties")); + "gets all types for extracted ObjectProperties", false)); options.add(CommonConfigOptions.getVerbosityOption()); options.add(new StringSetConfigOption("defaultGraphURIs", @@ -228,6 +233,7 @@ public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { String option = entry.getOptionName(); + if (option.equals("url")) { String s = (String) entry.getValue(); try { Modified: trunk/src/dl-learner/org/dllearner/scripts/AutoDetectFilter.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/AutoDetectFilter.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/scripts/AutoDetectFilter.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -1,4 +1,3 @@ - /** * Copyright (C) 2007-2008, Jens Lehmann * @@ -15,7 +14,9 @@ * 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; + * along with this program. If not, see <http://www.gnu.org/licenses/>. + **/ +package org.dllearner.scripts; import java.util.SortedSet; import java.util.TreeSet; Added: trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -0,0 +1,313 @@ +/** + * 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.scripts; + +import java.io.File; +import java.util.LinkedList; +import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.configuration.Configurator; +import org.dllearner.utilities.Files; + + +/** + * Collects information about all used configuration options and writes them + * into a file. This way the documentation is always in sync with the source + * code. + * + * @author Jens Lehmann + * + */ +public class ConfigJavaGenerator { + + private static final String TARGET_DIR = "src/dl-learner/org/dllearner/core/configuration"; + + private static final String HEADER_FILE = "doc/header.txt"; + + private static final String HEADER = getHeader(); + + private static final String TEMPLATE_DIR = "doc/template/"; + + private static final String CLASSADDITION = "Configurator"; + + private static final SortedSet<String> configuratorImports = new TreeSet<String>(); + private static final SortedSet<String> configuratorMethods = new TreeSet<String>(); + + /** + * @param args + */ + public static void main(String[] args) { + + Files.deleteDir(TARGET_DIR); + + ComponentManager cm = ComponentManager.getInstance(); + configuratorImports.add(ComponentManager.class.getCanonicalName()); + + + for (Class<? extends KnowledgeSource> component : cm + .getKnowledgeSources()) { + String componentType = "knowledgeSource"; + + if (component.getSimpleName().equalsIgnoreCase( + "OWLFile")) { + configuratorImports.add(component.getCanonicalName()); + configuratorImports.add("org.dllearner.core.configuration."+component.getSimpleName()+CLASSADDITION); + make (component, componentType); + }if (component.getSimpleName().equalsIgnoreCase( + "SparqlKnowledgeSource")) { + configuratorImports.add(component.getCanonicalName()); + configuratorImports.add("org.dllearner.core.configuration."+component.getSimpleName()+CLASSADDITION); + make (component, componentType); + } + + + } + + makeConfiguratorSuperClass(); + + System.out.println("Done"); + } + + public static void makeConfiguratorSuperClass(){ + StringBuffer current = new StringBuffer(); + current.append(HEADER+"\n"); + current.append("package org.dllearner.core.configuration;\n\n"); + for (String string : configuratorImports) { + current.append("import "+string+";\n"); + } + current.append("\n"+getClassComment()); + current.append("public class "+CLASSADDITION+" {\n\n"); + for (String string : configuratorMethods) { + current.append(string+"\n"); + } + current.append("}\n"); + Files.createFile(new File(TARGET_DIR + "/" + CLASSADDITION + ".java"), current.toString()); + } + + public static void make(Class<? extends KnowledgeSource> component, String componentType){ + StringBuffer current = new StringBuffer(); + StringBuffer vars = new StringBuffer(); + StringBuffer setters = new StringBuffer(); + StringBuffer getters = new StringBuffer(); + SortedSet<String> imports = new TreeSet<String>(); + String className = component.getSimpleName(); + List<ConfigOption<?>> mandatoryOptions = new LinkedList<ConfigOption<?>>(); + + imports.add(component.getCanonicalName()); + imports.add(ComponentManager.class.getCanonicalName()); + imports.add(Configurator.class.getCanonicalName()); + imports.add(ConfigEntry.class.getCanonicalName()); + //imports.add("import "+ConfigOption.class.getCanonicalName()+";"); + + vars.append(className+" "+ className+";\n"); + current.append(HEADER + "\n"); + current.append("package org.dllearner.core.configuration;\n\n"); + + + for (ConfigOption<?> option : ComponentManager + .getConfigOptions(component)) { + if(option.isMandatory()){ + mandatoryOptions.add(option); + configuratorImports.addAll(option.getJavaImports()); + } + + imports.addAll(option.getJavaImports()); + vars.append(getVarDef(option)); + setters.append(getSetter(option)); + getters.append(getGetter(option)); + // System.out.println(option); + // componentOptions.get(component)) { + + } + for (String string : imports) { + current.append("import "+string+";\n"); + } + current.append("\n\n"); + current.append(getClassDefinition(className)); + current.append(vars); + current.append("\n\n"); + current.append(getMandatoryFunctions(className, componentType, mandatoryOptions)); + current.append("\n\n"); + current.append(makeApplyConfigEntry(ComponentManager.getConfigOptions(component))); + current.append("\n\n"); + current.append(setters+"\n\n"+getters+"\n\n"); + current.append("}\n"); + + configuratorMethods.add(getSuperClassFunction(className, componentType, mandatoryOptions)); + + Files.createFile(new File(TARGET_DIR + "/" + className + + CLASSADDITION + ".java"), current.toString()); + } + + private static String getConstructor(String className){ + return ""; + } + + public static String makeApplyConfigEntry(List<ConfigOption<?>> options){ + String ret ="@SuppressWarnings({ \"unchecked\" })\n" + + "public <T> void applyConfigEntry(ConfigEntry<T> entry){\n"; + ret+="String optionName = entry.getOptionName();\n"; + //ret+="ConfigOption<T> option = entry.getOption();\n"; + if(!options.isEmpty()){ + ConfigOption<?> first = options.remove(0); + ret+="if (optionName.equals("+first.getName()+")){\n" + + ""+first.getName()+" = ("+rightType(first.getValueTypeAsJavaString())+") " + + " entry.getValue();\n"; + } + for (ConfigOption<?> option : options) { + ret+="}else if (optionName.equals("+option.getName()+")){\n"; + ret+=""+option.getName()+" = ("+rightType(option.getValueTypeAsJavaString())+") " + + " entry.getValue();\n"; + + } + ret+="}\n}\n"; + return ret; + } + + public static String rightType(String type){ + if(type.equals("int"))return "Integer"; + else if(type.equals("boolean"))return "Boolean"; + else return type; + + } + + private static String getMandatoryFunctionComment(List<ConfigOption<?>> options){ + String ret = "/**\n"; + for (ConfigOption<?> option : options) { + ret+=option.getDescription()+"\n"; + } + ret+="**/\n"; + return ret; + } + + private static String getMandatoryFunctions(String className, String componentType, List<ConfigOption<?>> options){ + String mandParametersWithType = getMandatoryParameters(options, true); + //String mandParametersNoType = getMandatoryParameters(options, false); + String mandFunctionBody = mandatoryFunctionBody(options); + String ret= getMandatoryFunctionComment(options); + ret += "public void setMandatoryOptions ("+mandParametersWithType+" ) {\n" + + ""+mandFunctionBody+"}\n"; + + ret+= getMandatoryFunctionComment(options); + ret+= "public static "+className+" get"+className+" (ComponentManager cm, "+mandParametersWithType+" ) {\n" + + className+" component = cm."+componentType+"("+className+".class);\n"; + for (ConfigOption<?> option : options) { + ret+="cm.applyConfigEntry(component, \""+option.getName()+"\", "+option.getName()+");\n"; + } + + ret+="return component;\n}\n"; + return ret; + } + + private static String getSuperClassFunction(String className, String componentType, List<ConfigOption<?>> options){ + String mandParametersWithType = getMandatoryParameters(options, true); + String mandParametersNoType = getMandatoryParameters(options, false); + //String mandFunctionBody = mandatoryFunctionBody(options); + String ret = getMandatoryFunctionComment(options); + ret += "public static "+className+" get"+className+" (ComponentManager cm, "+mandParametersWithType+" ) {\n" + + "return "+ className+CLASSADDITION+".get"+className+"(cm, "+mandParametersNoType+");\n}\n"; + return ret; + } + + public static String getMandatoryParameters (List<ConfigOption<?>> options, boolean includeType){ + if(options.isEmpty())return ""; + String ret = ""; + String type = ""; + for (ConfigOption<?> option : options) { + type = (includeType)?option.getValueTypeAsJavaString():""; + ret += type + " " + option.getName()+", "; + } + ret = ret.substring(0,ret.length()-2); + return ret; + } + + private static String mandatoryFunctionBody(List<ConfigOption<?>> options){ + String ret = ""; + for (ConfigOption<?> option : options) { + ret += "this."+option.getName()+" = "+option.getName()+";\n"; + } + return ret; + } + + + private static String getVarDef(ConfigOption<?> option) { + return "private " + option.getValueTypeAsJavaString() + " " + + option.getName() + " = " + option.getDefaultValueInJava() + + ";\n"; + + } + + private static String getSetter(ConfigOption<?> option) { + String s = option.getName().substring(0, 1); + s = s.toUpperCase() + option.getName().substring(1); + String comment = "/**\n" + + "* "+option.getDescription()+"\n" + + "**/\n"; + + return comment + "public void set" + s + " (" + option.getValueTypeAsJavaString() + + " "+option.getName()+") {\n" + + "this." + option.getName()+" = "+ option.getName()+ + ";\n" + + "}\n\n"; + + } + + private static String getGetter(ConfigOption<?> option) { + String s = option.getName().substring(0, 1); + s = s.toUpperCase() + option.getName().substring(1); + String comment = "/**\n" + + "* "+option.getDescription()+"\n" + + "* \n" + + "**/\n"; + + return comment + "public "+option.getValueTypeAsJavaString()+" get" + s + " ( ) {\n" + + "return this." + option.getName()+";\n" + + "}\n\n"; + + } + + private static String getClassDefinition(String className) { + String ret = getClassComment() + + "public class " + className + CLASSADDITION + " extends Configurator {\n" + "\n"; + return ret; + } + + private static String getClassComment(){ + return "" + "/**\n" + + "* automatically generated, do not edit manually\n" + "**/\n"; + + } + + private static String getHeader() { + try { + return Files.readFile(new File(HEADER_FILE)); + } catch (Exception e) { + e.printStackTrace(); + } + return ""; + } + +} Modified: trunk/src/dl-learner/org/dllearner/scripts/Sample.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/Sample.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/scripts/Sample.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -39,6 +39,7 @@ import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; +import org.dllearner.core.configuration.Configurator; import org.dllearner.kb.OWLFile; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.reasoning.FastInstanceChecker; @@ -117,9 +118,11 @@ ComponentManager cm = ComponentManager.getInstance(); // knowledge source - KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); + //KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); + String fileURL = new File(owlFile).toURI().toString(); - cm.applyConfigEntry(ks, "url", fileURL); + OWLFile ks = Configurator.getOWLFile(cm, fileURL); + //cm.applyConfigEntry(ks, "url", fileURL); // reasoner ReasonerComponent r = cm.reasoner(FastInstanceChecker.class, ks); Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -166,6 +166,7 @@ } + @SuppressWarnings("unchecked") private static void learnOriginal(NamedClass target, SortedSet<Individual> posExamples, SortedSet<Individual> negExamples) { List<EvaluatedDescription> conceptresults = new ArrayList<EvaluatedDescription>(); System.out.println("Starting to learn original"); @@ -194,7 +195,7 @@ } - private static LearnSPARQLConfiguration getConfForSparql(NamedClass c) { + public static LearnSPARQLConfiguration getConfForSparql(NamedClass c) { LearnSPARQLConfiguration lc = new LearnSPARQLConfiguration(); // lsc.sparqlEndpoint = sparqlTasks.getSparqlEndpoint(); Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -46,7 +46,6 @@ import org.dllearner.utilities.Files; import org.dllearner.utilities.JamonMonitorLogger; import org.dllearner.utilities.datastructures.SetManipulation; -import org.dllearner.utilities.examples.ExampleContainer; import org.dllearner.utilities.learn.ConfWriter; import org.dllearner.utilities.owl.ReasoningServiceFactory; import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; Modified: trunk/src/dl-learner/org/dllearner/utilities/Files.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Files.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/utilities/Files.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -31,7 +31,7 @@ * */ public class Files { - public static boolean debug = true; + public static boolean debug = false; /** * Reads in a file. @@ -133,5 +133,28 @@ } } } + + /** + * deletes all Files in the dir, does not delete the dir itself + * no warning is issued, use with care, cannot undelete files + * + * @param dir without a separator e.g. tmp/dirtodelete + */ + public static void deleteDir(String dir) { + + File f = new File(dir); + + if(debug){ + System.out.println(dir); + System.exit(0); + } + + String[] files = f.list(); + + for (int i = 0; i < files.length; i++) { + + Files.deleteFile(new File(dir+File.separator+files[i])); + } + } } Modified: trunk/src/dl-learner/org/dllearner/utilities/learn/LearnOWLFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/learn/LearnOWLFile.java 2008-09-02 21:08:59 UTC (rev 1168) +++ trunk/src/dl-learner/org/dllearner/utilities/learn/LearnOWLFile.java 2008-09-03 19:29:41 UTC (rev 1169) @@ -65,7 +65,7 @@ cm = ComponentManager.getInstance(); // knowledge source - KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); + OWLFile ks = cm.knowledgeSource(OWLFile.class); // reasoner ReasonerComponent r = cm.reasoner(Reasoner, ks); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-02 21:09:13
|
Revision: 1168 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1168&view=rev Author: kurzum Date: 2008-09-02 21:08:59 +0000 (Tue, 02 Sep 2008) Log Message: ----------- latest changes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/scripts/RDF2NT.java trunk/src/dl-learner/org/dllearner/utilities/examples/ExampleContainer.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-09-01 10:50:00 UTC (rev 1167) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-09-02 21:08:59 UTC (rev 1168) @@ -399,9 +399,7 @@ // we record when a more accurate node is found and log it if (bestNodeStable.getCovPosMinusCovNeg() < candidatesStable.last() .getCovPosMinusCovNeg()) { - String acc = (candidatesStable.last().getAccuracy(nrOfPositiveExamples, nrOfNegativeExamples))+""; - try { acc = acc.substring(2,6); - acc= acc.substring(0,2)+"."+acc.substring(3)+"%";}catch (Exception e) { } + String acc = new DecimalFormat( ".00%" ).format((candidatesStable.last().getAccuracy(nrOfPositiveExamples, nrOfNegativeExamples))); // no handling needed, it will just look ugly in the output logger.info("more accurate ("+acc+") node found: " + candidatesStable.last()); bestNodeStable = candidatesStable.last(); Added: trunk/src/dl-learner/org/dllearner/scripts/RDF2NT.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/RDF2NT.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/RDF2NT.java 2008-09-02 21:08:59 UTC (rev 1168) @@ -0,0 +1,84 @@ +/** + * Copyright (C) 2007-2008, 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.io.PrintStream; +public class RDF2NT { + + + public static void main(String[] args) { + + //String ontopath=args[0]; + String ontopath = "examples/semantic_bible/NTNcombined.owl"; + convertRDF2NT(ontopath); + + + } + + + /** + * converts .nt file to rdf, same file name, different ending + * @param ontopath path to nt file + */ + public static void convertRDF2NT(String inputOntopath){ + + try { + //URI inputURI = new File(inputOntopath).toURI(); + String outputOntopath=""; +// outputURI + String ending = inputOntopath.substring(inputOntopath.lastIndexOf(".") + 1); + outputOntopath = inputOntopath.replace("." + ending, ".nt" ); + //URI outputURI = new File(ontopath).toURI(); + /* + java jena.rdfcat (options|input)* + where options are: + -out N3 (aliases n, n3, ttl) + -out N-TRIPLE (aliases t, ntriple) + -out RDF/XML (aliases x, rdf, xml, rdfxml) + -out RDF/XML-ABBREV (default) + -in N3 (aliases n, n3, ttl) + -in N-TRIPLE (aliases t, ntriple) + -in RDF/XML (aliases x, rdf, xml, rdfxml) + -include + -noinclude (default) + + input is one of: + -n <filename> for n3 input (aliases -n3, -N3, -ttl) + -x <filename> for rdf/xml input (aliases -rdf, -xml, -rdfxml) + -t <filename> for n-triple input (aliases -ntriple) + or just a URL, a filename, or - for the standard input. + + */ + PrintStream p = new PrintStream(new File(outputOntopath)); + System.setOut(p); + jena.rdfcat.main(new String[]{"-x", inputOntopath,"-out", "ntriple"}); + p.flush(); + p.close(); + + + } + catch (Exception e) { + System.out.println("The ontology could not be created: " + e.getMessage()); + e.printStackTrace(); + } + + } + + } + + Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-09-01 10:50:00 UTC (rev 1167) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-09-02 21:08:59 UTC (rev 1168) @@ -46,6 +46,7 @@ import org.dllearner.utilities.Files; import org.dllearner.utilities.JamonMonitorLogger; import org.dllearner.utilities.datastructures.SetManipulation; +import org.dllearner.utilities.examples.ExampleContainer; import org.dllearner.utilities.learn.ConfWriter; import org.dllearner.utilities.owl.ReasoningServiceFactory; import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; @@ -124,6 +125,7 @@ ComponentManager cm =ComponentManager.getInstance(); try{ + for (File f : confs) { Cache.getDefaultCache().clearCache(); String fileContent = Files.readFile(f); @@ -143,6 +145,7 @@ LearningAlgorithm la = cm.getLiveLearningAlgorithms().remove(0); EvaluatedDescription onFragment =(la.getCurrentlyBestEvaluatedDescription()); + accFragment.addNumber(onFragment.getAccuracy()); dDepthFragment.addNumber((double)onFragment.getDescriptionDepth()); dLengthFragment.addNumber((double)onFragment.getDescriptionLength()); Added: trunk/src/dl-learner/org/dllearner/utilities/examples/ExampleContainer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/examples/ExampleContainer.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/utilities/examples/ExampleContainer.java 2008-09-02 21:08:59 UTC (rev 1168) @@ -0,0 +1,85 @@ +/** + * 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.utilities.examples; + +import java.util.SortedSet; +import java.util.TreeSet; + +import org.dllearner.core.owl.Individual; + +public class ExampleContainer implements Comparable<ExampleContainer>{ + + + private static SortedSet<ExampleContainer> exampleSets = new TreeSet<ExampleContainer>(); + + private SortedSet<Individual> positiveExamples = new TreeSet<Individual>(); + private SortedSet<Individual> negativeExamples = new TreeSet<Individual>(); + + + public ExampleContainer(SortedSet<Individual> positiveExamples, SortedSet<Individual> negativeExamples) { + super(); + this.positiveExamples = positiveExamples; + this.negativeExamples = negativeExamples; + } + + + public static boolean add(ExampleContainer e){ + return exampleSets.add(e); + } + + public int compareTo(ExampleContainer e){ + + if(getNegativeExamples().equals(e.getNegativeExamples()) + && + getPositiveExamples().equals(e.getPositiveExamples())){ + return 0; + } + + boolean equalPosSize = false; + boolean equalNegSize = false; + + if(getPositiveExamples().size() == e.getPositiveExamples().size()){ + equalPosSize = true; + } + if(getNegativeExamples().size() == e.getNegativeExamples().size()){ + equalNegSize = true; + } + + + if(equalPosSize && !equalNegSize)return 1; + if(equalNegSize && !equalPosSize)return -1; + if(!equalPosSize && !equalPosSize)return 1; + + + return 1; + + } + + public SortedSet<Individual> getNegativeExamples() { + return negativeExamples; + } + public SortedSet<Individual> getPositiveExamples() { + return positiveExamples; + } + + + + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-01 10:50:13
|
Revision: 1167 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1167&view=rev Author: kurzum Date: 2008-09-01 10:50:00 +0000 (Mon, 01 Sep 2008) Log Message: ----------- added additional option to get property information Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/extraction/Configuration.java trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java trunk/src/dl-learner/org/dllearner/kb/extraction/ObjectPropertyNode.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java trunk/src/dl-learner/org/dllearner/test/SparqlExtractionTest.java trunk/src/dl-learner/org/dllearner/utilities/datastructures/RDFNodeTuple.java Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/Configuration.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/Configuration.java 2008-09-01 00:30:08 UTC (rev 1166) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/Configuration.java 2008-09-01 10:50:00 UTC (rev 1167) @@ -40,6 +40,7 @@ private int recursiondepth; private boolean getAllSuperClasses = true; private boolean closeAfterRecursion = true; + private boolean getPropertyInformation = false; private int breakSuperClassesAfter = 200; @@ -49,6 +50,7 @@ int recursiondepth, boolean getAllSuperClasses, boolean closeAfterRecursion, + boolean getPropertyInformation, int breakSuperClassesAfter) { this.tupelAquisitor = tupelAquisitor; @@ -56,6 +58,7 @@ this.recursiondepth = recursiondepth; this.getAllSuperClasses = getAllSuperClasses; this.closeAfterRecursion = closeAfterRecursion; + this.getPropertyInformation = getPropertyInformation; this.breakSuperClassesAfter = breakSuperClassesAfter; @@ -97,6 +100,11 @@ } + public boolean isGetPropertyInformation() { + return getPropertyInformation; + } + + Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java 2008-09-01 00:30:08 UTC (rev 1166) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/ExtractionAlgorithm.java 2008-09-01 10:50:00 UTC (rev 1167) @@ -71,11 +71,11 @@ * @param typedSparqlQuery * @return */ - public Node expandNode(String uri, TupleAquisitor tupelAquisitor) { + public Node expandNode(String uri, TupleAquisitor tupleAquisitor) { SimpleClock sc = new SimpleClock(); - if(tupelAquisitor instanceof SparqlTupleAquisitorImproved){ - ((SparqlTupleAquisitorImproved)tupelAquisitor).removeFromCache(uri); + if(tupleAquisitor instanceof SparqlTupleAquisitorImproved){ + ((SparqlTupleAquisitorImproved)tupleAquisitor).removeFromCache(uri); } Node seedNode = getFirstNode(uri); @@ -97,8 +97,8 @@ logger.info("Expanding " + nextNode); // these are the new not expanded nodes // the others are saved in connection with the original node - tupelAquisitor.setNextTaskToNormal(); - tmp.addAll(nextNode.expand(tupelAquisitor, + tupleAquisitor.setNextTaskToNormal(); + tmp.addAll(nextNode.expand(tupleAquisitor, configuration.getManipulator())); //System.out.println(tmpVec); @@ -116,20 +116,29 @@ Monitor m = JamonMonitorLogger.getTimeMonitor(ExtractionAlgorithm.class, "TimeCloseAfterRecursion").start(); List<InstanceNode> l = getInstanceNodes(newNodes); logger.info("Getting classes for remaining instances: "+l.size() + " instances"); - tupelAquisitor.setNextTaskToClassesForInstances(); - collectNodes.addAll(expandCloseAfterRecursion(l, tupelAquisitor)); + tupleAquisitor.setNextTaskToClassesForInstances(); + collectNodes.addAll(expandCloseAfterRecursion(l, tupleAquisitor)); m.stop(); } // gets All Class Nodes and expands them further if (configuration.isGetAllSuperClasses()) { Monitor m = JamonMonitorLogger.getTimeMonitor(ExtractionAlgorithm.class, "TimeGetAllSuperClasses").start(); List<ClassNode> allClassNodes = getClassNodes(collectNodes); - tupelAquisitor.setNextTaskToClassInformation(); + tupleAquisitor.setNextTaskToClassInformation(); logger.info("Get all superclasses for "+allClassNodes.size() + " classes"); - expandAllSuperClassesOfANode(allClassNodes, tupelAquisitor); + expandAllSuperClassesOfANode(allClassNodes, tupleAquisitor); m.stop(); } + + if(configuration.isGetPropertyInformation() ){ + + List<ObjectPropertyNode> l = getObjectPropertyNodes(collectNodes); + for (ObjectPropertyNode node : l) { + node.expandProperties(tupleAquisitor, configuration.getManipulator()); + } + } + return seedNode; } @@ -216,5 +225,17 @@ } return retList; } + + public static List<ObjectPropertyNode> getObjectPropertyNodes(List<Node> l ){ + List<ObjectPropertyNode> properties = new ArrayList<ObjectPropertyNode>(); + for (Node node : l) { + if (node instanceof InstanceNode) { + properties.addAll(( (InstanceNode) node).getObjectProperties()); + + } + + } + return properties; + } } Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2008-09-01 00:30:08 UTC (rev 1166) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2008-09-01 10:50:00 UTC (rev 1167) @@ -133,6 +133,12 @@ return returnSet; } + public List<ObjectPropertyNode> getObjectProperties() { + return objectProperties; + } + + + } Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/ObjectPropertyNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/ObjectPropertyNode.java 2008-09-01 00:30:08 UTC (rev 1166) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/ObjectPropertyNode.java 2008-09-01 10:50:00 UTC (rev 1167) @@ -23,11 +23,14 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.apache.log4j.Logger; import org.dllearner.kb.aquisitors.TupleAquisitor; import org.dllearner.kb.manipulator.Manipulator; import org.dllearner.utilities.datastructures.RDFNodeTuple; import org.dllearner.utilities.owl.OWLVocabulary; + + /** * Property node, has connection to a and b part * @@ -37,18 +40,22 @@ public class ObjectPropertyNode extends Node { + public static Logger logger = Logger.getLogger(ObjectPropertyNode.class); + // the a and b part of a property private Node a; private Node b; // specialtypes like owl:symmetricproperty - private SortedSet<String> specialTypes; + private SortedSet<String> specialTypes = new TreeSet<String>(); + @SuppressWarnings("unused") + private SortedSet<RDFNodeTuple> propertyInformation = new TreeSet<RDFNodeTuple>(); public ObjectPropertyNode(String uri, Node a, Node b) { super(uri); // this.type = "property"; this.a = a; this.b = b; - this.specialTypes = new TreeSet<String>(); + } // Property Nodes are normally not expanded, @@ -65,11 +72,16 @@ SortedSet<RDFNodeTuple> newTypes = tupelAquisitor.getTupelForResource(uri); for (RDFNodeTuple tuple : newTypes) { try { - if (tuple.a.equals(OWLVocabulary.RDF_TYPE)) { + if (tuple.a.toString().equals(OWLVocabulary.RDF_TYPE)) { specialTypes.add(tuple.b.toString()); + }else if(tuple.b.isAnon()){ + logger.warn("blanknodes currently not implemented in this tuple aquisitor"); + }else{ + propertyInformation.add(tuple); + } } catch (Exception e) { - System.out.println(tuple); + logger.warn("resource "+uri+" with "+ tuple); e.printStackTrace(); } } @@ -96,6 +108,10 @@ s.add("<" + uri + "><" + OWLVocabulary.RDF_TYPE + "><" + one + ">."); } + + for (RDFNodeTuple one : propertyInformation) { + s.add(one.getNTriple(uri)); + } return s; } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-01 00:30:08 UTC (rev 1166) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-01 10:50:00 UTC (rev 1167) @@ -104,6 +104,7 @@ private boolean useLits = false; private boolean getAllSuperClasses = true; private boolean closeAfterRecursion = true; + private boolean getPropertyInformation = true; private int breakSuperClassRetrievalAfter = 1000; private String cacheDir = "cache"; // private boolean learnDomain = false; @@ -197,8 +198,6 @@ "learns the Range for a Role")); options.add(new StringConfigOption("role", "role to learn Domain/Range from")); - options.add(new StringConfigOption("blankNodeIdentifier", - "used to identify blanknodes in Tripels")); options.add(new StringTupleListConfigOption("example", "example")); options.add(new StringTupleListConfigOption("replacePredicate", "rule for replacing predicates")); @@ -210,6 +209,8 @@ "numberOfInstancesUsedForRoleLearning", "")); options.add(new BooleanConfigOption("closeAfterRecursion", "gets all classes for all instances")); + options.add(new BooleanConfigOption("getPropertyInformation", + "gets all types for extracted ObjectProperties")); options.add(CommonConfigOptions.getVerbosityOption()); options.add(new StringSetConfigOption("defaultGraphURIs", @@ -267,7 +268,9 @@ useCache = (Boolean) entry.getValue(); }else if (option.equals("getAllSuperClasses")) { getAllSuperClasses = (Boolean) entry.getValue(); - } else if (option.equals("example")) { + }else if (option.equals("getPropertyInformation")) { + getPropertyInformation = (Boolean) entry.getValue(); + }else if (option.equals("example")) { // System.out.println(entry.getValue()); } else if (option.equals("replacePredicate")) { replacePredicate = (LinkedList) entry.getValue(); @@ -317,6 +320,7 @@ recursionDepth, getAllSuperClasses, closeAfterRecursion, + getPropertyInformation, breakSuperClassRetrievalAfter); // give everything to the manager Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-09-01 00:30:08 UTC (rev 1166) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-09-01 10:50:00 UTC (rev 1167) @@ -20,12 +20,9 @@ package org.dllearner.scripts; import java.io.File; -import java.text.DecimalFormat; -import java.text.NumberFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Locale; import java.util.SortedSet; import java.util.StringTokenizer; import java.util.TreeSet; @@ -70,7 +67,7 @@ public static String normaldir = dir+"normal/"; public static String tmpFilename = dir + "tmp.conf"; - static File log = new File(dir+"results.txt"); + static File log = new File(dir+"results+prop.txt"); private static Stat accFragment = new Stat(); private static Stat accOnOnto = new Stat(); @@ -116,9 +113,8 @@ initLogger(); logger.warn("Start"); File tmpFile = new File(tmpFilename); - String del="\t"; - String cr="\n"; + List<File> confs = getFilesContaining(useSPARQL,"ten","all", "99+"); //analyzeFiles(confs); @@ -161,7 +157,7 @@ SortedSet<Individual> retrieved = reasoningService.retrieval(onFragment.getDescription()); EvaluatedDescription onOnto = reEvaluateDescription( onFragment.getDescription(), retrieved, posEx, negEx); - double reachedAccuracy = onOnto.getAccuracy(); + accOnOnto.addNumber(onOnto.getAccuracy()); int tmp = (int)(Math.floor(onOnto.getAccuracy()*100)); @@ -212,6 +208,7 @@ cm.freeAllComponents(); writeLog(); + }//end for }catch (Exception e) { e.printStackTrace(); @@ -226,8 +223,8 @@ public static void writeLog(){ String l = "\n\n\n*********************\n"; l +="COUNT: "+accFragment.getCount()+"\n"; - l +="ALL: "+fragHasAll+" BOOL: "+fragHasBooleanData+" NOT: "+fragHasNot+" <>=: "+fragHasNrRes+"\n"; - l +="ALL: "+wholeHasAll+" BOOL: "+wholeHasBooleanData+" NOT: "+wholeHasNot+" <>=: "+wholeHasNrRes+"\n"; + l +="FRAGMENT: ALL: "+fragHasAll+" BOOL: "+fragHasBooleanData+" NOT: "+fragHasNot+" <>=: "+fragHasNrRes+"\n"; + l +="WHOLE: ALL: "+wholeHasAll+" BOOL: "+wholeHasBooleanData+" NOT: "+wholeHasNot+" <>=: "+wholeHasNrRes+"\n"; l+="accFragment\t\t"+accFragment.getMeanAsPercentage()+" +-"+accFragment.getStandardDeviation()+"\n"; @@ -395,6 +392,8 @@ "sparql.recursionDepth = 2;\n"+ "sparql.useLits = true;\n"+ "sparql.predefinedEndpoint = \"LOCALJOSEKIBIBLE\";\n"+ + "sparql.getPropertyInformation = true;\n"+ + "refexamples.maxExecutionTimeInSeconds = "+sparqllMaxExecution+";\n"+ "import(\"lalala\",\"SPARQL\");\n"+ getCombinedOptions()+ ""; Modified: trunk/src/dl-learner/org/dllearner/test/SparqlExtractionTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/SparqlExtractionTest.java 2008-09-01 00:30:08 UTC (rev 1166) +++ trunk/src/dl-learner/org/dllearner/test/SparqlExtractionTest.java 2008-09-01 10:50:00 UTC (rev 1167) @@ -72,6 +72,7 @@ recursionDepth, true, true, + false, 200 ); m.useConfiguration(conf); Modified: trunk/src/dl-learner/org/dllearner/utilities/datastructures/RDFNodeTuple.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/datastructures/RDFNodeTuple.java 2008-09-01 00:30:08 UTC (rev 1166) +++ trunk/src/dl-learner/org/dllearner/utilities/datastructures/RDFNodeTuple.java 2008-09-01 10:50:00 UTC (rev 1167) @@ -19,6 +19,8 @@ */ package org.dllearner.utilities.datastructures; +import org.dllearner.kb.extraction.LiteralNode; + import com.hp.hpl.jena.rdf.model.RDFNode; /** @@ -59,5 +61,18 @@ public boolean bPartContains(String partOf) { return b.toString().contains(partOf); } + + public String getNTriple (String subject){ + String ret = "<"+subject+"> "; + ret+="<"+a.toString()+"> "; + if(b.isLiteral()){ + ret+=new LiteralNode(b).getNTripleForm(); + + }else{ + ret+="<"+b.toString()+"> "; + } + ret+="."; + return ret; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-01 00:30:18
|
Revision: 1166 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1166&view=rev Author: kurzum Date: 2008-09-01 00:30:08 +0000 (Mon, 01 Sep 2008) Log Message: ----------- servercommit Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-09-01 00:00:09 UTC (rev 1165) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-09-01 00:30:08 UTC (rev 1166) @@ -90,8 +90,18 @@ private static int normalMaxExecution = 500; private static int sparqllMaxExecution = 250; + private static boolean fragHasNot = false; + private static boolean fragHasAll = false; + private static boolean fragHasBooleanData = false; + private static boolean fragHasNrRes = false; + private static boolean wholeHasNot = false; + private static boolean wholeHasAll = false; + private static boolean wholeHasBooleanData = false; + private static boolean wholeHasNrRes = false; + + //private static Class usedReasoner = FastInstanceChecker.class; private static boolean useSPARQL = true; @@ -101,6 +111,7 @@ */ public static void main(String[] args) { SimpleClock total = new SimpleClock(); + Files.createFile(log, ""); initLogger(); logger.warn("Start"); @@ -140,6 +151,13 @@ dDepthFragment.addNumber((double)onFragment.getDescriptionDepth()); dLengthFragment.addNumber((double)onFragment.getDescriptionLength()); + String desc = onFragment.getDescription().toKBSyntaxString(); + + fragHasNot = ( fragHasNot || desc.contains("NOT")); + fragHasAll = (fragHasAll || desc.contains("ALL")); + fragHasBooleanData = (fragHasBooleanData || desc.contains("= FALSE")|| desc.contains("= TRUE")); + fragHasNrRes = (fragHasNrRes || desc.contains("<")|| desc.contains(">")); + SortedSet<Individual> retrieved = reasoningService.retrieval(onFragment.getDescription()); EvaluatedDescription onOnto = reEvaluateDescription( onFragment.getDescription(), retrieved, posEx, negEx); @@ -186,10 +204,14 @@ dDepthWhole.addNumber((double)normalOnOnto.getDescriptionDepth()); dLengthWhole.addNumber((double)normalOnOnto.getDescriptionLength()); + fragHasNot = ( fragHasNot || desc.contains("NOT")); + fragHasAll = (fragHasAll || desc.contains("ALL")); + fragHasBooleanData = (fragHasBooleanData || desc.contains("= FALSE")|| desc.contains("= TRUE")); + fragHasNrRes = (fragHasNrRes || desc.contains("<")|| desc.contains(">")); + cm.freeAllComponents(); + writeLog(); - //writeLog(); - //System.exit(0); }//end for }catch (Exception e) { e.printStackTrace(); @@ -202,8 +224,11 @@ } public static void writeLog(){ - String l = "a"; - l += + String l = "\n\n\n*********************\n"; + l +="COUNT: "+accFragment.getCount()+"\n"; + l +="ALL: "+fragHasAll+" BOOL: "+fragHasBooleanData+" NOT: "+fragHasNot+" <>=: "+fragHasNrRes+"\n"; + l +="ALL: "+wholeHasAll+" BOOL: "+wholeHasBooleanData+" NOT: "+wholeHasNot+" <>=: "+wholeHasNrRes+"\n"; + l+="accFragment\t\t"+accFragment.getMeanAsPercentage()+" +-"+accFragment.getStandardDeviation()+"\n"; l+="accOnOnto\t\t"+accOnOnto.getMeanAsPercentage()+" +-"+accOnOnto.getStandardDeviation()+"\n"; @@ -219,7 +244,7 @@ l+="dLengthWhole\t\t"+dLengthWhole.getMean()+" +-"+dLengthWhole.getStandardDeviation()+"\n"; l+="dDepthWhole\t\t"+dDepthWhole.getMean()+" +-"+dDepthWhole.getStandardDeviation()+"\n"; - Files.createFile(log, l); + Files.appendFile(log, l); // write JaMON report in HTML file File jamonlog = new File("sembib/jamon.html"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-09-01 00:00:23
|
Revision: 1165 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1165&view=rev Author: kurzum Date: 2008-09-01 00:00:09 +0000 (Mon, 01 Sep 2008) Log Message: ----------- servercommit Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2008-08-31 19:55:38 UTC (rev 1164) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2008-09-01 00:00:09 UTC (rev 1165) @@ -28,6 +28,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; @@ -687,8 +688,43 @@ return new LinkedList<Class<? extends LearningAlgorithm>>(learningAlgorithms); } + + /** + * Retuns a list of all instanciated and registered Components + * @return + */ public List<Component> getLiveComponents(){ return pool.getComponents(); } + + /** + * Retuns a list of all instanciated and registered LearningAlgorithm + * @return + */ + public List<LearningAlgorithm> getLiveLearningAlgorithms(){ + List<LearningAlgorithm> list = new ArrayList<LearningAlgorithm>(); + for (Component component : cm.getLiveComponents()) { + if(component instanceof LearningAlgorithm){ + list.add((LearningAlgorithm) component); + } + + } + return list; + } + + /** + * Retuns a list of all instanciated and registered KnowledgeSource + * @return + */ + public List<KnowledgeSource> getLiveKnowledgeSources(){ + List<KnowledgeSource> list = new ArrayList<KnowledgeSource>(); + for (Component component : cm.getLiveComponents()) { + if(component instanceof KnowledgeSource){ + list.add((KnowledgeSource) component); + } + + } + return list; + } } Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java 2008-08-31 19:55:38 UTC (rev 1164) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/Manager.java 2008-09-01 00:00:09 UTC (rev 1165) @@ -35,6 +35,7 @@ private Configuration configuration; private ExtractionAlgorithm extractionAlgorithm; + private int nrOfExtractedTriples = 0; private static Logger logger = Logger .getLogger(Manager.class); @@ -85,6 +86,7 @@ logger.info("Finished extracting, start conversion"); StringBuffer nt = new StringBuffer(100000); Object[] arr = tripleCollector.toArray(); + nrOfExtractedTriples = arr.length; for (int i = 0; i < arr.length; i++) { nt.append((String) arr[i] + "\n"); if (i % 1000 == 0) @@ -105,4 +107,8 @@ return configuration; } + public int getNrOfExtractedTriples() { + return nrOfExtractedTriples; + } + } \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-08-31 19:55:38 UTC (rev 1164) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-01 00:00:09 UTC (rev 1165) @@ -129,6 +129,9 @@ // received ontology as KB, the internal format private KB kb; + //mainly used for statistic + private int nrOfExtractedTriples = 0; + public static String getName() { return "SPARQL Endpoint"; } @@ -368,6 +371,7 @@ } catch (Exception e) { e.printStackTrace(); } + nrOfExtractedTriples = m.getNrOfExtractedTriples(); logger.info("SparqlModul: ****Finished " + totalTime.getAndSet("") ); if(debugExitAfterExtraction){ @@ -505,6 +509,10 @@ return cacheDir; } + public int getNrOfExtractedTriples() { + return nrOfExtractedTriples; + } + /*public static void main(String[] args) throws MalformedURLException { String query = "SELECT ?pred ?obj\n" + "WHERE {<http://dbpedia.org/resource/Leipzig> ?pred ?obj}"; Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 19:55:38 UTC (rev 1164) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-09-01 00:00:09 UTC (rev 1165) @@ -20,9 +20,12 @@ package org.dllearner.scripts; import java.io.File; +import java.text.DecimalFormat; +import java.text.NumberFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Locale; import java.util.SortedSet; import java.util.StringTokenizer; import java.util.TreeSet; @@ -36,20 +39,23 @@ import org.dllearner.core.Component; import org.dllearner.core.ComponentManager; import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.ReasoningService; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.kb.sparql.Cache; +import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.utilities.Files; import org.dllearner.utilities.JamonMonitorLogger; -import org.dllearner.utilities.StringFormatter; import org.dllearner.utilities.datastructures.SetManipulation; +import org.dllearner.utilities.learn.ConfWriter; import org.dllearner.utilities.owl.ReasoningServiceFactory; import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; import org.dllearner.utilities.statistics.SimpleClock; +import org.dllearner.utilities.statistics.Stat; -import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; public class SemanticBible2 { @@ -66,7 +72,26 @@ public static String tmpFilename = dir + "tmp.conf"; static File log = new File(dir+"results.txt"); + private static Stat accFragment = new Stat(); + private static Stat accOnOnto = new Stat(); + private static Stat accPosExOnOnto = new Stat(); + private static Stat accNegExOnOnto = new Stat(); + private static Stat timeFragment = new Stat(); + private static Stat nrOfExtractedTriples = new Stat(); + private static Stat dLengthFragment = new Stat(); + private static Stat dDepthFragment = new Stat(); + private static Stat timeWhole = new Stat(); + private static Stat accWhole = new Stat(); + private static Stat dLengthWhole = new Stat(); + private static Stat dDepthWhole = new Stat(); + + private static int normalNoisePercentage = 0; + private static int normalMaxExecution = 500; + private static int sparqllMaxExecution = 250; + + + //private static Class usedReasoner = FastInstanceChecker.class; private static boolean useSPARQL = true; @@ -76,6 +101,7 @@ */ public static void main(String[] args) { SimpleClock total = new SimpleClock(); + initLogger(); logger.warn("Start"); File tmpFile = new File(tmpFilename); @@ -84,86 +110,123 @@ List<File> confs = getFilesContaining(useSPARQL,"ten","all", "99+"); //analyzeFiles(confs); - Files.createFile(log, - "accOnFragment"+del+ - "accOnOnt"+del+ - "timeFragme"+del+ - "coveredPos"+del+ - "coveredNeg"+del+ - "timeWhole"+cr); + reasoningService = ReasoningServiceFactory.getReasoningService(ontologyPath, AvailableReasoners.OWLAPIREASONERPELLET); ComponentManager cm =ComponentManager.getInstance(); try{ for (File f : confs) { + Cache.getDefaultCache().clearCache(); String fileContent = Files.readFile(f); - - String logLine =""; SortedSet<Individual> posEx = SetManipulation.stringToInd(getIndividuals(fileContent, true)); SortedSet<Individual> negEx = SetManipulation.stringToInd(getIndividuals(fileContent, false)); StringBuffer sbuf = new StringBuffer(fileContent); - sbuf.insert(0, (useSPARQL)?sparqlOptions():normalOptions()); + sbuf.insert(0, sparqlOptions()); Files.createFile(tmpFile, sbuf.toString()); - //System.out.println(tmpFile.getCanonicalPath()); - Monitor m = JamonMonitorLogger.getTimeMonitor(SemanticBible2.class, "learn on fragment").start(); SimpleClock sc = new SimpleClock(); Start.main(new String[] { tmpFilename }); - long time = sc.getTime(); - m.stop(); - LearningAlgorithm la = getLearningAlgorithm(); + timeFragment.addNumber((double) sc.getTime()); + + LearningAlgorithm la = cm.getLiveLearningAlgorithms().remove(0); EvaluatedDescription onFragment =(la.getCurrentlyBestEvaluatedDescription()); - logLine += StringFormatter.doubleToPercent(onFragment.getAccuracy())+del; + accFragment.addNumber(onFragment.getAccuracy()); + dDepthFragment.addNumber((double)onFragment.getDescriptionDepth()); + dLengthFragment.addNumber((double)onFragment.getDescriptionLength()); + SortedSet<Individual> retrieved = reasoningService.retrieval(onFragment.getDescription()); EvaluatedDescription onOnto = reEvaluateDescription( onFragment.getDescription(), retrieved, posEx, negEx); - /*if(onOnto.getAccuracy()!=1.0){ - Files.appendFile(log, onOnto.toString()+"\n"); - System.out.println(onOnto.toString()); - - System.out.println(onOnto.getCoveredPositives()); - System.out.println(onOnto.getCoveredNegatives().size()); - - System.out.println(onOnto.getNotCoveredPositives()); - System.out.println(onOnto.getNotCoveredNegatives()); - System.out.println("p then n"); - System.out.println(posEx); - System.out.println(negEx); - System.out.println(retrieved); - System.out.println((5-onOnto.getCoveredNegatives().size())+""); - double n = (double) (5-onOnto.getCoveredNegatives().size()); - System.out.println(); - System.out.println((n/5.0)); - System.exit(0); - }*/ - logLine += StringFormatter.doubleToPercent(onOnto.getAccuracy())+del; - logLine += time+del; - logLine += StringFormatter.doubleToPercent((double)(onOnto.getCoveredPositives().size()/5))+del; + double reachedAccuracy = onOnto.getAccuracy(); + accOnOnto.addNumber(onOnto.getAccuracy()); + + int tmp = (int)(Math.floor(onOnto.getAccuracy()*100)); + normalNoisePercentage = 100-tmp; + accPosExOnOnto.addNumber((double)(onOnto.getCoveredPositives().size()/5)); double n = (double) (5-onOnto.getCoveredNegatives().size()); - logLine += StringFormatter.doubleToPercent(n/5.0)+del; - logLine += " size of retrieve: "+retrieved.size()+del; - logLine += f.toString(); - Files.appendFile(log, logLine+cr); - Cache.getDefaultCache().clearCache(); + accNegExOnOnto.addNumber(n/5.0); + SparqlKnowledgeSource s=null; + for(KnowledgeSource ks : cm.getLiveKnowledgeSources()){ + if (ks instanceof SparqlKnowledgeSource) { + s = (SparqlKnowledgeSource) ks; + } + } + + double nrtrip = (double)(s.getNrOfExtractedTriples()); + nrOfExtractedTriples.addNumber(nrtrip); + + + cm.freeAllComponents(); + /*************comp**/ + logger.warn("learning normal"); + + StringBuffer sbufNormal = new StringBuffer(); + sbufNormal.append(normalOptions()); + sbufNormal.append(ConfWriter.listExamples(true, posEx)); + sbufNormal.append(ConfWriter.listExamples(false, negEx)); + //sbufNormal.append(ConfWriter.) + Files.createFile(tmpFile, sbufNormal.toString()); + SimpleClock scNormal = new SimpleClock(); + Start.main(new String[] { tmpFilename }); + timeWhole.addNumber((double) scNormal.getTime()); + + la = cm.getLiveLearningAlgorithms().remove(0); + + EvaluatedDescription normalOnOnto =(la.getCurrentlyBestEvaluatedDescription()); + accWhole.addNumber(normalOnOnto.getAccuracy()); + dDepthWhole.addNumber((double)normalOnOnto.getDescriptionDepth()); + dLengthWhole.addNumber((double)normalOnOnto.getDescriptionLength()); + + cm.freeAllComponents(); + + //writeLog(); + //System.exit(0); }//end for }catch (Exception e) { e.printStackTrace(); } + writeLog(); total.printAndSet("Finished"); //logger.warn("Finished"); } + public static void writeLog(){ + String l = "a"; + l += + + l+="accFragment\t\t"+accFragment.getMeanAsPercentage()+" +-"+accFragment.getStandardDeviation()+"\n"; + l+="accOnOnto\t\t"+accOnOnto.getMeanAsPercentage()+" +-"+accOnOnto.getStandardDeviation()+"\n"; + l+="accPosExOnOnto\t\t"+accPosExOnOnto.getMeanAsPercentage()+" +-"+accPosExOnOnto.getStandardDeviation()+"\n"; + l+="accNegExOnOnto\t\t"+accNegExOnOnto.getMeanAsPercentage()+" +-"+accNegExOnOnto.getStandardDeviation()+"\n"; + l+="timeFragment\t\t"+timeFragment.getMean()+" +-"+timeFragment.getStandardDeviation()+"\n"; + l+="nrOfExtractedTriples\t\t"+nrOfExtractedTriples.getMean()+" +-"+nrOfExtractedTriples.getStandardDeviation()+"\n"; + l+="dLengthFragment\t\t"+dLengthFragment.getMean()+" +-"+dLengthFragment.getStandardDeviation()+"\n"; + l+="dDepthFragment\t\t"+dDepthFragment.getMean()+" +-"+dDepthFragment.getStandardDeviation()+"\n"; + + l+="timeWhole\t\t"+timeWhole.getMean()+" +-"+timeWhole.getStandardDeviation()+"\n"; + l+="accWhole\t\t"+accWhole.getMeanAsPercentage()+" +-"+accWhole.getStandardDeviation()+"\n"; + l+="dLengthWhole\t\t"+dLengthWhole.getMean()+" +-"+dLengthWhole.getStandardDeviation()+"\n"; + l+="dDepthWhole\t\t"+dDepthWhole.getMean()+" +-"+dDepthWhole.getStandardDeviation()+"\n"; + + Files.createFile(log, l); + +// write JaMON report in HTML file + File jamonlog = new File("sembib/jamon.html"); + Files.createFile(jamonlog, MonitorFactory.getReport()); + Files.appendFile(jamonlog, "<xmp>\n"+JamonMonitorLogger.getStringForAllSortedByLabel()); + } + public static EvaluatedDescription reEvaluateDescription(Description d, SortedSet<Individual> retrieved ,SortedSet<Individual> posEx ,SortedSet<Individual> negEx ){ SortedSet<Individual> PosAsPos = new TreeSet<Individual>(); SortedSet<Individual> PosAsNeg = new TreeSet<Individual>(); @@ -304,7 +367,7 @@ public static String sparqlOptions (){ String s="// SPARQL options\n"+ - "sparql.recursionDepth = 3;\n"+ + "sparql.recursionDepth = 2;\n"+ "sparql.useLits = true;\n"+ "sparql.predefinedEndpoint = \"LOCALJOSEKIBIBLE\";\n"+ "import(\"lalala\",\"SPARQL\");\n"+ @@ -316,7 +379,9 @@ public static String normalOptions (){ String s="\n"+ "import(\"NTNcombined.owl\");\n"+ - "refexamples.maxExecutionTimeInSeconds = 1800;\n"+ + "refexamples.maxExecutionTimeInSeconds = "+normalMaxExecution+";\n"; + + s+="refexamples.noisePercentage = "+normalNoisePercentage+";\n"+ getCombinedOptions()+ ""; return s; Modified: trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java 2008-08-31 19:55:38 UTC (rev 1164) +++ trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java 2008-09-01 00:00:09 UTC (rev 1165) @@ -20,6 +20,8 @@ package org.dllearner.utilities.statistics; +import java.text.DecimalFormat; + /** * Utility class for calculating the mean and standard deviation of a given set * of numbers. @@ -34,6 +36,8 @@ private double squareSum = 0; private double min = Double.MAX_VALUE; private double max = Double.MIN_NORMAL; + //used to give a good percentage output + private DecimalFormat df = new DecimalFormat( ".00%" ); /** * Add a number to this object. @@ -77,6 +81,15 @@ public double getMean() { return sum / count; } + + /** + * Gets the mean of all numbers as percentage + * *100 so 0.5678 -> "56.78%" + * @return + */ + public String getMeanAsPercentage(){ + return df.format(getMean()); + } /** * Gets the standard deviation of all numbers. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-08-31 19:55:45
|
Revision: 1164 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1164&view=rev Author: kurzum Date: 2008-08-31 19:55:38 +0000 (Sun, 31 Aug 2008) Log Message: ----------- server commit Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 19:54:28 UTC (rev 1163) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 19:55:38 UTC (rev 1164) @@ -159,8 +159,8 @@ e.printStackTrace(); } - - logger.warn("Finished"); + total.printAndSet("Finished"); + //logger.warn("Finished"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-08-31 19:54:35
|
Revision: 1163 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1163&view=rev Author: kurzum Date: 2008-08-31 19:54:28 +0000 (Sun, 31 Aug 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java 2008-08-31 19:09:56 UTC (rev 1162) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java 2008-08-31 19:54:28 UTC (rev 1163) @@ -50,7 +50,7 @@ private double percentPerLengthUnit; public ScoreTwoValued(Set<Individual> posAsPos, Set<Individual> posAsNeg, Set<Individual> negAsPos, Set<Individual> negAsNeg) { - this(0,0,posAsPos,posAsNeg,negAsPos,posAsPos); + this(0,0,posAsPos,posAsNeg,negAsPos,negAsNeg); } public ScoreTwoValued(int conceptLength, double percentPerLengthUnit, Set<Individual> posAsPos, Set<Individual> posAsNeg, Set<Individual> negAsPos, Set<Individual> negAsNeg) { Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 19:09:56 UTC (rev 1162) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 19:54:28 UTC (rev 1163) @@ -75,9 +75,9 @@ * @param args */ public static void main(String[] args) { - + SimpleClock total = new SimpleClock(); initLogger(); - logger.info("Start"); + logger.warn("Start"); File tmpFile = new File(tmpFilename); String del="\t"; String cr="\n"; @@ -123,23 +123,32 @@ SortedSet<Individual> retrieved = reasoningService.retrieval(onFragment.getDescription()); EvaluatedDescription onOnto = reEvaluateDescription( onFragment.getDescription(), retrieved, posEx, negEx); - if(onOnto.getAccuracy()!=1.0){ + /*if(onOnto.getAccuracy()!=1.0){ Files.appendFile(log, onOnto.toString()+"\n"); System.out.println(onOnto.toString()); + System.out.println(onOnto.getCoveredPositives()); - System.out.println(onOnto.getCoveredNegatives()); + System.out.println(onOnto.getCoveredNegatives().size()); + System.out.println(onOnto.getNotCoveredPositives()); System.out.println(onOnto.getNotCoveredNegatives()); + System.out.println("p then n"); System.out.println(posEx); System.out.println(negEx); System.out.println(retrieved); + System.out.println((5-onOnto.getCoveredNegatives().size())+""); + double n = (double) (5-onOnto.getCoveredNegatives().size()); + System.out.println(); + System.out.println((n/5.0)); System.exit(0); - } + }*/ logLine += StringFormatter.doubleToPercent(onOnto.getAccuracy())+del; logLine += time+del; logLine += StringFormatter.doubleToPercent((double)(onOnto.getCoveredPositives().size()/5))+del; - logLine += StringFormatter.doubleToPercent((double)((5-onOnto.getCoveredNegatives().size())/5))+del; - logLine += " size of retrieve: "+retrieved.size(); + double n = (double) (5-onOnto.getCoveredNegatives().size()); + logLine += StringFormatter.doubleToPercent(n/5.0)+del; + logLine += " size of retrieve: "+retrieved.size()+del; + logLine += f.toString(); Files.appendFile(log, logLine+cr); Cache.getDefaultCache().clearCache(); cm.freeAllComponents(); @@ -151,7 +160,7 @@ } - logger.info("Finished"); + logger.warn("Finished"); } @@ -165,18 +174,27 @@ PosAsPos.addAll(posEx); PosAsPos.retainAll(retrieved); + //System.out.println(PosAsPos); + // PosAsNeg PosAsNeg.addAll(posEx); PosAsNeg.removeAll(retrieved); + //System.out.println(PosAsNeg); + // NegAsPos NegAsPos.addAll(negEx); NegAsPos.retainAll(retrieved); + + //System.out.println(NegAsPos); // PosAsNeg NegAsNeg.addAll(negEx); NegAsNeg.removeAll(retrieved); + //System.out.println(NegAsNeg); + + return new EvaluatedDescription(d, PosAsPos, PosAsNeg, NegAsPos,NegAsNeg); } @@ -199,7 +217,7 @@ //SortedSet<File> ret = new TreeSet<File>(); String actualDir = (sparql)?sparqldir:normaldir; - logger.info(actualDir); + logger.warn(actualDir); File f = new File(actualDir); String[] files = f.list(); Arrays.sort(files); @@ -214,7 +232,7 @@ consistent++; ret.add(new File(actualDir+files[i])); if(ret.size() != consistent){ - logger.info("double file: "+files[i]); + logger.warn("double file: "+files[i]); } } @@ -224,10 +242,10 @@ e.printStackTrace(); } if(consistent != ret.size()){ - logger.info("double files"+consistent+"::"+ret.size()); + logger.warn("double files"+consistent+"::"+ret.size()); System.exit(0); }else{ - logger.info("all files different"); + logger.warn("all files different"); } return ret; } @@ -320,9 +338,9 @@ ConsoleAppender consoleAppender = new ConsoleAppender(layout); logger.removeAllAppenders(); - //logger.addAppender(consoleAppender); + logger.addAppender(consoleAppender); logger.addAppender(fileAppender); - logger.setLevel(Level.INFO); + logger.setLevel(Level.WARN); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-08-31 19:10:04
|
Revision: 1162 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1162&view=rev Author: kurzum Date: 2008-08-31 19:09:56 +0000 (Sun, 31 Aug 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 17:18:32 UTC (rev 1161) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 19:09:56 UTC (rev 1162) @@ -20,6 +20,8 @@ package org.dllearner.scripts; import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.SortedSet; import java.util.StringTokenizer; @@ -79,9 +81,9 @@ File tmpFile = new File(tmpFilename); String del="\t"; String cr="\n"; - int max = 100; - SortedSet<String> confs = getFilesContaining(useSPARQL,"ten","all", "99+"); - analyzeFiles(confs); + + List<File> confs = getFilesContaining(useSPARQL,"ten","all", "99+"); + //analyzeFiles(confs); Files.createFile(log, "accOnFragment"+del+ "accOnOnt"+del+ @@ -94,9 +96,11 @@ reasoningService = ReasoningServiceFactory.getReasoningService(ontologyPath, AvailableReasoners.OWLAPIREASONERPELLET); ComponentManager cm =ComponentManager.getInstance(); try{ - int i=0; - for (String fileContent : confs) { - if(i>= max) {break;}i++; + + for (File f : confs) { + String fileContent = Files.readFile(f); + + String logLine =""; SortedSet<Individual> posEx = SetManipulation.stringToInd(getIndividuals(fileContent, true)); SortedSet<Individual> negEx = SetManipulation.stringToInd(getIndividuals(fileContent, false)); @@ -121,6 +125,15 @@ onFragment.getDescription(), retrieved, posEx, negEx); if(onOnto.getAccuracy()!=1.0){ Files.appendFile(log, onOnto.toString()+"\n"); + System.out.println(onOnto.toString()); + System.out.println(onOnto.getCoveredPositives()); + System.out.println(onOnto.getCoveredNegatives()); + System.out.println(onOnto.getNotCoveredPositives()); + System.out.println(onOnto.getNotCoveredNegatives()); + System.out.println(posEx); + System.out.println(negEx); + System.out.println(retrieved); + System.exit(0); } logLine += StringFormatter.doubleToPercent(onOnto.getAccuracy())+del; logLine += time+del; @@ -181,14 +194,15 @@ return null; } - public static SortedSet<String> getFilesContaining(boolean sparql, String numExamples, String allOrEx, String acc) { - //List<File> ret = new ArrayList<File>(); - SortedSet<String> ret = new TreeSet<String>(); + public static List<File> getFilesContaining(boolean sparql, String numExamples, String allOrEx, String acc) { + List<File> ret = new ArrayList<File>(); + //SortedSet<File> ret = new TreeSet<File>(); String actualDir = (sparql)?sparqldir:normaldir; logger.info(actualDir); File f = new File(actualDir); String[] files = f.list(); + Arrays.sort(files); int consistent = 0; try{ for (int i = 0; i < files.length; i++) { @@ -198,7 +212,7 @@ && files[i].contains(acc) ){ consistent++; - ret.add(Files.readFile(new File(actualDir+files[i]))); + ret.add(new File(actualDir+files[i])); if(ret.size() != consistent){ logger.info("double file: "+files[i]); } @@ -218,16 +232,17 @@ return ret; } - public static void analyzeFiles(SortedSet<String> l){ + /*public static void analyzeFiles(List<File> l){ + SortedSet<String> differentIndividuals = new TreeSet<String>(); - for (String content : l) { + for ( content : l) { differentIndividuals.addAll(getIndividuals(content, true)); differentIndividuals.addAll(getIndividuals(content, false)); } System.out.println("found diff inds "+differentIndividuals.size()); - } + }*/ public static SortedSet<String> getIndividuals(String target, boolean posOrNeg){ if(posOrNeg){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-08-31 17:18:36
|
Revision: 1161 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1161&view=rev Author: kurzum Date: 2008-08-31 17:18:32 +0000 (Sun, 31 Aug 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-08-31 16:58:06 UTC (rev 1160) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-08-31 17:18:32 UTC (rev 1161) @@ -100,7 +100,7 @@ // private Set<String> classList; private String format = "N-TRIPLES"; private boolean dumpToFile = true; - private boolean convertNT2RDF = true ; + private boolean convertNT2RDF = false ; private boolean useLits = false; private boolean getAllSuperClasses = true; private boolean closeAfterRecursion = true; Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 16:58:06 UTC (rev 1160) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 17:18:32 UTC (rev 1161) @@ -45,6 +45,7 @@ import org.dllearner.utilities.datastructures.SetManipulation; import org.dllearner.utilities.owl.ReasoningServiceFactory; import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; +import org.dllearner.utilities.statistics.SimpleClock; import com.jamonapi.Monitor; @@ -81,7 +82,13 @@ int max = 100; SortedSet<String> confs = getFilesContaining(useSPARQL,"ten","all", "99+"); analyzeFiles(confs); - Files.createFile(log, "accOnFragment"+del+"accOnOnt"+del+"timeFragme"+del+"timeWhole"+cr); + Files.createFile(log, + "accOnFragment"+del+ + "accOnOnt"+del+ + "timeFragme"+del+ + "coveredPos"+del+ + "coveredNeg"+del+ + "timeWhole"+cr); reasoningService = ReasoningServiceFactory.getReasoningService(ontologyPath, AvailableReasoners.OWLAPIREASONERPELLET); @@ -101,7 +108,9 @@ //System.out.println(tmpFile.getCanonicalPath()); Monitor m = JamonMonitorLogger.getTimeMonitor(SemanticBible2.class, "learn on fragment").start(); + SimpleClock sc = new SimpleClock(); Start.main(new String[] { tmpFilename }); + long time = sc.getTime(); m.stop(); LearningAlgorithm la = getLearningAlgorithm(); @@ -110,10 +119,16 @@ SortedSet<Individual> retrieved = reasoningService.retrieval(onFragment.getDescription()); EvaluatedDescription onOnto = reEvaluateDescription( onFragment.getDescription(), retrieved, posEx, negEx); + if(onOnto.getAccuracy()!=1.0){ + Files.appendFile(log, onOnto.toString()+"\n"); + } logLine += StringFormatter.doubleToPercent(onOnto.getAccuracy())+del; - logLine += m.getTotal()+del+"missing instead size of retrieve: "+retrieved.size()+cr; - Files.appendFile(log, logLine); - //Cache.getDefaultCache().clearCache(); + logLine += time+del; + logLine += StringFormatter.doubleToPercent((double)(onOnto.getCoveredPositives().size()/5))+del; + logLine += StringFormatter.doubleToPercent((double)((5-onOnto.getCoveredNegatives().size())/5))+del; + logLine += " size of retrieve: "+retrieved.size(); + Files.appendFile(log, logLine+cr); + Cache.getDefaultCache().clearCache(); cm.freeAllComponents(); @@ -122,7 +137,9 @@ e.printStackTrace(); } + logger.info("Finished"); + } public static EvaluatedDescription reEvaluateDescription(Description d, SortedSet<Individual> retrieved ,SortedSet<Individual> posEx ,SortedSet<Individual> negEx ){ @@ -243,7 +260,7 @@ "refexamples.useNegation = true;\n"+ "refexamples.useCardinalityRestrictions = true;\n"+ "refexamples.guaranteeXgoodDescriptions = 1;\n"+ - "refexamples.maxExecutionTimeInSeconds = 100;\n"+ + "\n"+ "reasoner = owlAPI;\n"+ //"reasoner = fastInstanceChecker;\n"+ @@ -266,6 +283,7 @@ public static String normalOptions (){ String s="\n"+ "import(\"NTNcombined.owl\");\n"+ + "refexamples.maxExecutionTimeInSeconds = 1800;\n"+ getCombinedOptions()+ ""; return s; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-08-31 16:58:12
|
Revision: 1160 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1160&view=rev Author: kurzum Date: 2008-08-31 16:58:06 +0000 (Sun, 31 Aug 2008) Log Message: ----------- sc Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java trunk/src/dl-learner/org/dllearner/utilities/Files.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-08-31 15:20:00 UTC (rev 1159) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-08-31 16:58:06 UTC (rev 1160) @@ -31,6 +31,7 @@ import java.util.LinkedList; import org.apache.log4j.Logger; +import org.dllearner.utilities.Files; import org.dllearner.utilities.JamonMonitorLogger; import com.jamonapi.Monitor; @@ -121,9 +122,8 @@ this.cacheDir = cacheDir + File.separator; if (!new File(cacheDir).exists()) { - logger - .info("Created directory: " + cacheDir + " : " + new File(cacheDir).mkdir() - + "."); + Files.mkdir(cacheDir); + logger.info("Created directory: " + cacheDir + "."); } } @@ -179,10 +179,13 @@ FileInputStream fos = new FileInputStream(filename); ObjectInputStream o = new ObjectInputStream(fos); entry = (LinkedList<Object>) o.readObject(); + o.close(); } catch (IOException e) { e.printStackTrace(); + if(Files.debug){System.exit(0);} } catch (ClassNotFoundException e) { e.printStackTrace(); + if(Files.debug){System.exit(0);} } // TODO: we need to check whether the query is correct @@ -297,17 +300,12 @@ * and can thus still be used without creating a new Cache Object */ public void clearCache() { - try{ + File f = new File(cacheDir); String[] files = f.list(); for (int i = 0; i < files.length; i++) { - new File(cacheDir+"/"+files[i]).delete(); - } - }catch (Exception e) { - logger.warn("deleting cache failed"); - e.printStackTrace(); - } - + Files.deleteFile(new File(cacheDir+"/"+files[i])); + } } /** Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-08-31 15:20:00 UTC (rev 1159) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-08-31 16:58:06 UTC (rev 1160) @@ -21,13 +21,14 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.FileWriter; +import java.io.File; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import javax.xml.ws.http.HTTPException; import org.apache.log4j.Logger; +import org.dllearner.utilities.Files; import org.dllearner.utilities.JamonMonitorLogger; import com.hp.hpl.jena.query.ResultSet; @@ -240,7 +241,15 @@ * @param s the String to log */ public static void writeToSparqlLog(String s) { - try { + + if(!logDeletedOnStart){ + Files.createFile(new File("log/sparql.txt"),s+"\n"); + logDeletedOnStart = true; + }else{ + Files.appendFile(new File("log/sparql.txt"), s+"\n"); + } + + /*try { FileWriter fw = new FileWriter("log/sparql.txt", logDeletedOnStart); logDeletedOnStart = true; @@ -252,7 +261,7 @@ // make the e object more special FileNotFound?? //new File("log").mkdir(); //writeToSparqlLog(s); - } + }*/ } Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 15:20:00 UTC (rev 1159) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 16:58:06 UTC (rev 1160) @@ -116,6 +116,7 @@ //Cache.getDefaultCache().clearCache(); cm.freeAllComponents(); + }//end for }catch (Exception e) { e.printStackTrace(); Modified: trunk/src/dl-learner/org/dllearner/utilities/Files.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Files.java 2008-08-31 15:20:00 UTC (rev 1159) +++ trunk/src/dl-learner/org/dllearner/utilities/Files.java 2008-08-31 16:58:06 UTC (rev 1160) @@ -31,6 +31,7 @@ * */ public class Files { + public static boolean debug = true; /** * Reads in a file. @@ -40,15 +41,20 @@ * @return Content of the file. */ public static String readFile(File file) throws FileNotFoundException, IOException { + + BufferedReader br = new BufferedReader(new FileReader(file)); + StringBuffer content = new StringBuffer(); + try{ String line; - StringBuffer content = new StringBuffer(); + while ((line = br.readLine()) != null) { content.append(line); content.append(System.getProperty("line.separator")); } - br.close(); + }finally{br.close();} return content.toString(); + } /** @@ -61,16 +67,17 @@ * Content of the file. */ public static void createFile(File file, String content) { + try { FileOutputStream fos = new FileOutputStream(file); fos.write(content.getBytes()); - fos.close(); + } catch (FileNotFoundException e) { - // TODO Auto-generated catch block e.printStackTrace(); + if(debug){System.exit(0);} } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); + if(debug){System.exit(0);} } } @@ -88,11 +95,11 @@ fos.write(content.getBytes()); fos.close(); } catch (FileNotFoundException e) { - // TODO Auto-generated catch block e.printStackTrace(); + if(debug){System.exit(0);} } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); + if(debug){System.exit(0);} } } @@ -101,15 +108,27 @@ createFile(file, ""); }catch (Exception e) { e.printStackTrace(); + if(debug){System.exit(0);} } } + public static void deleteFile(File file) { + + try{ + file.delete(); + }catch (Exception e) { + e.printStackTrace(); + if(debug){System.exit(0);} + } + } + public static void mkdir(String dir){ if (!new File(dir).exists()) { try{ new File(dir).mkdir(); }catch (Exception e) { e.printStackTrace(); + if(debug){System.exit(0);} // this should not be a show stopper } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-08-31 15:20:09
|
Revision: 1159 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1159&view=rev Author: kurzum Date: 2008-08-31 15:20:00 +0000 (Sun, 31 Aug 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-08-31 15:15:00 UTC (rev 1158) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-08-31 15:20:00 UTC (rev 1159) @@ -183,7 +183,7 @@ e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); - } + } // TODO: we need to check whether the query is correct // (may not always be the case due to md5 hashing) Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 15:15:00 UTC (rev 1158) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 15:20:00 UTC (rev 1159) @@ -113,13 +113,13 @@ logLine += StringFormatter.doubleToPercent(onOnto.getAccuracy())+del; logLine += m.getTotal()+del+"missing instead size of retrieve: "+retrieved.size()+cr; Files.appendFile(log, logLine); - Cache.getDefaultCache().clearCache(); + //Cache.getDefaultCache().clearCache(); cm.freeAllComponents(); }//end for }catch (Exception e) { e.printStackTrace(); - System.exit(0); + } logger.info("Finished"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-08-31 15:15:08
|
Revision: 1158 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1158&view=rev Author: kurzum Date: 2008-08-31 15:15:00 +0000 (Sun, 31 Aug 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 15:06:24 UTC (rev 1157) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 15:15:00 UTC (rev 1158) @@ -119,6 +119,7 @@ }//end for }catch (Exception e) { e.printStackTrace(); + System.exit(0); } logger.info("Finished"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-08-31 15:06:30
|
Revision: 1157 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1157&view=rev Author: kurzum Date: 2008-08-31 15:06:24 +0000 (Sun, 31 Aug 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 15:04:13 UTC (rev 1156) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 15:06:24 UTC (rev 1157) @@ -38,13 +38,13 @@ import org.dllearner.core.ReasoningService; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; +import org.dllearner.kb.sparql.Cache; import org.dllearner.utilities.Files; import org.dllearner.utilities.JamonMonitorLogger; import org.dllearner.utilities.StringFormatter; import org.dllearner.utilities.datastructures.SetManipulation; import org.dllearner.utilities.owl.ReasoningServiceFactory; import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; -import org.dllearner.utilities.statistics.SimpleClock; import com.jamonapi.Monitor; @@ -113,9 +113,9 @@ logLine += StringFormatter.doubleToPercent(onOnto.getAccuracy())+del; logLine += m.getTotal()+del+"missing instead size of retrieve: "+retrieved.size()+cr; Files.appendFile(log, logLine); - //Cache.getDefaultCache().clearCache(); + Cache.getDefaultCache().clearCache(); cm.freeAllComponents(); - System.exit(0); + }//end for }catch (Exception e) { e.printStackTrace(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-08-31 15:04:23
|
Revision: 1156 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1156&view=rev Author: kurzum Date: 2008-08-31 15:04:13 +0000 (Sun, 31 Aug 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/utilities/StringFormatter.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-08-30 16:43:11 UTC (rev 1155) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-08-31 15:04:13 UTC (rev 1156) @@ -83,8 +83,8 @@ static final boolean debug = false; static final boolean debugUseImprovedTupleAquisitor = debug && false; //switches tupleaquisitor static final boolean debugExitAfterExtraction = debug && false; //switches sysex und rdf generation - static final boolean debugAdditionallyGenerateRDF = debug && true; + private boolean useCache=true; // ConfigOptions public URL url; @@ -100,6 +100,7 @@ // private Set<String> classList; private String format = "N-TRIPLES"; private boolean dumpToFile = true; + private boolean convertNT2RDF = true ; private boolean useLits = false; private boolean getAllSuperClasses = true; private boolean closeAfterRecursion = true; @@ -172,6 +173,11 @@ "dumpToFile", "Specifies whether the extracted ontology is written to a file or not.", true)); + options + .add(new BooleanConfigOption( + "convertNT2RDF", + "Specifies whether the extracted NTriples are converted to RDF and deleted.", + true)); options.add(new BooleanConfigOption("useLits", "use Literals in SPARQL query")); options @@ -250,6 +256,8 @@ format = (String) entry.getValue(); } else if (option.equals("dumpToFile")) { dumpToFile = (Boolean) entry.getValue(); + } else if (option.equals("convertNT2RDF")) { + convertNT2RDF = (Boolean) entry.getValue(); } else if (option.equals("useLits")) { useLits = (Boolean) entry.getValue(); } else if (option.equals("useCache")) { @@ -329,16 +337,21 @@ new File(basedir).mkdir(); } + File dump = new File(basedir + filename); + FileWriter fw = new FileWriter( - new File(basedir + filename), true); + dump , true); fw.write(ont); fw.flush(); fw.close(); - dumpFile = (new File(basedir + filename)).toURI().toURL(); - if(debugAdditionallyGenerateRDF){ - NT2RDF.convertNT2RDF(basedir + filename); - //System.exit(0); + + dumpFile = (dump).toURI().toURL(); + + + if(convertNT2RDF){ + NT2RDF.convertNT2RDF(dump.getAbsolutePath()); + } } catch (Exception e) { e.printStackTrace(); Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-30 16:43:11 UTC (rev 1155) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-31 15:04:13 UTC (rev 1156) @@ -20,35 +20,34 @@ package org.dllearner.scripts; import java.io.File; -import java.util.ArrayList; import java.util.List; +import java.util.SortedSet; +import java.util.StringTokenizer; +import java.util.TreeSet; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.FileAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; -import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; import org.dllearner.cli.Start; import org.dllearner.core.Component; import org.dllearner.core.ComponentManager; -import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.ReasoningService; -import org.dllearner.kb.extraction.ExtractionAlgorithm; -import org.dllearner.kb.extraction.Manager; -import org.dllearner.kb.sparql.Cache; -import org.dllearner.kb.sparql.SparqlKnowledgeSource; -import org.dllearner.kb.sparql.SparqlQuery; -import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Individual; import org.dllearner.utilities.Files; -import org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL; -import org.dllearner.utilities.examples.AutomaticPositiveExampleFinderOWL; -import org.dllearner.utilities.examples.AutomaticPositiveExampleFinderSPARQL; +import org.dllearner.utilities.JamonMonitorLogger; +import org.dllearner.utilities.StringFormatter; +import org.dllearner.utilities.datastructures.SetManipulation; import org.dllearner.utilities.owl.ReasoningServiceFactory; import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; import org.dllearner.utilities.statistics.SimpleClock; +import com.jamonapi.Monitor; + public class SemanticBible2 { private static ReasoningService reasoningService; @@ -62,7 +61,9 @@ public static String normaldir = dir+"normal/"; public static String tmpFilename = dir + "tmp.conf"; + static File log = new File(dir+"results.txt"); + //private static Class usedReasoner = FastInstanceChecker.class; private static boolean useSPARQL = true; @@ -71,90 +72,191 @@ * @param args */ public static void main(String[] args) { - SimpleClock sc = new SimpleClock(); + initLogger(); logger.info("Start"); File tmpFile = new File(tmpFilename); + String del="\t"; + String cr="\n"; + int max = 100; + SortedSet<String> confs = getFilesContaining(useSPARQL,"ten","all", "99+"); + analyzeFiles(confs); + Files.createFile(log, "accOnFragment"+del+"accOnOnt"+del+"timeFragme"+del+"timeWhole"+cr); - List<File> confs = getFilesContaining(useSPARQL,"ten","all", "99+"); - System.out.println(confs); - //reasoningService = ReasoningServiceFactory.getReasoningService(ontologyPath, AvailableReasoners.OWLAPIREASONERPELLET); + reasoningService = ReasoningServiceFactory.getReasoningService(ontologyPath, AvailableReasoners.OWLAPIREASONERPELLET); + ComponentManager cm =ComponentManager.getInstance(); try{ - for (File file : confs) { - System.out.println(file.getAbsolutePath()); - StringBuffer sbuf = new StringBuffer(Files.readFile( file)); + int i=0; + for (String fileContent : confs) { + if(i>= max) {break;}i++; + String logLine =""; + SortedSet<Individual> posEx = SetManipulation.stringToInd(getIndividuals(fileContent, true)); + SortedSet<Individual> negEx = SetManipulation.stringToInd(getIndividuals(fileContent, false)); + + + StringBuffer sbuf = new StringBuffer(fileContent); sbuf.insert(0, (useSPARQL)?sparqlOptions():normalOptions()); Files.createFile(tmpFile, sbuf.toString()); //System.out.println(tmpFile.getCanonicalPath()); + Monitor m = JamonMonitorLogger.getTimeMonitor(SemanticBible2.class, "learn on fragment").start(); Start.main(new String[] { tmpFilename }); - ComponentManager cm =ComponentManager.getInstance(); - List<Component> comp = cm.getLiveComponents(); - for (Component component : comp) { - System.out.println(component.getClass().getCanonicalName()); - if(component instanceof LearningAlgorithm){ - System.out.println("yyyy"); - System.exit(0); - } - - } + m.stop(); + LearningAlgorithm la = getLearningAlgorithm(); - - Cache.getDefaultCache().clearCache(); + EvaluatedDescription onFragment =(la.getCurrentlyBestEvaluatedDescription()); + logLine += StringFormatter.doubleToPercent(onFragment.getAccuracy())+del; + SortedSet<Individual> retrieved = reasoningService.retrieval(onFragment.getDescription()); + EvaluatedDescription onOnto = reEvaluateDescription( + onFragment.getDescription(), retrieved, posEx, negEx); + logLine += StringFormatter.doubleToPercent(onOnto.getAccuracy())+del; + logLine += m.getTotal()+del+"missing instead size of retrieve: "+retrieved.size()+cr; + Files.appendFile(log, logLine); + //Cache.getDefaultCache().clearCache(); cm.freeAllComponents(); System.exit(0); }//end for }catch (Exception e) { e.printStackTrace(); } - logger.info("finished"); + logger.info("Finished"); } - public static List<File> getFilesContaining(boolean sparql, String numExamples, String allOrEx, String acc) { - List<File> ret = new ArrayList<File>(); - try{ + public static EvaluatedDescription reEvaluateDescription(Description d, SortedSet<Individual> retrieved ,SortedSet<Individual> posEx ,SortedSet<Individual> negEx ){ + SortedSet<Individual> PosAsPos = new TreeSet<Individual>(); + SortedSet<Individual> PosAsNeg = new TreeSet<Individual>(); + SortedSet<Individual> NegAsPos = new TreeSet<Individual>(); + SortedSet<Individual> NegAsNeg = new TreeSet<Individual>(); + + // PosAsPos + PosAsPos.addAll(posEx); + PosAsPos.retainAll(retrieved); + + // PosAsNeg + PosAsNeg.addAll(posEx); + PosAsNeg.removeAll(retrieved); + + // NegAsPos + NegAsPos.addAll(negEx); + NegAsPos.retainAll(retrieved); + + // PosAsNeg + NegAsNeg.addAll(negEx); + NegAsNeg.removeAll(retrieved); + + return new EvaluatedDescription(d, PosAsPos, PosAsNeg, NegAsPos,NegAsNeg); + + } + + public static LearningAlgorithm getLearningAlgorithm(){ + ComponentManager cm =ComponentManager.getInstance(); + + List<Component> comp = cm.getLiveComponents(); + for (Component component : comp) { + if(component instanceof LearningAlgorithm){ + return (LearningAlgorithm) component; + } + + } + return null; + } + + public static SortedSet<String> getFilesContaining(boolean sparql, String numExamples, String allOrEx, String acc) { + //List<File> ret = new ArrayList<File>(); + SortedSet<String> ret = new TreeSet<String>(); + String actualDir = (sparql)?sparqldir:normaldir; - System.out.println(actualDir); + logger.info(actualDir); File f = new File(actualDir); String[] files = f.list(); - + int consistent = 0; + try{ for (int i = 0; i < files.length; i++) { - System.out.println(files[i]); - if( - files[i].contains(numExamples) + + if( files[i].contains(numExamples) && files[i].contains(allOrEx) && files[i].contains(acc) ){ - ret.add(new File(actualDir+files[i])); + consistent++; + ret.add(Files.readFile(new File(actualDir+files[i]))); + if(ret.size() != consistent){ + logger.info("double file: "+files[i]); + } } } }catch (Exception e) { - logger.warn("deleting cache failed"); + e.printStackTrace(); } + if(consistent != ret.size()){ + logger.info("double files"+consistent+"::"+ret.size()); + System.exit(0); + }else{ + logger.info("all files different"); + } return ret; } + public static void analyzeFiles(SortedSet<String> l){ + SortedSet<String> differentIndividuals = new TreeSet<String>(); + for (String content : l) { + differentIndividuals.addAll(getIndividuals(content, true)); + differentIndividuals.addAll(getIndividuals(content, false)); + + } + System.out.println("found diff inds "+differentIndividuals.size()); + + } + public static SortedSet<String> getIndividuals(String target, boolean posOrNeg){ + if(posOrNeg){ + return getAllStringsBetween(target, "+\"", "\""); + }else{ + return getAllStringsBetween(target, "-\"", "\""); + } + + } + + public static SortedSet<String> getAllStringsBetween(String target, String start, String end){ + SortedSet<String> ret = new TreeSet<String>(); + StringTokenizer st = new StringTokenizer(target,"\n"); + while(st.hasMoreElements()){ + String line = st.nextToken(); + if(line.contains(start)){ + line = line.substring(line.indexOf(start)+start.length()); + String current = line.substring(0,line.indexOf(end)); + ret.add(current); + } + } + + return ret; + } + + public static String getCombinedOptions(){ + String s="\n"+ + "algorithm = refexamples;\n"+ + "refexamples.useAllConstructor = true;\n"+ + "refexamples.useNegation = true;\n"+ + "refexamples.useCardinalityRestrictions = true;\n"+ + "refexamples.guaranteeXgoodDescriptions = 1;\n"+ + "refexamples.maxExecutionTimeInSeconds = 100;\n"+ + "\n"+ + "reasoner = owlAPI;\n"+ + //"reasoner = fastInstanceChecker;\n"+ + "owlAPIReasoner.reasonerType = pellet;\n\n"+ + ""; + return s; + } + public static String sparqlOptions (){ String s="// SPARQL options\n"+ "sparql.recursionDepth = 3;\n"+ "sparql.useLits = true;\n"+ "sparql.predefinedEndpoint = \"LOCALJOSEKIBIBLE\";\n"+ "import(\"lalala\",\"SPARQL\");\n"+ - - "algorithm = refexamples;\n"+ - "refexamples.useAllConstructor = true;\n"+ - "refexamples.useNegation = true;\n"+ - "refexamples.useCardinalityRestrictions = true;\n"+ - "refexamples.guaranteeXgoodDescriptions = 1;\n"+ - "refexamples.maxExecutionTimeInSeconds = 1;\n"+ - "\n"+ - "reasoner = owlAPI;\n"+ - //"reasoner = fastInstanceChecker;\n"+ - //"owlAPIReasoner.reasonerType = pellet;\n\n"; + getCombinedOptions()+ ""; return s; } @@ -162,15 +264,7 @@ public static String normalOptions (){ String s="\n"+ "import(\"NTNcombined.owl\");\n"+ - "algorithm = refexamples;\n"+ - "refexamples.useAllConstructor = true;\n"+ - "refexamples.useNegation = true;\n"+ - "refexamples.useCardinalityRestrictions = true;\n"+ - "refexamples.guaranteeXgoodDescriptions = 1;\n"+ - "\n"+ - "reasoner = owlAPI;\n"+ - //"reasoner = fastInstanceChecker;\n"+ - //"owlAPIReasoner.reasonerType = pellet;\n\n"; + getCombinedOptions()+ ""; return s; } @@ -191,9 +285,9 @@ ConsoleAppender consoleAppender = new ConsoleAppender(layout); logger.removeAllAppenders(); - logger.addAppender(consoleAppender); + //logger.addAppender(consoleAppender); logger.addAppender(fileAppender); - logger.setLevel(Level.DEBUG); + logger.setLevel(Level.INFO); } Added: trunk/src/dl-learner/org/dllearner/utilities/StringFormatter.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/StringFormatter.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/utilities/StringFormatter.java 2008-08-31 15:04:13 UTC (rev 1156) @@ -0,0 +1,26 @@ +package org.dllearner.utilities; + + +public class StringFormatter { + + + /** + * formats a double value between 0 and 100 to a percentage + * ex: 0.7854684 will be return 78.5% + * @param d + * @return + */ + public static String doubleToPercent(double d){ + if(d>1.0 || d<0.0)return "bad format: "+d; + else if(d == 1.0){ + return "100.0%"; + }else if(d == 0.0 ){ + return "0.0%"; + }else { + String acc = (d*100)+""; + acc = acc.substring(0,"55.5".length()); + return acc+"%"; + } + + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-08-30 16:43:14
|
Revision: 1155 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1155&view=rev Author: kurzum Date: 2008-08-30 16:43:11 +0000 (Sat, 30 Aug 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java trunk/src/dl-learner/org/dllearner/core/ComponentPool.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2008-08-30 16:09:06 UTC (rev 1154) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2008-08-30 16:43:11 UTC (rev 1155) @@ -686,5 +686,9 @@ public List<Class<? extends LearningAlgorithm>> getLearningAlgorithms() { return new LinkedList<Class<? extends LearningAlgorithm>>(learningAlgorithms); } + + public List<Component> getLiveComponents(){ + return pool.getComponents(); + } } Modified: trunk/src/dl-learner/org/dllearner/core/ComponentPool.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentPool.java 2008-08-30 16:09:06 UTC (rev 1154) +++ trunk/src/dl-learner/org/dllearner/core/ComponentPool.java 2008-08-30 16:43:11 UTC (rev 1155) @@ -113,5 +113,12 @@ lastValidConfigValue = new HashMap<Component, Map<ConfigOption<?>, Object>>(); configEntryHistory = new HashMap<Component, List<ConfigEntry<?>>>(); } + + /** + * @return + */ + public List<Component> getComponents(){ + return components; + } } Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-30 16:09:06 UTC (rev 1154) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-30 16:43:11 UTC (rev 1155) @@ -30,7 +30,10 @@ import org.apache.log4j.SimpleLayout; import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; import org.dllearner.cli.Start; +import org.dllearner.core.Component; +import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.ReasoningService; import org.dllearner.kb.extraction.ExtractionAlgorithm; import org.dllearner.kb.extraction.Manager; @@ -60,9 +63,9 @@ public static String tmpFilename = dir + "tmp.conf"; - private static Class usedReasoner = FastInstanceChecker.class; + //private static Class usedReasoner = FastInstanceChecker.class; - private static boolean useSPARQL = false; + private static boolean useSPARQL = true; /** * @param args @@ -73,9 +76,10 @@ logger.info("Start"); File tmpFile = new File(tmpFilename); - List<File> confs = getFilesContaining(useSPARQL,"thirty","exists", "75+"); + List<File> confs = getFilesContaining(useSPARQL,"ten","all", "99+"); + System.out.println(confs); + //reasoningService = ReasoningServiceFactory.getReasoningService(ontologyPath, AvailableReasoners.OWLAPIREASONERPELLET); - //reasoningService = ReasoningServiceFactory.getReasoningService(ontologyPath, AvailableReasoners.OWLAPIREASONERPELLET); try{ for (File file : confs) { System.out.println(file.getAbsolutePath()); @@ -85,9 +89,22 @@ //System.out.println(tmpFile.getCanonicalPath()); Start.main(new String[] { tmpFilename }); + ComponentManager cm =ComponentManager.getInstance(); + List<Component> comp = cm.getLiveComponents(); + for (Component component : comp) { + System.out.println(component.getClass().getCanonicalName()); + if(component instanceof LearningAlgorithm){ + System.out.println("yyyy"); + System.exit(0); + } + + } + + Cache.getDefaultCache().clearCache(); + cm.freeAllComponents(); System.exit(0); - } + }//end for }catch (Exception e) { e.printStackTrace(); } @@ -98,9 +115,12 @@ List<File> ret = new ArrayList<File>(); try{ String actualDir = (sparql)?sparqldir:normaldir; + System.out.println(actualDir); File f = new File(actualDir); String[] files = f.list(); + for (int i = 0; i < files.length; i++) { + System.out.println(files[i]); if( files[i].contains(numExamples) && files[i].contains(allOrEx) @@ -130,9 +150,10 @@ "refexamples.useNegation = true;\n"+ "refexamples.useCardinalityRestrictions = true;\n"+ "refexamples.guaranteeXgoodDescriptions = 1;\n"+ + "refexamples.maxExecutionTimeInSeconds = 1;\n"+ "\n"+ - //"reasoner = owlAPI;\n"+ - "reasoner = fastInstanceChecker;\n"+ + "reasoner = owlAPI;\n"+ + //"reasoner = fastInstanceChecker;\n"+ //"owlAPIReasoner.reasonerType = pellet;\n\n"; ""; return s; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-08-30 16:09:10
|
Revision: 1154 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1154&view=rev Author: kurzum Date: 2008-08-30 16:09:06 +0000 (Sat, 30 Aug 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java Modified: trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-08-30 14:31:26 UTC (rev 1153) +++ trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-08-30 16:09:06 UTC (rev 1154) @@ -55,8 +55,8 @@ //private static Class usedReasoner = FastInstanceChecker.class; private static Class usedReasoner = OWLAPIReasoner.class; - private static boolean allOrExists = false; - private static boolean tenORthirty = false; + private static boolean allOrExists = true; + private static boolean tenORthirty = true; private static boolean sparql = true; @@ -89,7 +89,7 @@ int count = 1; while(count<10000){ - if((count%5)==0){ + /*if((count%5)==0){ //System.out.println(count+" "+allOrExists+"::"+tenORthirty); if(allOrExists && !tenORthirty){ @@ -107,7 +107,7 @@ } //System.out.println(count+" "+allOrExists+"::"+tenORthirty); - } + }*/ int exampleSize = (tenORthirty)?10:30; int half = (tenORthirty)?5:15; @@ -143,16 +143,21 @@ String div = (System.currentTimeMillis()%10000)+""; - filename+=(d.getDescriptionLength()<10)?"0"+d.getDescriptionLength():d.getDescriptionLength()+""; if(d.getAccuracy()>=0.99){ - filename +="_99+"; + filename +="99+"; + }else if(d.getAccuracy()>=0.90){ + filename +="90+"; }else if(d.getAccuracy()>=0.80){ - filename +="_80+"; - }else if(d.getAccuracy()>=0.60){ - filename +="_60+"; + filename +="80+"; + }else if(d.getAccuracy()>=0.70){ + filename +="70+"; + }else if(d.getAccuracy()>0.50){ + filename +="50+"; }else { - filename +="_60-"; + filename +="50-"; } + filename+="_"; + filename+=(d.getDescriptionLength()<10)?"0"+d.getDescriptionLength():d.getDescriptionLength()+""; filename += "_"+div+".conf"; String content = fileString(true, d, positiveEx, negativeEx); Modified: trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java 2008-08-30 14:31:26 UTC (rev 1153) +++ trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java 2008-08-30 16:09:06 UTC (rev 1154) @@ -17,6 +17,7 @@ public String predefinedEndpoint = null; public int recursiondepth = 1; public boolean closeAfterRecursion = true; + public boolean getAllSuperClasses = true; public boolean useLits = false; public boolean randomizeCache = false; public String predefinedFilter = null; @@ -41,7 +42,9 @@ cm.applyConfigEntry(ks, "useLits", useLits); cm.applyConfigEntry(ks, "recursionDepth", recursiondepth); cm.applyConfigEntry(ks, "closeAfterRecursion", closeAfterRecursion); + cm.applyConfigEntry(ks, "getAllSuperClasses", getAllSuperClasses); + if (randomizeCache) cm.applyConfigEntry(ks, "cacheDir", "cache/" + System.currentTimeMillis() + ""); Modified: trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java 2008-08-30 14:31:26 UTC (rev 1153) +++ trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java 2008-08-30 16:09:06 UTC (rev 1154) @@ -32,7 +32,6 @@ import org.dllearner.core.ReasoningService; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.learningproblems.PosNegDefinitionLP; -import org.dllearner.reasoning.FastInstanceChecker; /** * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-08-30 14:31:29
|
Revision: 1153 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1153&view=rev Author: kurzum Date: 2008-08-30 14:31:26 +0000 (Sat, 30 Aug 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-08-30 13:52:08 UTC (rev 1152) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-08-30 14:31:26 UTC (rev 1153) @@ -80,7 +80,7 @@ static int recursionDepthDefault = 1; //RBC - static final boolean debug = true; + static final boolean debug = false; static final boolean debugUseImprovedTupleAquisitor = debug && false; //switches tupleaquisitor static final boolean debugExitAfterExtraction = debug && false; //switches sysex und rdf generation static final boolean debugAdditionallyGenerateRDF = debug && true; Modified: trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-08-30 13:52:08 UTC (rev 1152) +++ trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-08-30 14:31:26 UTC (rev 1153) @@ -23,6 +23,7 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.apache.log4j.ConsoleAppender; import org.apache.log4j.FileAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; @@ -33,11 +34,14 @@ import org.dllearner.core.ReasoningService; import org.dllearner.core.owl.Individual; import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.utilities.Files; import org.dllearner.utilities.datastructures.SetManipulation; import org.dllearner.utilities.learn.ConfWriter; import org.dllearner.utilities.learn.LearnOWLFile; import org.dllearner.utilities.learn.LearnOWLFileConfiguration; +import org.dllearner.utilities.learn.LearnSPARQLConfiguration; +import org.dllearner.utilities.learn.LearnSparql; import org.dllearner.utilities.owl.ReasoningServiceFactory; import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; @@ -49,10 +53,14 @@ public static String ontologyPath = "examples/semantic_bible/NTNcombined.owl"; - private static Class usedReasoner = FastInstanceChecker.class; - //private static Class usedReasoner = OWLAPIReasoner.class; + //private static Class usedReasoner = FastInstanceChecker.class; + private static Class usedReasoner = OWLAPIReasoner.class; private static boolean allOrExists = false; private static boolean tenORthirty = false; + + private static boolean sparql = true; + + private static boolean DEBUG = false; //private static boolean allOrExists = true; /** @@ -60,6 +68,7 @@ */ public static void main(String[] args) { initLogger(); + logger.info("started"); //String fileURL = new File(ontologyFile).toURI().toString(); reasoningService = ReasoningServiceFactory.getReasoningService( @@ -124,8 +133,12 @@ } - - EvaluatedDescription d = learnOriginal( positiveEx, negativeEx); + EvaluatedDescription d; + if(sparql){ + d = learnSPARQL( positiveEx, negativeEx); + }else { + d = learnOriginal( positiveEx, negativeEx); + } @@ -133,12 +146,12 @@ filename+=(d.getDescriptionLength()<10)?"0"+d.getDescriptionLength():d.getDescriptionLength()+""; if(d.getAccuracy()>=0.99){ filename +="_99+"; - }else if(d.getAccuracy()>=0.75){ - filename +="_75+"; - }else if(d.getAccuracy()>=0.50){ - filename +="_50+"; + }else if(d.getAccuracy()>=0.80){ + filename +="_80+"; + }else if(d.getAccuracy()>=0.60){ + filename +="_60+"; }else { - filename +="_50-"; + filename +="_60-"; } filename += "_"+div+".conf"; @@ -220,6 +233,28 @@ } + + private static EvaluatedDescription learnSPARQL( SortedSet<Individual> posExamples, SortedSet<Individual> negExamples) { + + LearnSparql learner = new LearnSparql(getConfForSparql()); + LearningAlgorithm la = null; + try{ + la = learner.learn( + SetManipulation.indToString(posExamples), + SetManipulation.indToString(negExamples), + usedReasoner); + la.start(); + }catch (Exception e) { + System.out.println("ignoring the error "+e.toString()); + + } + + EvaluatedDescription d = la.getCurrentlyBestEvaluatedDescription(); + + return d; + + + } @@ -254,7 +289,41 @@ } + private static LearnSPARQLConfiguration getConfForSparql() { + LearnSPARQLConfiguration lc = new LearnSPARQLConfiguration(); + // lsc.sparqlEndpoint = sparqlTasks.getSparqlEndpoint(); + + + lc.recursiondepth = 2; + lc.closeAfterRecursion = true; + lc.useLits = true; + lc.predefinedEndpoint = "LOCALJOSEKIBIBLE"; + + lc.noisePercentage = 0; + lc.guaranteeXgoodDescriptions = 1; + lc.maxExecutionTimeInSeconds = 30; + + + + if(allOrExists){ + lc.useAllConstructor = true; + lc.useCardinalityRestrictions = true; + lc.useExistsConstructor =true; + lc.useNegation = true; + }else { + lc.useAllConstructor = false; + lc.useCardinalityRestrictions = false; + lc.useExistsConstructor =true; + lc.useNegation = false; + } + + // lsc.searchTreeFile = "log/WikipediaCleaner.txt"; + + return lc; + + } + private static void initLogger() { SimpleLayout layout = new SimpleLayout(); @@ -270,11 +339,16 @@ logger.removeAllAppenders(); - //ConsoleAppender consoleAppender = new ConsoleAppender(layout); - //logger.addAppender(consoleAppender); + if(DEBUG){ + logger.setLevel(Level.DEBUG); + ConsoleAppender consoleAppender = new ConsoleAppender(layout); + logger.addAppender(consoleAppender); + }else{ + logger.setLevel(Level.INFO); + } logger.addAppender(fileAppender); - logger.setLevel(Level.INFO); + } Modified: trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java 2008-08-30 13:52:08 UTC (rev 1152) +++ trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java 2008-08-30 14:31:26 UTC (rev 1153) @@ -43,6 +43,7 @@ import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.kb.sparql.SparqlQuery; +import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.scripts.improveWikipedia.ConceptSPARQLReEvaluator; import org.dllearner.scripts.improveWikipedia.ConceptSelector; import org.dllearner.scripts.improveWikipedia.WikipediaCategoryTasks; @@ -208,7 +209,7 @@ LearnSparql learner = new LearnSparql(getConfToRelearn()); LearningAlgorithm la = null; try { - la = learner.learn(posExamples, negExamples); + la = learner.learn(posExamples, negExamples, FastInstanceChecker.class); } catch (Exception e) { e.printStackTrace(); } @@ -221,6 +222,7 @@ private static LearnSPARQLConfiguration getConfToFindWrongIndividuals() { LearnSPARQLConfiguration lsc = new LearnSPARQLConfiguration(); lsc.sparqlEndpoint = sparqlTasks.getSparqlEndpoint(); + lsc.predefinedEndpoint = "DBPEDIA"; lsc.recursiondepth = 1; lsc.noisePercentage = 20; Modified: trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java 2008-08-30 13:52:08 UTC (rev 1152) +++ trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java 2008-08-30 14:31:26 UTC (rev 1153) @@ -14,10 +14,12 @@ // SparqlKnowledgeSource public SparqlEndpoint sparqlEndpoint = SparqlEndpoint.getEndpointDBpedia(); + public String predefinedEndpoint = null; public int recursiondepth = 1; public boolean closeAfterRecursion = true; + public boolean useLits = false; public boolean randomizeCache = false; - public String predefinedFilter = "YAGO"; + public String predefinedFilter = null; @Override @@ -25,11 +27,21 @@ try { super.applyConfigEntries(cm, ks, lp, rs, la); // KNOWLEDGESOURCE - cm.applyConfigEntry(ks, "url", sparqlEndpoint.getURL().toString()); - cm.applyConfigEntry(ks, "predefinedEndpoint", "DBPEDIA"); + if(predefinedEndpoint ==null){ + cm.applyConfigEntry(ks, "url", sparqlEndpoint.getURL().toString()); + }else { + cm.applyConfigEntry(ks, "predefinedEndpoint", predefinedEndpoint); + } + if(predefinedFilter==null){ + //todo manual + }else{ + cm.applyConfigEntry(ks, "predefinedFilter", predefinedFilter); + } + + cm.applyConfigEntry(ks, "useLits", useLits); cm.applyConfigEntry(ks, "recursionDepth", recursiondepth); cm.applyConfigEntry(ks, "closeAfterRecursion", closeAfterRecursion); - cm.applyConfigEntry(ks, "predefinedFilter", predefinedFilter); + if (randomizeCache) cm.applyConfigEntry(ks, "cacheDir", "cache/" + System.currentTimeMillis() + ""); Modified: trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java 2008-08-30 13:52:08 UTC (rev 1152) +++ trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java 2008-08-30 14:31:26 UTC (rev 1153) @@ -53,7 +53,7 @@ //return will be replaced by List Description public LearningAlgorithm learn( SortedSet<String> posExamples, - SortedSet<String> negExamples) throws ComponentInitException, + SortedSet<String> negExamples, Class<? extends ReasonerComponent> Reasoner) throws ComponentInitException, LearningProblemUnsupportedException { logger.info("Start Learning with"); @@ -72,7 +72,7 @@ cm.applyConfigEntry(ks, "instances", instances); // reasoner - ReasonerComponent r = cm.reasoner(FastInstanceChecker.class, ks); + ReasonerComponent r = cm.reasoner(Reasoner, ks); ReasoningService rs = cm.reasoningService(r); // learning problem This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-08-30 13:52:13
|
Revision: 1152 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1152&view=rev Author: kurzum Date: 2008-08-30 13:52:08 +0000 (Sat, 30 Aug 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java Modified: trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-08-30 01:29:38 UTC (rev 1151) +++ trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-08-30 13:52:08 UTC (rev 1152) @@ -51,8 +51,8 @@ private static Class usedReasoner = FastInstanceChecker.class; //private static Class usedReasoner = OWLAPIReasoner.class; - private static boolean allOrExists = true; - private static boolean tenORthirty = true; + private static boolean allOrExists = false; + private static boolean tenORthirty = false; //private static boolean allOrExists = true; /** Added: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-30 13:52:08 UTC (rev 1152) @@ -0,0 +1,181 @@ +/** + * Copyright (C) 2007-2008, 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.ArrayList; +import java.util.List; + +import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.FileAppender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.SimpleLayout; +import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; +import org.dllearner.cli.Start; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.ReasoningService; +import org.dllearner.kb.extraction.ExtractionAlgorithm; +import org.dllearner.kb.extraction.Manager; +import org.dllearner.kb.sparql.Cache; +import org.dllearner.kb.sparql.SparqlKnowledgeSource; +import org.dllearner.kb.sparql.SparqlQuery; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.utilities.Files; +import org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL; +import org.dllearner.utilities.examples.AutomaticPositiveExampleFinderOWL; +import org.dllearner.utilities.examples.AutomaticPositiveExampleFinderSPARQL; +import org.dllearner.utilities.owl.ReasoningServiceFactory; +import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; +import org.dllearner.utilities.statistics.SimpleClock; + +public class SemanticBible2 { + + private static ReasoningService reasoningService; + + private static Logger logger = Logger.getRootLogger(); + + + public static String ontologyPath = "examples/semantic_bible/NTNcombined.owl"; + public static String dir = "sembib/"; + public static String sparqldir = dir+"sparql/"; + public static String normaldir = dir+"normal/"; + + public static String tmpFilename = dir + "tmp.conf"; + + private static Class usedReasoner = FastInstanceChecker.class; + + private static boolean useSPARQL = false; + + /** + * @param args + */ + public static void main(String[] args) { + SimpleClock sc = new SimpleClock(); + initLogger(); + logger.info("Start"); + File tmpFile = new File(tmpFilename); + + List<File> confs = getFilesContaining(useSPARQL,"thirty","exists", "75+"); + + //reasoningService = ReasoningServiceFactory.getReasoningService(ontologyPath, AvailableReasoners.OWLAPIREASONERPELLET); + try{ + for (File file : confs) { + System.out.println(file.getAbsolutePath()); + StringBuffer sbuf = new StringBuffer(Files.readFile( file)); + sbuf.insert(0, (useSPARQL)?sparqlOptions():normalOptions()); + Files.createFile(tmpFile, sbuf.toString()); + //System.out.println(tmpFile.getCanonicalPath()); + + Start.main(new String[] { tmpFilename }); + Cache.getDefaultCache().clearCache(); + System.exit(0); + } + }catch (Exception e) { + e.printStackTrace(); + } + logger.info("finished"); + } + + public static List<File> getFilesContaining(boolean sparql, String numExamples, String allOrEx, String acc) { + List<File> ret = new ArrayList<File>(); + try{ + String actualDir = (sparql)?sparqldir:normaldir; + File f = new File(actualDir); + String[] files = f.list(); + for (int i = 0; i < files.length; i++) { + if( + files[i].contains(numExamples) + && files[i].contains(allOrEx) + && files[i].contains(acc) + ){ + ret.add(new File(actualDir+files[i])); + } + + } + }catch (Exception e) { + logger.warn("deleting cache failed"); + e.printStackTrace(); + } + return ret; + } + + + public static String sparqlOptions (){ + String s="// SPARQL options\n"+ + "sparql.recursionDepth = 3;\n"+ + "sparql.useLits = true;\n"+ + "sparql.predefinedEndpoint = \"LOCALJOSEKIBIBLE\";\n"+ + "import(\"lalala\",\"SPARQL\");\n"+ + + "algorithm = refexamples;\n"+ + "refexamples.useAllConstructor = true;\n"+ + "refexamples.useNegation = true;\n"+ + "refexamples.useCardinalityRestrictions = true;\n"+ + "refexamples.guaranteeXgoodDescriptions = 1;\n"+ + "\n"+ + //"reasoner = owlAPI;\n"+ + "reasoner = fastInstanceChecker;\n"+ + //"owlAPIReasoner.reasonerType = pellet;\n\n"; + ""; + return s; + } + + public static String normalOptions (){ + String s="\n"+ + "import(\"NTNcombined.owl\");\n"+ + "algorithm = refexamples;\n"+ + "refexamples.useAllConstructor = true;\n"+ + "refexamples.useNegation = true;\n"+ + "refexamples.useCardinalityRestrictions = true;\n"+ + "refexamples.guaranteeXgoodDescriptions = 1;\n"+ + "\n"+ + "reasoner = owlAPI;\n"+ + //"reasoner = fastInstanceChecker;\n"+ + //"owlAPIReasoner.reasonerType = pellet;\n\n"; + ""; + return s; + } + + + private static void initLogger() { + + SimpleLayout layout = new SimpleLayout(); + // create logger (a simple logger which outputs + // its messages to the console) + FileAppender fileAppender = null; + try { + fileAppender = new FileAppender(layout, "log/semBibleLog.txt", + false); + } catch (Exception e) { + e.printStackTrace(); + } + + ConsoleAppender consoleAppender = new ConsoleAppender(layout); + logger.removeAllAppenders(); + logger.addAppender(consoleAppender); + logger.addAppender(fileAppender); + logger.setLevel(Level.DEBUG); + + + } + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-08-30 01:29:42
|
Revision: 1151 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1151&view=rev Author: kurzum Date: 2008-08-30 01:29:38 +0000 (Sat, 30 Aug 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/utilities/Files.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnOWLFile.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java Added: trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-08-30 01:29:38 UTC (rev 1151) @@ -0,0 +1,281 @@ +/** + * Copyright (C) 2007-2008, 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.SortedSet; +import java.util.TreeSet; + +import org.apache.log4j.FileAppender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.SimpleLayout; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.owl.Individual; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.utilities.Files; +import org.dllearner.utilities.datastructures.SetManipulation; +import org.dllearner.utilities.learn.ConfWriter; +import org.dllearner.utilities.learn.LearnOWLFile; +import org.dllearner.utilities.learn.LearnOWLFileConfiguration; +import org.dllearner.utilities.owl.ReasoningServiceFactory; +import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; + +public class DumbLPFinder { + + private static Logger logger = Logger.getRootLogger(); + + private static ReasoningService reasoningService; + + public static String ontologyPath = "examples/semantic_bible/NTNcombined.owl"; + + private static Class usedReasoner = FastInstanceChecker.class; + //private static Class usedReasoner = OWLAPIReasoner.class; + private static boolean allOrExists = true; + private static boolean tenORthirty = true; + //private static boolean allOrExists = true; + + /** + * @param args + */ + public static void main(String[] args) { + initLogger(); + //String fileURL = new File(ontologyFile).toURI().toString(); + + reasoningService = ReasoningServiceFactory.getReasoningService( + ontologyPath, AvailableReasoners.OWLAPIREASONERPELLET); + + String baseDir = "sembib/"; + Files.mkdir(baseDir); + String baseDirSparql = baseDir+ "sparql/"; + Files.mkdir(baseDirSparql); + String baseDirNormal = baseDir+"normal/"; + Files.mkdir(baseDirNormal); + + SortedSet<Individual> allIndividuals = new TreeSet<Individual>(); + allIndividuals.addAll( reasoningService.getIndividuals()); + + reasoningService = null; + + int count = 1; + while(count<10000){ + + if((count%5)==0){ + //System.out.println(count+" "+allOrExists+"::"+tenORthirty); + + if(allOrExists && !tenORthirty){ + allOrExists = true; + tenORthirty = true; + }else if(!allOrExists && tenORthirty){ + allOrExists = true; + tenORthirty = false; + }else if(!allOrExists && !tenORthirty){ + allOrExists = false; + tenORthirty = true; + }else if(allOrExists && tenORthirty){ + allOrExists = false; + tenORthirty = false; + } + //System.out.println(count+" "+allOrExists+"::"+tenORthirty); + + } + + int exampleSize = (tenORthirty)?10:30; + int half = (tenORthirty)?5:15; + + String filename =""; + filename += (allOrExists)?"all_":"exists_"; + filename += (tenORthirty)?"ten_":"thirty_"; + + + try{ + + SortedSet<Individual> tmp = SetManipulation.fuzzyShrinkInd(allIndividuals, exampleSize); + + SortedSet<Individual> positiveEx = new TreeSet<Individual>(); + SortedSet<Individual> negativeEx = new TreeSet<Individual>(); + + for (Individual individual : tmp) { + if(positiveEx.size()< half){ + positiveEx.add(individual); + }else{ + negativeEx.add(individual); + } + + } + + + EvaluatedDescription d = learnOriginal( positiveEx, negativeEx); + + + + String div = (System.currentTimeMillis()%10000)+""; + filename+=(d.getDescriptionLength()<10)?"0"+d.getDescriptionLength():d.getDescriptionLength()+""; + if(d.getAccuracy()>=0.99){ + filename +="_99+"; + }else if(d.getAccuracy()>=0.75){ + filename +="_75+"; + }else if(d.getAccuracy()>=0.50){ + filename +="_50+"; + }else { + filename +="_50-"; + } + filename += "_"+div+".conf"; + + String content = fileString(true, d, positiveEx, negativeEx); + Files.createFile(new File(baseDirSparql+filename), content); + content = fileString(false, d, positiveEx, negativeEx); + Files.createFile(new File(baseDirNormal+filename), content); + + + + }catch (Exception e) { + e.printStackTrace(); + }finally{ + ComponentManager.getInstance().freeAllComponents(); + } + //System.out.println(count); + count++; + } + + + } + + public static String accString(EvaluatedDescription d){ + + String acc = (d.getAccuracy())+""; + try { acc = acc.substring(2,6); + acc= acc.substring(0,2)+"."+acc.substring(3)+"%";}catch (Exception e) { } + + return acc; + } + + public static String fileString(boolean sparql, EvaluatedDescription d, SortedSet<Individual> p, SortedSet<Individual> n){ + + String str = "/**\n" + + d.getDescription().toKBSyntaxString() + "\n"+ + d + "\n"+ + "\n"+ + "**/\n"+ + "\n\n"; + if(sparql){ + str+="sparql.instances = {\n"; + for (Individual individual : p) { + str+="\""+individual+"\",\n"; + } + for (Individual individual : n) { + str+="\""+individual+"\",\n"; + } + str = str.substring(0, str.length()-2); + str+="};\n"; + + } + + str+="\n"+ + "/**EXAMPLES**/\n"+ + ConfWriter.listExamples(true, p)+"\n"+ + ConfWriter.listExamples(false, n)+"\n"; + + return str; + } + + private static EvaluatedDescription learnOriginal( SortedSet<Individual> posExamples, SortedSet<Individual> negExamples) { + + LearnOWLFile learner = new LearnOWLFile(getConfForOriginal()); + LearningAlgorithm la = null; + try{ + la = learner.learn( + SetManipulation.indToString(posExamples), + SetManipulation.indToString(negExamples), + usedReasoner); + la.start(); + }catch (Exception e) { + System.out.println("ignoring the error "+e.toString()); + + } + + EvaluatedDescription d = la.getCurrentlyBestEvaluatedDescription(); + + return d; + + + } + + + + private static LearnOWLFileConfiguration getConfForOriginal() { + LearnOWLFileConfiguration lc = new LearnOWLFileConfiguration(); + + + lc.setOWLFileURL(ontologyPath); + + lc.noisePercentage = 0; + lc.guaranteeXgoodDescriptions = 1; + if(allOrExists){ + lc.useAllConstructor = true; + lc.useCardinalityRestrictions = true; + lc.useExistsConstructor =true; + lc.useNegation = true; + }else { + lc.useAllConstructor = false; + lc.useCardinalityRestrictions = false; + lc.useExistsConstructor =true; + lc.useNegation = false; + } + + + Class tmp = FastInstanceChecker.class; + if(usedReasoner.equals(tmp)){ + lc.maxExecutionTimeInSeconds = 30; + }else{ + lc.maxExecutionTimeInSeconds = 200; + } + return lc; + + } + + + private static void initLogger() { + + SimpleLayout layout = new SimpleLayout(); + // create logger (a simple logger which outputs + // its messages to the console) + FileAppender fileAppender = null; + try { + fileAppender = new FileAppender(layout, "log/semBibleLog.txt", + false); + } catch (Exception e) { + e.printStackTrace(); + } + + + logger.removeAllAppenders(); + //ConsoleAppender consoleAppender = new ConsoleAppender(layout); + //logger.addAppender(consoleAppender); + logger.addAppender(fileAppender); + logger.setLevel(Level.INFO); + + + } + +} Modified: trunk/src/dl-learner/org/dllearner/utilities/Files.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Files.java 2008-08-29 21:54:39 UTC (rev 1150) +++ trunk/src/dl-learner/org/dllearner/utilities/Files.java 2008-08-30 01:29:38 UTC (rev 1151) @@ -103,5 +103,16 @@ e.printStackTrace(); } } + + public static void mkdir(String dir){ + if (!new File(dir).exists()) { + try{ + new File(dir).mkdir(); + }catch (Exception e) { + e.printStackTrace(); + // this should not be a show stopper + } + } + } } Modified: trunk/src/dl-learner/org/dllearner/utilities/learn/LearnOWLFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/learn/LearnOWLFile.java 2008-08-29 21:54:39 UTC (rev 1150) +++ trunk/src/dl-learner/org/dllearner/utilities/learn/LearnOWLFile.java 2008-08-30 01:29:38 UTC (rev 1151) @@ -45,6 +45,8 @@ public LearnOWLFileConfiguration configuration; + public ComponentManager cm ; + public LearnOWLFile (LearnOWLFileConfiguration configuration){ this.configuration = configuration; } @@ -60,7 +62,7 @@ // the component manager is the central object to create // and configure components - ComponentManager cm = ComponentManager.getInstance(); + cm = ComponentManager.getInstance(); // knowledge source KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |