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. |