From: <jen...@us...> - 2009-05-05 10:02:00
|
Revision: 1733 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1733&view=rev Author: jenslehmann Date: 2009-05-05 10:01:50 +0000 (Tue, 05 May 2009) Log Message: ----------- implemented changes suggested by Francesca Lisi Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java trunk/src/dl-learner/org/dllearner/core/options/URLConfigOption.java trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java trunk/src/dl-learner/org/dllearner/gui/tutorial.html trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2009-05-04 13:47:49 UTC (rev 1732) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2009-05-05 10:01:50 UTC (rev 1733) @@ -20,6 +20,7 @@ package org.dllearner.core.configurators; +import java.net.URL; import org.dllearner.core.ComponentManager; import org.dllearner.core.ReasonerComponent; import org.dllearner.learningproblems.ClassLearningProblem; @@ -47,7 +48,7 @@ * @param classToDescribe class of which a description should be learned * @return ClassLearningProblem **/ -public static ClassLearningProblem getClassLearningProblem(ReasonerComponent reasoningService, String classToDescribe) { +public static ClassLearningProblem getClassLearningProblem(ReasonerComponent reasoningService, URL classToDescribe) { ClassLearningProblem component = ComponentManager.getInstance().learningProblem(ClassLearningProblem.class, reasoningService); ComponentManager.getInstance().applyConfigEntry(component, "classToDescribe", classToDescribe); return component; @@ -57,13 +58,13 @@ * classToDescribe class of which a description should be learned. * mandatory: true| reinit necessary: false * default value: null -* @return String +* @return URL **/ -public String getClassToDescribe() { -return (String) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "classToDescribe") ; +public URL getClassToDescribe() { +return (URL) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "classToDescribe") ; } /** -* type Whether to learn an equivalence class or super class axiom or domain/range of a property.. +* type whether to learn an equivalence class or super class axiom. * mandatory: false| reinit necessary: true * default value: equivalence * @return String @@ -77,11 +78,11 @@ * mandatory: true| reinit necessary: false * default value: null **/ -public void setClassToDescribe(String classToDescribe) { +public void setClassToDescribe(URL classToDescribe) { ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "classToDescribe", classToDescribe); } /** -* @param type Whether to learn an equivalence class or super class axiom or domain/range of a property.. +* @param type whether to learn an equivalence class or super class axiom. * mandatory: false| reinit necessary: true * default value: equivalence **/ Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2009-05-04 13:47:49 UTC (rev 1732) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2009-05-05 10:01:50 UTC (rev 1733) @@ -122,7 +122,7 @@ * @param reasoningService see ReasoningService * @return a component ready for initialization ClassLearningProblem **/ -public static ClassLearningProblem getClassLearningProblem(ReasonerComponent reasoningService, String classToDescribe) { +public static ClassLearningProblem getClassLearningProblem(ReasonerComponent reasoningService, URL classToDescribe) { return ClassLearningProblemConfigurator.getClassLearningProblem(reasoningService, classToDescribe); } Modified: trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2009-05-04 13:47:49 UTC (rev 1732) +++ trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2009-05-05 10:01:50 UTC (rev 1733) @@ -70,15 +70,6 @@ public boolean getDefaultNegation() { return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fastInstanceChecker, "defaultNegation") ; } -/** -* forallRetrievalSemantics This option controls how to interpret the all quantifier in orall r.C. The standard option isto return all those which do not have an r-filler not in C. The domain semantics is to use thosewhich are in the domain of r and do not have an r-filler not in C. The forallExists semantics is touse those which have at least one r-filler and do not have an r-filler not in C.. -* mandatory: false| reinit necessary: true -* default value: standard -* @return String -**/ -public String getForallRetrievalSemantics() { -return (String) ComponentManager.getInstance().getConfigOptionValue(fastInstanceChecker, "forallRetrievalSemantics") ; -} /** * @param reasonerType FaCT++ or Pellet to dematerialize. @@ -98,15 +89,6 @@ ComponentManager.getInstance().applyConfigEntry(fastInstanceChecker, "defaultNegation", defaultNegation); reinitNecessary = true; } -/** -* @param forallRetrievalSemantics This option controls how to interpret the all quantifier in orall r.C. The standard option isto return all those which do not have an r-filler not in C. The domain semantics is to use thosewhich are in the domain of r and do not have an r-filler not in C. The forallExists semantics is touse those which have at least one r-filler and do not have an r-filler not in C.. -* mandatory: false| reinit necessary: true -* default value: standard -**/ -public void setForallRetrievalSemantics(String forallRetrievalSemantics) { -ComponentManager.getInstance().applyConfigEntry(fastInstanceChecker, "forallRetrievalSemantics", forallRetrievalSemantics); -reinitNecessary = true; -} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/core/options/URLConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/options/URLConfigOption.java 2009-05-04 13:47:49 UTC (rev 1732) +++ trunk/src/dl-learner/org/dllearner/core/options/URLConfigOption.java 2009-05-05 10:01:50 UTC (rev 1733) @@ -33,6 +33,8 @@ private boolean refersToFile = false; + private boolean refersToOWLClass = false; + public URLConfigOption(String name, String description) { super(name, description); } @@ -64,6 +66,23 @@ this.refersToFile = refersToFile; } + /** + * Returns whether the URI can refer to a class in a loaded + * ontology. This can be used in user interfaces for this component. + * @return the refersToOWLClass Whether it refers to an OWL class. + */ + public boolean refersToOWLClass() { + return refersToOWLClass; + } + + /** + * @param refersToFile Set whether this option refers to an OWL class in the + * loaded ontology. + */ + public void setRefersToOWLClass(boolean refersToOWLClass) { + this.refersToOWLClass = refersToOWLClass; + } + /* (non-Javadoc) * @see org.dllearner.core.config.ConfigOption#checkType(java.lang.Object) */ Modified: trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java 2009-05-04 13:47:49 UTC (rev 1732) +++ trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java 2009-05-05 10:01:50 UTC (rev 1733) @@ -19,6 +19,7 @@ */ package org.dllearner.core.owl; +import java.net.URI; import java.util.Map; import org.dllearner.utilities.Helper; @@ -38,6 +39,10 @@ this.name = name; } + public NamedClass(URI uri) { + this.name = uri.toString(); + } + public String getName() { return name; } Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2009-05-04 13:47:49 UTC (rev 1732) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2009-05-05 10:01:50 UTC (rev 1733) @@ -46,6 +46,7 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; +import org.dllearner.algorithms.el.ELLearningAlgorithm; import org.dllearner.algorithms.refinement2.ROLComponent2; import org.dllearner.core.Component; import org.dllearner.core.KnowledgeSource; @@ -55,7 +56,9 @@ import org.dllearner.kb.OWLAPIOntology; import org.dllearner.kb.OWLFile; import org.dllearner.learningproblems.PosNegLPStandard; +import org.dllearner.learningproblems.PosNegLPStrict; import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.reasoning.FastRetrievalReasoner; /** * This class builds the basic GUI elements and is used to start the DL-Learner @@ -127,9 +130,15 @@ List<Class<? extends Component>> ignoredKnowledgeSources = new LinkedList<Class<? extends Component>>(); ignoredKnowledgeSources.add(OWLAPIOntology.class); panels[0] = new ComponentPanel(config, this, KnowledgeSource.class, OWLFile.class, ignoredKnowledgeSources); - panels[1] = new ComponentPanel(config, this, ReasonerComponent.class, FastInstanceChecker.class); - panels[2] = new ComponentPanel(config, this, LearningProblem.class, PosNegLPStandard.class); - panels[3] = new ComponentPanel(config, this, LearningAlgorithm.class, ROLComponent2.class); + List<Class<? extends Component>> ignoredReasoners = new LinkedList<Class<? extends Component>>(); + ignoredReasoners.add(FastRetrievalReasoner.class); + panels[1] = new ComponentPanel(config, this, ReasonerComponent.class, FastInstanceChecker.class, ignoredReasoners); + List<Class<? extends Component>> ignoredLearningProblems = new LinkedList<Class<? extends Component>>(); + ignoredLearningProblems.add(PosNegLPStrict.class); + panels[2] = new ComponentPanel(config, this, LearningProblem.class, PosNegLPStandard.class, ignoredLearningProblems); + List<Class<? extends Component>> ignoredAlgorithms = new LinkedList<Class<? extends Component>>(); + ignoredAlgorithms.add(ELLearningAlgorithm.class); + panels[3] = new ComponentPanel(config, this, LearningAlgorithm.class, ROLComponent2.class, ignoredAlgorithms); runPanel = new RunPanel(config, this); // add tabs for panels Modified: trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java 2009-05-04 13:47:49 UTC (rev 1732) +++ trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java 2009-05-05 10:01:50 UTC (rev 1733) @@ -34,7 +34,7 @@ private static final long serialVersionUID = 2426470148153461670L; - private String tabInitText = "Please fill in the mandatory config options and proceed to the next tab."; + private String tabInitText = "<html>Please fill in the mandatory config options and proceed to the next tab.<br />(Move the mouse over an option name to view a short description of it.)</html>"; private String tabCompleteText = "All mandatory options filled in. You can continue to the next tab."; Modified: trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java 2009-05-04 13:47:49 UTC (rev 1732) +++ trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java 2009-05-05 10:01:50 UTC (rev 1733) @@ -42,7 +42,7 @@ setTitle("Quick Tutorial"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setLocationByPlatform(true); - setSize(300, 600); + setSize(525, 600); setVisible(true); getContentPane().setLayout(new BorderLayout()); Modified: trunk/src/dl-learner/org/dllearner/gui/tutorial.html =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/tutorial.html 2009-05-04 13:47:49 UTC (rev 1732) +++ trunk/src/dl-learner/org/dllearner/gui/tutorial.html 2009-05-05 10:01:50 UTC (rev 1733) @@ -23,6 +23,27 @@ special role: It is used to start the learning algorithm and display statistical information. </p><br /> + +<p> +<i>Example:</i><br /> +Suppose you want to learn the definition of a class in an existing ontology. In this case, +you can proceed as follows:<br /> +1. In the tab "Knowledge Source", choose an OWL file containing your ontology.<br /> +2. Click on the tab "Reasoner". We recommend to the defaults unchanged here, but you + are free to modify the settings and choose the reasoner you like.<br /> +3. Click on the tab "Learning Problem". This may take a while, since the reasoner will now + read the ontology you specified in step 1. Since you want to learn the definition of a class, + use the drop down box and select "Class Learning Problem". After this, set the value of + the option "classToDescribe" to the desired class.<br /> +4. Click on the "Learning Algorithm" tab. Here, you can select a learning algorithm and + modify its settings. If you are unsure what to do, just stick with the default values.<br /> +5. Click on the "Run" tab and press the "Start" button. The algorithm is now running + and the currently best solutions found are displayed in the panel below (using Manchester + OWL Syntax) along with some reasoning statistics. Depending on the learning algorithm + and settings, the run may not terminate (in reasonable time). In such a case you can use + the "Stop" button to gracefully stop the algorithm.<br /> +For explanations of components in each step, please consult the DL-Learner manual. +</p><br /> <p> <i>Tab heads explanation:</i><br /> @@ -33,6 +54,7 @@ <p><i>Further references:</i><br /> Homepage: <a href="http://dl-learner.org">http://dl-learner.org</a><br /> +DL-Learner Manual: <a href="http://dl-learner.org/files/dl-learner-manual.pdf">http://dl-learner.org/files/dl-learner-manual.pdf</a><br /> DL-Learner Architecture: <a href="http://dl-learner.org/wiki/Architecture">http://dl-learner.org/wiki/Architecture</a> </p><br /> Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java 2009-05-04 13:47:49 UTC (rev 1732) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java 2009-05-05 10:01:50 UTC (rev 1733) @@ -23,14 +23,22 @@ import java.awt.event.ActionListener; import java.net.MalformedURLException; import java.net.URL; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; import javax.swing.JButton; +import javax.swing.JComboBox; import javax.swing.JFileChooser; import javax.swing.JLabel; import javax.swing.JTextField; import org.dllearner.core.Component; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.configurators.ClassLearningProblemConfigurator; import org.dllearner.core.options.URLConfigOption; +import org.dllearner.core.owl.NamedClass; import org.dllearner.gui.Config; import org.dllearner.gui.ExampleFileChooser; import org.dllearner.kb.OWLFile; @@ -51,6 +59,9 @@ private URL value; private JTextField stringField; + private JComboBox comboBox; + private List<NamedClass> classes; + /** * Provides a widget for URL options. * @@ -97,6 +108,16 @@ e1.printStackTrace(); } fireValueChanged(value); + } else if (e.getSource() == comboBox) { + // pick the selected class + NamedClass clazz = classes.get(comboBox.getSelectedIndex()); + try { + value = new URL(clazz.getName()); + } catch (MalformedURLException e1) { + // cannot happen + e1.printStackTrace(); + } + fireValueChanged(value); } } @@ -107,30 +128,45 @@ // get current value of this option for the given component value = config.getConfigOptionValue(component, configOption); - // text field for strings - stringField = new JTextField(35); - if (value != null) { - stringField.setText(value.toString()); - } - stringField.setToolTipText(configOption.getAllowedValuesDescription()); + // if the option value is an OWL class, we offer a dropdown box + if(((URLConfigOption) configOption).refersToOWLClass()) { + comboBox = new JComboBox(); + ReasonerComponent reasoner = config.getReasoner(); + String baseURI = reasoner.getBaseURI(); + Map<String,String> prefixes = reasoner.getPrefixes(); + classes = new LinkedList<NamedClass>(reasoner.getNamedClasses()); + for(NamedClass clazz : classes) { + comboBox.addItem(clazz.toManchesterSyntaxString(baseURI, prefixes)); + } + comboBox.addActionListener(this); + comboBox.setSelectedIndex(0); + add(comboBox); + } else { + // text field for strings + stringField = new JTextField(35); + if (value != null) { + stringField.setText(value.toString()); + } + stringField.setToolTipText(configOption.getAllowedValuesDescription()); - // set button (value is only updated when this button is pressed => - // would better without set) - setButton = new JButton("Set"); - setButton.addActionListener(this); + // set button (value is only updated when this button is pressed => + // would be better without set) + setButton = new JButton("Set"); + setButton.addActionListener(this); - add(stringField); - add(setButton); + add(stringField); + add(setButton); - // if the URL can refer to a file, we add the possibility to - // choose a local file - if (((URLConfigOption) configOption).refersToFile()) { - chooseLocalButton = new JButton("Choose Local File"); - chooseLocalButton.addActionListener(this); - add(new JLabel(" or ")); - add(chooseLocalButton); + // if the URL can refer to a file, we add the possibility to + // choose a local file + if (((URLConfigOption) configOption).refersToFile()) { + chooseLocalButton = new JButton("Choose Local File"); + chooseLocalButton.addActionListener(this); + add(new JLabel(" or ")); + add(chooseLocalButton); + } } - + } } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-05-04 13:47:49 UTC (rev 1732) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-05-05 10:01:50 UTC (rev 1733) @@ -33,6 +33,7 @@ import org.dllearner.core.configurators.ClassLearningProblemConfigurator; import org.dllearner.core.options.ConfigOption; import org.dllearner.core.options.StringConfigOption; +import org.dllearner.core.options.URLConfigOption; import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.EquivalentClassesAxiom; @@ -74,8 +75,10 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); - options.add(new StringConfigOption("classToDescribe", "class of which a description should be learned", null, true, false)); - StringConfigOption type = new StringConfigOption("type", "Whether to learn an equivalence class or super class axiom or domain/range of a property.","equivalence"); + URLConfigOption classToDescribeOption = new URLConfigOption("classToDescribe", "class of which a description should be learned", null, true, false); + classToDescribeOption.setRefersToOWLClass(true); + options.add(classToDescribeOption); + StringConfigOption type = new StringConfigOption("type", "whether to learn an equivalence class or super class axiom","equivalence"); // or domain/range of a property. type.setAllowedValues(new String[] {"equivalence", "superClass"}); // , "domain", "range"}); options.add(type); return options; @@ -87,7 +90,8 @@ @Override public void init() throws ComponentInitException { - classToDescribe = new NamedClass(configurator.getClassToDescribe()); + classToDescribe = new NamedClass(configurator.getClassToDescribe().toString()); + if(!reasoner.getNamedClasses().contains(classToDescribe)) { throw new ComponentInitException("The class \"" + configurator.getClassToDescribe() + "\" does not exist. Make sure you spelled it correctly."); } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-05-04 13:47:49 UTC (rev 1732) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-05-05 10:01:50 UTC (rev 1733) @@ -162,7 +162,7 @@ forallSemantics.setAllowedValues(new String[] { "standard", "domain", "forallExists" }); // closure option? see: // http://owlapi.svn.sourceforge.net/viewvc/owlapi/owl1_1/trunk/tutorial/src/main/java/uk/ac/manchester/owl/tutorial/examples/ClosureAxiomsExample.java?view=markup - options.add(forallSemantics); +// options.add(forallSemantics); return options; } @@ -586,9 +586,9 @@ // \forall restrictions are difficult to handle; assume we want to check // \forall hasChild.male with domain(hasChild)=Person; then for all non-persons // this is satisfied trivially (all of their non-existing children are male) - if(!configurator.getForallRetrievalSemantics().equals("standard")) { - throw new Error("Only forallExists semantics currently implemented."); - } +// if(!configurator.getForallRetrievalSemantics().equals("standard")) { +// throw new Error("Only forallExists semantics currently implemented."); +// } // problem: we need to make sure that \neg \exists r.\top \equiv \forall r.\bot // can still be reached in an algorithm (\forall r.\bot \equiv \bot under forallExists This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |