From: <jen...@us...> - 2008-09-12 10:52:19
|
Revision: 1199 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1199&view=rev Author: jenslehmann Date: 2008-09-12 10:52:14 +0000 (Fri, 12 Sep 2008) Log Message: ----------- fixed bug related to URL config option and commandline interface Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/URLConfigOption.java trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/InitWorker.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/kb/OWLFile.java Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-09-12 09:52:17 UTC (rev 1198) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-09-12 10:52:14 UTC (rev 1199) @@ -198,7 +198,7 @@ // configuration option "url"), so this may need to be changed in // the // future - cm.applyConfigEntry(ks, "url", entry.getKey().toString()); + cm.applyConfigEntry(ks, "url", entry.getKey()); sources.add(ks); configureComponent(cm, ks, componentPrefixMapping, parser); Modified: trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-09-12 09:52:17 UTC (rev 1198) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-09-12 10:52:14 UTC (rev 1199) @@ -141,6 +141,8 @@ } /** + * TODO Method should be removed and a mapping table in ConfigJavaGenerator + * created instead. * gets java imports * @return */ Modified: trunk/src/dl-learner/org/dllearner/core/config/URLConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/URLConfigOption.java 2008-09-12 09:52:17 UTC (rev 1198) +++ trunk/src/dl-learner/org/dllearner/core/config/URLConfigOption.java 2008-09-12 10:52:14 UTC (rev 1199) @@ -31,6 +31,8 @@ */ public class URLConfigOption extends ConfigOption<URL> { + private boolean refersToFile = false; + public URLConfigOption(String name, String description) { super(name, description); } @@ -44,6 +46,24 @@ super(name, description, defaultValue, mandatory, requiresInit); } + /** + * Returns whether the URI can refer to a file or not, e.g. the + * URL of an OWL knowledge source does refer to a file whereas + * the URL of a SPARQL endpoint cannot refer to a file. The distinction + * can be useful in GUIs (e.g. they may offer to choose a local file). + * @return the refersToFile + */ + public boolean refersToFile() { + return refersToFile; + } + + /** + * @param refersToFile Set whether this option can refer to a file. + */ + public void setRefersToFile(boolean refersToFile) { + this.refersToFile = refersToFile; + } + /* (non-Javadoc) * @see org.dllearner.core.config.ConfigOption#checkType(java.lang.Object) */ Modified: trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-09-12 09:52:17 UTC (rev 1198) +++ trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-09-12 10:52:14 UTC (rev 1199) @@ -21,8 +21,6 @@ /** * Class displaying a component (and its options). * - * @param <T> The type of the panel (KnowledgeSource, ReasonerComponent, - * LearningProblem, LearningAlgorithm). * @author Jens Lehmann * */ Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-12 09:52:17 UTC (rev 1198) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-12 10:52:14 UTC (rev 1199) @@ -20,6 +20,10 @@ package org.dllearner.gui; +import java.util.LinkedList; +import java.util.List; + +import org.apache.log4j.Logger; import org.dllearner.core.Component; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; @@ -47,7 +51,7 @@ public class Config { private ComponentManager cm = ComponentManager.getInstance(); -// private static Logger logger = Logger.getLogger(Config.class); + private static Logger logger = Logger.getLogger(Config.class); // the components currently active private KnowledgeSource source; @@ -425,9 +429,23 @@ // algorithmRunStopTime = null; // } + + // init the specified component and record which ones where initialised - public void init(int tabIndex) { + public void init(List<Integer> tabIndex) { + List<Component> components = new LinkedList<Component>(); + for(int i : tabIndex) { + switch(i) { + case 0: components.add(source); needsInit[i] = false; break; + case 1: components.add(reasoner); needsInit[i] = false; break; + case 2: components.add(lp); needsInit[i] = false; break; + case 3: components.add(la); needsInit[i] = false; break; + } + } + InitWorker worker = new InitWorker (components, gui); + worker.execute(); + /* // try { if(tabIndex==0) { InitWorker worker = new InitWorker(source, gui); @@ -451,9 +469,14 @@ // // TODO display message in status bar // e.printStackTrace(); // } + */ - needsInit[tabIndex] = false; - System.out.println("component " + tabIndex + " initialised."); + if(tabIndex.size() == 1) { + logger.info("Component " + tabIndex.get(0) + " initialised."); + } else if(tabIndex.size() > 1) { + logger.info("Components " + tabIndex + " initialised."); + } + } // applies a configuration option - used as delegate method, which invalidates components Modified: trunk/src/dl-learner/org/dllearner/gui/InitWorker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/InitWorker.java 2008-09-12 09:52:17 UTC (rev 1198) +++ trunk/src/dl-learner/org/dllearner/gui/InitWorker.java 2008-09-12 10:52:14 UTC (rev 1199) @@ -44,12 +44,12 @@ */ public class InitWorker extends SwingWorker<Boolean, Boolean> { - private Component component; + private List<Component> components; private StartGUI gui; - private boolean timeIntensive = true; + private boolean timeIntensive; - public InitWorker(Component component, StartGUI gui) { - this.component = component; + public InitWorker(List<Component> components, StartGUI gui) { + this.components = components; this.gui = gui; // create a list of components, which do need virtually @@ -59,9 +59,14 @@ nonTimeIntensiveComponents.add(OWLFile.class); nonTimeIntensiveComponents.add(KBFile.class); - if(nonTimeIntensiveComponents.contains(component.getClass())) { - timeIntensive = false; + // we check if any of the components is time-intensive + timeIntensive = false; + for(Component component : components) { + if(!nonTimeIntensiveComponents.contains(component.getClass())) { + timeIntensive = true; + } } + } @Override @@ -91,7 +96,9 @@ } try { - component.init(); + for(Component component : components) { + component.init(); + } } catch (ComponentInitException e) { gui.getStatusPanel().setExceptionMessage(e.getMessage()); e.printStackTrace(); @@ -107,7 +114,7 @@ // when the reasoner has been initialised, we need to update // the option panel (such that the user can see the existing // examples, classes etc.) - if(component instanceof ReasonerComponent) { + if(components instanceof ReasonerComponent) { gui.panels[2].updateOptionPanel(); gui.panels[3].updateOptionPanel(); } Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-12 09:52:17 UTC (rev 1198) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-12 10:52:14 UTC (rev 1199) @@ -179,14 +179,19 @@ int index = tabPane.getSelectedIndex(); // System.out.println(index); + // a list of all components (0 = knowledge source, + // 1 = reasoner etc.) which have to be initialised; + // the user can init several components at once + List<Integer> componentsToInit = new LinkedList<Integer>(); // check whether we need to initialise components if (index != 0 && config.tabNeedsInit(index - 1)) { for (int i = 0; i < index; i++) { if(config.tabNeedsInit(i)) { - config.init(i); + componentsToInit.add(i); } } } + config.init(componentsToInit); updateTabs(); @@ -227,7 +232,7 @@ Logger logger = Logger.getRootLogger(); logger.removeAllAppenders(); logger.addAppender(consoleAppender); - logger.setLevel(Level.DEBUG); + logger.setLevel(Level.TRACE); File file = null; if (args.length > 0) Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java 2008-09-12 09:52:17 UTC (rev 1198) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java 2008-09-12 10:52:14 UTC (rev 1199) @@ -243,8 +243,14 @@ if(individualsSet != null) { LinkedList<Individual> individuals = new LinkedList<Individual>( individualsSet); +// int i = 0; for (Individual ind : individuals) { cBL.add(ind.getName()); +// i++; + // do not display more than 200 examples (freezes GUI) +// if(i == 200) { +// break; +// } } } } Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-09-12 09:52:17 UTC (rev 1198) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-09-12 10:52:14 UTC (rev 1199) @@ -33,7 +33,6 @@ import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; -import org.dllearner.core.config.StringConfigOption; import org.dllearner.core.config.URLConfigOption; import org.dllearner.core.configurators.KBFileConfigurator; import org.dllearner.core.owl.KB; @@ -63,7 +62,7 @@ .getLogger(KBFile.class); // private File file; - private URL url; +// private URL url; private KB kb; private KBFileConfigurator configurator; @@ -98,8 +97,10 @@ 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, true, true)); - options.add(new URLConfigOption("url", "URL pointer to the KB file",null, false, true)); +// options.add(new StringConfigOption("filename", "pointer to the KB file on local file system",null, true, true)); + URLConfigOption urlOption = new URLConfigOption("url", "URL pointer to the KB file",null, false, true); + urlOption.setRefersToFile(true); + options.add(urlOption); return options; } @@ -118,25 +119,26 @@ public void init() throws ComponentInitException { //URL url = null; try { - String filename = configurator.getFilename(); - String urlString = configurator.getUrl().toString(); - if(filename!=null){ - url = new File(filename).toURI().toURL(); - }else if(urlString!=null){ - url = new URL(urlString); - } +// String filename = configurator.getFilename(); +// String urlString = configurator.getUrl().toString(); +// if(filename!=null){ +// url = new File(filename).toURI().toURL(); +// }else if(urlString!=null){ +// url = new URL(urlString); +// } +// +// if(url != null) { +// kb = KBParser.parseKBFile(url); +// } + kb = KBParser.parseKBFile(configurator.getUrl()); - if(url != null) { - kb = KBParser.parseKBFile(url); - } - } catch (MalformedURLException e) { logger.error(e.getMessage()); //throw new InvalidConfigOptionValueException(entry.getOption(),entry.getValue()); } catch (IOException e) { - throw new ComponentInitException("KB file " + url + " could not be read.", e); + throw new ComponentInitException("KB file " + configurator.getUrl() + " could not be read.", e); } catch (ParseException e) { - throw new ComponentInitException("KB file " + url + " could not be parsed correctly.", e); + throw new ComponentInitException("KB file " + configurator.getUrl() + " could not be parsed correctly.", e); } } @@ -206,7 +208,7 @@ } public URL getURL() { - return url; + return configurator.getUrl(); } @Override Modified: trunk/src/dl-learner/org/dllearner/kb/OWLFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2008-09-12 09:52:17 UTC (rev 1198) +++ trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2008-09-12 10:52:14 UTC (rev 1199) @@ -65,7 +65,9 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); - options.add(new URLConfigOption("url", "URL pointing to the OWL file", null, true, true)); + URLConfigOption urlOption = new URLConfigOption("url", "URL pointing to the OWL file", null, true, true); + urlOption.setRefersToFile(true); + options.add(urlOption); return options; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |