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: <jen...@us...> - 2007-10-19 12:01:13
|
Revision: 252 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=252&view=rev Author: jenslehmann Date: 2007-10-19 05:01:07 -0700 (Fri, 19 Oct 2007) Log Message: ----------- added export method to abstract knowledge source class Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.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/SparqlEndpoint.java trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/JenaOWLDIGConverter.java trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDIGConverter.java trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/OntologyFormat.java trunk/src/dl-learner/org/dllearner/core/OntologyFormatUnsupportedException.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/kb/OntologyFileFormat.java Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-10-19 12:01:07 UTC (rev 252) @@ -41,6 +41,7 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; +import org.dllearner.core.OntologyFormat; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; @@ -58,7 +59,6 @@ import org.dllearner.core.dl.Individual; import org.dllearner.kb.KBFile; import org.dllearner.kb.OWLFile; -import org.dllearner.kb.OntologyFileFormat; import org.dllearner.kb.SparqlEndpoint; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegInclusionLP; @@ -382,20 +382,20 @@ return; File file = null; - OntologyFileFormat format = null; + OntologyFormat format = null; for (List<String> export : exports) { file = new File(baseDir, export.get(0)); if (export.size() == 1) // use RDF/XML by default - format = OntologyFileFormat.RDF_XML; + format = OntologyFormat.RDF_XML; // rs.saveOntology(file, OntologyFileFormat.RDF_XML); else { String formatString = export.get(1); // OntologyFileFormat format; if (formatString.equals("RDF/XML")) - format = OntologyFileFormat.RDF_XML; + format = OntologyFormat.RDF_XML; else - format = OntologyFileFormat.N_TRIPLES; + format = OntologyFormat.N_TRIPLES; // rs.saveOntology(file, format); } } Modified: trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java 2007-10-19 12:01:07 UTC (rev 252) @@ -19,9 +19,12 @@ */ package org.dllearner.core; +import java.io.File; import java.net.URI; /** + * Represents a knowledge source component. + * * @author Jens Lehmann * */ @@ -29,4 +32,6 @@ public abstract String toDIG(URI kbURI); + public abstract void export(File file, OntologyFormat format) throws OntologyFormatUnsupportedException; + } Added: trunk/src/dl-learner/org/dllearner/core/OntologyFormat.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/OntologyFormat.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/OntologyFormat.java 2007-10-19 12:01:07 UTC (rev 252) @@ -0,0 +1,20 @@ +package org.dllearner.core; + +public enum OntologyFormat { + + /** + * RDF-Triples in XML file + */ + RDF_XML, + + /** + * N-Triple format (subformat of N3) + */ + N_TRIPLES, + + /** + * internal KB format + */ + KB, + +} Added: trunk/src/dl-learner/org/dllearner/core/OntologyFormatUnsupportedException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/OntologyFormatUnsupportedException.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/OntologyFormatUnsupportedException.java 2007-10-19 12:01:07 UTC (rev 252) @@ -0,0 +1,38 @@ +/** + * 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.core; + + +/** + * Indicates that an operation is not supported/implemented for + * a specific ontology file format. + * + * @author Jens Lehmann + * + */ +public class OntologyFormatUnsupportedException extends Exception { + + private static final long serialVersionUID = 1080949376967068007L; + + public OntologyFormatUnsupportedException(String operation, OntologyFormat format) { + super("The operation " + operation + " does not support the ontology file format " + format); + } + +} Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2007-10-19 12:01:07 UTC (rev 252) @@ -33,7 +33,6 @@ import org.dllearner.core.dl.Individual; import org.dllearner.core.dl.RoleHierarchy; import org.dllearner.core.dl.SubsumptionHierarchy; -import org.dllearner.kb.OntologyFileFormat; import org.dllearner.reasoning.DIGReasoner; import org.dllearner.reasoning.KAON2Reasoner; import org.dllearner.reasoning.ReasonerType; @@ -406,7 +405,7 @@ } // speichern einer Ontolgie wird speziell behandelt, da kein Reasoning - public void saveOntology(File file, OntologyFileFormat format) { + public void saveOntology(File file, OntologyFormat format) { if (getReasonerType() == ReasonerType.KAON2) { ((KAON2Reasoner) reasoner).saveOntology(file, format); } else if (getReasonerType() == ReasonerType.DIG) { Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2007-10-19 12:01:07 UTC (rev 252) @@ -116,11 +116,12 @@ return kb.toString(); } - public void export(File file, org.dllearner.kb.OntologyFileFormat format) { + @Override + public void export(File file, org.dllearner.core.OntologyFormat format){ Reasoner kaon2Reasoner = KAON2Reasoner.getKAON2Reasoner(kb); String kaon2Format = ""; - if(format.equals(org.dllearner.kb.OntologyFileFormat.RDF_XML)) + if(format.equals(org.dllearner.core.OntologyFormat.RDF_XML)) kaon2Format = OntologyFileFormat.OWL_RDF; else { System.err.println("Warning: Cannot export format " + format + ". Exiting."); Modified: trunk/src/dl-learner/org/dllearner/kb/OWLFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2007-10-19 12:01:07 UTC (rev 252) @@ -19,6 +19,7 @@ */ package org.dllearner.kb; +import java.io.File; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; @@ -26,6 +27,8 @@ import java.util.LinkedList; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.OntologyFormat; +import org.dllearner.core.OntologyFormatUnsupportedException; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; @@ -88,11 +91,20 @@ @Override public String toDIG(URI kbURI) { // TODO: need some handling for cases where the URL was not set - return OWLAPIDIGConverter.getTellsString(url, OntologyFileFormat.RDF_XML, kbURI); + return OWLAPIDIGConverter.getTellsString(url, OntologyFormat.RDF_XML, kbURI); } public URL getURL() { return url; } + /* (non-Javadoc) + * @see org.dllearner.core.KnowledgeSource#export(java.io.File, org.dllearner.core.OntologyFormat) + */ + @Override + public void export(File file, OntologyFormat format) throws OntologyFormatUnsupportedException { + // currently no export functions implemented, so we just throw an exception + throw new OntologyFormatUnsupportedException("export", format); + } + } Deleted: trunk/src/dl-learner/org/dllearner/kb/OntologyFileFormat.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/OntologyFileFormat.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/kb/OntologyFileFormat.java 2007-10-19 12:01:07 UTC (rev 252) @@ -1,20 +0,0 @@ -package org.dllearner.kb; - -public enum OntologyFileFormat { - - /** - * RDF-Triples in XML file - */ - RDF_XML, - - /** - * N-Triple format (subformat of N3) - */ - N_TRIPLES, - - /** - * internal KB format - */ - KB, - -} Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-19 12:01:07 UTC (rev 252) @@ -30,6 +30,8 @@ import java.util.Set; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.OntologyFormat; +import org.dllearner.core.OntologyFormatUnsupportedException; import org.dllearner.core.config.BooleanConfigOption; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; @@ -170,10 +172,19 @@ */ @Override public String toDIG(URI kbURI) { - if (format.equals("N-TRIPLES")) return JenaOWLDIGConverter.getTellsString(dumpFile, OntologyFileFormat.N_TRIPLES, kbURI); + if (format.equals("N-TRIPLES")) return JenaOWLDIGConverter.getTellsString(dumpFile, OntologyFormat.N_TRIPLES, kbURI); else return DIGConverter.getDIGString(kb, kbURI).toString(); } + /* (non-Javadoc) + * @see org.dllearner.core.KnowledgeSource#export(java.io.File, org.dllearner.core.OntologyFormat) + */ + @Override + public void export(File file, OntologyFormat format) throws OntologyFormatUnsupportedException { + // currently no export functions implemented, so we just throw an exception + throw new OntologyFormatUnsupportedException("export", format); + } + public URL getURL() { return url; } Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java 2007-10-19 12:01:07 UTC (rev 252) @@ -31,7 +31,6 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; -import java.util.StringTokenizer; import java.util.Vector; Modified: trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2007-10-19 12:01:07 UTC (rev 252) @@ -37,6 +37,7 @@ import org.apache.xmlbeans.XmlCursor; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.OntologyFormat; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.config.BooleanConfigOption; import org.dllearner.core.config.ConfigEntry; @@ -51,7 +52,6 @@ import org.dllearner.core.dl.RoleHierarchy; import org.dllearner.core.dl.SubsumptionHierarchy; import org.dllearner.core.dl.Top; -import org.dllearner.kb.OntologyFileFormat; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; @@ -755,7 +755,7 @@ // TODO: not working yet - it is probably better to include a method // in knowledge source to save the corresponding source to a file - public void saveOntology(File file, OntologyFileFormat format) { + public void saveOntology(File file, OntologyFormat format) { // KAON2-Reasoner erzeugen und den die Ontologie speichern lassen // (später könnte man das über Jena erledigen, allerdings funktioniert // das mit KAON2 auch gut) Modified: trunk/src/dl-learner/org/dllearner/reasoning/JenaOWLDIGConverter.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/JenaOWLDIGConverter.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/reasoning/JenaOWLDIGConverter.java 2007-10-19 12:01:07 UTC (rev 252) @@ -16,7 +16,7 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import org.dllearner.kb.OntologyFileFormat; +import org.dllearner.core.OntologyFormat; import org.w3c.dom.Document; import com.hp.hpl.jena.graph.Graph; @@ -35,7 +35,7 @@ String tells = ""; try { URL url = file.toURI().toURL(); - tells = getTellsString(url, OntologyFileFormat.RDF_XML, new URI("kk")); + tells = getTellsString(url, OntologyFormat.RDF_XML, new URI("kk")); } catch (URISyntaxException e) { e.printStackTrace(); } catch (MalformedURLException e) { @@ -46,7 +46,7 @@ // returns a DIG 1.1 Tells String from an ontology file // using the Jena library - public static String getTellsString(URL file, OntologyFileFormat format, URI kbURI) { + public static String getTellsString(URL file, OntologyFormat format, URI kbURI) { String tellString = ""; // Spezifikation erzeugen: OWL DL @@ -74,7 +74,7 @@ // OntModel m = ModelFactory.createOntologyModel(); Model m = spec.createBaseModel(); String lang = ""; - if(format.equals(OntologyFileFormat.RDF_XML)) + if(format.equals(OntologyFormat.RDF_XML)) lang = "RDF/XML"; else lang = "N-TRIPLES"; Modified: trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-10-19 12:01:07 UTC (rev 252) @@ -91,7 +91,7 @@ private org.semanticweb.kaon2.api.reasoner.Reasoner kaon2Reasoner; private KAON2Connection kaon2Connection; - public KAON2Reasoner(KB kb, Map<URL,org.dllearner.kb.OntologyFileFormat> imports) { + public KAON2Reasoner(KB kb, Map<URL,org.dllearner.core.OntologyFormat> imports) { if(imports.size()>1) System.out.println("Warning: KAON2-Reasoner currently supports only one import file. Ignoring all other imports."); @@ -472,11 +472,11 @@ return returnMap; } - public void saveOntology(File file, org.dllearner.kb.OntologyFileFormat format) { + public void saveOntology(File file, org.dllearner.core.OntologyFormat format) { // File exportFile = new File(baseDir, fileName); // String format = OntologyFileFormat.OWL_RDF; String kaon2Format = ""; - if(format.equals(org.dllearner.kb.OntologyFileFormat.RDF_XML)) + if(format.equals(org.dllearner.core.OntologyFormat.RDF_XML)) kaon2Format = OntologyFileFormat.OWL_RDF; else { System.err.println("Warning: Cannot export format " + format + ". Exiting."); @@ -520,7 +520,7 @@ return ontology; } - private static Ontology importKB(String ontologyURI, org.dllearner.kb.OntologyFileFormat format, KAON2Connection connection) { + private static Ontology importKB(String ontologyURI, org.dllearner.core.OntologyFormat format, KAON2Connection connection) { Ontology ontology = null; try { long importStartTime = System.currentTimeMillis(); Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDIGConverter.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDIGConverter.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDIGConverter.java 2007-10-19 12:01:07 UTC (rev 252) @@ -14,7 +14,7 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import org.dllearner.kb.OntologyFileFormat; +import org.dllearner.core.OntologyFormat; import org.semanticweb.owl.apibinding.OWLManager; import org.semanticweb.owl.model.OWLOntologyCreationException; import org.semanticweb.owl.model.OWLOntologyManager; @@ -25,7 +25,7 @@ public class OWLAPIDIGConverter { - public static String getTellsString(URL file, OntologyFileFormat format, URI kbURI) { + public static String getTellsString(URL file, OntologyFormat format, URI kbURI) { // public static String getTellsString(URL file, URI kbURI){//throws OWLOntologyCreationException{ String ret=""; try{ Modified: trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-10-19 12:01:07 UTC (rev 252) @@ -34,11 +34,11 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; +import org.dllearner.core.OntologyFormat; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; import org.dllearner.kb.OWLFile; -import org.dllearner.kb.OntologyFileFormat; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.parser.ConfParser; import org.dllearner.reasoning.DIGReasoner; @@ -157,7 +157,7 @@ String baseDir = confFiles[exampleNr].getParent(); // read which files were imported (internal KB is ignored) and initialise reasoner - Map<URL, OntologyFileFormat> imports = getImports(learner.getFunctionCalls(), confFiles[exampleNr]); + Map<URL, OntologyFormat> imports = getImports(learner.getFunctionCalls(), confFiles[exampleNr]); //Map<URL, Class<? extends KnowledgeSource>> imports = Start.getImportedFiles(learner, baseDir); // detect specified positive and negative examples @@ -304,10 +304,10 @@ } - private static Map<URL, OntologyFileFormat> getImports(Map<String,List<List<String>>> functionCalls, File confFile) { - Map<URL, OntologyFileFormat> importedFiles = new HashMap<URL, OntologyFileFormat>(); + private static Map<URL, OntologyFormat> getImports(Map<String,List<List<String>>> functionCalls, File confFile) { + Map<URL, OntologyFormat> importedFiles = new HashMap<URL, OntologyFormat>(); - OntologyFileFormat format = null; + OntologyFormat format = null; URL url = null; List<List<String>> imports = functionCalls.get("import"); @@ -331,13 +331,13 @@ if (call.size() == 2) // falls nichts angegeben, dann wird RDF/XML gewählt - importedFiles.put(url, OntologyFileFormat.RDF_XML); + importedFiles.put(url, OntologyFormat.RDF_XML); else { String formatString = call.get(2); if (formatString.equals("RDF/XML")) - format = OntologyFileFormat.RDF_XML; + format = OntologyFormat.RDF_XML; else - format = OntologyFileFormat.N_TRIPLES; + format = OntologyFormat.N_TRIPLES; importedFiles.put(url, format); } // } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-19 11:48:44
|
Revision: 251 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=251&view=rev Author: jenslehmann Date: 2007-10-19 04:48:42 -0700 (Fri, 19 Oct 2007) Log Message: ----------- implemented export function for internal KB format Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-10-19 09:53:14 UTC (rev 250) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-10-19 11:48:42 UTC (rev 251) @@ -174,7 +174,7 @@ initComponent(cm, la); // perform file exports - performExports(parser, baseDir, rs); + performExports(parser, baseDir, sources, rs); // show examples (display each one if they do not take up much space, // otherwise just show the number of examples) @@ -375,25 +375,40 @@ return importedFiles; } - private static void performExports(ConfParser parser, String baseDir, ReasoningService rs) { + private static void performExports(ConfParser parser, String baseDir, Set<KnowledgeSource> sources, ReasoningService rs) { List<List<String>> exports = parser.getFunctionCalls().get("export"); + if (exports == null) return; + + File file = null; + OntologyFileFormat format = null; for (List<String> export : exports) { - File file = new File(baseDir, export.get(0)); + file = new File(baseDir, export.get(0)); if (export.size() == 1) // use RDF/XML by default - rs.saveOntology(file, OntologyFileFormat.RDF_XML); + format = OntologyFileFormat.RDF_XML; + // rs.saveOntology(file, OntologyFileFormat.RDF_XML); else { String formatString = export.get(1); - OntologyFileFormat format; + // OntologyFileFormat format; if (formatString.equals("RDF/XML")) format = OntologyFileFormat.RDF_XML; else format = OntologyFileFormat.N_TRIPLES; - rs.saveOntology(file, format); + // rs.saveOntology(file, format); } } + // hack: ideally we would have the possibility to export each knowledge + // source to specified files with specified formats (and maybe including + // the option to merge them all in one file) + // however implementing this requires quite some effort so for the + // moment we just stick to exporting KB files (moreover all but the last + // export statement are ignored) + for(KnowledgeSource source : sources) { + if(source instanceof KBFile) + ((KBFile)source).export(file, format); + } } private static void processCLIOptions(ComponentManager cm, ConfParser parser, Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2007-10-19 09:53:14 UTC (rev 250) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2007-10-19 11:48:42 UTC (rev 251) @@ -36,6 +36,10 @@ import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; import org.dllearner.reasoning.DIGConverter; +import org.dllearner.reasoning.KAON2Reasoner; +import org.semanticweb.kaon2.api.KAON2Exception; +import org.semanticweb.kaon2.api.formatting.OntologyFileFormat; +import org.semanticweb.kaon2.api.reasoner.Reasoner; /** * @author Jens Lehmann @@ -112,6 +116,28 @@ return kb.toString(); } + public void export(File file, org.dllearner.kb.OntologyFileFormat format) { + Reasoner kaon2Reasoner = KAON2Reasoner.getKAON2Reasoner(kb); + + String kaon2Format = ""; + if(format.equals(org.dllearner.kb.OntologyFileFormat.RDF_XML)) + kaon2Format = OntologyFileFormat.OWL_RDF; + else { + System.err.println("Warning: Cannot export format " + format + ". Exiting."); + System.exit(0); + } + + try { + kaon2Reasoner.getOntology().saveOntology(kaon2Format,file,"ISO-8859-1"); + } catch (KAON2Exception e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + public URL getURL() { return url; } Modified: trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-10-19 09:53:14 UTC (rev 250) +++ trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-10-19 11:48:42 UTC (rev 251) @@ -586,7 +586,24 @@ throw new IllegalArgumentException("Unsupported concept type."); } - private org.semanticweb.kaon2.api.reasoner.Reasoner getKAON2Reasoner(KB kb, + public static org.semanticweb.kaon2.api.reasoner.Reasoner getKAON2Reasoner(KB kb) { + try { + KAON2Connection connection = KAON2Manager.newConnection(); + + DefaultOntologyResolver resolver = new DefaultOntologyResolver(); + resolver.registerReplacement("http://localhost/foo", "file:nothing.xml"); + connection.setOntologyResolver(resolver); + Ontology ontology = connection.createOntology("http://localhost/foo", + new HashMap<String, Object>()); + return getKAON2Reasoner(kb, ontology); + + } catch (KAON2Exception e) { + e.printStackTrace(); + return null; + } + } + + private static org.semanticweb.kaon2.api.reasoner.Reasoner getKAON2Reasoner(KB kb, Ontology ontology) { org.semanticweb.kaon2.api.reasoner.Reasoner reasoner = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2007-10-19 09:53:19
|
Revision: 250 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=250&view=rev Author: sknappe Date: 2007-10-19 02:53:14 -0700 (Fri, 19 Oct 2007) Log Message: ----------- new version Modified Paths: -------------- trunk/src/dbpedia-navigator/SparqlConnection.php trunk/src/dbpedia-navigator/master.php Modified: trunk/src/dbpedia-navigator/SparqlConnection.php =================================================================== --- trunk/src/dbpedia-navigator/SparqlConnection.php 2007-10-19 09:52:23 UTC (rev 249) +++ trunk/src/dbpedia-navigator/SparqlConnection.php 2007-10-19 09:53:14 UTC (rev 250) @@ -7,50 +7,39 @@ private $DBPediaUrl; private $DLLearnerUri; private $client; - private $id; - - public function getID(){ - return $this->id; - } - - function SparqlConnection($DBPediaUrl,$DLLearnerUri,$getID=0) + + function SparqlConnection($DBPediaUrl,$DLLearnerUri) { ini_set("soap.wsdl_cache_enabled","0"); $this->DBPediaUrl=$DBPediaUrl; $this->DLLearnerUri=$DLLearnerUri; $this->loadWSDLfiles($DLLearnerUri); $this->client=new SoapClient("main.wsdl"); - if($getID==0) - { - $this->id=$this->client->generateID(); - } - else - { - $this->id=$getID; - } } function getConceptFromExamples($posExamples,$negExamples) { - $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); - $this->client->applyConfigEntryInt($this->id, $ksID, "numberOfRecursions", 2); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "instances", array_merge($posExamples,$negExamples)); - $this->client->applyConfigEntryInt($this->id, $ksID, "filterMode", 0); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "predList", array()); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "objList", array()); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "classList", array()); - $this->client->applyConfigEntryString($this->id, $ksID, "format", "KB"); - $this->client->applyConfigEntryBoolean($this->id, $ksID, "dumpToFile", false); + $id=$this->client->generateID(); - $this->client->setReasoner($this->id, "dig"); - $this->client->setLearningProblem($this->id, "posNegDefinition"); - $this->client->setPositiveExamples($this->id, $posExamples); - $this->client->setNegativeExamples($this->id, $negExamples); - $this->client->setLearningAlgorithm($this->id, "refinement"); + $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); + $this->client->applyConfigEntryInt($id, $ksID, "numberOfRecursions", 2); + $this->client->applyConfigEntryStringArray($id, $ksID, "instances", array_merge($posExamples,$negExamples)); + $this->client->applyConfigEntryInt($id, $ksID, "filterMode", 0); + $this->client->applyConfigEntryStringArray($id, $ksID, "predList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "objList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "classList", array()); + $this->client->applyConfigEntryString($id, $ksID, "format", "KB"); + $this->client->applyConfigEntryBoolean($id, $ksID, "dumpToFile", true); + $this->client->setReasoner($id, "dig"); + $this->client->setLearningProblem($id, "posNegDefinition"); + $this->client->setPositiveExamples($id, $posExamples); + $this->client->setNegativeExamples($id, $negExamples); + $this->client->setLearningAlgorithm($id, "refinement"); + $start = microtime(true); - $this->client->init($this->id); + $this->client->init($id); $learn_start = microtime(true); $init = $learn_start - $start; @@ -96,18 +85,20 @@ function getTriples($individual) { - $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); - $this->client->applyConfigEntryInt($this->id, $ksID, "numberOfRecursions", 1); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "instances", array($individual)); - $this->client->applyConfigEntryInt($this->id, $ksID, "filterMode", 3); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "predList", array()); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "objList", array()); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "classList", array()); - $this->client->applyConfigEntryString($this->id, $ksID, "format", "Array"); - $this->client->applyConfigEntryBoolean($this->id, $ksID, "dumpToFile", false); - $this->client->applyConfigEntryBoolean($this->id,$ksID,"useLits",true); + $id=$this->client->generateID(); - $object=$this->client->getTriples($this->id,$ksID); + $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); + $this->client->applyConfigEntryInt($id, $ksID, "numberOfRecursions", 1); + $this->client->applyConfigEntryStringArray($id, $ksID, "instances", array($individual)); + $this->client->applyConfigEntryInt($id, $ksID, "filterMode", 3); + $this->client->applyConfigEntryStringArray($id, $ksID, "predList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "objList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "classList", array()); + $this->client->applyConfigEntryString($id, $ksID, "format", "Array"); + $this->client->applyConfigEntryBoolean($id, $ksID, "dumpToFile", false); + $this->client->applyConfigEntryBoolean($id,$ksID,"useLits",true); + + $object=$this->client->getTriples($id,$ksID); $array=$object->item; $ret=array(); foreach ($array as $element) @@ -121,8 +112,10 @@ function getSubjects($label,$limit) { - $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); - $object=$this->client->getSubjects($this->id,$ksID,$label,$limit); + $id=$this->client->generateID(); + + $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); + $object=$this->client->getSubjects($id,$ksID,$label,$limit); return $object->item; } @@ -198,18 +191,4 @@ } } - -$positive=array("http://dbpedia.org/resource/Pythagoras", - "http://dbpedia.org/resource/Philolaus", - "http://dbpedia.org/resource/Archytas"); -$negative=array("http://dbpedia.org/resource/Socrates", - "http://dbpedia.org/resource/Zeno_of_Elea", - "http://dbpedia.org/resource/Plato"); - -$sparqlConnection=new SparqlConnection("http://dbpedia.openlinksw.com:8890/sparql","http://localhost:8181/services?wsdl"); -//$sparqlConnection->getConceptFromExamples($positive,$negative); -//$triples=$sparqlConnection->getTriples("http://dbpedia.org/resource/Leipzig"); -//print_r($triples); -//$subjects=$sparqlConnection->getSubjects("Leipzig",5); -//print_r($subjects); ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/master.php =================================================================== --- trunk/src/dbpedia-navigator/master.php 2007-10-19 09:52:23 UTC (rev 249) +++ trunk/src/dbpedia-navigator/master.php 2007-10-19 09:53:14 UTC (rev 250) @@ -26,8 +26,22 @@ </div> <!-- box --> -".$left." +<div class=\"box\" id=\"examples\"> + <div class=\"boxtitle\">Examples<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a></div> + <div class=\"boxcontent\"> + ".$examples." + </div> <!-- boxcontent --> + +</div> <!-- box --> +<div class=\"box\" id=\"examples\"> + <div class=\"boxtitle\">Concept<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a></div> + <div class=\"boxcontent\"> + ".$concept." + </div> <!-- boxcontent --> + +</div> <!-- box --> + <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> </div><!-- END leftSidebar --> @@ -38,7 +52,7 @@ ".$content." </div> <!-- boxcontent --> </div> <!-- box --> -".$middle." + <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> </div><!-- content --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2007-10-19 09:52:28
|
Revision: 249 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=249&view=rev Author: sknappe Date: 2007-10-19 02:52:23 -0700 (Fri, 19 Oct 2007) Log Message: ----------- new version Modified Paths: -------------- trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2007-10-19 09:47:16 UTC (rev 248) +++ trunk/src/dbpedia-navigator/index.php 2007-10-19 09:52:23 UTC (rev 249) @@ -7,37 +7,66 @@ ini_set('error_reporting',E_ALL); ini_set('max_execution_time',200); -$lastAction="View"; $content=""; -$possibleActions=""; -$instances=" "; -$left=""; -$right=""; -$middle=""; $search=""; -$system=""; +$examples=""; +$positiveAdd=""; +$negativeAdd=""; -$settings=new Settings(); +$settings=new Settings(); echo "<a href='index.php?clearsession=clear'>start from scratch</a>"; -if(isset($_GET['clearsession']))$_SESSION['State_ID'] =false; +if(isset($_GET['clearsession'])){ + unset($_SESSION['positive']); + unset($_SESSION['negative']); +} - - -if( (!isset($_SESSION['State_ID'] ) ) || ($_SESSION['State_ID']=="")) -{ - //get new ID - $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); - $_SESSION['State_ID']=$sc->getID(); - -} - -else{ - //echo "Current ID is: ".$_SESSION['Learner_ID']."<br>"; - $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['State_ID']); -} - - +$sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); + +//add positives or negatives to session +if (@$_GET['action']=='AddPositive'){ + $_GET=$_SESSION["lastGet"]; + if (!isset($_SESSION['positive'])){ + $array=array($_GET['subject']); + $_SESSION['positive']=$array; + } + else{ + $array=$_SESSION['positive']; + $array[]=$_GET['subject']; + $_SESSION['positive']=$array; + } +} +if (@$_GET['action']=='AddNegative'){ + $_GET=$_SESSION["lastGet"]; + if (!isset($_SESSION['negative'])){ + $array=array($_GET['subject']); + $_SESSION['negative']=$array; + } + else{ + $array=$_SESSION['negative']; + $array[]=$_GET['subject']; + $_SESSION['negative']=$array; + } +} +if (@$_GET['action']=='ClearPositive'){ + $_GET=$_SESSION["lastGet"]; + unset($_SESSION['positive']); +} +if (@$_GET['action']=='ClearNegative'){ + $_GET=$_SESSION["lastGet"]; + unset($_SESSION['negative']); +} + +//learn a concept +if (@$_GET['action']=="GetConcept") +{ + $_GET=$_SESSION["lastGet"]; + $conc=$sc->getConceptFromExamples($_SESSION['positive'],$_SESSION['negative']); + $_SESSION['learnedConcept']=$conc; +} +if (isset($_SESSION['learnedConcept'])) $learnedConcept="<br/>Last learned Concept: ".$_SESSION['learnedConcept']; +else $learnedConcept=""; + //SearchBox $search="<form action=\"index.php\" method=\"GET\">\n". "<table border=\"0\">\n". @@ -70,17 +99,51 @@ foreach ($triples as $triple){ $content.="Subject: ".urldecode($triple[0])."<br/>Predicate: ".urldecode($triple[1])."<br/>Object: ".urldecode($triple[2])."<br/><br/>\n"; } - } + $positiveAdd="<input type=\"submit\" name=\"action\" value=\"AddPositive\">"; + $negativeAdd="<input type=\"submit\" name=\"action\" value=\"AddNegative\">"; + } + +//add box for adding articles to positive or negative + $examples.="<form action=\"index.php\" method=\"GET\">\n". + "Positive:<br/>\n"; + if (!isset($_SESSION['positive'])) $examples.="No positive example picked yet.<br/>\n"; + else{ + $pos=$_SESSION['positive']; + foreach ($pos as $p) + { + $examples.=$p."<br/>\n"; + } + } + $examples.="<br/>".$positiveAdd." <input type=\"submit\" name=\"action\" value=\"ClearPositive\">\n". + "</form>\n"; + + $examples.="<form action=\"index.php\" method=\"GET\">\n". + "<br/>Negative:<br/>\n"; + if (!isset($_SESSION['negative'])) $examples.="No negative example picked yet.<br/>\n"; + else{ + $neg=$_SESSION['negative']; + foreach ($neg as $n) + { + $examples.=$n."<br/>\n"; + } + } + $examples.="<br/>".$negativeAdd." <input type=\"submit\" name=\"action\" value=\"ClearNegative\">\n". + "</form>\n"; + +//fill concept box + $concept="<form action=\"index.php\" method=\"GET\">\n". + "<input type=\"submit\" name=\"action\" value=\"GetConcept\">\n". + "</form>\n"; + $concept.=$learnedConcept; - +//include master + $_SESSION['lastGet']=$_GET; include("master.php"); echo $masterContent; - - - - - + + + //make a box function makeBox($title,$content,$toggleBoxContent=true) { if($toggleBoxContent) @@ -97,14 +160,4 @@ </div> <!-- box -->"; return $ret; } - - - function shorten($a) - { - if(($strpos=strpos($a,'#'))>=4){ - return substr($a,$strpos); - } - else {return $a;} - } - ?> \ 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...> - 2007-10-19 09:47:19
|
Revision: 248 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=248&view=rev Author: kurzum Date: 2007-10-19 02:47:16 -0700 (Fri, 19 Oct 2007) Log Message: ----------- small comment Modified Paths: -------------- trunk/examples/daimler/Automatik.conf Modified: trunk/examples/daimler/Automatik.conf =================================================================== --- trunk/examples/daimler/Automatik.conf 2007-10-19 09:40:13 UTC (rev 247) +++ trunk/examples/daimler/Automatik.conf 2007-10-19 09:47:16 UTC (rev 248) @@ -1,6 +1,7 @@ // lernt Die Definition f\xFCr Automatikgetriebe in der C-Klasse -// +// alle automatik getriebe in der CKlasse haben +// entweder 5 G\xE4nge oder 7 (Bezeichnung dann 7G-TRONIC) refinement.ignoredConcepts = {"http://www.daimler.de/test#Automatik"}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2007-10-19 09:31:40
|
Revision: 246 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=246&view=rev Author: sknappe Date: 2007-10-19 02:31:37 -0700 (Fri, 19 Oct 2007) Log Message: ----------- deleted DBPedia-Navigator Removed Paths: ------------- trunk/src/DBPedia-Navigator/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-19 08:54:41
|
Revision: 245 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=245&view=rev Author: jenslehmann Date: 2007-10-19 01:54:40 -0700 (Fri, 19 Oct 2007) Log Message: ----------- added .lastUsedExample to ignored files (the file is created when using quick start) Property Changed: ---------------- trunk/ Property changes on: trunk ___________________________________________________________________ Name: svn:ignore - .settings .project .classpath classes log cache + .lastUsedExample .settings .project .classpath classes log cache This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2007-10-19 08:52:01
|
Revision: 244 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=244&view=rev Author: sknappe Date: 2007-10-19 01:51:59 -0700 (Fri, 19 Oct 2007) Log Message: ----------- added the DBPedia-Navigator Added Paths: ----------- trunk/src/DBPedia-Navigator/ trunk/src/DBPedia-Navigator/Settings.php trunk/src/DBPedia-Navigator/SparqlConnection.php trunk/src/DBPedia-Navigator/def0.xsd trunk/src/DBPedia-Navigator/def1.xsd trunk/src/DBPedia-Navigator/default.css trunk/src/DBPedia-Navigator/index.php trunk/src/DBPedia-Navigator/main.wsdl trunk/src/DBPedia-Navigator/master.php trunk/src/DBPedia-Navigator/pear/ trunk/src/DBPedia-Navigator/pear/HTTP_Request.php trunk/src/DBPedia-Navigator/pear/PEAR.php trunk/src/DBPedia-Navigator/pear/Socket.php trunk/src/DBPedia-Navigator/pear/URL.php trunk/src/DBPedia-Navigator/test.php Added: trunk/src/DBPedia-Navigator/Settings.php =================================================================== --- trunk/src/DBPedia-Navigator/Settings.php (rev 0) +++ trunk/src/DBPedia-Navigator/Settings.php 2007-10-19 08:51:59 UTC (rev 244) @@ -0,0 +1,12 @@ +<?php + +class Settings{ + + +public $wsdluri="http://localhost:8181/services?wsdl"; + + +public $uri="http://localhost/dllearner/"; +public $dbpediauri="http://dbpedia.openlinksw.com:8890/sparql"; +} +?> \ No newline at end of file Added: trunk/src/DBPedia-Navigator/SparqlConnection.php =================================================================== --- trunk/src/DBPedia-Navigator/SparqlConnection.php (rev 0) +++ trunk/src/DBPedia-Navigator/SparqlConnection.php 2007-10-19 08:51:59 UTC (rev 244) @@ -0,0 +1,194 @@ +<?php + +require_once 'pear/HTTP_Request.php'; + +class SparqlConnection +{ + private $DBPediaUrl; + private $DLLearnerUri; + private $client; + + function SparqlConnection($DBPediaUrl,$DLLearnerUri) + { + ini_set("soap.wsdl_cache_enabled","0"); + $this->DBPediaUrl=$DBPediaUrl; + $this->DLLearnerUri=$DLLearnerUri; + $this->loadWSDLfiles($DLLearnerUri); + $this->client=new SoapClient("main.wsdl"); + } + + function getConceptFromExamples($posExamples,$negExamples) + { + $id=$this->client->generateID(); + + $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); + $this->client->applyConfigEntryInt($id, $ksID, "numberOfRecursions", 2); + $this->client->applyConfigEntryStringArray($id, $ksID, "instances", array_merge($posExamples,$negExamples)); + $this->client->applyConfigEntryInt($id, $ksID, "filterMode", 0); + $this->client->applyConfigEntryStringArray($id, $ksID, "predList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "objList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "classList", array()); + $this->client->applyConfigEntryString($id, $ksID, "format", "KB"); + $this->client->applyConfigEntryBoolean($id, $ksID, "dumpToFile", true); + + $this->client->setReasoner($id, "dig"); + $this->client->setLearningProblem($id, "posNegDefinition"); + $this->client->setPositiveExamples($id, $posExamples); + $this->client->setNegativeExamples($id, $negExamples); + $this->client->setLearningAlgorithm($id, "refinement"); + + $start = microtime(true); + + $this->client->init($id); + + $learn_start = microtime(true); + $init = $learn_start - $start; + echo 'components initialised in '.$init.' seconds<br />'; + + $threaded=true; + + if($threaded == false) { + + $concept = $this->client->learn($id); + + $learn = microtime(true) - $learn_start; + echo 'concept learned in '.$learn.' seconds<br />'; + + echo 'result: '.$concept; + + } else { + + $this->client->learnThreaded($id); + + $i = 1; + $sleeptime = 1; + + do { + // sleep a while + sleep($sleeptime); + + // see what we have learned so far + $concept=$this->client->getCurrentlyBestConcept($id); + $running=$this->client->isAlgorithmRunning($id); + + $seconds = $i * $sleeptime; + + echo 'result after '.$seconds.' seconds of sleep: '.$concept.'<br />'; + + $i++; + } while($running); + + echo 'algorithm finished'; + } + return $concept; + } + + function getTriples($individual) + { + $id=$this->client->generateID(); + + $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); + $this->client->applyConfigEntryInt($id, $ksID, "numberOfRecursions", 1); + $this->client->applyConfigEntryStringArray($id, $ksID, "instances", array($individual)); + $this->client->applyConfigEntryInt($id, $ksID, "filterMode", 3); + $this->client->applyConfigEntryStringArray($id, $ksID, "predList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "objList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "classList", array()); + $this->client->applyConfigEntryString($id, $ksID, "format", "Array"); + $this->client->applyConfigEntryBoolean($id, $ksID, "dumpToFile", false); + $this->client->applyConfigEntryBoolean($id,$ksID,"useLits",true); + + $object=$this->client->getTriples($id,$ksID); + $array=$object->item; + $ret=array(); + foreach ($array as $element) + { + $items=preg_split("[<]",$element,-1, PREG_SPLIT_NO_EMPTY); + $ret[]=$items; + } + + return $ret; + } + + function getSubjects($label,$limit) + { + $id=$this->client->generateID(); + + $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); + $object=$this->client->getSubjects($id,$ksID,$label,$limit); + return $object->item; + } + + private function loadWSDLfiles($wsdluri){ + $main=$this->getwsdl($wsdluri); + $other=$this->getOtherWSDL($main); + $newMain=$this->changeWSDL($main); + $this->writeToFile("main.wsdl",$newMain); + $x=0; + foreach ($other as $o){ + $this->writeToFile("def".($x++).".xsd",$this->getwsdl($o)); + } + + } + + private function changeWSDL($wsdl){ + $before="<xsd:import schemaLocation=\""; + $after="\" namespace=\""; + $newWSDL=""; + $desca="def"; + $descb=".xsd"; + $x=0; + while($posstart= strpos ( $wsdl, $before )){ + + $posstart+=strlen($before); + $newWSDL.=substr($wsdl,0,$posstart); + $wsdl=substr($wsdl,$posstart); + $newWSDL.=$desca.($x++).$descb; + $posend= strpos ( $wsdl, $after ); + $wsdl=substr($wsdl,$posend); + + } + return $newWSDL.$wsdl; + + } + + private function getOtherWSDL($wsdl){ + $before="<xsd:import schemaLocation=\""; + $after="\" namespace=\""; + $ret=array(); + while($posstart= strpos ( $wsdl, $before )){ + $posstart+=strlen($before); + $wsdl=substr($wsdl,$posstart); + $posend= strpos ( $wsdl, $after ); + $tmp=substr($wsdl,0,$posend); + $ret[]=$tmp; + $wsdl=substr($wsdl,$posend+strlen($after)); + } + return $ret; + } + + + + + private function getwsdl($wsdluri){ + // this is copied from the Pear example + // please don't ask me how it works + $req = &new HTTP_Request($wsdluri); + $message=""; + $req->setMethod(HTTP_REQUEST_METHOD_GET); + $req->sendRequest(); + $ret=$req->getResponseBody(); + return $ret; + } + + + + private function writeToFile($filename,$content){ + + $fp=fopen($filename,"w"); + fwrite($fp,$content); + fclose($fp); + + } +} +?> \ No newline at end of file Added: trunk/src/DBPedia-Navigator/def0.xsd =================================================================== --- trunk/src/DBPedia-Navigator/def0.xsd (rev 0) +++ trunk/src/DBPedia-Navigator/def0.xsd 2007-10-19 08:51:59 UTC (rev 244) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:tns="http://server.dllearner.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://server.dllearner.org/" version="1.0"> + + <xs:element name="ClientNotKnownException" type="tns:ClientNotKnownException"></xs:element> + + <xs:element name="ConfigOptionTypeException" type="tns:ConfigOptionTypeException"></xs:element> + + <xs:element name="UnknownComponentException" type="tns:UnknownComponentException"></xs:element> + + <xs:complexType name="ClientNotKnownException"> + <xs:sequence> + <xs:element name="message" type="xs:string" minOccurs="0"></xs:element> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="UnknownComponentException"> + <xs:sequence> + <xs:element name="message" type="xs:string" minOccurs="0"></xs:element> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="ConfigOptionTypeException"> + <xs:sequence> + <xs:element name="message" type="xs:string" minOccurs="0"></xs:element> + </xs:sequence> + </xs:complexType> +</xs:schema> \ No newline at end of file Added: trunk/src/DBPedia-Navigator/def1.xsd =================================================================== --- trunk/src/DBPedia-Navigator/def1.xsd (rev 0) +++ trunk/src/DBPedia-Navigator/def1.xsd 2007-10-19 08:51:59 UTC (rev 244) @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://jaxb.dev.java.net/array" version="1.0"> + + <xs:complexType final="#all" name="stringArray"> + <xs:sequence> + <xs:element nillable="true" maxOccurs="unbounded" name="item" type="xs:string" minOccurs="0"></xs:element> + </xs:sequence> + </xs:complexType> +</xs:schema> \ No newline at end of file Added: trunk/src/DBPedia-Navigator/default.css =================================================================== --- trunk/src/DBPedia-Navigator/default.css (rev 0) +++ trunk/src/DBPedia-Navigator/default.css 2007-10-19 08:51:59 UTC (rev 244) @@ -0,0 +1,453 @@ +/** + * default.css + * main Ontowiki style sheet + * @author: Norman Heino + * @version: $Id: default.css 751 2007-02-14 19:20:17Z nheino $ + */ + +/* remove browser specific margins */ +* { + margin: 0; + padding: 0; +} + +html { + font: 80%/1.2 "Lucida Grande", Helvetica, Arial, sans-serif; +} + +p { + margin: 8px 0; +} + +h2 { + margin: 0.5em 0 0.1em 0; +/* background-color: #eee;*/ + font-size: 110%; +} + + +/* + * Main site structure + */ + +#wrapper { + position: relative; + max-width: 100%; + padding: 15px; +/* margin: 15px;*/ +} + +#content { + margin: 0 19em; + overflow: hidden; +/* border-left: 1px solid #bbb; + border-right: 1px solid #bbb; + padding: 0 5px;*/ +} + +/* + * Side bars are positioned absolutely due to several reasons: + * (1)Internet Explorer has problems displaying float elements, + * (2) the content's position in html is irrelevant, + * (3) positioning the content div is more straightforward. + */ +#leftSidebar { + position: absolute; + width: 18em; +} + +#rightSidebar { + position: absolute; + width: 18em; + top: 15px; + right: 15px; +} + +#clear { + clear: both; +} + + +/* + * sidebar content (boxes) + */ + +.box { + color: #666; + margin-bottom: 20px; + border: 1px solid #bbb; + font-size: 85%; +} + +/*.box td { + font-size: 100%; +}*/ + +.box .boxtitle { + color: #666; + background-color: #eee; + padding: 3px 0.4em; + font-weight: bold; + white-space: nowrap; +} + +.box .boxtitle .boxtitle_string { + width: 80%; + overflow: hidden; +/* display: none;*/ +} + +.box .boxcontent { + padding: 0.6em; + border-top: 1px solid #bbb; +} + +/* restrict content of certain boxes */ +.box#predicates .boxcontent, +.box#classes .boxcontent { + overflow: hidden; +} + +.box p { + margin: 0 2px 4px 0; +} + +.box ul, .box ol { + margin: 0px; +/* padding-left: 15px;*/ + list-style-position: inside; +} + +.box ul.no_bullet, .box ul.no_bullet { + list-style-type: none; +} + +.box ul li.horizontal, .box ol li.horizontal, +.box ul.horizontal, .box ol.horizontal { + display: inline; +} + +.box a.title_switch { + position: absolute; + right: 0.5em; + margin: auto 0; + color: #666; + border: 1px solid #bbb; + width: 1em; + height: 1em; + background-color: #fff; + text-align: center; +} + +.box a.title_switch:hover { + color: #02a; + text-decoration: none; + background-color: #eee; +} + +.box hr { + margin: 0.5em 0; + border: none; + border-top: 1px dotted #bbb; + height: 0; +} + +.box#classes .boxcontent a { + display: block; +} + +/*.box select { + width: 250px; /* TODO remove absolute size */ +}*/ + +.box input { + width: auto; +} + +.box td input { + width: 100%; +} + +.box img.rating { + position: relative; + top: 1px; +} + +.hidden { + display: none; +} + + +/* + * Links + */ + +a, a:link, a:visited { + color: #02a; + text-decoration: none; + cursor: pointer; +} + +a:hover { + text-decoration: underline; +} + + +/* + * Tabs + */ + +/* all the tabs */ +.tabs { + float: left; + width: 100%; + background: #fff url("../images/tabs_back.png") repeat-x bottom; +} + +.tabs ul { + list-style: none; +} + +.tabs li { + float: left; + margin-right: 1px; +} + +.tabs a { + display: block; + margin-top: 1px; + padding: 0.35em 1.35em; + background-image: url("../images/tab_back.png"); + background-repeat: repeat-x; + background-color: #cbcbcb; + border: 1px solid #bbb; +} + +.tabs a:hover { + background: #fff; + text-decoration: none; +} + +.tabs a.current { + background: #fff; + border-bottom: 1px solid #fff; +} + +/* horizontal line underneath the tabs */ +#tab-line { + height: 1em; + clear: both; +} + +#instances { + float: right; +} + +.selected { + background-color: #bde; /*#b4d5fe;*/ +} + +.button { + border: solid black 1px; + padding: 0px 1px; + background-color: #eee; +} + +/* + * Tables + */ + +tr.odd { + background-color: #ccc; +} + +tr.even { + background-color: #eee; +} + +table.instanceTable th { + text-align: left; +/* background-color: #eee;*/ +} + +table.instanceTable > tbody > tr > td { + padding-top: 0.5em; +} + +table.instanceTable td.property { + text-align: right; + font-style: italic; + padding-right: 5px; +} + +table.instanceTable ul { + margin: 0px; + padding-left: 20px; +} + +table.instanceTable { + width: 100%; +} + +.searchHighlight { + background-color: orange; +} + +table.tripletable { + width: 100%; + font-size: 90%; +} + +.tripletable td { + padding: 0.4em; +} + +table.blind tr td { + padding-top: 0.4em; +} + +/* + * Instances + */ + +.instance .instance { + margin-left: 13px; + background-color: #ddd; +} +.instance .instance td { + font-size: 90%; +} +.instance .instance .instance { + background-color: #eee; +} + +.instance .instance .instance .instance { + background-color: #fff; +} + +#instanceEdit { + border-spacing: 0px; + width: 100%; +} + +#instanceEdit input, #instanceEdit textarea { +/* width: 250px;*/ + background-color: #fff; + font-size: 95%; + font-family: "Lucida Grande", Helvetica, Arial, sans-serif; + padding: 0.1em 0; +} + +#instanceEdit > tbody > tr > td, #instanceEdit > tr > td { + background-color: #eee; + padding: 5px; + border-bottom: 2px solid #fdfdfd; +} + +/* + * Calendar + */ + +table.calendar { + margin-top: 1em; + width: 100%; + height: 730px; + table-layout: fixed; + font-size: 90%; +} + +.calendar .weekday0 { + background-color: #eee; + padding: 0.4em; +} +.calendar .weekday1 { + background-color: #f5f5f5; + padding: 0.4em; +} +.calendar .weekend0 { + background-color: #ddd; + padding: 0.4em; +} +.calendar .weekend1 { + background-color: #eaeaea; + padding: 0.4em; +} + +#map { + margin-top: 0.5em; + width: 100%; + height: 750px; + font-size: 90%; +} + +#map .instance td { + font-size: 80%; + padding: 0 3px; + border-bottom: 5px solid white; +} + +#superClassPath { + margin-bottom: 0.5em; +} + +img { + border: none; +} + +span.submit { + float: right; + padding-right: 100px; +} + +/* + * Autosuggest box + */ +div.autosuggest { + font-size: 85%; + position: absolute; + background-color: #fff; + border: 1px solid #bbb; +} + +div.autosuggest ul { + list-style-type: none; + list-style-position: inside; + padding-left: 0px; +} + +div.autosuggest ul li.selected { + background-color: #bde; +} + +div.autosuggest ul li { + display: block; + padding: 0.2em; +/* height: 22px;*/ + cursor: pointer; +} + +span.formal { + display: none; +} + +/* + * Layer + */ +#layer { + width: 100%; + height: 100%; + position: absolute; + background-image: url("../images/black_50.png"); + background-repeat: repeat; + z-index: 98; +} + +#layerContent { + margin-top: 100px; + margin: auto; + width: 500px; + height: 300px; + background-color: #ffb; + border: 2px solid #bbb; + z-index: 99; +} Added: trunk/src/DBPedia-Navigator/index.php =================================================================== --- trunk/src/DBPedia-Navigator/index.php (rev 0) +++ trunk/src/DBPedia-Navigator/index.php 2007-10-19 08:51:59 UTC (rev 244) @@ -0,0 +1,163 @@ +<?php + +@session_start(); +include_once("Settings.php"); +include_once("SparqlConnection.php"); + + ini_set('error_reporting',E_ALL); + ini_set('max_execution_time',200); + +$content=""; +$search=""; +$examples=""; +$positiveAdd=""; +$negativeAdd=""; + +$settings=new Settings(); + +echo "<a href='index.php?clearsession=clear'>start from scratch</a>"; +if(isset($_GET['clearsession'])){ + unset($_SESSION['positive']); + unset($_SESSION['negative']); +} + +$sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); + +//add positives or negatives to session +if (@$_GET['action']=='AddPositive'){ + $_GET=$_SESSION["lastGet"]; + if (!isset($_SESSION['positive'])){ + $array=array($_GET['subject']); + $_SESSION['positive']=$array; + } + else{ + $array=$_SESSION['positive']; + $array[]=$_GET['subject']; + $_SESSION['positive']=$array; + } +} +if (@$_GET['action']=='AddNegative'){ + $_GET=$_SESSION["lastGet"]; + if (!isset($_SESSION['negative'])){ + $array=array($_GET['subject']); + $_SESSION['negative']=$array; + } + else{ + $array=$_SESSION['negative']; + $array[]=$_GET['subject']; + $_SESSION['negative']=$array; + } +} +if (@$_GET['action']=='ClearPositive'){ + $_GET=$_SESSION["lastGet"]; + unset($_SESSION['positive']); +} +if (@$_GET['action']=='ClearNegative'){ + $_GET=$_SESSION["lastGet"]; + unset($_SESSION['negative']); +} + +//learn a concept +if (@$_GET['action']=="GetConcept") +{ + $_GET=$_SESSION["lastGet"]; + $conc=$sc->getConceptFromExamples($_SESSION['positive'],$_SESSION['negative']); + $_SESSION['learnedConcept']=$conc; +} +if (isset($_SESSION['learnedConcept'])) $learnedConcept="<br/>Last learned Concept: ".$_SESSION['learnedConcept']; +else $learnedConcept=""; + +//SearchBox + $search="<form action=\"index.php\" method=\"GET\">\n". + "<table border=\"0\">\n". + "<tr><tb>Search:<br/></tb></tr>\n". + "<tr><tb><input type=\"textfield\" name=\"search\"><select name=\"limit\" size=\"1\">\n". + "<option>1</option>\n". + "<option selected=\"selected\">5</option>\n". + "<option>10</option>\n". + "<option>15</option>\n". + "</select><br/></tb></tr>\n". + "<tr><tb><input type=\"submit\" name=\"action\" value=\"Search\"><input type=\"submit\" name=\"action\" value=\"Fulltext\"></tb></tr>\n". + "</table>\n". + "</form>\n"; + +//Get Search result + if (@$_GET['action']=='Search') + { + $label=$_GET['search']; + $limit=$_GET['limit']; + $subjects=$sc->getSubjects($label,$limit); + foreach ($subjects as $subject){ + $content.="<a href=\"index.php?action=showPage&subject=".$subject."\">".$subject."</a><br/>\n"; + } + } + +//Show Subject Page + if (@$_GET['action']=="showPage") + { + $triples=$sc->getTriples($_GET['subject']); + foreach ($triples as $triple){ + $content.="Subject: ".urldecode($triple[0])."<br/>Predicate: ".urldecode($triple[1])."<br/>Object: ".urldecode($triple[2])."<br/><br/>\n"; + } + $positiveAdd="<input type=\"submit\" name=\"action\" value=\"AddPositive\">"; + $negativeAdd="<input type=\"submit\" name=\"action\" value=\"AddNegative\">"; + } + +//add box for adding articles to positive or negative + $examples.="<form action=\"index.php\" method=\"GET\">\n". + "Positive:<br/>\n"; + if (!isset($_SESSION['positive'])) $examples.="No positive example picked yet.<br/>\n"; + else{ + $pos=$_SESSION['positive']; + foreach ($pos as $p) + { + $examples.=$p."<br/>\n"; + } + } + $examples.="<br/>".$positiveAdd." <input type=\"submit\" name=\"action\" value=\"ClearPositive\">\n". + "</form>\n"; + + $examples.="<form action=\"index.php\" method=\"GET\">\n". + "<br/>Negative:<br/>\n"; + if (!isset($_SESSION['negative'])) $examples.="No negative example picked yet.<br/>\n"; + else{ + $neg=$_SESSION['negative']; + foreach ($neg as $n) + { + $examples.=$n."<br/>\n"; + } + } + $examples.="<br/>".$negativeAdd." <input type=\"submit\" name=\"action\" value=\"ClearNegative\">\n". + "</form>\n"; + +//fill concept box + $concept="<form action=\"index.php\" method=\"GET\">\n". + "<input type=\"submit\" name=\"action\" value=\"GetConcept\">\n". + "</form>\n"; + $concept.=$learnedConcept; + +//include master + $_SESSION['lastGet']=$_GET; + include("master.php"); + + echo $masterContent; + + + //make a box + function makeBox($title,$content,$toggleBoxContent=true) + { + if($toggleBoxContent) + { + $click="<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a>"; + } + else{$click="";} + $ret=" + <div class=\"box\" id=\"ontology\"> + <div class=\"boxtitle\">".$title.$click."</div> + <div class=\"boxcontent\"> + ".$content." + </div> <!-- boxcontent --> + </div> <!-- box -->"; + return $ret; + } +?> \ No newline at end of file Added: trunk/src/DBPedia-Navigator/main.wsdl =================================================================== --- trunk/src/DBPedia-Navigator/main.wsdl (rev 0) +++ trunk/src/DBPedia-Navigator/main.wsdl 2007-10-19 08:51:59 UTC (rev 244) @@ -0,0 +1,934 @@ +<?xml version="1.0" encoding="UTF-8"?><definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://server.dllearner.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://server.dllearner.org/" name="DLLearnerWSService"> + <types> + <xsd:schema> + <xsd:import schemaLocation="def0.xsd" namespace="http://server.dllearner.org/"></xsd:import> + </xsd:schema> + <xsd:schema> + <xsd:import schemaLocation="def1.xsd" namespace="http://jaxb.dev.java.net/array"></xsd:import> + </xsd:schema> + </types> + <message name="generateID"></message> + <message name="generateIDResponse"> + <part name="return" type="xsd:int"></part> + </message> + <message name="getKnowledgeSources"></message> + <message name="getKnowledgeSourcesResponse"> + <part xmlns:ns1="http://jaxb.dev.java.net/array" name="return" type="ns1:stringArray"></part> + </message> + <message name="getReasoners"></message> + <message name="getReasonersResponse"> + <part xmlns:ns2="http://jaxb.dev.java.net/array" name="return" type="ns2:stringArray"></part> + </message> + <message name="getLearningProblems"></message> + <message name="getLearningProblemsResponse"> + <part xmlns:ns3="http://jaxb.dev.java.net/array" name="return" type="ns3:stringArray"></part> + </message> + <message name="getLearningAlgorithms"></message> + <message name="getLearningAlgorithmsResponse"> + <part xmlns:ns4="http://jaxb.dev.java.net/array" name="return" type="ns4:stringArray"></part> + </message> + <message name="getConfigOptions"> + <part name="arg0" type="xsd:string"></part> + <part name="arg1" type="xsd:boolean"></part> + </message> + <message name="getConfigOptionsResponse"> + <part xmlns:ns5="http://jaxb.dev.java.net/array" name="return" type="ns5:stringArray"></part> + </message> + <message name="UnknownComponentException"> + <part element="tns:UnknownComponentException" name="fault"></part> + </message> + <message name="addKnowledgeSource"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:string"></part> + <part name="arg2" type="xsd:string"></part> + </message> + <message name="addKnowledgeSourceResponse"> + <part name="return" type="xsd:int"></part> + </message> + <message name="ClientNotKnownException"> + <part element="tns:ClientNotKnownException" name="fault"></part> + </message> + <message name="removeKnowledgeSource"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + </message> + <message name="removeKnowledgeSourceResponse"></message> + <message name="setReasoner"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:string"></part> + </message> + <message name="setReasonerResponse"> + <part name="return" type="xsd:int"></part> + </message> + <message name="setLearningProblem"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:string"></part> + </message> + <message name="setLearningProblemResponse"> + <part name="return" type="xsd:int"></part> + </message> + <message name="setLearningAlgorithm"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:string"></part> + </message> + <message name="setLearningAlgorithmResponse"> + <part name="return" type="xsd:int"></part> + </message> + <message name="learn"> + <part name="arg0" type="xsd:int"></part> + </message> + <message name="learnResponse"> + <part name="return" type="xsd:string"></part> + </message> + <message name="learnThreaded"> + <part name="arg0" type="xsd:int"></part> + </message> + <message name="learnThreadedResponse"></message> + <message name="getCurrentlyBestConcept"> + <part name="arg0" type="xsd:int"></part> + </message> + <message name="getCurrentlyBestConceptResponse"> + <part name="return" type="xsd:string"></part> + </message> + <message name="isAlgorithmRunning"> + <part name="arg0" type="xsd:int"></part> + </message> + <message name="isAlgorithmRunningResponse"> + <part name="return" type="xsd:boolean"></part> + </message> + <message name="setPositiveExamples"> + <part name="arg0" type="xsd:int"></part> + <part xmlns:ns6="http://jaxb.dev.java.net/array" name="arg1" type="ns6:stringArray"></part> + </message> + <message name="setPositiveExamplesResponse"></message> + <message name="setNegativeExamples"> + <part name="arg0" type="xsd:int"></part> + <part xmlns:ns7="http://jaxb.dev.java.net/array" name="arg1" type="ns7:stringArray"></part> + </message> + <message name="setNegativeExamplesResponse"></message> + <message name="applyConfigEntryInt"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + <part name="arg2" type="xsd:string"></part> + <part name="arg3" type="xsd:int"></part> + </message> + <message name="applyConfigEntryIntResponse"></message> + <message name="applyConfigEntryString"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + <part name="arg2" type="xsd:string"></part> + <part name="arg3" type="xsd:string"></part> + </message> + <message name="applyConfigEntryStringResponse"></message> + <message name="applyConfigEntryStringArray"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + <part name="arg2" type="xsd:string"></part> + <part xmlns:ns8="http://jaxb.dev.java.net/array" name="arg3" type="ns8:stringArray"></part> + </message> + <message name="applyConfigEntryStringArrayResponse"></message> + <message name="applyConfigEntryBoolean"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + <part name="arg2" type="xsd:string"></part> + <part name="arg3" type="xsd:boolean"></part> + </message> + <message name="applyConfigEntryBooleanResponse"></message> + <message name="getConfigOptionValueStringArray"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + <part name="arg2" type="xsd:string"></part> + </message> + <message name="getConfigOptionValueStringArrayResponse"> + <part xmlns:ns9="http://jaxb.dev.java.net/array" name="return" type="ns9:stringArray"></part> + </message> + <message name="ConfigOptionTypeException"> + <part element="tns:ConfigOptionTypeException" name="fault"></part> + </message> + <message name="getConfigOptionValueString"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + <part name="arg2" type="xsd:string"></part> + </message> + <message name="getConfigOptionValueStringResponse"> + <part name="return" type="xsd:string"></part> + </message> + <message name="getConfigOptionValueDouble"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + <part name="arg2" type="xsd:string"></part> + </message> + <message name="getConfigOptionValueDoubleResponse"> + <part name="return" type="xsd:double"></part> + </message> + <message name="getConfigOptionValueBoolean"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + <part name="arg2" type="xsd:string"></part> + </message> + <message name="getConfigOptionValueBooleanResponse"> + <part name="return" type="xsd:boolean"></part> + </message> + <message name="getConfigOptionValueInt"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + <part name="arg2" type="xsd:string"></part> + </message> + <message name="getConfigOptionValueIntResponse"> + <part name="return" type="xsd:int"></part> + </message> + <message name="getAtomicConcepts"> + <part name="arg0" type="xsd:int"></part> + </message> + <message name="getAtomicConceptsResponse"> + <part xmlns:ns10="http://jaxb.dev.java.net/array" name="return" type="ns10:stringArray"></part> + </message> + <message name="getSubsumptionHierarchy"> + <part name="arg0" type="xsd:int"></part> + </message> + <message name="getSubsumptionHierarchyResponse"> + <part name="return" type="xsd:string"></part> + </message> + <message name="retrieval"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:string"></part> + </message> + <message name="retrievalResponse"> + <part xmlns:ns11="http://jaxb.dev.java.net/array" name="return" type="ns11:stringArray"></part> + </message> + <message name="getAtomicRoles"> + <part name="arg0" type="xsd:int"></part> + </message> + <message name="getAtomicRolesResponse"> + <part xmlns:ns12="http://jaxb.dev.java.net/array" name="return" type="ns12:stringArray"></part> + </message> + <message name="getInstances"> + <part name="arg0" type="xsd:int"></part> + </message> + <message name="getInstancesResponse"> + <part xmlns:ns13="http://jaxb.dev.java.net/array" name="return" type="ns13:stringArray"></part> + </message> + <message name="getIndividualsForARole"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:string"></part> + </message> + <message name="getIndividualsForARoleResponse"> + <part xmlns:ns14="http://jaxb.dev.java.net/array" name="return" type="ns14:stringArray"></part> + </message> + <message name="getTriples"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + </message> + <message name="getTriplesResponse"> + <part xmlns:ns15="http://jaxb.dev.java.net/array" name="return" type="ns15:stringArray"></part> + </message> + <message name="getSubjects"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + <part name="arg2" type="xsd:string"></part> + <part name="arg3" type="xsd:int"></part> + </message> + <message name="getSubjectsResponse"> + <part xmlns:ns16="http://jaxb.dev.java.net/array" name="return" type="ns16:stringArray"></part> + </message> + <message name="init"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + </message> + <message name="initResponse"></message> + <message name="stop"> + <part name="arg0" type="xsd:int"></part> + </message> + <message name="stopResponse"></message> + <message name="getComponents"></message> + <message name="getComponentsResponse"> + <part xmlns:ns17="http://jaxb.dev.java.net/array" name="return" type="ns17:stringArray"></part> + </message> + <portType name="DLLearnerWebService"> + <operation name="generateID" parameterOrder=""> + <input message="tns:generateID"></input> + <output message="tns:generateIDResponse"></output> + </operation> + <operation name="getKnowledgeSources" parameterOrder=""> + <input message="tns:getKnowledgeSources"></input> + <output message="tns:getKnowledgeSourcesResponse"></output> + </operation> + <operation name="getReasoners" parameterOrder=""> + <input message="tns:getReasoners"></input> + <output message="tns:getReasonersResponse"></output> + </operation> + <operation name="getLearningProblems" parameterOrder=""> + <input message="tns:getLearningProblems"></input> + <output message="tns:getLearningProblemsResponse"></output> + </operation> + <operation name="getLearningAlgorithms" parameterOrder=""> + <input message="tns:getLearningAlgorithms"></input> + <output message="tns:getLearningAlgorithmsResponse"></output> + </operation> + <operation name="getConfigOptions" parameterOrder="arg0 arg1"> + <input message="tns:getConfigOptions"></input> + <output message="tns:getConfigOptionsResponse"></output> + <fault message="tns:UnknownComponentException" name="UnknownComponentException"></fault> + </operation> + <operation name="addKnowledgeSource" parameterOrder="arg0 arg1 arg2"> + <input message="tns:addKnowledgeSource"></input> + <output message="tns:addKnowledgeSourceResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + <fault message="tns:UnknownComponentException" name="UnknownComponentException"></fault> + </operation> + <operation name="removeKnowledgeSource" parameterOrder="arg0 arg1"> + <input message="tns:removeKnowledgeSource"></input> + <output message="tns:removeKnowledgeSourceResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="setReasoner" parameterOrder="arg0 arg1"> + <input message="tns:setReasoner"></input> + <output message="tns:setReasonerResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + <fault message="tns:UnknownComponentException" name="UnknownComponentException"></fault> + </operation> + <operation name="setLearningProblem" parameterOrder="arg0 arg1"> + <input message="tns:setLearningProblem"></input> + <output message="tns:setLearningProblemResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + <fault message="tns:UnknownComponentException" name="UnknownComponentException"></fault> + </operation> + <operation name="setLearningAlgorithm" parameterOrder="arg0 arg1"> + <input message="tns:setLearningAlgorithm"></input> + <output message="tns:setLearningAlgorithmResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + <fault message="tns:UnknownComponentException" name="UnknownComponentException"></fault> + </operation> + <operation name="learn" parameterOrder="arg0"> + <input message="tns:learn"></input> + <output message="tns:learnResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="learnThreaded" parameterOrder="arg0"> + <input message="tns:learnThreaded"></input> + <output message="tns:learnThreadedResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="getCurrentlyBestConcept" parameterOrder="arg0"> + <input message="tns:getCurrentlyBestConcept"></input> + <output message="tns:getCurrentlyBestConceptResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="isAlgorithmRunning" parameterOrder="arg0"> + <input message="tns:isAlgorithmRunning"></input> + <output message="tns:isAlgorithmRunningResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="setPositiveExamples" parameterOrder="arg0 arg1"> + <input message="tns:setPositiveExamples"></input> + <output message="tns:setPositiveExamplesResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="setNegativeExamples" parameterOrder="arg0 arg1"> + <input message="tns:setNegativeExamples"></input> + <output message="tns:setNegativeExamplesResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="applyConfigEntryInt" parameterOrder="arg0 arg1 arg2 arg3"> + <input message="tns:applyConfigEntryInt"></input> + <output message="tns:applyConfigEntryIntResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + <fault message="tns:UnknownComponentException" name="UnknownComponentException"></fault> + </operation> + <operation name="applyConfigEntryString" parameterOrder="arg0 arg1 arg2 arg3"> + <input message="tns:applyConfigEntryString"></input> + <output message="tns:applyConfigEntryStringResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + <fault message="tns:UnknownComponentException" name="UnknownComponentException"></fault> + </operation> + <operation name="applyConfigEntryStringArray" parameterOrder="arg0 arg1 arg2 arg3"> + <input message="tns:applyConfigEntryStringArray"></input> + <output message="tns:applyConfigEntryStringArrayResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + <fault message="tns:UnknownComponentException" name="UnknownComponentException"></fault> + </operation> + <operation name="applyConfigEntryBoolean" parameterOrder="arg0 arg1 arg2 arg3"> + <input message="tns:applyConfigEntryBoolean"></input> + <output message="tns:applyConfigEntryBooleanResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + <fault message="tns:UnknownComponentException" name="UnknownComponentException"></fault> + </operation> + <operation name="getConfigOptionValueStringArray" parameterOrder="arg0 arg1 arg2"> + <input message="tns:getConfigOptionValueStringArray"></input> + <output message="tns:getConfigOptionValueStringArrayResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + <fault message="tns:UnknownComponentException" name="UnknownComponentException"></fault> + <fault message="tns:ConfigOptionTypeException" name="ConfigOptionTypeException"></fault> + </operation> + <operation name="getConfigOptionValueString" parameterOrder="arg0 arg1 arg2"> + <input message="tns:getConfigOptionValueString"></input> + <output message="tns:getConfigOptionValueStringResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + <fault message="tns:UnknownComponentException" name="UnknownComponentException"></fault> + <fault message="tns:ConfigOptionTypeException" name="ConfigOptionTypeException"></fault> + </operation> + <operation name="getConfigOptionValueDouble" parameterOrder="arg0 arg1 arg2"> + <input message="tns:getConfigOptionValueDouble"></input> + <output message="tns:getConfigOptionValueDoubleResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + <fault message="tns:UnknownComponentException" name="UnknownComponentException"></fault> + <fault message="tns:ConfigOptionTypeException" name="ConfigOptionTypeException"></fault> + </operation> + <operation name="getConfigOptionValueBoolean" parameterOrder="arg0 arg1 arg2"> + <input message="tns:getConfigOptionValueBoolean"></input> + <output message="tns:getConfigOptionValueBooleanResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + <fault message="tns:UnknownComponentException" name="UnknownComponentException"></fault> + <fault message="tns:ConfigOptionTypeException" name="ConfigOptionTypeException"></fault> + </operation> + <operation name="getConfigOptionValueInt" parameterOrder="arg0 arg1 arg2"> + <input message="tns:getConfigOptionValueInt"></input> + <output message="tns:getConfigOptionValueIntResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + <fault message="tns:UnknownComponentException" name="UnknownComponentException"></fault> + <fault message="tns:ConfigOptionTypeException" name="ConfigOptionTypeException"></fault> + </operation> + <operation name="getAtomicConcepts" parameterOrder="arg0"> + <input message="tns:getAtomicConcepts"></input> + <output message="tns:getAtomicConceptsResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="getSubsumptionHierarchy" parameterOrder="arg0"> + <input message="tns:getSubsumptionHierarchy"></input> + <output message="tns:getSubsumptionHierarchyResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="retrieval" parameterOrder="arg0 arg1"> + <input message="tns:retrieval"></input> + <output message="tns:retrievalResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="getAtomicRoles" parameterOrder="arg0"> + <input message="tns:getAtomicRoles"></input> + <output message="tns:getAtomicRolesResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="getInstances" parameterOrder="arg0"> + <input message="tns:getInstances"></input> + <output message="tns:getInstancesResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="getIndividualsForARole" parameterOrder="arg0 arg1"> + <input message="tns:getIndividualsForARole"></input> + <output message="tns:getIndividualsForARoleResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="getTriples" parameterOrder="arg0 arg1"> + <input message="tns:getTriples"></input> + <output message="tns:getTriplesResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="getSubjects" parameterOrder="arg0 arg1 arg2 arg3"> + <input message="tns:getSubjects"></input> + <output message="tns:getSubjectsResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="init" parameterOrder="arg0 arg1"> + <input message="tns:init"></input> + <output message="tns:initResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="stop" parameterOrder="arg0"> + <input message="tns:stop"></input> + <output message="tns:stopResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="getComponents" parameterOrder=""> + <input message="tns:getComponents"></input> + <output message="tns:getComponentsResponse"></output> + </operation> + </portType> + <binding name="DLLearnerWebServicePortBinding" type="tns:DLLearnerWebService"> + <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"></soap:binding> + <operation name="generateID"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + </operation> + <operation name="getKnowledgeSources"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + </operation> + <operation name="getReasoners"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + </operation> + <operation name="getLearningProblems"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + </operation> + <operation name="getLearningAlgorithms"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + </operation> + <operation name="getConfigOptions"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="UnknownComponentException"> + <soap:fault name="UnknownComponentException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="addKnowledgeSource"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + <fault name="UnknownComponentException"> + <soap:fault name="UnknownComponentException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="removeKnowledgeSource"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="setReasoner"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + <fault name="UnknownComponentException"> + <soap:fault name="UnknownComponentException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="setLearningProblem"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + <fault name="UnknownComponentException"> + <soap:fault name="UnknownComponentException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="setLearningAlgorithm"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + <fault name="UnknownComponentException"> + <soap:fault name="UnknownComponentException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="learn"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="learnThreaded"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="getCurrentlyBestConcept"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="isAlgorithmRunning"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="setPositiveExamples"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="setNegativeExamples"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="applyConfigEntryInt"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + <fault name="UnknownComponentException"> + <soap:fault name="UnknownComponentException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="applyConfigEntryString"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + <fault name="UnknownComponentException"> + <soap:fault name="UnknownComponentException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="applyConfigEntryStringArray"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + <fault name="UnknownComponentException"> + <soap:fault name="UnknownComponentException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="applyConfigEntryBoolean"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + <fault name="UnknownComponentException"> + <soap:fault name="UnknownComponentException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="getConfigOptionValueStringArray"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + <fault name="UnknownComponentException"> + <soap:fault name="UnknownComponentException" use="literal"></soap:fault> + </fault> + <fault name="ConfigOptionTypeException"> + <soap:fault name="ConfigOptionTypeException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="getConfigOptionValueString"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + <fault name="UnknownComponentException"> + <soap:fault name="UnknownComponentException" use="literal"></soap:fault> + </fault> + <fault name="ConfigOptionTypeException"> + <soap:fault name="ConfigOptionTypeException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="getConfigOptionValueDouble"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + <fault name="UnknownComponentException"> + <soap:fault name="UnknownComponentException" use="literal"></soap:fault> + </fault> + <fault name="ConfigOptionTypeException"> + <soap:fault name="ConfigOptionTypeException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="getConfigOptionValueBoolean"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + <fault name="UnknownComponentException"> + <soap:fault name="UnknownComponentException" use="literal"></soap:fault> + </fault> + <fault name="ConfigOptionTypeException"> + <soap:fault name="ConfigOptionTypeException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="getConfigOptionValueInt"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + <fault name="UnknownComponentException"> + <soap:fault name="UnknownComponentException" use="literal"></soap:fault> + </fault> + <fault name="ConfigOptionTypeException"> + <soap:fault name="ConfigOptionTypeException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="getAtomicConcepts"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="getSubsumptionHierarchy"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="retrieval"> + <soap:operation soapAction=""></soap:operation> +... [truncated message content] |
From: <sk...@us...> - 2007-10-19 08:47:38
|
Revision: 243 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=243&view=rev Author: sknappe Date: 2007-10-19 01:47:35 -0700 (Fri, 19 Oct 2007) Log Message: ----------- deleted unnecessary imports Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-19 08:41:15 UTC (rev 242) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-19 08:47:35 UTC (rev 243) @@ -28,8 +28,6 @@ import java.util.Collection; import java.util.LinkedList; import java.util.Set; -import java.util.StringTokenizer; -import java.util.Vector; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.config.BooleanConfigOption; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-19 08:41:18
|
Revision: 242 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=242&view=rev Author: jenslehmann Date: 2007-10-19 01:41:15 -0700 (Fri, 19 Oct 2007) Log Message: ----------- some code style improvements in QuickStart Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/QuickStart.java Modified: trunk/src/dl-learner/org/dllearner/cli/QuickStart.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/QuickStart.java 2007-10-19 08:36:09 UTC (rev 241) +++ trunk/src/dl-learner/org/dllearner/cli/QuickStart.java 2007-10-19 08:41:15 UTC (rev 242) @@ -31,8 +31,8 @@ import java.util.Iterator; /** - * A tool to quickly start a learning example. It detects all conf files in - * the examples directory and offers the user to start one of them. + * A tool to quickly start a learning example. It detects all conf files in the + * examples directory and offers the user to start one of them. * * @author Sebastian Hellmann * @author Jens Lehmann @@ -47,8 +47,8 @@ String lastused = readit(); String tab = " "; int the_Number = 0; - ArrayList<String> FinalSelection = new ArrayList<String>(); - FinalSelection.add("na"); + ArrayList<String> finalSelection = new ArrayList<String>(); + finalSelection.add("na"); hm = new HashMap<String, ArrayList<String>>(); String path = pm + File.separator + "examples"; @@ -83,7 +83,7 @@ Arrays.sort(files); for (int j = 0; j < files.length; j++) { the_Number++; - FinalSelection.add(the_Number, s + files[j] + ".conf");// tmp=the_Number+":"+tab+files[j]; + finalSelection.add(the_Number, s + files[j] + ".conf");// tmp=the_Number+":"+tab+files[j]; System.out.println(" " + the_Number + ":" + tab + files[j] + ""); } @@ -96,7 +96,7 @@ try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int target = 0; - String Selected = ""; + String selected = ""; while (true) { String cmd = br.readLine(); try { @@ -114,20 +114,19 @@ }// end while if (number) { try { - Selected = FinalSelection.get(target); + selected = finalSelection.get(target); } catch (Exception e) { System.out.println("number does not exist"); } ; - writeit(Selected); - System.out.println(Selected); + writeit(selected); + System.out.println(selected); } else if (!number) { - Selected = lastused; + selected = lastused; } - System.out.println("ToDo: start commandline interface with selected conf file"); // DLLearner.main(new String[] { Selected }); - Start.main(new String[] { Selected }); + Start.main(new String[] { selected }); } catch (Exception e) { e.printStackTrace(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-19 08:36:11
|
Revision: 241 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=241&view=rev Author: jenslehmann Date: 2007-10-19 01:36:09 -0700 (Fri, 19 Oct 2007) Log Message: ----------- fixed quick start Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/QuickStart.java Modified: trunk/src/dl-learner/org/dllearner/cli/QuickStart.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/QuickStart.java 2007-10-18 17:26:55 UTC (rev 240) +++ trunk/src/dl-learner/org/dllearner/cli/QuickStart.java 2007-10-19 08:36:09 UTC (rev 241) @@ -127,6 +127,7 @@ System.out.println("ToDo: start commandline interface with selected conf file"); // DLLearner.main(new String[] { Selected }); + Start.main(new String[] { Selected }); } catch (Exception e) { e.printStackTrace(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-18 17:27:02
|
Revision: 240 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=240&view=rev Author: jenslehmann Date: 2007-10-18 10:26:55 -0700 (Thu, 18 Oct 2007) Log Message: ----------- changed directory name to small letters Added Paths: ----------- trunk/src/dbpedia-navigator/ trunk/src/dbpedia-navigator/Settings.php trunk/src/dbpedia-navigator/SparqlConnection.php trunk/src/dbpedia-navigator/default.css trunk/src/dbpedia-navigator/index.php trunk/src/dbpedia-navigator/master.php trunk/src/dbpedia-navigator/pear/ Removed Paths: ------------- trunk/src/DBPedia-Navigator/ trunk/src/dbpedia-navigator/Settings.php trunk/src/dbpedia-navigator/SparqlConnection.php trunk/src/dbpedia-navigator/default.css trunk/src/dbpedia-navigator/index.php trunk/src/dbpedia-navigator/master.php trunk/src/dbpedia-navigator/pear/ Copied: trunk/src/dbpedia-navigator (from rev 237, trunk/src/DBPedia-Navigator) Deleted: trunk/src/dbpedia-navigator/Settings.php =================================================================== --- trunk/src/DBPedia-Navigator/Settings.php 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dbpedia-navigator/Settings.php 2007-10-18 17:26:55 UTC (rev 240) @@ -1,12 +0,0 @@ -<?php - -class Settings{ - - -public $wsdluri="http://localhost:8181/services?wsdl"; - - -public $uri="http://localhost/dllearner/"; -public $dbpediauri="http://dbpedia.openlinksw.com:8890/sparql"; -} -?> \ No newline at end of file Copied: trunk/src/dbpedia-navigator/Settings.php (from rev 236, trunk/src/DBPedia-Navigator/Settings.php) =================================================================== --- trunk/src/dbpedia-navigator/Settings.php (rev 0) +++ trunk/src/dbpedia-navigator/Settings.php 2007-10-18 17:26:55 UTC (rev 240) @@ -0,0 +1,12 @@ +<?php + +class Settings{ + + +public $wsdluri="http://localhost:8181/services?wsdl"; + + +public $uri="http://localhost/dllearner/"; +public $dbpediauri="http://dbpedia.openlinksw.com:8890/sparql"; +} +?> \ No newline at end of file Deleted: trunk/src/dbpedia-navigator/SparqlConnection.php =================================================================== --- trunk/src/DBPedia-Navigator/SparqlConnection.php 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dbpedia-navigator/SparqlConnection.php 2007-10-18 17:26:55 UTC (rev 240) @@ -1,215 +0,0 @@ -<?php - -require_once 'pear/HTTP_Request.php'; - -class SparqlConnection -{ - private $DBPediaUrl; - private $DLLearnerUri; - private $client; - private $id; - - public function getID(){ - return $this->id; - } - - function SparqlConnection($DBPediaUrl,$DLLearnerUri,$getID=0) - { - ini_set("soap.wsdl_cache_enabled","0"); - $this->DBPediaUrl=$DBPediaUrl; - $this->DLLearnerUri=$DLLearnerUri; - $this->loadWSDLfiles($DLLearnerUri); - $this->client=new SoapClient("main.wsdl"); - if($getID==0) - { - $this->id=$this->client->generateID(); - } - else - { - $this->id=$getID; - } - } - - function getConceptFromExamples($posExamples,$negExamples) - { - $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); - $this->client->applyConfigEntryInt($this->id, $ksID, "numberOfRecursions", 2); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "instances", array_merge($posExamples,$negExamples)); - $this->client->applyConfigEntryInt($this->id, $ksID, "filterMode", 0); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "predList", array()); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "objList", array()); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "classList", array()); - $this->client->applyConfigEntryString($this->id, $ksID, "format", "KB"); - $this->client->applyConfigEntryBoolean($this->id, $ksID, "dumpToFile", false); - - $this->client->setReasoner($this->id, "dig"); - $this->client->setLearningProblem($this->id, "posNegDefinition"); - $this->client->setPositiveExamples($this->id, $posExamples); - $this->client->setNegativeExamples($this->id, $negExamples); - $this->client->setLearningAlgorithm($this->id, "refinement"); - - $start = microtime(true); - - $this->client->init($this->id); - - $learn_start = microtime(true); - $init = $learn_start - $start; - echo 'components initialised in '.$init.' seconds<br />'; - - $threaded=true; - - if($threaded == false) { - - $concept = $this->client->learn($id); - - $learn = microtime(true) - $learn_start; - echo 'concept learned in '.$learn.' seconds<br />'; - - echo 'result: '.$concept; - - } else { - - $this->client->learnThreaded($id); - - $i = 1; - $sleeptime = 1; - - do { - // sleep a while - sleep($sleeptime); - - // see what we have learned so far - $concept=$this->client->getCurrentlyBestConcept($id); - $running=$this->client->isAlgorithmRunning($id); - - $seconds = $i * $sleeptime; - - echo 'result after '.$seconds.' seconds of sleep: '.$concept.'<br />'; - - $i++; - } while($running); - - echo 'algorithm finished'; - } - return $concept; - } - - function getTriples($individual) - { - $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); - $this->client->applyConfigEntryInt($this->id, $ksID, "numberOfRecursions", 1); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "instances", array($individual)); - $this->client->applyConfigEntryInt($this->id, $ksID, "filterMode", 3); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "predList", array()); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "objList", array()); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "classList", array()); - $this->client->applyConfigEntryString($this->id, $ksID, "format", "Array"); - $this->client->applyConfigEntryBoolean($this->id, $ksID, "dumpToFile", false); - $this->client->applyConfigEntryBoolean($this->id,$ksID,"useLits",true); - - $object=$this->client->getTriples($this->id,$ksID); - $array=$object->item; - $ret=array(); - foreach ($array as $element) - { - $items=preg_split("[<]",$element,-1, PREG_SPLIT_NO_EMPTY); - $ret[]=$items; - } - - return $ret; - } - - function getSubjects($label,$limit) - { - $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); - $object=$this->client->getSubjects($this->id,$ksID,$label,$limit); - return $object->item; - } - - private function loadWSDLfiles($wsdluri){ - $main=$this->getwsdl($wsdluri); - $other=$this->getOtherWSDL($main); - $newMain=$this->changeWSDL($main); - $this->writeToFile("main.wsdl",$newMain); - $x=0; - foreach ($other as $o){ - $this->writeToFile("def".($x++).".xsd",$this->getwsdl($o)); - } - - } - - private function changeWSDL($wsdl){ - $before="<xsd:import schemaLocation=\""; - $after="\" namespace=\""; - $newWSDL=""; - $desca="def"; - $descb=".xsd"; - $x=0; - while($posstart= strpos ( $wsdl, $before )){ - - $posstart+=strlen($before); - $newWSDL.=substr($wsdl,0,$posstart); - $wsdl=substr($wsdl,$posstart); - $newWSDL.=$desca.($x++).$descb; - $posend= strpos ( $wsdl, $after ); - $wsdl=substr($wsdl,$posend); - - } - return $newWSDL.$wsdl; - - } - - private function getOtherWSDL($wsdl){ - $before="<xsd:import schemaLocation=\""; - $after="\" namespace=\""; - $ret=array(); - while($posstart= strpos ( $wsdl, $before )){ - $posstart+=strlen($before); - $wsdl=substr($wsdl,$posstart); - $posend= strpos ( $wsdl, $after ); - $tmp=substr($wsdl,0,$posend); - $ret[]=$tmp; - $wsdl=substr($wsdl,$posend+strlen($after)); - } - return $ret; - } - - - - - private function getwsdl($wsdluri){ - // this is copied from the Pear example - // please don't ask me how it works - $req = &new HTTP_Request($wsdluri); - $message=""; - $req->setMethod(HTTP_REQUEST_METHOD_GET); - $req->sendRequest(); - $ret=$req->getResponseBody(); - return $ret; - } - - - - private function writeToFile($filename,$content){ - - $fp=fopen($filename,"w"); - fwrite($fp,$content); - fclose($fp); - - } -} - -$positive=array("http://dbpedia.org/resource/Pythagoras", - "http://dbpedia.org/resource/Philolaus", - "http://dbpedia.org/resource/Archytas"); -$negative=array("http://dbpedia.org/resource/Socrates", - "http://dbpedia.org/resource/Zeno_of_Elea", - "http://dbpedia.org/resource/Plato"); - -$sparqlConnection=new SparqlConnection("http://dbpedia.openlinksw.com:8890/sparql","http://localhost:8181/services?wsdl"); -//$sparqlConnection->getConceptFromExamples($positive,$negative); -//$triples=$sparqlConnection->getTriples("http://dbpedia.org/resource/Leipzig"); -//print_r($triples); -//$subjects=$sparqlConnection->getSubjects("Leipzig",5); -//print_r($subjects); -?> \ No newline at end of file Copied: trunk/src/dbpedia-navigator/SparqlConnection.php (from rev 236, trunk/src/DBPedia-Navigator/SparqlConnection.php) =================================================================== --- trunk/src/dbpedia-navigator/SparqlConnection.php (rev 0) +++ trunk/src/dbpedia-navigator/SparqlConnection.php 2007-10-18 17:26:55 UTC (rev 240) @@ -0,0 +1,215 @@ +<?php + +require_once 'pear/HTTP_Request.php'; + +class SparqlConnection +{ + private $DBPediaUrl; + private $DLLearnerUri; + private $client; + private $id; + + public function getID(){ + return $this->id; + } + + function SparqlConnection($DBPediaUrl,$DLLearnerUri,$getID=0) + { + ini_set("soap.wsdl_cache_enabled","0"); + $this->DBPediaUrl=$DBPediaUrl; + $this->DLLearnerUri=$DLLearnerUri; + $this->loadWSDLfiles($DLLearnerUri); + $this->client=new SoapClient("main.wsdl"); + if($getID==0) + { + $this->id=$this->client->generateID(); + } + else + { + $this->id=$getID; + } + } + + function getConceptFromExamples($posExamples,$negExamples) + { + $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); + $this->client->applyConfigEntryInt($this->id, $ksID, "numberOfRecursions", 2); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "instances", array_merge($posExamples,$negExamples)); + $this->client->applyConfigEntryInt($this->id, $ksID, "filterMode", 0); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "predList", array()); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "objList", array()); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "classList", array()); + $this->client->applyConfigEntryString($this->id, $ksID, "format", "KB"); + $this->client->applyConfigEntryBoolean($this->id, $ksID, "dumpToFile", false); + + $this->client->setReasoner($this->id, "dig"); + $this->client->setLearningProblem($this->id, "posNegDefinition"); + $this->client->setPositiveExamples($this->id, $posExamples); + $this->client->setNegativeExamples($this->id, $negExamples); + $this->client->setLearningAlgorithm($this->id, "refinement"); + + $start = microtime(true); + + $this->client->init($this->id); + + $learn_start = microtime(true); + $init = $learn_start - $start; + echo 'components initialised in '.$init.' seconds<br />'; + + $threaded=true; + + if($threaded == false) { + + $concept = $this->client->learn($id); + + $learn = microtime(true) - $learn_start; + echo 'concept learned in '.$learn.' seconds<br />'; + + echo 'result: '.$concept; + + } else { + + $this->client->learnThreaded($id); + + $i = 1; + $sleeptime = 1; + + do { + // sleep a while + sleep($sleeptime); + + // see what we have learned so far + $concept=$this->client->getCurrentlyBestConcept($id); + $running=$this->client->isAlgorithmRunning($id); + + $seconds = $i * $sleeptime; + + echo 'result after '.$seconds.' seconds of sleep: '.$concept.'<br />'; + + $i++; + } while($running); + + echo 'algorithm finished'; + } + return $concept; + } + + function getTriples($individual) + { + $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); + $this->client->applyConfigEntryInt($this->id, $ksID, "numberOfRecursions", 1); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "instances", array($individual)); + $this->client->applyConfigEntryInt($this->id, $ksID, "filterMode", 3); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "predList", array()); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "objList", array()); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "classList", array()); + $this->client->applyConfigEntryString($this->id, $ksID, "format", "Array"); + $this->client->applyConfigEntryBoolean($this->id, $ksID, "dumpToFile", false); + $this->client->applyConfigEntryBoolean($this->id,$ksID,"useLits",true); + + $object=$this->client->getTriples($this->id,$ksID); + $array=$object->item; + $ret=array(); + foreach ($array as $element) + { + $items=preg_split("[<]",$element,-1, PREG_SPLIT_NO_EMPTY); + $ret[]=$items; + } + + return $ret; + } + + function getSubjects($label,$limit) + { + $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); + $object=$this->client->getSubjects($this->id,$ksID,$label,$limit); + return $object->item; + } + + private function loadWSDLfiles($wsdluri){ + $main=$this->getwsdl($wsdluri); + $other=$this->getOtherWSDL($main); + $newMain=$this->changeWSDL($main); + $this->writeToFile("main.wsdl",$newMain); + $x=0; + foreach ($other as $o){ + $this->writeToFile("def".($x++).".xsd",$this->getwsdl($o)); + } + + } + + private function changeWSDL($wsdl){ + $before="<xsd:import schemaLocation=\""; + $after="\" namespace=\""; + $newWSDL=""; + $desca="def"; + $descb=".xsd"; + $x=0; + while($posstart= strpos ( $wsdl, $before )){ + + $posstart+=strlen($before); + $newWSDL.=substr($wsdl,0,$posstart); + $wsdl=substr($wsdl,$posstart); + $newWSDL.=$desca.($x++).$descb; + $posend= strpos ( $wsdl, $after ); + $wsdl=substr($wsdl,$posend); + + } + return $newWSDL.$wsdl; + + } + + private function getOtherWSDL($wsdl){ + $before="<xsd:import schemaLocation=\""; + $after="\" namespace=\""; + $ret=array(); + while($posstart= strpos ( $wsdl, $before )){ + $posstart+=strlen($before); + $wsdl=substr($wsdl,$posstart); + $posend= strpos ( $wsdl, $after ); + $tmp=substr($wsdl,0,$posend); + $ret[]=$tmp; + $wsdl=substr($wsdl,$posend+strlen($after)); + } + return $ret; + } + + + + + private function getwsdl($wsdluri){ + // this is copied from the Pear example + // please don't ask me how it works + $req = &new HTTP_Request($wsdluri); + $message=""; + $req->setMethod(HTTP_REQUEST_METHOD_GET); + $req->sendRequest(); + $ret=$req->getResponseBody(); + return $ret; + } + + + + private function writeToFile($filename,$content){ + + $fp=fopen($filename,"w"); + fwrite($fp,$content); + fclose($fp); + + } +} + +$positive=array("http://dbpedia.org/resource/Pythagoras", + "http://dbpedia.org/resource/Philolaus", + "http://dbpedia.org/resource/Archytas"); +$negative=array("http://dbpedia.org/resource/Socrates", + "http://dbpedia.org/resource/Zeno_of_Elea", + "http://dbpedia.org/resource/Plato"); + +$sparqlConnection=new SparqlConnection("http://dbpedia.openlinksw.com:8890/sparql","http://localhost:8181/services?wsdl"); +//$sparqlConnection->getConceptFromExamples($positive,$negative); +//$triples=$sparqlConnection->getTriples("http://dbpedia.org/resource/Leipzig"); +//print_r($triples); +//$subjects=$sparqlConnection->getSubjects("Leipzig",5); +//print_r($subjects); +?> \ No newline at end of file Deleted: trunk/src/dbpedia-navigator/default.css =================================================================== --- trunk/src/DBPedia-Navigator/default.css 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dbpedia-navigator/default.css 2007-10-18 17:26:55 UTC (rev 240) @@ -1,453 +0,0 @@ -/** - * default.css - * main Ontowiki style sheet - * @author: Norman Heino - * @version: $Id: default.css 751 2007-02-14 19:20:17Z nheino $ - */ - -/* remove browser specific margins */ -* { - margin: 0; - padding: 0; -} - -html { - font: 80%/1.2 "Lucida Grande", Helvetica, Arial, sans-serif; -} - -p { - margin: 8px 0; -} - -h2 { - margin: 0.5em 0 0.1em 0; -/* background-color: #eee;*/ - font-size: 110%; -} - - -/* - * Main site structure - */ - -#wrapper { - position: relative; - max-width: 100%; - padding: 15px; -/* margin: 15px;*/ -} - -#content { - margin: 0 19em; - overflow: hidden; -/* border-left: 1px solid #bbb; - border-right: 1px solid #bbb; - padding: 0 5px;*/ -} - -/* - * Side bars are positioned absolutely due to several reasons: - * (1)Internet Explorer has problems displaying float elements, - * (2) the content's position in html is irrelevant, - * (3) positioning the content div is more straightforward. - */ -#leftSidebar { - position: absolute; - width: 18em; -} - -#rightSidebar { - position: absolute; - width: 18em; - top: 15px; - right: 15px; -} - -#clear { - clear: both; -} - - -/* - * sidebar content (boxes) - */ - -.box { - color: #666; - margin-bottom: 20px; - border: 1px solid #bbb; - font-size: 85%; -} - -/*.box td { - font-size: 100%; -}*/ - -.box .boxtitle { - color: #666; - background-color: #eee; - padding: 3px 0.4em; - font-weight: bold; - white-space: nowrap; -} - -.box .boxtitle .boxtitle_string { - width: 80%; - overflow: hidden; -/* display: none;*/ -} - -.box .boxcontent { - padding: 0.6em; - border-top: 1px solid #bbb; -} - -/* restrict content of certain boxes */ -.box#predicates .boxcontent, -.box#classes .boxcontent { - overflow: hidden; -} - -.box p { - margin: 0 2px 4px 0; -} - -.box ul, .box ol { - margin: 0px; -/* padding-left: 15px;*/ - list-style-position: inside; -} - -.box ul.no_bullet, .box ul.no_bullet { - list-style-type: none; -} - -.box ul li.horizontal, .box ol li.horizontal, -.box ul.horizontal, .box ol.horizontal { - display: inline; -} - -.box a.title_switch { - position: absolute; - right: 0.5em; - margin: auto 0; - color: #666; - border: 1px solid #bbb; - width: 1em; - height: 1em; - background-color: #fff; - text-align: center; -} - -.box a.title_switch:hover { - color: #02a; - text-decoration: none; - background-color: #eee; -} - -.box hr { - margin: 0.5em 0; - border: none; - border-top: 1px dotted #bbb; - height: 0; -} - -.box#classes .boxcontent a { - display: block; -} - -/*.box select { - width: 250px; /* TODO remove absolute size */ -}*/ - -.box input { - width: auto; -} - -.box td input { - width: 100%; -} - -.box img.rating { - position: relative; - top: 1px; -} - -.hidden { - display: none; -} - - -/* - * Links - */ - -a, a:link, a:visited { - color: #02a; - text-decoration: none; - cursor: pointer; -} - -a:hover { - text-decoration: underline; -} - - -/* - * Tabs - */ - -/* all the tabs */ -.tabs { - float: left; - width: 100%; - background: #fff url("../images/tabs_back.png") repeat-x bottom; -} - -.tabs ul { - list-style: none; -} - -.tabs li { - float: left; - margin-right: 1px; -} - -.tabs a { - display: block; - margin-top: 1px; - padding: 0.35em 1.35em; - background-image: url("../images/tab_back.png"); - background-repeat: repeat-x; - background-color: #cbcbcb; - border: 1px solid #bbb; -} - -.tabs a:hover { - background: #fff; - text-decoration: none; -} - -.tabs a.current { - background: #fff; - border-bottom: 1px solid #fff; -} - -/* horizontal line underneath the tabs */ -#tab-line { - height: 1em; - clear: both; -} - -#instances { - float: right; -} - -.selected { - background-color: #bde; /*#b4d5fe;*/ -} - -.button { - border: solid black 1px; - padding: 0px 1px; - background-color: #eee; -} - -/* - * Tables - */ - -tr.odd { - background-color: #ccc; -} - -tr.even { - background-color: #eee; -} - -table.instanceTable th { - text-align: left; -/* background-color: #eee;*/ -} - -table.instanceTable > tbody > tr > td { - padding-top: 0.5em; -} - -table.instanceTable td.property { - text-align: right; - font-style: italic; - padding-right: 5px; -} - -table.instanceTable ul { - margin: 0px; - padding-left: 20px; -} - -table.instanceTable { - width: 100%; -} - -.searchHighlight { - background-color: orange; -} - -table.tripletable { - width: 100%; - font-size: 90%; -} - -.tripletable td { - padding: 0.4em; -} - -table.blind tr td { - padding-top: 0.4em; -} - -/* - * Instances - */ - -.instance .instance { - margin-left: 13px; - background-color: #ddd; -} -.instance .instance td { - font-size: 90%; -} -.instance .instance .instance { - background-color: #eee; -} - -.instance .instance .instance .instance { - background-color: #fff; -} - -#instanceEdit { - border-spacing: 0px; - width: 100%; -} - -#instanceEdit input, #instanceEdit textarea { -/* width: 250px;*/ - background-color: #fff; - font-size: 95%; - font-family: "Lucida Grande", Helvetica, Arial, sans-serif; - padding: 0.1em 0; -} - -#instanceEdit > tbody > tr > td, #instanceEdit > tr > td { - background-color: #eee; - padding: 5px; - border-bottom: 2px solid #fdfdfd; -} - -/* - * Calendar - */ - -table.calendar { - margin-top: 1em; - width: 100%; - height: 730px; - table-layout: fixed; - font-size: 90%; -} - -.calendar .weekday0 { - background-color: #eee; - padding: 0.4em; -} -.calendar .weekday1 { - background-color: #f5f5f5; - padding: 0.4em; -} -.calendar .weekend0 { - background-color: #ddd; - padding: 0.4em; -} -.calendar .weekend1 { - background-color: #eaeaea; - padding: 0.4em; -} - -#map { - margin-top: 0.5em; - width: 100%; - height: 750px; - font-size: 90%; -} - -#map .instance td { - font-size: 80%; - padding: 0 3px; - border-bottom: 5px solid white; -} - -#superClassPath { - margin-bottom: 0.5em; -} - -img { - border: none; -} - -span.submit { - float: right; - padding-right: 100px; -} - -/* - * Autosuggest box - */ -div.autosuggest { - font-size: 85%; - position: absolute; - background-color: #fff; - border: 1px solid #bbb; -} - -div.autosuggest ul { - list-style-type: none; - list-style-position: inside; - padding-left: 0px; -} - -div.autosuggest ul li.selected { - background-color: #bde; -} - -div.autosuggest ul li { - display: block; - padding: 0.2em; -/* height: 22px;*/ - cursor: pointer; -} - -span.formal { - display: none; -} - -/* - * Layer - */ -#layer { - width: 100%; - height: 100%; - position: absolute; - background-image: url("../images/black_50.png"); - background-repeat: repeat; - z-index: 98; -} - -#layerContent { - margin-top: 100px; - margin: auto; - width: 500px; - height: 300px; - background-color: #ffb; - border: 2px solid #bbb; - z-index: 99; -} Copied: trunk/src/dbpedia-navigator/default.css (from rev 236, trunk/src/DBPedia-Navigator/default.css) =================================================================== --- trunk/src/dbpedia-navigator/default.css (rev 0) +++ trunk/src/dbpedia-navigator/default.css 2007-10-18 17:26:55 UTC (rev 240) @@ -0,0 +1,453 @@ +/** + * default.css + * main Ontowiki style sheet + * @author: Norman Heino + * @version: $Id: default.css 751 2007-02-14 19:20:17Z nheino $ + */ + +/* remove browser specific margins */ +* { + margin: 0; + padding: 0; +} + +html { + font: 80%/1.2 "Lucida Grande", Helvetica, Arial, sans-serif; +} + +p { + margin: 8px 0; +} + +h2 { + margin: 0.5em 0 0.1em 0; +/* background-color: #eee;*/ + font-size: 110%; +} + + +/* + * Main site structure + */ + +#wrapper { + position: relative; + max-width: 100%; + padding: 15px; +/* margin: 15px;*/ +} + +#content { + margin: 0 19em; + overflow: hidden; +/* border-left: 1px solid #bbb; + border-right: 1px solid #bbb; + padding: 0 5px;*/ +} + +/* + * Side bars are positioned absolutely due to several reasons: + * (1)Internet Explorer has problems displaying float elements, + * (2) the content's position in html is irrelevant, + * (3) positioning the content div is more straightforward. + */ +#leftSidebar { + position: absolute; + width: 18em; +} + +#rightSidebar { + position: absolute; + width: 18em; + top: 15px; + right: 15px; +} + +#clear { + clear: both; +} + + +/* + * sidebar content (boxes) + */ + +.box { + color: #666; + margin-bottom: 20px; + border: 1px solid #bbb; + font-size: 85%; +} + +/*.box td { + font-size: 100%; +}*/ + +.box .boxtitle { + color: #666; + background-color: #eee; + padding: 3px 0.4em; + font-weight: bold; + white-space: nowrap; +} + +.box .boxtitle .boxtitle_string { + width: 80%; + overflow: hidden; +/* display: none;*/ +} + +.box .boxcontent { + padding: 0.6em; + border-top: 1px solid #bbb; +} + +/* restrict content of certain boxes */ +.box#predicates .boxcontent, +.box#classes .boxcontent { + overflow: hidden; +} + +.box p { + margin: 0 2px 4px 0; +} + +.box ul, .box ol { + margin: 0px; +/* padding-left: 15px;*/ + list-style-position: inside; +} + +.box ul.no_bullet, .box ul.no_bullet { + list-style-type: none; +} + +.box ul li.horizontal, .box ol li.horizontal, +.box ul.horizontal, .box ol.horizontal { + display: inline; +} + +.box a.title_switch { + position: absolute; + right: 0.5em; + margin: auto 0; + color: #666; + border: 1px solid #bbb; + width: 1em; + height: 1em; + background-color: #fff; + text-align: center; +} + +.box a.title_switch:hover { + color: #02a; + text-decoration: none; + background-color: #eee; +} + +.box hr { + margin: 0.5em 0; + border: none; + border-top: 1px dotted #bbb; + height: 0; +} + +.box#classes .boxcontent a { + display: block; +} + +/*.box select { + width: 250px; /* TODO remove absolute size */ +}*/ + +.box input { + width: auto; +} + +.box td input { + width: 100%; +} + +.box img.rating { + position: relative; + top: 1px; +} + +.hidden { + display: none; +} + + +/* + * Links + */ + +a, a:link, a:visited { + color: #02a; + text-decoration: none; + cursor: pointer; +} + +a:hover { + text-decoration: underline; +} + + +/* + * Tabs + */ + +/* all the tabs */ +.tabs { + float: left; + width: 100%; + background: #fff url("../images/tabs_back.png") repeat-x bottom; +} + +.tabs ul { + list-style: none; +} + +.tabs li { + float: left; + margin-right: 1px; +} + +.tabs a { + display: block; + margin-top: 1px; + padding: 0.35em 1.35em; + background-image: url("../images/tab_back.png"); + background-repeat: repeat-x; + background-color: #cbcbcb; + border: 1px solid #bbb; +} + +.tabs a:hover { + background: #fff; + text-decoration: none; +} + +.tabs a.current { + background: #fff; + border-bottom: 1px solid #fff; +} + +/* horizontal line underneath the tabs */ +#tab-line { + height: 1em; + clear: both; +} + +#instances { + float: right; +} + +.selected { + background-color: #bde; /*#b4d5fe;*/ +} + +.button { + border: solid black 1px; + padding: 0px 1px; + background-color: #eee; +} + +/* + * Tables + */ + +tr.odd { + background-color: #ccc; +} + +tr.even { + background-color: #eee; +} + +table.instanceTable th { + text-align: left; +/* background-color: #eee;*/ +} + +table.instanceTable > tbody > tr > td { + padding-top: 0.5em; +} + +table.instanceTable td.property { + text-align: right; + font-style: italic; + padding-right: 5px; +} + +table.instanceTable ul { + margin: 0px; + padding-left: 20px; +} + +table.instanceTable { + width: 100%; +} + +.searchHighlight { + background-color: orange; +} + +table.tripletable { + width: 100%; + font-size: 90%; +} + +.tripletable td { + padding: 0.4em; +} + +table.blind tr td { + padding-top: 0.4em; +} + +/* + * Instances + */ + +.instance .instance { + margin-left: 13px; + background-color: #ddd; +} +.instance .instance td { + font-size: 90%; +} +.instance .instance .instance { + background-color: #eee; +} + +.instance .instance .instance .instance { + background-color: #fff; +} + +#instanceEdit { + border-spacing: 0px; + width: 100%; +} + +#instanceEdit input, #instanceEdit textarea { +/* width: 250px;*/ + background-color: #fff; + font-size: 95%; + font-family: "Lucida Grande", Helvetica, Arial, sans-serif; + padding: 0.1em 0; +} + +#instanceEdit > tbody > tr > td, #instanceEdit > tr > td { + background-color: #eee; + padding: 5px; + border-bottom: 2px solid #fdfdfd; +} + +/* + * Calendar + */ + +table.calendar { + margin-top: 1em; + width: 100%; + height: 730px; + table-layout: fixed; + font-size: 90%; +} + +.calendar .weekday0 { + background-color: #eee; + padding: 0.4em; +} +.calendar .weekday1 { + background-color: #f5f5f5; + padding: 0.4em; +} +.calendar .weekend0 { + background-color: #ddd; + padding: 0.4em; +} +.calendar .weekend1 { + background-color: #eaeaea; + padding: 0.4em; +} + +#map { + margin-top: 0.5em; + width: 100%; + height: 750px; + font-size: 90%; +} + +#map .instance td { + font-size: 80%; + padding: 0 3px; + border-bottom: 5px solid white; +} + +#superClassPath { + margin-bottom: 0.5em; +} + +img { + border: none; +} + +span.submit { + float: right; + padding-right: 100px; +} + +/* + * Autosuggest box + */ +div.autosuggest { + font-size: 85%; + position: absolute; + background-color: #fff; + border: 1px solid #bbb; +} + +div.autosuggest ul { + list-style-type: none; + list-style-position: inside; + padding-left: 0px; +} + +div.autosuggest ul li.selected { + background-color: #bde; +} + +div.autosuggest ul li { + display: block; + padding: 0.2em; +/* height: 22px;*/ + cursor: pointer; +} + +span.formal { + display: none; +} + +/* + * Layer + */ +#layer { + width: 100%; + height: 100%; + position: absolute; + background-image: url("../images/black_50.png"); + background-repeat: repeat; + z-index: 98; +} + +#layerContent { + margin-top: 100px; + margin: auto; + width: 500px; + height: 300px; + background-color: #ffb; + border: 2px solid #bbb; + z-index: 99; +} Deleted: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/DBPedia-Navigator/index.php 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dbpedia-navigator/index.php 2007-10-18 17:26:55 UTC (rev 240) @@ -1,110 +0,0 @@ -<?php - -@session_start(); -include_once("Settings.php"); -include_once("SparqlConnection.php"); - - ini_set('error_reporting',E_ALL); - ini_set('max_execution_time',200); - -$lastAction="View"; -$content=""; -$possibleActions=""; -$instances=" "; -$left=""; -$right=""; -$middle=""; -$search=""; -$system=""; - -$settings=new Settings(); - -echo "<a href='index.php?clearsession=clear'>start from scratch</a>"; -if(isset($_GET['clearsession']))$_SESSION['State_ID'] =false; - - - -if( (!isset($_SESSION['State_ID'] ) ) || ($_SESSION['State_ID']=="")) -{ - //get new ID - $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); - $_SESSION['State_ID']=$sc->getID(); - -} - -else{ - //echo "Current ID is: ".$_SESSION['Learner_ID']."<br>"; - $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['State_ID']); -} - - -//SearchBox - $search="<form action=\"index.php\" method=\"GET\">\n". - "<table border=\"0\">\n". - "<tr><tb>Search:<br/></tb></tr>\n". - "<tr><tb><input type=\"textfield\" name=\"search\"><select name=\"limit\" size=\"1\">\n". - "<option>1</option>\n". - "<option selected=\"selected\">5</option>\n". - "<option>10</option>\n". - "<option>15</option>\n". - "</select><br/></tb></tr>\n". - "<tr><tb><input type=\"submit\" name=\"action\" value=\"Search\"><input type=\"submit\" name=\"action\" value=\"Fulltext\"></tb></tr>\n". - "</table>\n". - "</form>\n"; - -//Get Search result - if (@$_GET['action']=='Search') - { - $label=$_GET['search']; - $limit=$_GET['limit']; - $subjects=$sc->getSubjects($label,$limit); - foreach ($subjects as $subject){ - $content.="<a href=\"index.php?action=showPage&subject=".$subject."\">".$subject."</a><br/>\n"; - } - } - -//Show Subject Page - if (@$_GET['action']=="showPage") - { - $triples=$sc->getTriples($_GET['subject']); - foreach ($triples as $triple){ - $content.="Subject: ".urldecode($triple[0])."<br/>Predicate: ".urldecode($triple[1])."<br/>Object: ".urldecode($triple[2])."<br/><br/>\n"; - } - } - - - include("master.php"); - - echo $masterContent; - - - - - - function makeBox($title,$content,$toggleBoxContent=true) - { - if($toggleBoxContent) - { - $click="<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a>"; - } - else{$click="";} - $ret=" - <div class=\"box\" id=\"ontology\"> - <div class=\"boxtitle\">".$title.$click."</div> - <div class=\"boxcontent\"> - ".$content." - </div> <!-- boxcontent --> - </div> <!-- box -->"; - return $ret; - } - - - function shorten($a) - { - if(($strpos=strpos($a,'#'))>=4){ - return substr($a,$strpos); - } - else {return $a;} - } - -?> \ No newline at end of file Copied: trunk/src/dbpedia-navigator/index.php (from rev 236, trunk/src/DBPedia-Navigator/index.php) =================================================================== --- trunk/src/dbpedia-navigator/index.php (rev 0) +++ trunk/src/dbpedia-navigator/index.php 2007-10-18 17:26:55 UTC (rev 240) @@ -0,0 +1,110 @@ +<?php + +@session_start(); +include_once("Settings.php"); +include_once("SparqlConnection.php"); + + ini_set('error_reporting',E_ALL); + ini_set('max_execution_time',200); + +$lastAction="View"; +$content=""; +$possibleActions=""; +$instances=" "; +$left=""; +$right=""; +$middle=""; +$search=""; +$system=""; + +$settings=new Settings(); + +echo "<a href='index.php?clearsession=clear'>start from scratch</a>"; +if(isset($_GET['clearsession']))$_SESSION['State_ID'] =false; + + + +if( (!isset($_SESSION['State_ID'] ) ) || ($_SESSION['State_ID']=="")) +{ + //get new ID + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); + $_SESSION['State_ID']=$sc->getID(); + +} + +else{ + //echo "Current ID is: ".$_SESSION['Learner_ID']."<br>"; + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['State_ID']); +} + + +//SearchBox + $search="<form action=\"index.php\" method=\"GET\">\n". + "<table border=\"0\">\n". + "<tr><tb>Search:<br/></tb></tr>\n". + "<tr><tb><input type=\"textfield\" name=\"search\"><select name=\"limit\" size=\"1\">\n". + "<option>1</option>\n". + "<option selected=\"selected\">5</option>\n". + "<option>10</option>\n". + "<option>15</option>\n". + "</select><br/></tb></tr>\n". + "<tr><tb><input type=\"submit\" name=\"action\" value=\"Search\"><input type=\"submit\" name=\"action\" value=\"Fulltext\"></tb></tr>\n". + "</table>\n". + "</form>\n"; + +//Get Search result + if (@$_GET['action']=='Search') + { + $label=$_GET['search']; + $limit=$_GET['limit']; + $subjects=$sc->getSubjects($label,$limit); + foreach ($subjects as $subject){ + $content.="<a href=\"index.php?action=showPage&subject=".$subject."\">".$subject."</a><br/>\n"; + } + } + +//Show Subject Page + if (@$_GET['action']=="showPage") + { + $triples=$sc->getTriples($_GET['subject']); + foreach ($triples as $triple){ + $content.="Subject: ".urldecode($triple[0])."<br/>Predicate: ".urldecode($triple[1])."<br/>Object: ".urldecode($triple[2])."<br/><br/>\n"; + } + } + + + include("master.php"); + + echo $masterContent; + + + + + + function makeBox($title,$content,$toggleBoxContent=true) + { + if($toggleBoxContent) + { + $click="<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a>"; + } + else{$click="";} + $ret=" + <div class=\"box\" id=\"ontology\"> + <div class=\"boxtitle\">".$title.$click."</div> + <div class=\"boxcontent\"> + ".$content." + </div> <!-- boxcontent --> + </div> <!-- box -->"; + return $ret; + } + + + function shorten($a) + { + if(($strpos=strpos($a,'#'))>=4){ + return substr($a,$strpos); + } + else {return $a;} + } + +?> \ No newline at end of file Deleted: trunk/src/dbpedia-navigator/master.php =================================================================== --- trunk/src/DBPedia-Navigator/master.php 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dbpedia-navigator/master.php 2007-10-18 17:26:55 UTC (rev 240) @@ -1,57 +0,0 @@ -<?php - -$masterContent=" - - -<html> - <head> - <title>DL Learner</title> - <meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\"/> - <link rel=\"stylesheet\" href=\"default.css\"/> - </head> - <body> -<script type=\"text/javascript\" src=\"jscript/wz_tooltip.js\"></script> -<script type=\"text/javascript\" src=\"jscript/scripts.js\"></script> -<h3>DBPedia-Navigator-Test</h3> -<div id=\"layer\" style=\"display:none\"><div id=\"layerContent\" style=\"display:none\"></div></div> -<div id=\"wrapper\"> - -<div id=\"leftSidebar\"> - -<div class=\"box\" id=\"search\"> - <div class=\"boxtitle\">Search<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a></div> - <div class=\"boxcontent\"> - ".$search." - </div> <!-- boxcontent --> - -</div> <!-- box --> - -".$left." - -<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> -</div><!-- END leftSidebar --> - -<div id=\"content\"> -<div class=\"box\" id=\"search\"> - <div class=\"boxtitle\">Content</div> - <div class=\"boxcontent\"> - ".$content." - </div> <!-- boxcontent --> -</div> <!-- box --> -".$middle." -<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> -</div><!-- content --> - -<div id=\"rightSidebar\"> - -<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> -</div><!-- rightSidebar --> - - <div id=\"clear\"></div> -</div><!-- wrapper --> - - </body> -</html> -"; - -?> \ No newline at end of file Copied: trunk/src/dbpedia-navigator/master.php (from rev 236, trunk/src/DBPedia-Navigator/master.php) =================================================================== --- trunk/src/dbpedia-navigator/master.php (rev 0) +++ trunk/src/dbpedia-navigator/master.php 2007-10-18 17:26:55 UTC (rev 240) @@ -0,0 +1,57 @@ +<?php + +$masterContent=" + + +<html> + <head> + <title>DL Learner</title> + <meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\"/> + <link rel=\"stylesheet\" href=\"default.css\"/> + </head> + <body> +<script type=\"text/javascript\" src=\"jscript/wz_tooltip.js\"></script> +<script type=\"text/javascript\" src=\"jscript/scripts.js\"></script> +<h3>DBPedia-Navigator-Test</h3> +<div id=\"layer\" style=\"display:none\"><div id=\"layerContent\" style=\"display:none\"></div></div> +<div id=\"wrapper\"> + +<div id=\"leftSidebar\"> + +<div class=\"box\" id=\"search\"> + <div class=\"boxtitle\">Search<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a></div> + <div class=\"boxcontent\"> + ".$search." + </div> <!-- boxcontent --> + +</div> <!-- box --> + +".$left." + +<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> +</div><!-- END leftSidebar --> + +<div id=\"content\"> +<div class=\"box\" id=\"search\"> + <div class=\"boxtitle\">Content</div> + <div class=\"boxcontent\"> + ".$content." + </div> <!-- boxcontent --> +</div> <!-- box --> +".$middle." +<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> +</div><!-- content --> + +<div id=\"rightSidebar\"> + +<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> +</div><!-- rightSidebar --> + + <div id=\"clear\"></div> +</div><!-- wrapper --> + + </body> +</html> +"; + +?> \ No newline at end of file Copied: trunk/src/dbpedia-navigator/pear (from rev 236, trunk/src/DBPedia-Navigator/pear) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-18 17:23:34
|
Revision: 239 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=239&view=rev Author: jenslehmann Date: 2007-10-18 10:23:31 -0700 (Thu, 18 Oct 2007) Log Message: ----------- fixed bug in role initialisation Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-18 17:21:38 UTC (rev 238) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-18 17:23:31 UTC (rev 239) @@ -255,6 +255,8 @@ } else if(ignoredRoles != null) { Helper.checkRoles(rs, ignoredRoles); usedRoles = Helper.difference(rs.getAtomicRoles(), ignoredRoles); + } else { + usedRoles = rs.getAtomicRoles(); } // prepare subsumption and role hierarchies, because they are needed This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-18 17:21:43
|
Revision: 238 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=238&view=rev Author: jenslehmann Date: 2007-10-18 10:21:38 -0700 (Thu, 18 Oct 2007) Log Message: ----------- created config package and moved appropriate classes to it Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/Component.java trunk/src/dl-learner/org/dllearner/core/ComponentManager.java trunk/src/dl-learner/org/dllearner/core/ComponentPool.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/SparqlEndpoint.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyInclusionLP.java trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/config/ trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/CommonConfigMappings.java trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/config/ConfigDocumentationGenerator.java trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.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/InvalidConfigOptionValueException.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/UnknownConfigOptionException.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/core/BooleanConfigOption.java trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/ConfigDocumentationGenerator.java trunk/src/dl-learner/org/dllearner/core/ConfigEntry.java trunk/src/dl-learner/org/dllearner/core/ConfigOption.java trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java trunk/src/dl-learner/org/dllearner/core/InvalidConfigOptionValueException.java trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java trunk/src/dl-learner/org/dllearner/core/StringSetConfigOption.java trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2007-10-18 17:21:38 UTC (rev 238) @@ -26,15 +26,15 @@ import java.util.List; import java.util.Map; -import org.dllearner.core.CommonConfigOptions; -import org.dllearner.core.ConfigEntry; -import org.dllearner.core.ConfigOption; -import org.dllearner.core.IntegerConfigOption; -import org.dllearner.core.InvalidConfigOptionValueException; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; +import org.dllearner.core.config.CommonConfigOptions; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.IntegerConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.dl.All; import org.dllearner.core.dl.AtomicConcept; import org.dllearner.core.dl.AtomicRole; Modified: trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2007-10-18 17:21:38 UTC (rev 238) @@ -24,14 +24,14 @@ import org.dllearner.algorithms.gp.Program; import org.dllearner.algorithms.gp.GPUtilities; -import org.dllearner.core.ConfigEntry; -import org.dllearner.core.ConfigOption; -import org.dllearner.core.IntegerConfigOption; -import org.dllearner.core.InvalidConfigOptionValueException; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.IntegerConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.dl.Concept; public class RandomGuesser extends LearningAlgorithm { Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2007-10-18 17:21:38 UTC (rev 238) @@ -47,16 +47,16 @@ import org.dllearner.Config; import org.dllearner.algorithms.hybridgp.Psi; -import org.dllearner.core.BooleanConfigOption; -import org.dllearner.core.ConfigEntry; -import org.dllearner.core.ConfigOption; -import org.dllearner.core.DoubleConfigOption; -import org.dllearner.core.IntegerConfigOption; -import org.dllearner.core.InvalidConfigOptionValueException; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.Score; -import org.dllearner.core.StringConfigOption; +import org.dllearner.core.config.BooleanConfigOption; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.DoubleConfigOption; +import org.dllearner.core.config.IntegerConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.config.StringConfigOption; import org.dllearner.core.dl.Concept; import org.dllearner.core.dl.Top; import org.dllearner.learningproblems.PosNegLP; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-18 17:21:38 UTC (rev 238) @@ -12,18 +12,18 @@ import java.util.TreeSet; import org.dllearner.Config; -import org.dllearner.core.BooleanConfigOption; -import org.dllearner.core.CommonConfigMappings; -import org.dllearner.core.CommonConfigOptions; -import org.dllearner.core.ConfigEntry; -import org.dllearner.core.ConfigOption; -import org.dllearner.core.DoubleConfigOption; -import org.dllearner.core.InvalidConfigOptionValueException; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; -import org.dllearner.core.StringConfigOption; +import org.dllearner.core.config.BooleanConfigOption; +import org.dllearner.core.config.CommonConfigMappings; +import org.dllearner.core.config.CommonConfigOptions; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.DoubleConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.config.StringConfigOption; import org.dllearner.core.dl.AtomicConcept; import org.dllearner.core.dl.AtomicRole; import org.dllearner.core.dl.Concept; Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-10-18 17:21:38 UTC (rev 238) @@ -36,22 +36,22 @@ import org.dllearner.algorithms.gp.GP; import org.dllearner.algorithms.refinement.ROLearner; -import org.dllearner.core.BooleanConfigOption; import org.dllearner.core.Component; import org.dllearner.core.ComponentManager; -import org.dllearner.core.ConfigEntry; -import org.dllearner.core.ConfigOption; -import org.dllearner.core.DoubleConfigOption; -import org.dllearner.core.IntegerConfigOption; -import org.dllearner.core.InvalidConfigOptionValueException; 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.Score; -import org.dllearner.core.StringConfigOption; -import org.dllearner.core.StringSetConfigOption; +import org.dllearner.core.config.BooleanConfigOption; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.DoubleConfigOption; +import org.dllearner.core.config.IntegerConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.config.StringConfigOption; +import org.dllearner.core.config.StringSetConfigOption; import org.dllearner.core.dl.AtomicConcept; import org.dllearner.core.dl.AtomicRole; import org.dllearner.core.dl.Concept; Deleted: trunk/src/dl-learner/org/dllearner/core/BooleanConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/BooleanConfigOption.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/BooleanConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,52 +0,0 @@ -/** - * 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.core; - -/** - * @author Jens Lehmann - * - */ -public class BooleanConfigOption extends ConfigOption<Boolean> { - - 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.ConfigOption#checkType(java.lang.Object) - */ - @Override - public boolean checkType(Object object) { - return (object instanceof Boolean); - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) - */ - @Override - public boolean isValidValue(Boolean value) { - return true; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,56 +0,0 @@ -/** - * 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.core; - -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.dllearner.core.dl.AtomicConcept; -import org.dllearner.core.dl.AtomicRole; -import org.dllearner.core.dl.Individual; - -/** - * @author Jens Lehmann - * - */ -public class CommonConfigMappings { - - public static SortedSet<Individual> getIndividualSet(Set<String> individuals) { - SortedSet<Individual> set = new TreeSet<Individual>(); - for(String individual : individuals) - set.add(new Individual(individual)); - return set; - } - - public static SortedSet<AtomicConcept> getAtomicConceptSet(Set<String> atomicConcepts) { - SortedSet<AtomicConcept> set = new TreeSet<AtomicConcept>(); - for(String atomicConcept : atomicConcepts) - set.add(new AtomicConcept(atomicConcept)); - return set; - } - - public static SortedSet<AtomicRole> getAtomicRoleSet(Set<String> atomicRoles) { - SortedSet<AtomicRole> set = new TreeSet<AtomicRole>(); - for(String atomicRole : atomicRoles) - set.add(new AtomicRole(atomicRole)); - return set; - } -} Deleted: trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,84 +0,0 @@ -/** - * 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.core; - -/** - * Contains methods for creating common configuration options, i.e. options - * which are or may be of use for several components. - * - * @author Jens Lehmann - * - */ -public final class CommonConfigOptions { - - public static StringConfigOption getVerbosityOption() { - StringConfigOption verbosityOption = new StringConfigOption("verbosity", "control verbosity of output for this component", "warning"); - String[] allowedValues = new String[] {"quiet", "error", "warning", "notice", "info", "debug"}; - verbosityOption.setAllowedValues(allowedValues); - return verbosityOption; - } - - 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); - option.setLowerLimit(0.0); - option.setUpperLimit(1.0); - return option; - } - - public static StringConfigOption getReturnType() { - return new StringConfigOption("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."); - } - - public static BooleanConfigOption getUNA() { - return new BooleanConfigOption("una", "unique names assumption", false); - } - - public static BooleanConfigOption getOWA() { - return new BooleanConfigOption("owa", "open world assumption (if set to false, we try to close the world", true); - } - - public static StringSetConfigOption allowedConcepts() { - return new StringSetConfigOption("allowedConcepts", "concepts the algorithm is allowed to use"); - } - - public static StringSetConfigOption allowedRoles() { - return new StringSetConfigOption("allowedRoles", "roles the algorithm is allowed to use"); - } - - public static StringSetConfigOption ignoredConcepts() { - return new StringSetConfigOption("ignoredConcepts", "concepts the algorithm must ignore"); - } - - public static StringSetConfigOption ignoredRoles() { - return new StringSetConfigOption("ignoredRoles", "roles the algorithm must ignore"); - } - - public static BooleanConfigOption useAllConstructor() { - return new BooleanConfigOption("useAllConstructor", "specifies whether to universal concept constructor is used in the learning algorothm"); - } - - public static BooleanConfigOption useExistsConstructor() { - return new BooleanConfigOption("useExistsConstructor", "specifies whether to existential concept constructor is used in the learning algorothm"); - } - - public static BooleanConfigOption useNegation() { - return new BooleanConfigOption("useNegation", "specifies whether negation is used in the learning algorothm"); - } -} Modified: trunk/src/dl-learner/org/dllearner/core/Component.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Component.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/Component.java 2007-10-18 17:21:38 UTC (rev 238) @@ -22,6 +22,10 @@ import java.util.Collection; import java.util.LinkedList; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; + /** * General component base class. * Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-10-18 17:21:38 UTC (rev 238) @@ -39,6 +39,9 @@ import java.util.TreeMap; import java.util.TreeSet; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.utilities.Files; /** Modified: trunk/src/dl-learner/org/dllearner/core/ComponentPool.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentPool.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/ComponentPool.java 2007-10-18 17:21:38 UTC (rev 238) @@ -24,6 +24,9 @@ import java.util.List; import java.util.Map; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; + /** * Stores all live components and the configuration options, which were * applied to them. Deleted: trunk/src/dl-learner/org/dllearner/core/ConfigDocumentationGenerator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ConfigDocumentationGenerator.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/ConfigDocumentationGenerator.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,43 +0,0 @@ -/** - * 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.core; - -import java.io.File; - -/** - * 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 ConfigDocumentationGenerator { - - /** - * @param args - */ - public static void main(String[] args) { - File file = new File("doc/configOptions.txt"); - ComponentManager cm = ComponentManager.getInstance(); - cm.writeConfigDocumentation(file); - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/ConfigEntry.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ConfigEntry.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/ConfigEntry.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,54 +0,0 @@ -/** - * 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.core; - -/** - * A config entry is a configuration option and a value for the option. - * - * @author Jens Lehmann - * - */ -public class ConfigEntry<T> { - - private ConfigOption<T> option; - private T value; - - public ConfigEntry(ConfigOption<T> option, T value) throws InvalidConfigOptionValueException { - if(!option.isValidValue(value)) { - throw new InvalidConfigOptionValueException(option, value); - } else { - this.option = option; - this.value = value; - } - } - - public ConfigOption<T> getOption() { - return option; - } - - public String getOptionName() { - return option.getName(); - } - - public T getValue() { - return value; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/ConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ConfigOption.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/ConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,88 +0,0 @@ -/** - * 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.core; - -/** - * This class represents a configuration option (without a value for the - * option). - * - * 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. - * - * @author Jens Lehmann - * - */ -public abstract class ConfigOption<T> { - - protected String name; - - protected String description; - - protected T defaultValue; - - public ConfigOption(String name, String description) { - this(name, description, null); - } - - public ConfigOption(String name, String description, T defaultValue) { - this.name = name; - this.description = description; - this.defaultValue = defaultValue; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - /** - * @return the defaultValue - */ - public T getDefaultValue() { - return defaultValue; - } - - /** - * Checks whether the object has the correct type to be used as - * a value for this option (this method is necessary, because - * generic information is erased at runtime in Java). - * - * @param object The object to check. - * @return - */ - public abstract boolean checkType(Object object); - - public abstract boolean isValidValue(T value); - - public String getAllowedValuesDescription() { - return getClass().toString(); - } - - @Override - public String toString() { - return "option name: " + name + "\ndescription: " + description + "\nvalues: " + getAllowedValuesDescription() + "\ndefault value: " + defaultValue + "\n"; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,99 +0,0 @@ -/** - * 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.core; - -/** - * Represents a configuration option with values of type value. Similar - * to the integer option a minimum and a maximum value can specified. - * - * @author Jens Lehmann - * - */ -public class DoubleConfigOption extends ConfigOption<Double> { - - private double lowerLimit = Double.MIN_VALUE; - private double upperLimit = Double.MAX_VALUE; - - 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.ConfigOption#isValidValue(java.lang.Object) - */ - @Override - public boolean isValidValue(Double value) { - if(value >= lowerLimit && value <= upperLimit) - return true; - else - return false; - } - - /** - * @return the The lowest possible value for this configuration option. - */ - public double getLowerLimit() { - return lowerLimit; - } - - /** - * @param lowerLimit The lowest possible value for this configuration option. - */ - public void setLowerLimit(double lowerLimit) { - this.lowerLimit = lowerLimit; - } - - /** - * @return the The highest possible value for this configuration option. - */ - public double getUpperLimit() { - return upperLimit; - } - - /** - * @param upperLimit The highest possible value for this configuration option. - */ - public void setUpperLimit(double upperLimit) { - this.upperLimit = upperLimit; - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) - */ - @Override - public boolean checkType(Object object) { - return (object instanceof Double); - } - - @Override - public String getAllowedValuesDescription() { - String str = getClass().toString(); - if(lowerLimit != Double.MIN_VALUE) - str += " min " + lowerLimit; - if(upperLimit != Double.MAX_VALUE) - str += " max " + upperLimit; - return str; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,99 +0,0 @@ -/** - * 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.core; - -/** - * A configuration option, which allows values of type integer. A minimum and - * maximum value of the argument can optionally be specified. - * - * @author Jens Lehmann - * - */ -public class IntegerConfigOption extends ConfigOption<Integer> { - - private int lowerLimit = Integer.MIN_VALUE; - private int upperLimit = Integer.MAX_VALUE; - - 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.ConfigOption#isValidValue(java.lang.Object) - */ - @Override - public boolean isValidValue(Integer value) { - if(value >= lowerLimit && value <= upperLimit) - return true; - else - return false; - } - - /** - * @return the The lowest possible value for this configuration option. - */ - public int getLowerLimit() { - return lowerLimit; - } - - /** - * @param lowerLimit The lowest possible value for this configuration option. - */ - public void setLowerLimit(int lowerLimit) { - this.lowerLimit = lowerLimit; - } - - /** - * @return the The highest possible value for this configuration option. - */ - public int getUpperLimit() { - return upperLimit; - } - - /** - * @param upperLimit The highest possible value for this configuration option. - */ - public void setUpperLimit(int upperLimit) { - this.upperLimit = upperLimit; - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) - */ - @Override - public boolean checkType(Object object) { - return (object instanceof Integer); - } - - @Override - public String getAllowedValuesDescription() { - String str = getClass().toString(); - if(lowerLimit != Integer.MIN_VALUE) - str += " min " + lowerLimit; - if(upperLimit != Integer.MAX_VALUE) - str += " max " + upperLimit; - return str; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/InvalidConfigOptionValueException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/InvalidConfigOptionValueException.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/InvalidConfigOptionValueException.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,38 +0,0 @@ -/** - * 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.core; - -/** - * @author Jens Lehmann - * - */ -public class InvalidConfigOptionValueException extends Exception { - - private static final long serialVersionUID = 3286110428258072698L; - - public InvalidConfigOptionValueException(ConfigOption<?> option, Object value) { - super("The value " + value + " is not valid for the configuration option " + option + "."); - } - - public InvalidConfigOptionValueException(ConfigOption<?> option, Object value, String reason) { - super("The value " + value + " is not valid for the configuration option " + option + ". Reason: " + reason + "."); - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,82 +0,0 @@ -/** - * 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.core; - -import java.util.Arrays; -import java.util.Set; -import java.util.TreeSet; - -/** - * A configuration option, which allows values of type String. Optionally a set - * of allowed strings can be set. By default all strings are allowed. - * - * @author Jens Lehmann - * - */ -public class StringConfigOption extends ConfigOption<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) { - super(name, description, defaultValue); - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) - */ - @Override - public boolean isValidValue(String value) { - if(allowedValues.size() == 0 || allowedValues.contains(value)) - return true; - else - return false; - } - - /** - * @return the allowedValues - */ - public Set<String> getAllowedValues() { - return allowedValues; - } - - /** - * @param allowedValues the allowedValues to set - */ - public void setAllowedValues(Set<String> allowedValues) { - this.allowedValues = allowedValues; - } - - public void setAllowedValues(String[] allowedValues) { - this.allowedValues = new TreeSet<String>(Arrays.asList(allowedValues)); - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) - */ - @Override - public boolean checkType(Object object) { - return (object instanceof String); - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/StringSetConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/StringSetConfigOption.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/StringSetConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,59 +0,0 @@ -/** - * 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.core; - -import java.util.Set; - -/** - * @author Jens Lehmann - * - */ -public class StringSetConfigOption extends ConfigOption<Set<String>> { - - public StringSetConfigOption(String name, String description) { - super(name, description); - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) - */ - @Override - public boolean isValidValue(Set<String> value) { - return true; - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) - */ - @Override - public boolean checkType(Object object) { - if(!(object instanceof Set)) - return false; - - Set<?> set = (Set<?>) object; - for(Object element : set) { - if(!(element instanceof String)) - return false; - } - - return true; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,38 +0,0 @@ -/** - * 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.core; - -/** - * @author Jens Lehmann - * - */ -public class UnknownConfigOptionException extends Exception { - - private static final long serialVersionUID = -7808637210577591687L; - - public UnknownConfigOptionException(Class<? extends Component> componentClass, String optionName) { - super("Option " + optionName + " unknown in component " + ComponentManager.getInstance().getComponentName(componentClass) + "(" + componentClass.getName() + ")"); - } - - public UnknownConfigOptionException(Class<? extends Component> componentClass, ConfigOption<?> option) { - super("Option " + option.getName() + " unknown in component " + ComponentManager.getInstance().getComponentName(componentClass) + "(" + componentClass.getName() + ")"); - } - -} Copied: trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/BooleanConfigOption.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,53 @@ +/** + * 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.core.config; + + +/** + * @author Jens Lehmann + * + */ +public class BooleanConfigOption extends ConfigOption<Boolean> { + + 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.ConfigOption#checkType(java.lang.Object) + */ + @Override + public boolean checkType(Object object) { + return (object instanceof Boolean); + } + + /* (non-Javadoc) + * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) + */ + @Override + public boolean isValidValue(Boolean value) { + return true; + } + +} Copied: trunk/src/dl-learner/org/dllearner/core/config/CommonConfigMappings.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/CommonConfigMappings.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/CommonConfigMappings.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,56 @@ +/** + * 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.core.config; + +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.dllearner.core.dl.AtomicConcept; +import org.dllearner.core.dl.AtomicRole; +import org.dllearner.core.dl.Individual; + +/** + * @author Jens Lehmann + * + */ +public class CommonConfigMappings { + + public static SortedSet<Individual> getIndividualSet(Set<String> individuals) { + SortedSet<Individual> set = new TreeSet<Individual>(); + for(String individual : individuals) + set.add(new Individual(individual)); + return set; + } + + public static SortedSet<AtomicConcept> getAtomicConceptSet(Set<String> atomicConcepts) { + SortedSet<AtomicConcept> set = new TreeSet<AtomicConcept>(); + for(String atomicConcept : atomicConcepts) + set.add(new AtomicConcept(atomicConcept)); + return set; + } + + public static SortedSet<AtomicRole> getAtomicRoleSet(Set<String> atomicRoles) { + SortedSet<AtomicRole> set = new TreeSet<AtomicRole>(); + for(String atomicRole : atomicRoles) + set.add(new AtomicRole(atomicRole)); + return set; + } +} Copied: trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2007-10-18 17:21:38 UTC (rev 238) @@ -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.core.config; + + +/** + * Contains methods for creating common configuration options, i.e. options + * which are or may be of use for several components. + * + * @author Jens Lehmann + * + */ +public final class CommonConfigOptions { + + public static StringConfigOption getVerbosityOption() { + StringConfigOption verbosityOption = new StringConfigOption("verbosity", "control verbosity of output for this component", "warning"); + String[] allowedValues = new String[] {"quiet", "error", "warning", "notice", "info", "debug"}; + verbosityOption.setAllowedValues(allowedValues); + return verbosityOption; + } + + 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); + option.setLowerLimit(0.0); + option.setUpperLimit(1.0); + return option; + } + + public static StringConfigOption getReturnType() { + return new StringConfigOption("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."); + } + + public static BooleanConfigOption getUNA() { + return new BooleanConfigOption("una", "unique names assumption", false); + } + + public static BooleanConfigOption getOWA() { + return new BooleanConfigOption("owa", "open world assumption (if set to false, we try to close the world", true); + } + + public static StringSetConfigOption allowedConcepts() { + return new StringSetConfigOption("allowedConcepts", "concepts the algorithm is allowed to use"); + } + + public static StringSetConfigOption allowedRoles() { + return new StringSetConfigOption("allowedRoles", "roles the algorithm is allowed to use"); + } + + public static StringSetConfigOption ignoredConcepts() { + return new StringSetConfigOption("ignoredConcepts", "concepts the algorithm must ignore"); + } + + public static StringSetConfigOption ignoredRoles() { + return new StringSetConfigOption("ignoredRoles", "roles the algorithm must ignore"); + } + + public static BooleanConfigOption useAllConstructor() { + return new BooleanConfigOption("useAllConstructor", "specifies whether to universal concept constructor is used in the learning algorothm"); + } + + public static BooleanConfigOption useExistsConstructor() { + return new BooleanConfigOption("useExistsConstructor", "specifies whether to existential concept constructor is used in the learning algorothm"); + } + + public static BooleanConfigOption useNegation() { + return new BooleanConfigOption("useNegation", "specifies whether negation is used in the learning algorothm"); + } +} Copied: trunk/src/dl-learner/org/dllearner/core/config/ConfigDocumentationGenerator.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/ConfigDocumentationGenerator.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigDocumentationGenerator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigDocumentationGenerator.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,45 @@ +/** + * 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.core.config; + +import java.io.File; + +import org.dllearner.core.ComponentManager; + +/** + * 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 ConfigDocumentationGenerator { + + /** + * @param args + */ + public static void main(String[] args) { + File file = new File("doc/configOptions.txt"); + ComponentManager cm = ComponentManager.getInstance(); + cm.writeConfigDocumentation(file); + } + +} Copied: trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/ConfigEntry.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,55 @@ +/** + * 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.core.config; + + +/** + * A config entry is a configuration option and a value for the option. + * + * @author Jens Lehmann + * + */ +public class ConfigEntry<T> { + + private ConfigOption<T> option; + private T value; + + public ConfigEntry(ConfigOption<T> option, T value) throws InvalidConfigOptionValueException { + if(!option.isValidValue(value)) { + throw new InvalidConfigOptionValueException(option, value); + } else { + this.option = option; + this.value = value; + } + } + + public ConfigOption<T> getOption() { + return option; + } + + public String getOptionName() { + return option.getName(); + } + + public T getValue() { + return value; + } + +} Copied: trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/ConfigOption.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,88 @@ +/** + * 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.core.config; + +/** + * This class represents a configuration option (without a value for the + * option). + * + * 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. + * + * @author Jens Lehmann + * + */ +public abstract class ConfigOption<T> { + + protected String name; + + protected String description; + + protected T defaultValue; + + public ConfigOption(String name, String description) { + this(name, description, null); + } + + public ConfigOption(String name, String description, T defaultValue) { + this.name = name; + this.description = description; + this.defaultValue = defaultValue; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + /** + * @return the defaultValue + */ + public T getDefaultValue() { + return defaultValue; + } + + /** + * Checks whether the object has the correct type to be used as + * a value for this option (this method is necessary, because + * generic information is erased at runtime in Java). + * + * @param object The object to check. + * @return + */ + public abstract boolean checkType(Object object); + + public abstract boolean isValidValue(T value); + + public String getAllowedValuesDescription() { + return getClass().toString(); + } + + @Override + public String toString() { + return "option name: " + name + "\ndescription: " + description + "\nvalues: " + getAllowedValuesDescription() + "\ndefault value: " + defaultValue + "\n"; + } + +} Copied: trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,100 @@ +/** + * 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.core.config; + + +/** + * Represents a configuration option with values of type value. Similar + * to the integer option a minimum and a maximum value can specified. + * + * @author Jens Lehmann + * + */ +public class DoubleConfigOption extends ConfigOption<Double> { + + private double lowerLimit = Double.MIN_VALUE; + private double upperLimit = Double.MAX_VALUE; + + 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.ConfigOption#isValidValue(java.lang.Object) + */ + @Override + public boolean isValidValue(Double value) { + if(value >= lowerLimit && value <= upperLimit) + return true; + else + return false; + } + + /** + * @return the The lowest possible value for this configuration option. + */ + public double getLowerLimit() { + return lowerLimit; + } + + /** + * @param lowerLimit The lowest possible value for this configuration option. + */ + public void setLowerLimit(double lowerLimit) { + this.lowerLimit = lowerLimit; + } + + /** + * @return the The highest possible value for this configuration option. + */ + public double getUpperLimit() { + return upperLimit; + } + + /** + * @param upperLimit The highest possible value for this configuration option. + */ + public void setUpperLimit(double upperLimit) { + this.upperLimit = upperLimit; + } + + /* (non-Javadoc) + * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) + */ + @Override + public boolean checkType(Object object) { + return (object instanceof Double); + } + + @Override + public String getAllowedValuesDescription() { + String str = getClass().toString(); + if(lowerLimit != Double.MIN_VALUE) + str += " min " + lowerLimit; + if(upperLimit != Double.MAX_VALUE) + str += " max " + upperLimit; + return str; + } + +} Copied: trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,100 @@ +/** + * 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.core.config; + + +/** + * A configuration option, which allows values of type integer. A minimum and + * ... [truncated message content] |
From: <jen...@us...> - 2007-10-18 16:24:34
|
Revision: 237 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=237&view=rev Author: jenslehmann Date: 2007-10-18 09:24:22 -0700 (Thu, 18 Oct 2007) Log Message: ----------- added SVN ignored flags for wsdl and xsd files Property Changed: ---------------- trunk/src/DBPedia-Navigator/ Property changes on: trunk/src/DBPedia-Navigator ___________________________________________________________________ Name: svn:ignore + main.wsdl def0.xsd def1.xsd This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2007-10-18 16:04:38
|
Revision: 236 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=236&view=rev Author: sknappe Date: 2007-10-18 09:04:36 -0700 (Thu, 18 Oct 2007) Log Message: ----------- added the DBPedia-Navigator Added Paths: ----------- trunk/src/DBPedia-Navigator/pear/ trunk/src/DBPedia-Navigator/pear/HTTP_Request.php trunk/src/DBPedia-Navigator/pear/PEAR.php trunk/src/DBPedia-Navigator/pear/Socket.php trunk/src/DBPedia-Navigator/pear/URL.php Added: trunk/src/DBPedia-Navigator/pear/HTTP_Request.php =================================================================== --- trunk/src/DBPedia-Navigator/pear/HTTP_Request.php (rev 0) +++ trunk/src/DBPedia-Navigator/pear/HTTP_Request.php 2007-10-18 16:04:36 UTC (rev 236) @@ -0,0 +1,2760 @@ +<?php + +// +-----------------------------------------------------------------------+ +// | Copyright (c) 2002-2003, Richard Heyes | +// | All rights reserved. | +// | | +// | Redistribution and use in source and binary forms, with or without | +// | modification, are permitted provided that the following conditions | +// | are met: | +// | | +// | o Redistributions of source code must retain the above copyright | +// | notice, this list of conditions and the following disclaimer. | +// | o Redistributions in binary form must reproduce the above copyright | +// | notice, this list of conditions and the following disclaimer in the | +// | documentation and/or other materials provided with the distribution.| +// | o The names of the authors may not be used to endorse or promote | +// | products derived from this software without specific prior written | +// | permission. | +// | | +// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | +// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | +// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | +// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | + +// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | + +// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | + +// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | + +// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | + +// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | + +// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | + +// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | + +// | | + +// +-----------------------------------------------------------------------+ + +// | Author: Richard Heyes <ri...@ph...> | + +// +-----------------------------------------------------------------------+ + +/* +// $Id: Request.php,v 1.1 2006/12/12 16:42:26 punkrock Exp $ +// +// HTTP_Request Class +// +// Simple example, (Fetches yahoo.com and displays it): +// +// $a = &new HTTP_Request('http://localhost:8081'); +// $a->sendRequest(); +// echo $a->getResponseBody(); +*/ + + + +require_once 'PEAR.php'; + +require_once 'Socket.php'; + +require_once 'URL.php'; + + + +define('HTTP_REQUEST_METHOD_GET', 'GET', true); + +define('HTTP_REQUEST_METHOD_HEAD', 'HEAD', true); + +define('HTTP_REQUEST_METHOD_POST', 'POST', true); + +define('HTTP_REQUEST_METHOD_PUT', 'PUT', true); + +define('HTTP_REQUEST_METHOD_DELETE', 'DELETE', true); + +define('HTTP_REQUEST_METHOD_OPTIONS', 'OPTIONS', true); + +define('HTTP_REQUEST_METHOD_TRACE', 'TRACE', true); + + + +define('HTTP_REQUEST_HTTP_VER_1_0', '1.0', true); + +define('HTTP_REQUEST_HTTP_VER_1_1', '1.1', true); + + + +class HTTP_Request { + + + + /** + + * Instance of Net_URL + + * @var object Net_URL + + */ + + var $_url; + + + + /** + + * Type of request + + * @var string + + */ + + var $_method; + + + + /** + + * HTTP Version + + * @var string + + */ + + var $_http; + + + + /** + + * Request headers + + * @var array + + */ + + var $_requestHeaders; + + + + /** + + * Basic Auth Username + + * @var string + + */ + + var $_user; + + + + /** + + * Basic Auth Password + + * @var string + + */ + + var $_pass; + + + + /** + + * Socket object + + * @var object Net_Socket + + */ + + var $_sock; + + + + /** + + * Proxy server + + * @var string + + */ + + var $_proxy_host; + + + + /** + + * Proxy port + + * @var integer + + */ + + var $_proxy_port; + + + + /** + + * Proxy username + + * @var string + + */ + + var $_proxy_user; + + + + /** + + * Proxy password + + * @var string + + */ + + var $_proxy_pass; + + + + /** + + * Post data + + * @var array + + */ + + var $_postData; + + + + /** + + * Request body + + * @var string + + */ + + var $_body; + + + + /** + + * A list of methods that MUST NOT have a request body, per RFC 2616 + + * @var array + + */ + + var $_bodyDisallowed = array('TRACE'); + + + + /** + + * Files to post + + * @var array + + */ + + var $_postFiles = array(); + + + + /** + + * Connection timeout. + + * @var float + + */ + + var $_timeout; + + + + /** + + * HTTP_Response object + + * @var object HTTP_Response + + */ + + var $_response; + + + + /** + + * Whether to allow redirects + + * @var boolean + + */ + + var $_allowRedirects; + + + + /** + + * Maximum redirects allowed + + * @var integer + + */ + + var $_maxRedirects; + + + + /** + + * Current number of redirects + + * @var integer + + */ + + var $_redirects; + + + + /** + + * Whether to append brackets [] to array variables + + * @var bool + + */ + + var $_useBrackets = true; + + + + /** + + * Attached listeners + + * @var array + + */ + + var $_listeners = array(); + + + + /** + + * Whether to save response body in response object property + + * @var bool + + */ + + var $_saveBody = true; + + + + /** + + * Timeout for reading from socket (array(seconds, microseconds)) + + * @var array + + */ + + var $_readTimeout = null; + + + + /** + + * Options to pass to Net_Socket::connect. See stream_context_create + + * @var array + + */ + + var $_socketOptions = null; + + + + /** + + * Constructor + + * + + * Sets up the object + + * @param string The url to fetch/access + + * @param array Associative array of parameters which can have the following keys: + + * <ul> + + * <li>method - Method to use, GET, POST etc (string)</li> + + * <li>http - HTTP Version to use, 1.0 or 1.1 (string)</li> + + * <li>user - Basic Auth username (string)</li> + + * <li>pass - Basic Auth password (string)</li> + + * <li>proxy_host - Proxy server host (string)</li> + + * <li>proxy_port - Proxy server port (integer)</li> + + * <li>proxy_user - Proxy auth username (string)</li> + + * <li>proxy_pass - Proxy auth password (string)</li> + + * <li>timeout - Connection timeout in seconds (float)</li> + + * <li>allowRedirects - Whether to follow redirects or not (bool)</li> + + * <li>maxRedirects - Max number of redirects to follow (integer)</li> + + * <li>useBrackets - Whether to append [] to array variable names (bool)</li> + + * <li>saveBody - Whether to save response body in response object property (bool)</li> + + * <li>readTimeout - Timeout for reading / writing data over the socket (array (seconds, microseconds))</li> + + * <li>socketOptions - Options to pass to Net_Socket object (array)</li> + + * </ul> + + * @access public + + */ + + function HTTP_Request($url = '', $params = array()) + + { + + $this->_method = HTTP_REQUEST_METHOD_GET; + + $this->_http = HTTP_REQUEST_HTTP_VER_1_1; + + $this->_requestHeaders = array(); + + $this->_postData = array(); + + $this->_body = null; + + + + $this->_user = null; + + $this->_pass = null; + + + + $this->_proxy_host = null; + + $this->_proxy_port = null; + + $this->_proxy_user = null; + + $this->_proxy_pass = null; + + + + $this->_allowRedirects = false; + + $this->_maxRedirects = 3; + + $this->_redirects = 0; + + + + $this->_timeout = null; + + $this->_response = null; + + + + foreach ($params as $key => $value) { + + $this->{'_' . $key} = $value; + + } + + + + if (!empty($url)) { + + $this->setURL($url); + + } + + + + // Default useragent + + $this->addHeader('User-Agent', 'PEAR HTTP_Request class ( http://pear.php.net/ )'); + + + + // We don't do keep-alives by default + + $this->addHeader('Connection', 'close'); + + + + // Basic authentication + + if (!empty($this->_user)) { + + $this->addHeader('Authorization', 'Basic ' . base64_encode($this->_user . ':' . $this->_pass)); + + } + + + + // Proxy authentication (see bug #5913) + + if (!empty($this->_proxy_user)) { + + $this->addHeader('Proxy-Authorization', 'Basic ' . base64_encode($this->_proxy_user . ':' . $this->_proxy_pass)); + + } + + + + // Use gzip encoding if possible + + // Avoid gzip encoding if using multibyte functions (see #1781) + + if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && extension_loaded('zlib') && + + 0 == (2 & ini_get('mbstring.func_overload'))) { + + + + $this->addHeader('Accept-Encoding', 'gzip'); + + } + + } + + + + /** + + * Generates a Host header for HTTP/1.1 requests + + * + + * @access private + + * @return string + + */ + + function _generateHostHeader() + + { + + if ($this->_url->port != 80 AND strcasecmp($this->_url->protocol, 'http') == 0) { + + $host = $this->_url->host . ':' . $this->_url->port; + + + + } elseif ($this->_url->port != 443 AND strcasecmp($this->_url->protocol, 'https') == 0) { + + $host = $this->_url->host . ':' . $this->_url->port; + + + + } elseif ($this->_url->port == 443 AND strcasecmp($this->_url->protocol, 'https') == 0 AND strpos($this->_url->url, ':443') !== false) { + + $host = $this->_url->host . ':' . $this->_url->port; + + + + } else { + + $host = $this->_url->host; + + } + + + + return $host; + + } + + + + /** + + * Resets the object to its initial state (DEPRECATED). + + * Takes the same parameters as the constructor. + + * + + * @param string $url The url to be requested + + * @param array $params Associative array of parameters + + * (see constructor for details) + + * @access public + + * @deprecated deprecated since 1.2, call the constructor if this is necessary + + */ + + function reset($url, $params = array()) + + { + + $this->HTTP_Request($url, $params); + + } + + + + /** + + * Sets the URL to be requested + + * + + * @param string The url to be requested + + * @access public + + */ + + function setURL($url) + + { + + $this->_url = &new Net_URL($url, $this->_useBrackets); + + + + if (!empty($this->_url->user) || !empty($this->_url->pass)) { + + $this->setBasicAuth($this->_url->user, $this->_url->pass); + + } + + + + if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http) { + + $this->addHeader('Host', $this->_generateHostHeader()); + + } + + + + // set '/' instead of empty path rather than check later (see bug #8662) + + if (empty($this->_url->path)) { + + $this->_url->path = '/'; + + } + + } + + + + /** + + * Returns the current request URL + + * + + * @return string Current request URL + + * @access public + + */ + + function getUrl($url) + + { + + return empty($this->_url)? '': $this->_url->getUrl(); + + } + + + + /** + + * Sets a proxy to be used + + * + + * @param string Proxy host + + * @param int Proxy port + + * @param string Proxy username + + * @param string Proxy password + + * @access public + + */ + + function setProxy($host, $port = 8080, $user = null, $pass = null) + + { + + $this->_proxy_host = $host; + + $this->_proxy_port = $port; + + $this->_proxy_user = $user; + + $this->_proxy_pass = $pass; + + + + if (!empty($user)) { + + $this->addHeader('Proxy-Authorization', 'Basic ' . base64_encode($user . ':' . $pass)); + + } + + } + + + + /** + + * Sets basic authentication parameters + + * + + * @param string Username + + * @param string Password + + */ + + function setBasicAuth($user, $pass) + + { + + $this->_user = $user; + + $this->_pass = $pass; + + + + $this->addHeader('Authorization', 'Basic ' . base64_encode($user . ':' . $pass)); + + } + + + + /** + + * Sets the method to be used, GET, POST etc. + + * + + * @param string Method to use. Use the defined constants for this + + * @access public + + */ + + function setMethod($method) + + { + + $this->_method = $method; + + } + + + + /** + + * Sets the HTTP version to use, 1.0 or 1.1 + + * + + * @param string Version to use. Use the defined constants for this + + * @access public + + */ + + function setHttpVer($http) + + { + + $this->_http = $http; + + } + + + + /** + + * Adds a request header + + * + + * @param string Header name + + * @param string Header value + + * @access public + + */ + + function addHeader($name, $value) + + { + + $this->_requestHeaders[strtolower($name)] = $value; + + } + + + + /** + + * Removes a request header + + * + + * @param string Header name to remove + + * @access public + + */ + + function removeHeader($name) + + { + + if (isset($this->_requestHeaders[strtolower($name)])) { + + unset($this->_requestHeaders[strtolower($name)]); + + } + + } + + + + /** + + * Adds a querystring parameter + + * + + * @param string Querystring parameter name + + * @param string Querystring parameter value + + * @param bool Whether the value is already urlencoded or not, default = not + + * @access public + + */ + + function addQueryString($name, $value, $preencoded = false) + + { + + $this->_url->addQueryString($name, $value, $preencoded); + + } + + + + /** + + * Sets the querystring to literally what you supply + + * + + * @param string The querystring data. Should be of the format foo=bar&x=y etc + + * @param bool Whether data is already urlencoded or not, default = already encoded + + * @access public + + */ + + function addRawQueryString($querystring, $preencoded = true) + + { + + $this->_url->addRawQueryString($querystring, $preencoded); + + } + + + + /** + + * Adds postdata items + + * + + * @param string Post data name + + * @param string Post data value + + * @param bool Whether data is already urlencoded or not, default = not + + * @access public + + */ + + function addPostData($name, $value, $preencoded = false) + + { + + if ($preencoded) { + + $this->_postData[$name] = $value; + + } else { + + $this->_postData[$name] = $this->_arrayMapRecursive('urlencode', $value); + + } + + } + + + + /** + + * Recursively applies the callback function to the value + + * + + * @param mixed Callback function + + * @param mixed Value to process + + * @access private + + * @return mixed Processed value + + */ + + function _arrayMapRecursive($callback, $value) + + { + + if (!is_array($value)) { + + return call_user_func($callback, $value); + + } else { + + $map = array(); + + foreach ($value as $k => $v) { + + $map[$k] = $this->_arrayMapRecursive($callback, $v); + + } + + return $map; + + } + + } + + + + /** + + * Adds a file to upload + + * + + * This also changes content-type to 'multipart/form-data' for proper upload + + * + + * @access public + + * @param string name of file-upload field + + * @param mixed file name(s) + + * @param mixed content-type(s) of file(s) being uploaded + + * @return bool true on success + + * @throws PEAR_Error + + */ + + function addFile($inputName, $fileName, $contentType = 'application/octet-stream') + + { + + if (!is_array($fileName) && !is_readable($fileName)) { + + return PEAR::raiseError("File '{$fileName}' is not readable"); + + } elseif (is_array($fileName)) { + + foreach ($fileName as $name) { + + if (!is_readable($name)) { + + return PEAR::raiseError("File '{$name}' is not readable"); + + } + + } + + } + + $this->addHeader('Content-Type', 'multipart/form-data'); + + $this->_postFiles[$inputName] = array( + + 'name' => $fileName, + + 'type' => $contentType + + ); + + return true; + + } + + + + /** + + * Adds raw postdata (DEPRECATED) + + * + + * @param string The data + + * @param bool Whether data is preencoded or not, default = already encoded + + * @access public + + * @deprecated deprecated since 1.3.0, method setBody() should be used instead + + */ + + function addRawPostData($postdata, $preencoded = true) + + { + + $this->_body = $preencoded ? $postdata : urlencode($postdata); + + } + + + + /** + + * Sets the request body (for POST, PUT and similar requests) + + * + + * @param string Request body + + * @access public + + */ + + function setBody($body) + + { + + $this->_body = $body; + + } + + + + /** + + * Clears any postdata that has been added (DEPRECATED). + + * + + * Useful for multiple request scenarios. + + * + + * @access public + + * @deprecated deprecated since 1.2 + + */ + + function clearPostData() + + { + + $this->_postData = null; + + } + + + + /** + + * Appends a cookie to "Cookie:" header + + * + + * @param string $name cookie name + + * @param string $value cookie value + + * @access public + + */ + + function addCookie($name, $value) + + { + + $cookies = isset($this->_requestHeaders['cookie']) ? $this->_requestHeaders['cookie']. '; ' : ''; + + $this->addHeader('Cookie', $cookies . $name . '=' . $value); + + } + + + + /** + + * Clears any cookies that have been added (DEPRECATED). + + * + + * Useful for multiple request scenarios + + * + + * @access public + + * @deprecated deprecated since 1.2 + + */ + + function clearCookies() + + { + + $this->removeHeader('Cookie'); + + } + + + + /** + + * Sends the request + + * + + * @access public + + * @param bool Whether to store response body in Response object property, + + * set this to false if downloading a LARGE file and using a Listener + + * @return mixed PEAR error on error, true otherwise + + */ + + function sendRequest($saveBody = true){ + + if (!is_a($this->_url, 'Net_URL')) { + + return PEAR::raiseError('No URL given.'); + + } + + + + $host = isset($this->_proxy_host) ? $this->_proxy_host : $this->_url->host; + + $port = isset($this->_proxy_port) ? $this->_proxy_port : $this->_url->port; + + + + // 4.3.0 supports SSL connections using OpenSSL. The function test determines + + // we running on at least 4.3.0 + + if (strcasecmp($this->_url->protocol, 'https') == 0 AND function_exists('file_get_contents') AND extension_loaded('openssl')) { + + if (isset($this->_proxy_host)) { + + return PEAR::raiseError('HTTPS proxies are not supported.'); + + } + + $host = 'ssl://' . $host; + + } + + + + // magic quotes may fuck up file uploads and chunked response processing + + $magicQuotes = ini_get('magic_quotes_runtime'); + + ini_set('magic_quotes_runtime', false); + + + + // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive + + // connection token to a proxy server... + + if (isset($this->_proxy_host) && !empty($this->_requestHeaders['connection']) && + + 'Keep-Alive' == $this->_requestHeaders['connection']) + + { + + $this->removeHeader('connection'); + + } + + + + $keepAlive = (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && empty($this->_requestHeaders['connection'])) || + + (!empty($this->_requestHeaders['connection']) && 'Keep-Alive' == $this->_requestHeaders['connection']); + + $sockets = &PEAR::getStaticProperty('HTTP_Request', 'sockets'); + + $sockKey = $host . ':' . $port; + + unset($this->_sock); + + + + // There is a connected socket in the "static" property? + + if ($keepAlive && !empty($sockets[$sockKey]) && + + !empty($sockets[$sockKey]->fp)) + + { + + $this->_sock =& $sockets[$sockKey]; + + $err = null; + + } else { + + $this->_notify('connect'); + + $this->_sock =& new Net_Socket(); + + $err = $this->_sock->connect($host, $port, null, $this->_timeout, $this->_socketOptions); + + } + + PEAR::isError($err) or $err = $this->_sock->write($this->_buildRequest()); + + + + if (!PEAR::isError($err)) { + + if (!empty($this->_readTimeout)) { + + $this->_sock->setTimeout($this->_readTimeout[0], $this->_readTimeout[1]); + + } + + + + $this->_notify('sentRequest'); + + + + // Read the response + + $this->_response = &new HTTP_Response($this->_sock, $this->_listeners); + + $err = $this->_response->process( + + $this->_saveBody && $saveBody, + + HTTP_REQUEST_METHOD_HEAD != $this->_method + + ); + + + + if ($keepAlive) { + + $keepAlive = (isset($this->_response->_headers['content-length']) + + || (isset($this->_response->_headers['transfer-encoding']) + + && strtolower($this->_response->_headers['transfer-encoding']) == 'chunked')); + + if ($keepAlive) { + + if (isset($this->_response->_headers['connection'])) { + + $keepAlive = strtolower($this->_response->_headers['connection']) == 'keep-alive'; + + } else { + + $keepAlive = 'HTTP/'.HTTP_REQUEST_HTTP_VER_1_1 == $this->_response->_protocol; + + } + + } + + } + + } + + + + ini_set('magic_quotes_runtime', $magicQuotes); + + + + if (PEAR::isError($err)) { + + return $err; + + } + + + + if (!$keepAlive) { + + $this->disconnect(); + + // Store the connected socket in "static" property + + } elseif (empty($sockets[$sockKey]) || empty($sockets[$sockKey]->fp)) { + + $sockets[$sockKey] =& $this->_sock; + + } + + + + // Check for redirection + + if ( $this->_allowRedirects + + AND $this->_redirects <= $this->_maxRedirects + + AND $this->getResponseCode() > 300 + + AND $this->getResponseCode() < 399 + + AND !empty($this->_response->_headers['location'])) { + + + + + + $redirect = $this->_response->_headers['location']; + + + + // Absolute URL + + if (preg_match('/^https?:\/\//i', $redirect)) { + + $this->_url = &new Net_URL($redirect); + + $this->addHeader('Host', $this->_generateHostHeader()); + + // Absolute path + + } elseif ($redirect{0} == '/') { + + $this->_url->path = $redirect; + + + + // Relative path + + } elseif (substr($redirect, 0, 3) == '../' OR substr($redirect, 0, 2) == './') { + + if (substr($this->_url->path, -1) == '/') { + + $redirect = $this->_url->path . $redirect; + + } else { + + $redirect = dirname($this->_url->path) . '/' . $redirect; + + } + + $redirect = Net_URL::resolvePath($redirect); + + $this->_url->path = $redirect; + + + + // Filename, no path + + } else { + + if (substr($this->_url->path, -1) == '/') { + + $redirect = $this->_url->path . $redirect; + + } else { + + $redirect = dirname($this->_url->path) . '/' . $redirect; + + } + + $this->_url->path = $redirect; + + } + + + + $this->_redirects++; + + return $this->sendRequest($saveBody); + + + + // Too many redirects + + } elseif ($this->_allowRedirects AND $this->_redirects > $this->_maxRedirects) { + + return PEAR::raiseError('Too many redirects'); + + } + + + + return true; + + } + + + + /** + + * Disconnect the socket, if connected. Only useful if using Keep-Alive. + + * + + * @access public + + */ + + function disconnect() + + { + + if (!empty($this->_sock) && !empty($this->_sock->fp)) { + + $this->_notify('disconnect'); + + $this->_sock->disconnect(); + + } + + } + + + + /** + + * Returns the response code + + * + + * @access public + + * @return mixed Response code, false if not set + + */ + + function getResponseCode() + + { + + return isset($this->_response->_code) ? $this->_response->_code : false; + + } + + + + /** + + * Returns either the named header or all if no name given + + * + + * @access public + + * @param string The header name to return, do not set to get all headers + + * @return mixed either the value of $headername (false if header is not present) + + * or an array of all headers + + */ + + function getResponseHeader($headername = null) + + { + + if (!isset($headername)) { + + return isset($this->_response->_headers)? $this->_response->_headers: array(); + + } else { + + $headername = strtolower($headername); + + return isset($this->_response->_headers[$headername]) ? $this->_response->_headers[$headername] : false; + + } + + } + + + + /** + + * Returns the body of the response + + * + + * @access public + + * @return mixed response body, false if not set + + */ + + function getResponseBody() + + { + + return isset($this->_response->_body) ? $this->_response->_body : false; + + } + + + + /** + + * Returns cookies set in response + + * + + * @access public + + * @return mixed array of response cookies, false if none are present + + */ + + function getResponseCookies() + + { + + return isset($this->_response->_cookies) ? $this->_response->_cookies : false; + + } + + + + /** + + * Builds the request string + + * + + * @access private + + * @return string The request string + + */ + + function _buildRequest() + + { + + $separator = ini_get('arg_separator.output'); + + ini_set('arg_separator.output', '&'); + + $querystring = ($querystring = $this->_url->getQueryString()) ? '?' . $querystring : ''; + + ini_set('arg_separator.output', $separator); + + + + $host = isset($this->_proxy_host) ? $this->_url->protocol . '://' . $this->_url->host : ''; + + $port = (isset($this->_proxy_host) AND $this->_url->port != 80) ? ':' . $this->_url->port : ''; + + $path = $this->_url->path . $querystring; + + $url = $host . $port . $path; + + + + $request = $this->_method . ' ' . $url . ' HTTP/' . $this->_http . "\r\n"; + + + + if (in_array($this->_method, $this->_bodyDisallowed) || + + (empty($this->_body) && (HTTP_REQUEST_METHOD_POST != $this->_method || + + (empty($this->_postData) && empty($this->_postFiles))))) + + { + + $this->removeHeader('Content-Type'); + + } else { + + if (empty($this->_requestHeaders['content-type'])) { + + // Add default content-type + + $this->addHeader('Content-Type', 'application/x-www-form-urlencoded'); + + } elseif ('multipart/form-data' == $this->_requestHeaders['content-type']) { + + $boundary = 'HTTP_Request_' . md5(uniqid('request') . microtime()); + + $this->addHeader('Content-Type', 'multipart/form-data; boundary=' . $boundary); + + } + + } + + + + // Request Headers + + if (!empty($this->_requestHeaders)) { + + foreach ($this->_requestHeaders as $name => $value) { + + $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); + + $request .= $canonicalName . ': ' . $value . "\r\n"; + + } + + } + + + + // No post data or wrong method, so simply add a final CRLF + + if (in_array($this->_method, $this->_bodyDisallowed) || + + (HTTP_REQUEST_METHOD_POST != $this->_method && empty($this->_body))) { + + + + $request .= "\r\n"; + + + + // Post data if it's an array + + } elseif (HTTP_REQUEST_METHOD_POST == $this->_method && + + (!empty($this->_postData) || !empty($this->_postFiles))) { + + + + // "normal" POST request + + if (!isset($boundary)) { + + $postdata = implode('&', array_map( + + create_function('$a', 'return $a[0] . \'=\' . $a[1];'), + + $this->_flattenArray('', $this->_postData) + + )); + + + + // multipart request, probably with file uploads + + } else { + + $postdata = ''; + + if (!empty($this->_postData)) { + + $flatData = $this->_flattenArray('', $this->_postData); + + foreach ($flatData as $item) { + + $postdata .= '--' . $boundary . "\r\n"; + + $postdata .= 'Content-Disposition: form-data; name="' . $item[0] . '"'; + + $postdata .= "\r\n\r\n" . urldecode($item[1]) . "\r\n"; + + } + + } + + foreach ($this->_postFiles as $name => $value) { + + if (is_array($value['name'])) { + + $varname = $name . ($this->_useBrackets? '[]': ''); + + } else { + + $varname = $name; + + $value['name'] = array($value['name']); + + } + + foreach ($value['name'] as $key => $filename) { + + $fp = fopen($filename, 'r'); + + $data = fread($fp, filesize($filename)); + + fclose($fp); + + $basename = basename($filename); + + $type = is_array($value['type'])? @$value['type'][$key]: $value['type']; + + + + $postdata .= '--' . $boundary . "\r\n"; + + $postdata .= 'Content-Disposition: form-data; name="' . $varname . '"; filename="' . $basename . '"'; + + $postdata .= "\r\nContent-Type: " . $type; + + $postdata .= "\r\n\r\n" . $data . "\r\n"; + + } + + } + + $postdata .= '--' . $boundary . "--\r\n"; + + } + + $request .= 'Content-Length: ' . strlen($postdata) . "\r\n\r\n"; + + $request .= $postdata; + + + + // Explicitly set request body + + } elseif (!empty($this->_body)) { + + + + $request .= 'Content-Length: ' . strlen($this->_body) . "\r\n\r\n"; + + $request .= $this->_body; + + } + + + + return $request; + + } + + + + /** + + * Helper function to change the (probably multidimensional) associative array + + * into the simple one. + + * + + * @param string name for item + + * @param mixed item's values + + * @return array array with the following items: array('item name', 'item value'); + + */ + + function _flattenArray($name, $values) + + { + + if (!is_array($values)) { + + return array(array($name, $values)); + + } else { + + $ret = array(); + + foreach ($values as $k => $v) { + + if (empty($name)) { + + $newName = $k; + + } elseif ($this->_useBrackets) { + + $newName = $name . '[' . $k . ']'; + + } else { + + $newName = $name; + + } + + $ret = array_merge($ret, $this->_flattenArray($newName, $v)); + + } + + return $ret; + + } + + } + + + + + + /** + + * Adds a Listener to the list of listeners that are notified of + + * the object's events + + * + + * @param object HTTP_Request_Listener instance to attach + + * @return boolean whether the listener was successfully attached + + * @access public + + */ + + function attach(&$listener) + + { + + if (!is_a($listener, 'HTTP_Request_Listener')) { + + return false; + + } + + $this->_listeners[$listener->getId()] =& $listener; + + return true; + + } + + + + + + /** + + * Removes a Listener from the list of listeners + + * + + * @param object HTTP_Request_Listener instance to detach + + * @return boolean whether the listener was successfully detached + + * @access public + + */ + + function detach(&$listener) + + { + + if (!is_a($listener, 'HTTP_Request_Listener') || + + !isset($this->_listeners[$listener->getId()])) { + + return false; + + } + + unset($this->_listeners[$listener->getId()]); + + return true; + + } + + + + + + /** + + * Notifies all registered listeners of an event. + + * + + * Events sent by HTTP_Request object + + * - 'connect': on connection to server + + * - 'sentRequest': after the request was sent + + * - 'disconnect': on disconnection from server + + * + + * Events sent by HTTP_Response object + + * - 'gotHeaders': after receiving response headers (headers are passed in $data) + + * - 'tick': on receiving a part of response body (the part is passed in $data) + + * - 'gzTick': on receiving a gzip-encoded part of response body (ditto) + + * - 'gotBody': after receiving the response body (passes the decoded body in $data if it was gzipped) + + * + + * @param string Event name + + * @param mixed Additional data + + * @access private + + */ + + function _notify($event, $data = null) + + { + + foreach (array_keys($this->_listeners) as $id) { + + $this->_listeners[$id]->update($this, $event, $data); + + } + + } + +} + + + + + +/** + +* Response class to complement the Request class + +*/ + +class HTTP_Response + +{ + + /** + + * Socket object + + * @var object + + */ + + var $_sock; + + + + /** + + * Protocol + + * @var string + + */ + + var $_protocol; + + + + /** + + * Return code + + * @var string + + */ + + var $_code; + + + + /** + + * Response headers + + * @var array + + */ + + var $_headers; + + + + /** + + * Cookies set in response + + * @var array + + */ + + var $_cookies; + + + + /** + + * Response body + + * @var string + + */ + + var $_body = ''; + + + + /** + + * Used by _readChunked(): remaining length of the current chunk + + * @var string + + */ + + var $_chunkLength = 0; + + + + /** + + * Attached listeners + + * @var array + + */ + + var $_listeners = array(); + + + + /** + + * Bytes left to read from message-body + + * @var null|int + + */ + + var $_toRead; + + + + /** + + * Constructor + + * + + * @param object Net_Socket socket to read the response from + + * @param array listeners attached to request + + * @return mixed PEAR Error on error, true otherwise + + */ + + function HTTP_Response(&$sock, &$listeners) + + { + + $this->_sock =& $sock; + + $this->_listeners =& $listeners; + + } + + + + + + /** + + * Processes a HTTP response + + * + + * This extracts response code, headers, cookies and decodes body if it + + * was encoded in some way + + * + + * @access public + + * @param bool Whether to store response body in object property, set + + * this to false if downloading a LARGE file and using a Listener. + + * This is assumed to be true if body is gzip-encoded. + + * @param bool Whether the response can actually have a message-body. + + * Will be set to false for HEAD requests. + + * @throws PEAR_Error + + * @return mixed true on success, PEAR_Error in case of malformed response + + */ + + function process($saveBody = true, $canHaveBody = true) + + { + + do { + + $line = $this->_sock->readLine(); + + if (sscanf($line, 'HTTP/%s %s', $http_version, $returncode) != 2) { + + return PEAR::raiseError('Malformed response.'); + + } else { + + $this->_protocol = 'HTTP/' . $http_version; + + $this->_code = intval($returncode); + + } + + while ('' !== ($header = $this->_sock->readLine())) { + + $this->_processHeader($header); + + } + + } while (100 == $this->_code); + + + + $this->_notify('gotHeaders', $this->_headers); + + + + // RFC 2616, section 4.4: + + // 1. Any response message which "MUST NOT" include a message-body ... + + // is always terminated by the first empty line after the header fields + + // 3. ... If a message is received with both a + + // Transfer-Encoding header field and a Content-Length header field, + + // the latter MUST be ignored. + + $canHaveBody = $canHaveBody && $this->_code >= 200 && + + $this->_code != 204 && $this->_code != 304; + + + + // If response body is present, read it and decode + + $chunked = isset($this->_headers['transfer-encoding']) && ('chunked' == $this->_headers['transfer-encoding']); + + $gzipped = isset($this->_headers['content-encoding']) && ('gzip' == $this->_headers['content-encoding']); + + $hasBody = false; + + if ($canHaveBody && ($chunked || !isset($this->_headers['content-length']) || + + 0 != $this->_headers['content-length'])) + + { + + if ($chunked || !isset($this->_headers['content-length'])) { + + $this->_toRead = null; + + } else { + + $this->_toRead = $this->_headers['content-length']; + + } + + while (!$this->_sock->eof() && (is_null($this->_toRead) || 0 < $this->_toRead)) { + + if ($chunked) { + + $data = $this->_readChunked(); + + } elseif (is_null($this->_toRead)) { + + $data = $this->_sock->read(4096); + + } else { + + $data = $this->_sock->read(min(4096, $this->_toRead)); + + $this->_toRead -= strlen($data); + + } + + if ('' == $data) { + + break; + + } else { + + $hasBody = true; + + if ($saveBody || $gzipped) { + + $this->_body .= $data; + + } + + $this->_notify($gzipped? 'gzTick': 'tick', $data); + + } + + } + + } + + + + if ($hasBody) { + + // Uncompress the body if needed + + if ($gzipped) { + + $body = $this->_decodeGzip($this->_body); + + if (PEAR::isError($body)) { + + return $body; + + } + + $this->_body = $body; + + $this->_notify('gotBody', $this->_body); + + } else { + + $this->_notify('gotBody'); + + } + + } + + return true; + + } + + + + + + /** + + * Processes the response header + + * + + * @access private + + * @param string HTTP header + + */ + + function _processHeader($header) + + { + + if (false === strpos($header, ':')) { + + return; + + } + + list($headername, $headervalue) = explode(':', $header, 2); + + $headername = strtolower($headername); + + $headervalue = ltrim($headervalue); + + + + if ('set-cookie' != $headername) { + + if (isset($this->_headers[$headername])) { + + $this->_headers[$headername] .= ',' . $headervalue; + + } else { + + $this->_headers[$headername] = $headervalue; + + } + + } else { + + $this->_parseCookie($headervalue); + + } + + } + + + + + + /** + + * Parse a Set-Cookie header to fill $_cookies array + + * + + * @access private + + * @param string value of Set-Cookie header + + */ + + function _parseCookie($headervalue) + + { + + $cookie = array( + + 'expires' => null, + + 'domain' => null, + + 'path' => null, + + 'secure' => false + + ); + + + + // Only a name=value pair + + if (!strpos($headervalue, ';')) { + + $pos = strpos($headervalue, '='); + + $cookie['name'] = trim(substr($headervalue, 0, $pos)); + + $cookie['value'] = trim(substr($headervalue, $pos + 1)); + + + + // Some optional parameters are supplied + + } else { + + $elements = explode(';', $headervalue); + + $pos = strpos($elements[0], '='); + + $cookie['name'] = trim(substr($elements[0], 0, $pos)); + + $cookie['value'] = trim(substr($elements[0], $pos + 1)); + + + + for ($i = 1; $i < count($elements); $i++) { + + if (false === strpos($elements[$i], '=')) { + + $elName = trim($elements[$i]); + + $elValue = null; + + } else { + + list ($elName, $elValue) = array_map('trim', explode('=', $elements[$i])); + + } + + $elName = strtolower($elName); + + if ('secure' == $elName) { + + $cookie['secure'] = true; + + } elseif ('expires' == $elName) { + + $cookie['expires'] = str_replace('"', '', $elValue); + + } elseif ('path' == $elName || 'domain' == $elName) { + + $cookie[$elName] = urldecode($elValue); + + } else { + + $cookie[$elName] = $elValue; + + } + + } + + } + + $this->_cookies[] = $cookie; + + } + + + + + + /** + + * Read a part of response body encoded with chunked Transfer-Encoding + + * + + * @access private + + * @return string + + */ + + function _readChunked() + + { + + // at start of the next chunk? + + if (0 == $this->_chunkLength) { + + $line = $this->_sock->readLine(); + + if (preg_match('/^([0-9a-f]+)/i', $line, $matches)) { + + $this->_chunkLength = hexdec($matches[1]); + + // Chunk with zero length indicates the end + + if (0 == $this->_chunkLength) { + + $this->_sock->readLine(); // make this an eof() + + return ''; + + } + + } else { + + return ''; + + } + + } + + $data = $this->_sock->read($this->_chunkLength); + + $this->_chunkLength -= strlen($data); + + if (0 == $this->_chunkLength) { + + $this->_sock->readLine(); // Trailing CRLF + + } + + return $data; + + } + + + + + + /** + + * Notifies all registered listeners of an event. + + * + + * @param string Event name + + * @param mixed Additional data + + * @access private + + * @see HTTP_Request::_notify() + + */ + + function _notify($event, $data = null) + + { + + foreach (array_keys($this->_listeners) as $id) { + + $this->_listeners[$id]->update($this, $event, $data); + + } + + } + + + + + + /** + + * Decodes the message-body encoded by gzip + + * + + * The real decoding work is done by gzinflate() built-in function, this + + * method only parses the header and checks data for compliance with + + * RFC 1952 + + * + + * @access private + + * @param string gzip-encoded data + + * @return string decoded data + + */ + + function _decodeGzip($data) + + { + + $length = strlen($data); + + // If it doesn't look like gzip-encoded data, don't bother + + if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) { + + return $data; + + } + + $method = ord(substr($data, 2, 1)); + + if (8 != $method) { + + return PEAR::raiseError('_decodeGzip(): unknown compression method'); + + } + + $flags = ord(substr($data, 3, 1)); + + if ($flags & 224) { + + return PEAR::raiseError('_decodeGzip(): reserved bits are set'); + + } + + + + // header is 10 bytes minimum. may be longer, though. + + $headerLength = 10; + + // extra fields, need to skip 'em + + if ($flags & 4) { + + if ($length - $headerLength - 2 < 8) { + + return PEAR::raiseError('_decodeGzip(): data too short'); + + } + + $extraLength = unpack('v', substr($data, 10, 2)); + + if ($length - $headerLength - 2 - $extraLength[1] < 8) { + + return PEAR::raiseError('_decodeGzip(): data too short'); + + } + + $headerLength += $extraLength[1] + 2; + + } + + // file name, need to skip that + + if ($flags & 8) { + + if ($length - $headerLength - 1 < 8) { + + return PEAR::raiseError('_decodeGzip(): data too short'); + + } + + $filenameLength = strpos(substr($data, $headerLength), chr(0)); + + if (false === $filenameLength || $length - $headerLength - $filenameLength - 1 < 8) { + + return PEAR::raiseError('_decodeGzip(): data too short'); + + } + + $headerLength += $filenameLength + 1; + + } + + // comment, need to skip that also + + if ($flags & 16) { + + if ($length - $headerLength - 1 < 8) { + + return PEAR::raiseError('_decodeGzip(): data too short'); + + } + + $commentLength = strpos(substr($data, $headerLength), chr(0)); + + if (false === $commentLength || $length - $headerLength - $commentLength - 1 < 8) { + + return PEAR::raiseError('_decodeGzip(): data too short'); + + } + + $headerLength += $commentLength + 1; + + } + + // have a CRC for header. let's check + + if ($flags & 1) { + + if ($length - $headerLength - 2 < 8) { + + return PEAR::raiseError('_decodeGzip(): data too short'); + + } + + $crcReal = 0xffff & crc32(substr($data, 0, $headerLength)); + + $crcStored = unpack('v', substr($data, $headerLength, 2)); + + if ($crcReal != $crcStored[1]) { + + return PEAR::raiseError('_decodeGzip(): header CRC check failed'); + + } + + $headerLength += 2; + + } + + // unpacked data CRC and size at the end of encoded data + + $tmp = unpack('V2', substr($data, -8)); + + $dataCrc = $tmp[1]; + + $dataSize = $tmp[2]; + + + + // finally, call the gzinflate() function + + $unpacked = @gzinflate(substr($data, $headerLength, -8), $dataSize); + + if (false === $unpacked) { + + return PEAR::raiseError('_decodeGzip(): gzinflate() call failed'); + + } elseif ($dataSize != strlen($unpacked)) { + + return PEAR::raiseError('_decodeGzip(): data size check failed'); + + } elseif ($dataCrc != crc32($unpacked)) { + + return PEAR::raiseError('_decodeGzip(): data CRC check failed'); + + } + + return $unpacked; + + } + +} // End class HTTP_Response + +?> + Added: trunk/src/DBPedia-Navigator/pear/PEAR.php =================================================================== --- trunk/src/DBPedia-Navigator/pear/PEAR.php (rev 0) +++ trunk/src/DBPedia-Navigator/pear/PEAR.php 2007-10-18 16:04:36 UTC (rev 236) @@ -0,0 +1,1108 @@ +<?php +/** + * PEAR, the PHP Extension and Application Repository + * + * PEAR class and PEAR_Error class + * + * PHP versions 4 and 5 + * + * LICENSE: This source file is subject to version 3.0 of the PHP license + * that is available through the world-wide-web at the following URI: + * http://www.php.net/license/3_0.txt. If you did not receive a copy of + * the PHP License and are unable to obtain it through the web, please + * send a note to li...@ph... so we can mail you a copy immediately. + * + * @category pear + * @package PEAR + * @author Sterling Hughes <ste...@ph...> + * @author Stig Bakken <ss...@ph...> + * @author Tomas V.V.Cox <co...@id...> + * @author Greg Beaver <ce...@ph...> + * @copyright 1997-2006 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version CVS: $Id: PEAR.php,v 1.101 2006/04/25 02:41:03 cellog Exp $ + * @link http://pear.php.net/package/PEAR + * @since File available since Release 0.1 + */ + +/**#@+ + * ERROR constants + */ +define('PEAR_ERROR_RETURN', 1); +define('PEAR_ERROR_PRINT', 2); +define('PEAR_ERROR_TRIGGER', 4); +define('PEAR_ERROR_DIE', 8); +define('PEAR_ERROR_CALLBACK', 16); +/** + * WARNING: obsolete + * @deprecated + */ +define('PEAR_ERROR_EXCEPTION', 32); +/**#@-*/ +define('PEAR_ZE2', (function_exists('version_compare') && + version_compare(zend_version(), "2-dev", "ge"))); + +if (substr(PHP_OS, 0, 3) == 'WIN') { + define('OS_WINDOWS', true); + define('OS_UNIX', false); + define('PEAR_OS', 'Windows'); +} else { + define('OS_WINDOWS', false); + define('OS_UNIX', true); + define('PEAR_OS', 'Unix'); // blatant assumption +} + +// instant backwards compatibility +if (!defined('PATH_SEPARATOR')) { + if (OS_WINDOWS) { + define('PATH_SEPARATOR', ';'); + } else { + define('PATH_SEPARATOR', ':'); + } +} + +$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; +$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; +$GLOBALS['_PEAR_destructor_object_list'] = array(); +$GLOBALS['_PEAR_shutdown_funcs'] = array(); +$GLOBALS['_PEAR_error_handler_stack'] = array(); + +@ini_set('track_errors', true); + +/** + * Base class for other PEAR classes. Provides rudimentary + * emulation of destructors. + * + * If you want a destructor in your class, inherit PEAR and make a + * destructor method called _yourclassname (same name as the + * constructor, but with a "_" prefix). Also, in your constructor you + * have to call the PEAR constructor: $this->PEAR();. + * The destructor method will be called without parameters. Note that + * at in some SAPI implementations (such as Apache), any output during + * the request shutdown (in which destructors are called) seems to be + * discarded. If you need to get any debug information from your + * destructor, use error_log(), syslog() or something similar. + * + * IMPORTANT! To use the emulated destructors you need to create the + * objects by reference: $obj =& new PEAR_child; + * + * @category pear + * @package PEAR + * @author Stig Bakken <ss...@ph...> + * @author Tomas V.V. Cox <co...@id...> + * @author Greg Beaver <ce...@ph...> + * @copyright 1997-2006 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: 1.5.3 + * @link http://pear.php.net/package/PEAR + * @see PEAR_Error + * @since Class available since PHP 4.0.2 + * @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear + */ +class PEAR +{ + // {{{ properties + + /** + * Whether to enable internal debug messages. + * + * @var bool + * @access private + */ + var $_debug = false; + + /** + * Default error mode for this object. + * + * @var int + * @access private + */ + var $_default_error_mode = null; + + /** + * Default error options used for this object when error mode + * is PEAR_ERROR_TRIGGER. + * + * @var int + * @access private + */ + var $_default_error_options = null; + + /** + * Default error handler (callback) for this object, if error mode is + * PEAR_ERROR_CALLBACK. + * + * @var string + * @access private + */ + var $_default_error_handler = ''; + + /** + * Which class to use for error objects. + * + * @var string + * @access private + */ + var $_error_class = 'PEAR_Error'; + + /** + * An array of expected errors. + * + * @var array + * @access private + */ + var $_expected_errors = array(); + + // }}} + + // {{{ constructor + + /** + * Constructor. Registers this object in + * $_PEAR_destructor_object_list for destructor emulation if a + * destructor object exists. + * + * @param string $error_class (optional) which class to use for + * error objects, defaults to PEAR_Error. + * @access public + * @return void + */ + function PEAR($error_class = null) + { + $classname = strtolower(get_class($this)); + if ($this->_debug) { + print "PEAR constructor called, class=$classname\n"; + } + if ($error_class !== null) { + $this->_error_class = $error_class; + } + while ($classname && strcasecmp($classname, "pear")) { + $destructor = "_$classname"; + if (method_exists($this, $destructor)) { + global $_PEAR_destructor_object_list; + $_PEAR_destructor_object_list[] = &$this; + if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { + register_shutdown_function("_PEAR_call_destructors"); + $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; + } + break; + } else { + $classname = get_parent_class($classname); + } + } + } + + // }}} + // {{{ destructor + + /** + * Destructor (the emulated type of...). Does nothing right now, + * but is included for forward compatibility, so subclass + * destructors should always call it. + * + * See the note in the class desciption about output from + * destructors. + * + * @access public + * @return void + */ + function _PEAR() { + if ($this->_debug) { + printf("PEAR destructor called, class=%s\n", strtolower(get_class($this))); + } + } + + // }}} + // {{{ getStaticProperty() + + /** + * If you have a class that's mostly/entirely static, and you need static + * properties, you can use this method to simulate them. Eg. in your method(s) + * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); + * You MUST use a reference, or they will not persist! + * + * @access public + * @param string $class The calling classname, to prevent clashes + * @param string $var The variable to retrieve. + * @return mixed A reference to the variable. If not set it will be + * auto initialised to NULL. + */ + function &getStaticProperty($class, $var) + { + static $properties; + if (!isset($properties[$class])) { + $properties[$class] = array(); + } + if (!array_key_exists($var, $properties[$class])) { + $properties[$class][$var] = null; + } + return $properties[$class][$var]; + } + + // }}} + // {{{ registerShutdownFunc() + + /** + * Use this function to register a shutdown method for static + * classes. + * + * @access public + * @param mixed $func The function name (or array of class/method) to call + * @param mixed $args The arguments to pass to the function + * @return void + */ + function registerShutdownFunc($func, $args = array()) + { + // if we are called statically, there is a potential + // that no shutdown func is registered. Bug #6445 + if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { + register_shutdown_function("_PEAR_call_destructors"); + $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; + } + $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); + } + + // }}} + // {{{ isError() + + /** + * Tell whether a value is a PEAR error. + * + * @param mixed $data the value to test + * @param int $code if $data is an error object, return true + * only if $code is a string and + * $obj->getMessage() == $code or + * $code is an integer and $obj->getCode() == $code + * @access public + * @return bool true if parameter is an error + */ + function isError($data, $code = null) + { + if (is_a($data, 'PEAR_Error')) { + if (is_null($code)) { + return true; + } elseif (is_string($code)) { + return $data->getMessage() == $code; + } else { + return $data->getCode() == $code; + } + } + return false; + } + + // }}} + // {{{ setErrorHandling() + + /** + * Sets how errors generated by this object should be handled. + * Can be invoked both in objects and statically. If called + * statically, setErrorHandling sets the default behaviour for all + * PEAR objects. If called in an object, setErrorHandling sets + * the default behaviour for that object. + * + * @param int $mode + * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, + * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, + * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION. + * + * @param mixed $options + * When $mode is PEAR_ERROR_T... [truncated message content] |
From: <sk...@us...> - 2007-10-18 16:03:29
|
Revision: 235 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=235&view=rev Author: sknappe Date: 2007-10-18 09:03:25 -0700 (Thu, 18 Oct 2007) Log Message: ----------- added the DBPedia-Navigator Added Paths: ----------- trunk/src/DBPedia-Navigator/ trunk/src/DBPedia-Navigator/Settings.php trunk/src/DBPedia-Navigator/SparqlConnection.php trunk/src/DBPedia-Navigator/default.css trunk/src/DBPedia-Navigator/index.php trunk/src/DBPedia-Navigator/master.php Added: trunk/src/DBPedia-Navigator/Settings.php =================================================================== --- trunk/src/DBPedia-Navigator/Settings.php (rev 0) +++ trunk/src/DBPedia-Navigator/Settings.php 2007-10-18 16:03:25 UTC (rev 235) @@ -0,0 +1,12 @@ +<?php + +class Settings{ + + +public $wsdluri="http://localhost:8181/services?wsdl"; + + +public $uri="http://localhost/dllearner/"; +public $dbpediauri="http://dbpedia.openlinksw.com:8890/sparql"; +} +?> \ No newline at end of file Added: trunk/src/DBPedia-Navigator/SparqlConnection.php =================================================================== --- trunk/src/DBPedia-Navigator/SparqlConnection.php (rev 0) +++ trunk/src/DBPedia-Navigator/SparqlConnection.php 2007-10-18 16:03:25 UTC (rev 235) @@ -0,0 +1,215 @@ +<?php + +require_once 'pear/HTTP_Request.php'; + +class SparqlConnection +{ + private $DBPediaUrl; + private $DLLearnerUri; + private $client; + private $id; + + public function getID(){ + return $this->id; + } + + function SparqlConnection($DBPediaUrl,$DLLearnerUri,$getID=0) + { + ini_set("soap.wsdl_cache_enabled","0"); + $this->DBPediaUrl=$DBPediaUrl; + $this->DLLearnerUri=$DLLearnerUri; + $this->loadWSDLfiles($DLLearnerUri); + $this->client=new SoapClient("main.wsdl"); + if($getID==0) + { + $this->id=$this->client->generateID(); + } + else + { + $this->id=$getID; + } + } + + function getConceptFromExamples($posExamples,$negExamples) + { + $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); + $this->client->applyConfigEntryInt($this->id, $ksID, "numberOfRecursions", 2); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "instances", array_merge($posExamples,$negExamples)); + $this->client->applyConfigEntryInt($this->id, $ksID, "filterMode", 0); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "predList", array()); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "objList", array()); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "classList", array()); + $this->client->applyConfigEntryString($this->id, $ksID, "format", "KB"); + $this->client->applyConfigEntryBoolean($this->id, $ksID, "dumpToFile", false); + + $this->client->setReasoner($this->id, "dig"); + $this->client->setLearningProblem($this->id, "posNegDefinition"); + $this->client->setPositiveExamples($this->id, $posExamples); + $this->client->setNegativeExamples($this->id, $negExamples); + $this->client->setLearningAlgorithm($this->id, "refinement"); + + $start = microtime(true); + + $this->client->init($this->id); + + $learn_start = microtime(true); + $init = $learn_start - $start; + echo 'components initialised in '.$init.' seconds<br />'; + + $threaded=true; + + if($threaded == false) { + + $concept = $this->client->learn($id); + + $learn = microtime(true) - $learn_start; + echo 'concept learned in '.$learn.' seconds<br />'; + + echo 'result: '.$concept; + + } else { + + $this->client->learnThreaded($id); + + $i = 1; + $sleeptime = 1; + + do { + // sleep a while + sleep($sleeptime); + + // see what we have learned so far + $concept=$this->client->getCurrentlyBestConcept($id); + $running=$this->client->isAlgorithmRunning($id); + + $seconds = $i * $sleeptime; + + echo 'result after '.$seconds.' seconds of sleep: '.$concept.'<br />'; + + $i++; + } while($running); + + echo 'algorithm finished'; + } + return $concept; + } + + function getTriples($individual) + { + $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); + $this->client->applyConfigEntryInt($this->id, $ksID, "numberOfRecursions", 1); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "instances", array($individual)); + $this->client->applyConfigEntryInt($this->id, $ksID, "filterMode", 3); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "predList", array()); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "objList", array()); + $this->client->applyConfigEntryStringArray($this->id, $ksID, "classList", array()); + $this->client->applyConfigEntryString($this->id, $ksID, "format", "Array"); + $this->client->applyConfigEntryBoolean($this->id, $ksID, "dumpToFile", false); + $this->client->applyConfigEntryBoolean($this->id,$ksID,"useLits",true); + + $object=$this->client->getTriples($this->id,$ksID); + $array=$object->item; + $ret=array(); + foreach ($array as $element) + { + $items=preg_split("[<]",$element,-1, PREG_SPLIT_NO_EMPTY); + $ret[]=$items; + } + + return $ret; + } + + function getSubjects($label,$limit) + { + $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); + $object=$this->client->getSubjects($this->id,$ksID,$label,$limit); + return $object->item; + } + + private function loadWSDLfiles($wsdluri){ + $main=$this->getwsdl($wsdluri); + $other=$this->getOtherWSDL($main); + $newMain=$this->changeWSDL($main); + $this->writeToFile("main.wsdl",$newMain); + $x=0; + foreach ($other as $o){ + $this->writeToFile("def".($x++).".xsd",$this->getwsdl($o)); + } + + } + + private function changeWSDL($wsdl){ + $before="<xsd:import schemaLocation=\""; + $after="\" namespace=\""; + $newWSDL=""; + $desca="def"; + $descb=".xsd"; + $x=0; + while($posstart= strpos ( $wsdl, $before )){ + + $posstart+=strlen($before); + $newWSDL.=substr($wsdl,0,$posstart); + $wsdl=substr($wsdl,$posstart); + $newWSDL.=$desca.($x++).$descb; + $posend= strpos ( $wsdl, $after ); + $wsdl=substr($wsdl,$posend); + + } + return $newWSDL.$wsdl; + + } + + private function getOtherWSDL($wsdl){ + $before="<xsd:import schemaLocation=\""; + $after="\" namespace=\""; + $ret=array(); + while($posstart= strpos ( $wsdl, $before )){ + $posstart+=strlen($before); + $wsdl=substr($wsdl,$posstart); + $posend= strpos ( $wsdl, $after ); + $tmp=substr($wsdl,0,$posend); + $ret[]=$tmp; + $wsdl=substr($wsdl,$posend+strlen($after)); + } + return $ret; + } + + + + + private function getwsdl($wsdluri){ + // this is copied from the Pear example + // please don't ask me how it works + $req = &new HTTP_Request($wsdluri); + $message=""; + $req->setMethod(HTTP_REQUEST_METHOD_GET); + $req->sendRequest(); + $ret=$req->getResponseBody(); + return $ret; + } + + + + private function writeToFile($filename,$content){ + + $fp=fopen($filename,"w"); + fwrite($fp,$content); + fclose($fp); + + } +} + +$positive=array("http://dbpedia.org/resource/Pythagoras", + "http://dbpedia.org/resource/Philolaus", + "http://dbpedia.org/resource/Archytas"); +$negative=array("http://dbpedia.org/resource/Socrates", + "http://dbpedia.org/resource/Zeno_of_Elea", + "http://dbpedia.org/resource/Plato"); + +$sparqlConnection=new SparqlConnection("http://dbpedia.openlinksw.com:8890/sparql","http://localhost:8181/services?wsdl"); +//$sparqlConnection->getConceptFromExamples($positive,$negative); +//$triples=$sparqlConnection->getTriples("http://dbpedia.org/resource/Leipzig"); +//print_r($triples); +//$subjects=$sparqlConnection->getSubjects("Leipzig",5); +//print_r($subjects); +?> \ No newline at end of file Added: trunk/src/DBPedia-Navigator/default.css =================================================================== --- trunk/src/DBPedia-Navigator/default.css (rev 0) +++ trunk/src/DBPedia-Navigator/default.css 2007-10-18 16:03:25 UTC (rev 235) @@ -0,0 +1,453 @@ +/** + * default.css + * main Ontowiki style sheet + * @author: Norman Heino + * @version: $Id: default.css 751 2007-02-14 19:20:17Z nheino $ + */ + +/* remove browser specific margins */ +* { + margin: 0; + padding: 0; +} + +html { + font: 80%/1.2 "Lucida Grande", Helvetica, Arial, sans-serif; +} + +p { + margin: 8px 0; +} + +h2 { + margin: 0.5em 0 0.1em 0; +/* background-color: #eee;*/ + font-size: 110%; +} + + +/* + * Main site structure + */ + +#wrapper { + position: relative; + max-width: 100%; + padding: 15px; +/* margin: 15px;*/ +} + +#content { + margin: 0 19em; + overflow: hidden; +/* border-left: 1px solid #bbb; + border-right: 1px solid #bbb; + padding: 0 5px;*/ +} + +/* + * Side bars are positioned absolutely due to several reasons: + * (1)Internet Explorer has problems displaying float elements, + * (2) the content's position in html is irrelevant, + * (3) positioning the content div is more straightforward. + */ +#leftSidebar { + position: absolute; + width: 18em; +} + +#rightSidebar { + position: absolute; + width: 18em; + top: 15px; + right: 15px; +} + +#clear { + clear: both; +} + + +/* + * sidebar content (boxes) + */ + +.box { + color: #666; + margin-bottom: 20px; + border: 1px solid #bbb; + font-size: 85%; +} + +/*.box td { + font-size: 100%; +}*/ + +.box .boxtitle { + color: #666; + background-color: #eee; + padding: 3px 0.4em; + font-weight: bold; + white-space: nowrap; +} + +.box .boxtitle .boxtitle_string { + width: 80%; + overflow: hidden; +/* display: none;*/ +} + +.box .boxcontent { + padding: 0.6em; + border-top: 1px solid #bbb; +} + +/* restrict content of certain boxes */ +.box#predicates .boxcontent, +.box#classes .boxcontent { + overflow: hidden; +} + +.box p { + margin: 0 2px 4px 0; +} + +.box ul, .box ol { + margin: 0px; +/* padding-left: 15px;*/ + list-style-position: inside; +} + +.box ul.no_bullet, .box ul.no_bullet { + list-style-type: none; +} + +.box ul li.horizontal, .box ol li.horizontal, +.box ul.horizontal, .box ol.horizontal { + display: inline; +} + +.box a.title_switch { + position: absolute; + right: 0.5em; + margin: auto 0; + color: #666; + border: 1px solid #bbb; + width: 1em; + height: 1em; + background-color: #fff; + text-align: center; +} + +.box a.title_switch:hover { + color: #02a; + text-decoration: none; + background-color: #eee; +} + +.box hr { + margin: 0.5em 0; + border: none; + border-top: 1px dotted #bbb; + height: 0; +} + +.box#classes .boxcontent a { + display: block; +} + +/*.box select { + width: 250px; /* TODO remove absolute size */ +}*/ + +.box input { + width: auto; +} + +.box td input { + width: 100%; +} + +.box img.rating { + position: relative; + top: 1px; +} + +.hidden { + display: none; +} + + +/* + * Links + */ + +a, a:link, a:visited { + color: #02a; + text-decoration: none; + cursor: pointer; +} + +a:hover { + text-decoration: underline; +} + + +/* + * Tabs + */ + +/* all the tabs */ +.tabs { + float: left; + width: 100%; + background: #fff url("../images/tabs_back.png") repeat-x bottom; +} + +.tabs ul { + list-style: none; +} + +.tabs li { + float: left; + margin-right: 1px; +} + +.tabs a { + display: block; + margin-top: 1px; + padding: 0.35em 1.35em; + background-image: url("../images/tab_back.png"); + background-repeat: repeat-x; + background-color: #cbcbcb; + border: 1px solid #bbb; +} + +.tabs a:hover { + background: #fff; + text-decoration: none; +} + +.tabs a.current { + background: #fff; + border-bottom: 1px solid #fff; +} + +/* horizontal line underneath the tabs */ +#tab-line { + height: 1em; + clear: both; +} + +#instances { + float: right; +} + +.selected { + background-color: #bde; /*#b4d5fe;*/ +} + +.button { + border: solid black 1px; + padding: 0px 1px; + background-color: #eee; +} + +/* + * Tables + */ + +tr.odd { + background-color: #ccc; +} + +tr.even { + background-color: #eee; +} + +table.instanceTable th { + text-align: left; +/* background-color: #eee;*/ +} + +table.instanceTable > tbody > tr > td { + padding-top: 0.5em; +} + +table.instanceTable td.property { + text-align: right; + font-style: italic; + padding-right: 5px; +} + +table.instanceTable ul { + margin: 0px; + padding-left: 20px; +} + +table.instanceTable { + width: 100%; +} + +.searchHighlight { + background-color: orange; +} + +table.tripletable { + width: 100%; + font-size: 90%; +} + +.tripletable td { + padding: 0.4em; +} + +table.blind tr td { + padding-top: 0.4em; +} + +/* + * Instances + */ + +.instance .instance { + margin-left: 13px; + background-color: #ddd; +} +.instance .instance td { + font-size: 90%; +} +.instance .instance .instance { + background-color: #eee; +} + +.instance .instance .instance .instance { + background-color: #fff; +} + +#instanceEdit { + border-spacing: 0px; + width: 100%; +} + +#instanceEdit input, #instanceEdit textarea { +/* width: 250px;*/ + background-color: #fff; + font-size: 95%; + font-family: "Lucida Grande", Helvetica, Arial, sans-serif; + padding: 0.1em 0; +} + +#instanceEdit > tbody > tr > td, #instanceEdit > tr > td { + background-color: #eee; + padding: 5px; + border-bottom: 2px solid #fdfdfd; +} + +/* + * Calendar + */ + +table.calendar { + margin-top: 1em; + width: 100%; + height: 730px; + table-layout: fixed; + font-size: 90%; +} + +.calendar .weekday0 { + background-color: #eee; + padding: 0.4em; +} +.calendar .weekday1 { + background-color: #f5f5f5; + padding: 0.4em; +} +.calendar .weekend0 { + background-color: #ddd; + padding: 0.4em; +} +.calendar .weekend1 { + background-color: #eaeaea; + padding: 0.4em; +} + +#map { + margin-top: 0.5em; + width: 100%; + height: 750px; + font-size: 90%; +} + +#map .instance td { + font-size: 80%; + padding: 0 3px; + border-bottom: 5px solid white; +} + +#superClassPath { + margin-bottom: 0.5em; +} + +img { + border: none; +} + +span.submit { + float: right; + padding-right: 100px; +} + +/* + * Autosuggest box + */ +div.autosuggest { + font-size: 85%; + position: absolute; + background-color: #fff; + border: 1px solid #bbb; +} + +div.autosuggest ul { + list-style-type: none; + list-style-position: inside; + padding-left: 0px; +} + +div.autosuggest ul li.selected { + background-color: #bde; +} + +div.autosuggest ul li { + display: block; + padding: 0.2em; +/* height: 22px;*/ + cursor: pointer; +} + +span.formal { + display: none; +} + +/* + * Layer + */ +#layer { + width: 100%; + height: 100%; + position: absolute; + background-image: url("../images/black_50.png"); + background-repeat: repeat; + z-index: 98; +} + +#layerContent { + margin-top: 100px; + margin: auto; + width: 500px; + height: 300px; + background-color: #ffb; + border: 2px solid #bbb; + z-index: 99; +} Added: trunk/src/DBPedia-Navigator/index.php =================================================================== --- trunk/src/DBPedia-Navigator/index.php (rev 0) +++ trunk/src/DBPedia-Navigator/index.php 2007-10-18 16:03:25 UTC (rev 235) @@ -0,0 +1,110 @@ +<?php + +@session_start(); +include_once("Settings.php"); +include_once("SparqlConnection.php"); + + ini_set('error_reporting',E_ALL); + ini_set('max_execution_time',200); + +$lastAction="View"; +$content=""; +$possibleActions=""; +$instances=" "; +$left=""; +$right=""; +$middle=""; +$search=""; +$system=""; + +$settings=new Settings(); + +echo "<a href='index.php?clearsession=clear'>start from scratch</a>"; +if(isset($_GET['clearsession']))$_SESSION['State_ID'] =false; + + + +if( (!isset($_SESSION['State_ID'] ) ) || ($_SESSION['State_ID']=="")) +{ + //get new ID + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); + $_SESSION['State_ID']=$sc->getID(); + +} + +else{ + //echo "Current ID is: ".$_SESSION['Learner_ID']."<br>"; + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['State_ID']); +} + + +//SearchBox + $search="<form action=\"index.php\" method=\"GET\">\n". + "<table border=\"0\">\n". + "<tr><tb>Search:<br/></tb></tr>\n". + "<tr><tb><input type=\"textfield\" name=\"search\"><select name=\"limit\" size=\"1\">\n". + "<option>1</option>\n". + "<option selected=\"selected\">5</option>\n". + "<option>10</option>\n". + "<option>15</option>\n". + "</select><br/></tb></tr>\n". + "<tr><tb><input type=\"submit\" name=\"action\" value=\"Search\"><input type=\"submit\" name=\"action\" value=\"Fulltext\"></tb></tr>\n". + "</table>\n". + "</form>\n"; + +//Get Search result + if (@$_GET['action']=='Search') + { + $label=$_GET['search']; + $limit=$_GET['limit']; + $subjects=$sc->getSubjects($label,$limit); + foreach ($subjects as $subject){ + $content.="<a href=\"index.php?action=showPage&subject=".$subject."\">".$subject."</a><br/>\n"; + } + } + +//Show Subject Page + if (@$_GET['action']=="showPage") + { + $triples=$sc->getTriples($_GET['subject']); + foreach ($triples as $triple){ + $content.="Subject: ".urldecode($triple[0])."<br/>Predicate: ".urldecode($triple[1])."<br/>Object: ".urldecode($triple[2])."<br/><br/>\n"; + } + } + + + include("master.php"); + + echo $masterContent; + + + + + + function makeBox($title,$content,$toggleBoxContent=true) + { + if($toggleBoxContent) + { + $click="<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a>"; + } + else{$click="";} + $ret=" + <div class=\"box\" id=\"ontology\"> + <div class=\"boxtitle\">".$title.$click."</div> + <div class=\"boxcontent\"> + ".$content." + </div> <!-- boxcontent --> + </div> <!-- box -->"; + return $ret; + } + + + function shorten($a) + { + if(($strpos=strpos($a,'#'))>=4){ + return substr($a,$strpos); + } + else {return $a;} + } + +?> \ No newline at end of file Added: trunk/src/DBPedia-Navigator/master.php =================================================================== --- trunk/src/DBPedia-Navigator/master.php (rev 0) +++ trunk/src/DBPedia-Navigator/master.php 2007-10-18 16:03:25 UTC (rev 235) @@ -0,0 +1,57 @@ +<?php + +$masterContent=" + + +<html> + <head> + <title>DL Learner</title> + <meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\"/> + <link rel=\"stylesheet\" href=\"default.css\"/> + </head> + <body> +<script type=\"text/javascript\" src=\"jscript/wz_tooltip.js\"></script> +<script type=\"text/javascript\" src=\"jscript/scripts.js\"></script> +<h3>DBPedia-Navigator-Test</h3> +<div id=\"layer\" style=\"display:none\"><div id=\"layerContent\" style=\"display:none\"></div></div> +<div id=\"wrapper\"> + +<div id=\"leftSidebar\"> + +<div class=\"box\" id=\"search\"> + <div class=\"boxtitle\">Search<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a></div> + <div class=\"boxcontent\"> + ".$search." + </div> <!-- boxcontent --> + +</div> <!-- box --> + +".$left." + +<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> +</div><!-- END leftSidebar --> + +<div id=\"content\"> +<div class=\"box\" id=\"search\"> + <div class=\"boxtitle\">Content</div> + <div class=\"boxcontent\"> + ".$content." + </div> <!-- boxcontent --> +</div> <!-- box --> +".$middle." +<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> +</div><!-- content --> + +<div id=\"rightSidebar\"> + +<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> +</div><!-- rightSidebar --> + + <div id=\"clear\"></div> +</div><!-- wrapper --> + + </body> +</html> +"; + +?> \ 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: <sk...@us...> - 2007-10-18 15:55:01
|
Revision: 234 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=234&view=rev Author: sknappe Date: 2007-10-18 08:54:56 -0700 (Thu, 18 Oct 2007) Log Message: ----------- Added functions for DBPedia-Navigator Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java trunk/src/dl-learner/org/dllearner/kb/SparqlFilter.java trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java trunk/src/dl-learner/org/dllearner/kb/SparqlQueryMaker.java Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-18 15:54:15 UTC (rev 233) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-18 15:54:56 UTC (rev 234) @@ -28,6 +28,8 @@ import java.util.Collection; import java.util.LinkedList; import java.util.Set; +import java.util.StringTokenizer; +import java.util.Vector; import org.dllearner.core.BooleanConfigOption; import org.dllearner.core.ConfigEntry; @@ -56,7 +58,7 @@ private URL url; private Set<String> instances; - private URL ntFile; + private URL dumpFile; private int numberOfRecursions; private int filterMode; private Set<String> predList; @@ -65,6 +67,8 @@ private KB kb; private String format; private boolean dumpToFile; + private boolean useLits=false; + private String[] ontArray; public static String getName() { return "SPARQL Endpoint"; @@ -81,6 +85,7 @@ options.add(new StringSetConfigOption("classList","a class list")); options.add(new StringConfigOption("format", "N-TRIPLES or KB format")); options.add(new BooleanConfigOption("dumpToFile", "wether Ontology from DBPedia is written to a file or not")); + options.add(new BooleanConfigOption("useLits","use Literals in SPARQL query")); return options; } @@ -114,6 +119,8 @@ format=(String)entry.getValue(); } else if(option.equals("dumpToFile")){ dumpToFile=(Boolean)entry.getValue(); + } else if(option.equals("useLits")){ + useLits=(Boolean)entry.getValue(); } } @@ -125,10 +132,16 @@ System.out.println("SparqlModul: Collecting Ontology"); String[] a=new String[0]; SparqlOntologyCollector oc=new SparqlOntologyCollector(instances.toArray(a), numberOfRecursions, - filterMode, Datastructures.setToArray(predList),Datastructures.setToArray( objList),Datastructures.setToArray(classList),format,url); - String ont=oc.collectOntology(); + filterMode, Datastructures.setToArray(predList),Datastructures.setToArray( objList),Datastructures.setToArray(classList),format,url,useLits); + String ont=""; + if (format.equals("Array")){ + ontArray=oc.collectOntologyAsArray(); + } + else{ + ont=oc.collectOntology(); + } - if (format.equals("N-TRIPLES")||dumpToFile){ + if (dumpToFile){ String filename=System.currentTimeMillis()+".nt"; String basedir="cache"+File.separator; try{ @@ -140,7 +153,7 @@ fw.flush(); fw.close(); - ntFile=(new File(basedir+filename)).toURI().toURL(); + dumpFile=(new File(basedir+filename)).toURI().toURL(); }catch (Exception e) {e.printStackTrace();} } if (format.equals("KB")) { @@ -159,11 +172,24 @@ */ @Override public String toDIG(URI kbURI) { - if (format.equals("N-TRIPLES")) return JenaOWLDIGConverter.getTellsString(ntFile, OntologyFileFormat.N_TRIPLES, kbURI); + if (format.equals("N-TRIPLES")) return JenaOWLDIGConverter.getTellsString(dumpFile, OntologyFileFormat.N_TRIPLES, kbURI); else return DIGConverter.getDIGString(kb, kbURI).toString(); } public URL getURL() { return url; } + + public String[] getOntArray() { + return ontArray; + } + + public String[] getSubjects(String label,int limit) + { + System.out.println("SparqlModul: Collecting Subjects"); + SparqlOntologyCollector oc=new SparqlOntologyCollector(null, 1,0,null,null,null,null,url,false); + String[] ret=oc.getSubjectsFromLabel(label,limit); + System.out.println("SparqlModul: ****Finished"); + return ret; + } } Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlFilter.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlFilter.java 2007-10-18 15:54:15 UTC (rev 233) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlFilter.java 2007-10-18 15:54:56 UTC (rev 234) @@ -81,6 +81,7 @@ public SparqlFilter(int mode, String[] pred, String[] obj) { if (mode==-1 && (pred==null || pred.length==0 || obj==null||obj.length==0)) {mode=0;} + else this.mode=mode; switch (mode){ case 0: //yago Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java 2007-10-18 15:54:15 UTC (rev 233) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java 2007-10-18 15:54:56 UTC (rev 234) @@ -31,6 +31,8 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import java.util.StringTokenizer; +import java.util.Vector; /** @@ -85,7 +87,7 @@ * @param defClasses */ public SparqlOntologyCollector(String[] subjectList,int numberOfRecursions, - int filterMode, String[] FilterPredList,String[] FilterObjList,String[] defClasses, String format, URL url){ + int filterMode, String[] FilterPredList,String[] FilterObjList,String[] defClasses, String format, URL url, boolean useLits){ this.subjectList=subjectList; this.numberOfRecursions=numberOfRecursions; this.format=format; @@ -93,10 +95,9 @@ this.c=new SparqlCache("cache"); if(defClasses!=null && defClasses.length>0 ){ this.defaultClasses=defClasses; - } - + } try{ - this.sf=new SparqlFilter(filterMode,FilterPredList,FilterObjList); + this.sf=new SparqlFilter(filterMode,FilterPredList,FilterObjList,useLits); this.url=url; this.properties=new HashSet<String>(); this.classes=new HashSet<String>(); @@ -122,6 +123,32 @@ return ret; } + public String[] collectOntologyAsArray(){ + getRecursiveList(subjectList, numberOfRecursions); + if (sf.mode!=3) finalize(); + String[] a=new String[0]; + return triples.toArray(a); + } + + public String[] getSubjectsFromLabel(String label, int limit){ + System.out.println("Searching for Label: "+label); + String sparql=q.makeLabelQuery(label,limit); + String FromCache=c.get(label, sparql); + String xml; + // if not in cache get it from dbpedia + if(FromCache==null){ + xml=sendAndReceive(sparql); + c.put(label, xml, sparql); + System.out.print("\n"); + } + else{ + xml=FromCache; + System.out.println("FROM CACHE"); + } + + return processSubjects(xml); + } + /** * calls getRecursive for each subject in list * @param subjects @@ -191,20 +218,25 @@ public String[] processResult(String subject,String xml){ //TODO if result is empty, catch exceptions String one="<binding name=\"predicate\"><uri>"; - String two="<binding name=\"object\"><uri>"; + String two="<binding name=\"object\">"; String end="</uri></binding>"; String predtmp=""; String objtmp=""; ArrayList<String> al=new ArrayList<String>(); - while(xml.indexOf(one)!=-1){ //get pred xml=xml.substring(xml.indexOf(one)+one.length()); predtmp=xml.substring(0,xml.indexOf(end)); //getobj xml=xml.substring(xml.indexOf(two)+two.length()); - objtmp=xml.substring(0,xml.indexOf(end)); + if (xml.startsWith("<literal xml:lang=\"en\">")){ + xml=xml.substring(xml.indexOf(">")+1); + objtmp=xml.substring(0,xml.indexOf("</literal>")); + } + else if (xml.startsWith("<uri>")) objtmp=xml.substring(5,xml.indexOf(end)); + else continue; + System.out.println("Pred: "+predtmp+" Obj: "+objtmp); // writes the triples and resources in the hashsets // also fills the arraylist al processTriples(subject, predtmp, objtmp,al); @@ -280,6 +312,23 @@ return; } + + private String[] processSubjects(String xml){ + Vector<String> vec=new Vector<String>(); + String one="<binding name=\"subject\"><uri>"; + String end="</uri></binding>"; + String subject=""; + while(xml.indexOf(one)!=-1){ + //get subject + xml=xml.substring(xml.indexOf(one)+one.length()); + subject=xml.substring(0,xml.indexOf(end)); + + System.out.println("Subject: "+subject); + vec.addElement(subject); + } + String[] a=new String[vec.size()]; + return vec.toArray(a); + } // /** * also makes subclass property between classes @@ -296,6 +345,10 @@ if (p.equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")) ret="\""+o+"\"(\""+s+"\").\n"; else ret="\""+p+"\"(\""+s+"\",\""+o+"\").\n"; } + else if (format.equals("Array")) + { + ret=s+"<"+p+"<"+o+"\n"; + } return ret; } @@ -375,7 +428,7 @@ // String an Sparql-Endpoint schicken HttpURLConnection connection; - + try { connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlQueryMaker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlQueryMaker.java 2007-10-18 15:54:15 UTC (rev 233) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlQueryMaker.java 2007-10-18 15:54:56 UTC (rev 234) @@ -27,26 +27,7 @@ * */ public class SparqlQueryMaker { - //Good - /*public static String owl ="http://www.w3.org/2002/07/owl#"; - public static String xsd="http://www.w3.org/2001/XMLSchema#"; - public static String rdfs="http://www.w3.org/2000/01/rdf-schema#"; - public static String rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; - public static String base="http://dbpedia.org/resource/"; - public static String dbpedia2="http://dbpedia.org/property/"; - public static String dbpedia="http://dbpedia.org/"; - - //BAD - public static String skos="http://www.w3.org/2004/02/skos/core#"; - public static String foaf="http://xmlns.com/foaf/0.1/"; - public static String dc="http://purl.org/dc/elements/1.1/"; - public static String foreign="http://dbpedia.org/property/wikipage-"; - public static String sameAs="http://www.w3.org/2002/07/owl#sameAs"; - public static String reference="http://dbpedia.org/property/reference";*/ - - int tempyago=0; - /** * reads all the options and makes the sparql query accordingly * @param subject @@ -57,7 +38,7 @@ String Filter=""; - if(!sf.useLiterals)Filter+="!isLiteral(?object))"; + if(!sf.useLiterals)Filter+="!isLiteral(?object)"; for (String p : sf.getPredFilter()) { Filter+="\n" + filterPredicate(p); } @@ -65,43 +46,19 @@ Filter+="\n" + filterObject(o); } - String ret= "SELECT * WHERE { \n" + "<"+ subject+ - - "> ?predicate ?object.\n" + - "FILTER( \n" + - "(" +Filter+").}"; + "> ?predicate ?object.\n"; + if (!(Filter.length()==0)) + ret+="FILTER( \n" + + "(" +Filter+"))."; + ret+="}"; //System.out.println(ret); return ret; } - - /*public String makeQueryDefault(String subject){ - String ret= - "SELECT * WHERE { \n" + - "<"+ - subject+ - - "> ?predicate ?object.\n" + - "FILTER( \n" + - "(!isLiteral(?object))" + - "\n" + filterPredicate(skos)+ - //"\n" + filterObject(skos)+ - "\n" + filterPredicate(foaf)+ - "\n" + filterObject(foaf)+ - "\n" + filterPredicate(foreign)+ - "\n" + filterPredicate(sameAs)+ - "\n" + filterPredicate(reference)+ - ")." + - " }"; - - //System.out.println(ret); - return ret; -}*/ - /** * add a new object filter * (objects are filtered out of sparql result) @@ -120,4 +77,11 @@ public String filterPredicate(String ns){ return "&&( !regex(str(?predicate), '"+ns+"') )"; } + + public String makeLabelQuery(String label,int limit){ + return "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>\n"+ + "SELECT DISTINCT ?subject\n"+ + "WHERE { ?subject rdfs:label ?object.FILTER regex(?object,\""+label+"\"@en)}\n"+ + "LIMIT "+limit; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2007-10-18 15:54:18
|
Revision: 233 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=233&view=rev Author: sknappe Date: 2007-10-18 08:54:15 -0700 (Thu, 18 Oct 2007) Log Message: ----------- Added functions for DBPedia-Navigator Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-17 16:54:24 UTC (rev 232) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-18 15:54:15 UTC (rev 233) @@ -439,4 +439,21 @@ Set<Individual> individuals = m.keySet(); return Datastructures.sortedSet2StringListIndividuals(individuals); } + + @WebMethod + public String[] getTriples(int id, int componentID) throws ClientNotKnownException + { + ClientState state=getState(id); + Component component = state.getComponent(componentID); + component.init(); + return ((SparqlEndpoint)component).getOntArray(); + } + + @WebMethod + public String[] getSubjects(int id, int componentID, String label, int limit) throws ClientNotKnownException + { + ClientState state=getState(id); + Component component = state.getComponent(componentID); + return ((SparqlEndpoint)component).getSubjects(label,limit); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-17 16:56:07
|
Revision: 232 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=232&view=rev Author: jenslehmann Date: 2007-10-17 09:54:24 -0700 (Wed, 17 Oct 2007) Log Message: ----------- moved another couple of options to new structure involving many related changes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java trunk/src/dl-learner/org/dllearner/utilities/Helper.java trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java Modified: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-10-17 16:54:24 UTC (rev 232) @@ -1,12 +1,9 @@ package org.dllearner; import java.lang.reflect.Field; -import java.util.Set; import org.dllearner.algorithms.gp.GP.AlgorithmType; import org.dllearner.algorithms.gp.GP.SelectionType; -import org.dllearner.core.dl.AtomicConcept; -import org.dllearner.core.dl.AtomicRole; public class Config { // standardmäßig wird bis Tiefe 7 gesucht @@ -151,9 +148,9 @@ // Konzepte, die in der Definition vorkommen können (per Default // ("null") alle) // nicht implementiert - public static Set<AtomicConcept> allowedConcepts = null; +// public static Set<AtomicConcept> allowedConcepts = null; // ignorierte Konzepte; Default null = keine - public static Set<AtomicConcept> ignoredConcepts = null; +// public static Set<AtomicConcept> ignoredConcepts = null; // beachte: es können nur entweder die erlaubten oder die ignorierten // Konzepte // gesetzt werden @@ -161,13 +158,13 @@ // true falls die Konzepte vom Nutzer gesetzt worden (also // allowedConcepts // gleich null), ansonsten false - public static boolean allowedConceptsAutoDetect = true; +// public static boolean allowedConceptsAutoDetect = true; // Rollen, die in der Lösung vorkommen können // nicht implementiert - public static Set<AtomicRole> allowedRoles = null; - public static Set<AtomicRole> ignoredRoles = null; - public static boolean allowedRolesAutoDetect = true; +// public static Set<AtomicRole> allowedRoles = null; +// public static Set<AtomicRole> ignoredRoles = null; +// public static boolean allowedRolesAutoDetect = true; // max. Verschachtelungstiefe der Lösung // nicht implementiert Modified: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-17 16:54:24 UTC (rev 232) @@ -7,17 +7,11 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.TreeSet; import org.dllearner.algorithms.gp.GP.AlgorithmType; import org.dllearner.algorithms.gp.GP.SelectionType; import org.dllearner.cli.ConfFileOption; -import org.dllearner.core.dl.AtomicConcept; -import org.dllearner.core.dl.AtomicRole; -import org.dllearner.parser.KBParser; -import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.Datastructures; -import org.dllearner.utilities.RoleComparator; /** * Nach dem einlesen der Datei werden hier alle Konfigurationsoptionen @@ -542,24 +536,24 @@ // System.out.println(":" + optionString + " " + setValues); if(optionString.equals("refinement.allowedConcepts")) { - Config.Refinement.allowedConceptsAutoDetect = false; - Config.Refinement.allowedConcepts = new TreeSet<AtomicConcept>(new ConceptComparator()); - for(String s : setValues) +// Config.Refinement.allowedConceptsAutoDetect = false; + ; // Config.Refinement.allowedConcepts = new TreeSet<AtomicConcept>(new ConceptComparator()); +// for(String s : setValues) // es wird die gleiche Funktion wie im Parser genommen um Namen auf URIs zu mappen - Config.Refinement.allowedConcepts.add(new AtomicConcept(KBParser.getInternalURI(s))); +// Config.Refinement.allowedConcepts.add(new AtomicConcept(KBParser.getInternalURI(s))); } else if(optionString.equals("refinement.allowedRoles")) { - Config.Refinement.allowedRolesAutoDetect = false; - Config.Refinement.allowedRoles = new TreeSet<AtomicRole>(new RoleComparator()); - for(String s : setValues) - Config.Refinement.allowedRoles.add(new AtomicRole(KBParser.getInternalURI(s))); +// Config.Refinement.allowedRolesAutoDetect = false; +// Config.Refinement.allowedRoles = new TreeSet<AtomicRole>(new RoleComparator()); +// for(String s : setValues) +// Config.Refinement.allowedRoles.add(new AtomicRole(KBParser.getInternalURI(s))); } else if(optionString.equals("refinement.ignoredConcepts")) { - Config.Refinement.ignoredConcepts = new TreeSet<AtomicConcept>(new ConceptComparator()); - for(String s : setValues) - Config.Refinement.ignoredConcepts.add(new AtomicConcept(KBParser.getInternalURI(s))); +// Config.Refinement.ignoredConcepts = new TreeSet<AtomicConcept>(new ConceptComparator()); +// for(String s : setValues) +// Config.Refinement.ignoredConcepts.add(new AtomicConcept(KBParser.getInternalURI(s))); } else if(optionString.equals("refinement.ignoredRoles")) { - Config.Refinement.ignoredRoles = new TreeSet<AtomicRole>(new RoleComparator()); - for(String s : setValues) - Config.Refinement.ignoredRoles.add(new AtomicRole(KBParser.getInternalURI(s))); +// Config.Refinement.ignoredRoles = new TreeSet<AtomicRole>(new RoleComparator()); +// for(String s : setValues) +// Config.Refinement.ignoredRoles.add(new AtomicRole(KBParser.getInternalURI(s))); } } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-17 16:54:24 UTC (rev 232) @@ -13,6 +13,7 @@ import org.dllearner.Config; import org.dllearner.core.BooleanConfigOption; +import org.dllearner.core.CommonConfigMappings; import org.dllearner.core.CommonConfigOptions; import org.dllearner.core.ConfigEntry; import org.dllearner.core.ConfigOption; @@ -23,6 +24,8 @@ import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; import org.dllearner.core.StringConfigOption; +import org.dllearner.core.dl.AtomicConcept; +import org.dllearner.core.dl.AtomicRole; import org.dllearner.core.dl.Concept; import org.dllearner.core.dl.MultiConjunction; import org.dllearner.core.dl.MultiDisjunction; @@ -43,6 +46,13 @@ private File searchTreeFile; private static String defaultSearchTreeFile = "log/searchTree.txt"; private Heuristic heuristic = Heuristic.LEXICOGRAPHIC; + Set<AtomicConcept> allowedConcepts; + Set<AtomicRole> allowedRoles; + Set<AtomicConcept> ignoredConcepts; + Set<AtomicRole> ignoredRoles; + // these are computed as the result of the previous four settings + Set<AtomicConcept> usedConcepts; + Set<AtomicRole> usedRoles; private boolean stop = false; @@ -164,6 +174,7 @@ options.add(new BooleanConfigOption("improveSubsumptionHierarchy", "simplify subsumption hierarchy to reduce search space (see publication for description)", true)); // TODO: replace by a general verbosity option for all components options.add(new BooleanConfigOption("quiet", "may be deprecated soon", false)); + // allowed/ignored concepts/roles could also be a reasoner option (?) options.add(CommonConfigOptions.allowedConcepts()); options.add(CommonConfigOptions.ignoredConcepts()); options.add(CommonConfigOptions.allowedRoles()); @@ -178,6 +189,7 @@ * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.ConfigEntry) */ @Override + @SuppressWarnings({"unchecked"}) public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { String name = entry.getOptionName(); if(name.equals("writeSearchTree")) @@ -190,7 +202,16 @@ heuristic = Heuristic.LEXICOGRAPHIC; else heuristic = Heuristic.FLEXIBLE; - } + } else if(name.equals("allowedConcepts")) { + allowedConcepts = CommonConfigMappings.getAtomicConceptSet((Set<String>)entry.getValue()); + } else if(name.equals("allowedRoles")) { + allowedRoles = CommonConfigMappings.getAtomicRoleSet((Set<String>)entry.getValue()); + } else if(name.equals("ignoredConcepts")) { + ignoredConcepts = CommonConfigMappings.getAtomicConceptSet((Set<String>)entry.getValue()); + } else if(name.equals("ignoredRoles")) { + ignoredRoles = CommonConfigMappings.getAtomicRoleSet((Set<String>)entry.getValue()); + } + } /* (non-Javadoc) @@ -218,13 +239,29 @@ candidates = new TreeSet<Node>(nodeComparator); // newCandidates = new TreeSet<Node>(nodeComparator); - // TODO: this needs to be changed - Helper.autoDetectConceptsAndRoles(rs); + if(allowedConcepts != null) { + // sanity check to control if no non-existing concepts are in the list + Helper.checkConcepts(rs, allowedConcepts); + usedConcepts = allowedConcepts; + } else if(ignoredConcepts != null) { + usedConcepts = Helper.computeConceptsUsingIgnoreList(rs, ignoredConcepts); + } else { + usedConcepts = Helper.computeConcepts(rs); + } + + if(allowedRoles != null) { + Helper.checkRoles(rs, allowedRoles); + usedRoles = allowedRoles; + } else if(ignoredRoles != null) { + Helper.checkRoles(rs, ignoredRoles); + usedRoles = Helper.difference(rs.getAtomicRoles(), ignoredRoles); + } + // prepare subsumption and role hierarchies, because they are needed // during the run of the algorithm - rs.prepareSubsumptionHierarchy(); + rs.prepareSubsumptionHierarchy(usedConcepts); rs.getSubsumptionHierarchy().improveSubsumptionHierarchy(); - rs.prepareRoleHierarchy(); + rs.prepareRoleHierarchy(usedRoles); } public static String getName() { Modified: trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java 2007-10-17 16:54:24 UTC (rev 232) @@ -23,6 +23,8 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.dllearner.core.dl.AtomicConcept; +import org.dllearner.core.dl.AtomicRole; import org.dllearner.core.dl.Individual; /** @@ -38,4 +40,17 @@ return set; } + public static SortedSet<AtomicConcept> getAtomicConceptSet(Set<String> atomicConcepts) { + SortedSet<AtomicConcept> set = new TreeSet<AtomicConcept>(); + for(String atomicConcept : atomicConcepts) + set.add(new AtomicConcept(atomicConcept)); + return set; + } + + public static SortedSet<AtomicRole> getAtomicRoleSet(Set<String> atomicRoles) { + SortedSet<AtomicRole> set = new TreeSet<AtomicRole>(); + for(String atomicRole : atomicRoles) + set.add(new AtomicRole(atomicRole)); + return set; + } } Modified: trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-17 16:54:24 UTC (rev 232) @@ -20,14 +20,18 @@ package org.dllearner.core; /** + * Contains methods for creating common configuration options, i.e. options + * which are or may be of use for several components. + * * @author Jens Lehmann * */ public final class CommonConfigOptions { - public static final IntegerConfigOption getVerbosityOption() { - // TODO: temporary code - IntegerConfigOption verbosityOption = new IntegerConfigOption("verbosity", "control verbosity of output"); + public static StringConfigOption getVerbosityOption() { + StringConfigOption verbosityOption = new StringConfigOption("verbosity", "control verbosity of output for this component", "warning"); + String[] allowedValues = new String[] {"quiet", "error", "warning", "notice", "info", "debug"}; + verbosityOption.setAllowedValues(allowedValues); return verbosityOption; } Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2007-10-17 16:54:24 UTC (rev 232) @@ -47,8 +47,8 @@ // pro erstelltem ReasoningService bzw. Reasoner aufgerufen werden) // => erstellt auch vereinfachte Sichten auf Subsumptionhierarchie // (siehe einfacher Traversal in Diplomarbeit) - public void prepareSubsumptionHierarchy(); - public void prepareRoleHierarchy() throws ReasoningMethodUnsupportedException; + public void prepareSubsumptionHierarchy(Set<AtomicConcept> allowedConcepts); + public void prepareRoleHierarchy(Set<AtomicRole> allowedRoles) throws ReasoningMethodUnsupportedException; public boolean subsumes(Concept superConcept, Concept subConcept) throws ReasoningMethodUnsupportedException; Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2007-10-17 16:54:24 UTC (rev 232) @@ -108,7 +108,7 @@ throw new ReasoningMethodUnsupportedException(); } - public void prepareRoleHierarchy() throws ReasoningMethodUnsupportedException { + public void prepareRoleHierarchy(Set<AtomicRole> allowedRoles) throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); } Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2007-10-17 16:54:24 UTC (rev 232) @@ -342,8 +342,8 @@ return getRoleHierarchy().getMostSpecialRoles(); } - public void prepareSubsumptionHierarchy() { - reasoner.prepareSubsumptionHierarchy(); + public void prepareSubsumptionHierarchy(Set<AtomicConcept> allowedConcepts) { + reasoner.prepareSubsumptionHierarchy(allowedConcepts); } public SubsumptionHierarchy getSubsumptionHierarchy() { @@ -356,9 +356,9 @@ } } - public void prepareRoleHierarchy() { + public void prepareRoleHierarchy(Set<AtomicRole> allowedRoles) { try { - reasoner.prepareRoleHierarchy(); + reasoner.prepareRoleHierarchy(allowedRoles); } catch (ReasoningMethodUnsupportedException e) { handleExceptions(e); } Modified: trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2007-10-17 16:54:24 UTC (rev 232) @@ -36,7 +36,6 @@ import javax.xml.namespace.QName; import org.apache.xmlbeans.XmlCursor; -import org.dllearner.Config; import org.dllearner.core.BooleanConfigOption; import org.dllearner.core.ConfigEntry; import org.dllearner.core.ConfigOption; @@ -202,9 +201,9 @@ * Construct a subsumption hierarchy using DIG queries. After calling this * method one can ask for children or parents in the subsumption hierarchy. */ - public void prepareSubsumptionHierarchy() { + public void prepareSubsumptionHierarchy(Set<AtomicConcept> allowedConcepts) { allowedConceptsInSubsumptionHierarchy = new TreeSet<Concept>(conceptComparator); - allowedConceptsInSubsumptionHierarchy.addAll(Config.Refinement.allowedConcepts); + allowedConceptsInSubsumptionHierarchy.addAll(allowedConcepts); allowedConceptsInSubsumptionHierarchy.add(new Top()); allowedConceptsInSubsumptionHierarchy.add(new Bottom()); @@ -237,7 +236,7 @@ subsumptionHierarchyUp.put(atom, tmp); } - subsumptionHierarchy = new SubsumptionHierarchy(Config.Refinement.allowedConcepts, + subsumptionHierarchy = new SubsumptionHierarchy(allowedConcepts, subsumptionHierarchyUp, subsumptionHierarchyDown); } @@ -248,19 +247,19 @@ * @todo Does not yet take ignored roles into account. */ @Override - public void prepareRoleHierarchy() { + public void prepareRoleHierarchy(Set<AtomicRole> allowedRoles) { TreeMap<AtomicRole, TreeSet<AtomicRole>> roleHierarchyUp = new TreeMap<AtomicRole, TreeSet<AtomicRole>>( roleComparator); TreeMap<AtomicRole, TreeSet<AtomicRole>> roleHierarchyDown = new TreeMap<AtomicRole, TreeSet<AtomicRole>>( roleComparator); - + // Refinement atomarer Konzepte for (AtomicRole role : atomicRoles) { roleHierarchyDown.put(role, getMoreSpecialRolesDIG(role)); roleHierarchyUp.put(role, getMoreGeneralRolesDIG(role)); } - roleHierarchy = new RoleHierarchy(Config.Refinement.allowedRoles, roleHierarchyUp, + roleHierarchy = new RoleHierarchy(allowedRoles, roleHierarchyUp, roleHierarchyDown); } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2007-10-17 16:54:24 UTC (rev 232) @@ -79,7 +79,7 @@ return abox; } - public void prepareSubsumptionHierarchy() { + public void prepareSubsumptionHierarchy(Set<AtomicConcept> allowedConcepts) { // hier muss nichts getan werden } Modified: trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-10-17 16:54:24 UTC (rev 232) @@ -248,7 +248,7 @@ // TODO: hier werden momentan keine allowed concepts berücksichtigt // (benötigt rekursive Aufrufe, da ein erlaubtes Konzept von einem nicht // erlaubten verdeckt werden könnte) - public void prepareSubsumptionHierarchy() { + public void prepareSubsumptionHierarchy(Set<AtomicConcept> allowedConcepts) { try { kaon2SubsumptionHierarchy = kaon2Reasoner.getSubsumptionHierarchy(); } catch (KAON2Exception e) { Modified: trunk/src/dl-learner/org/dllearner/utilities/Helper.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2007-10-17 16:54:24 UTC (rev 232) @@ -1,6 +1,5 @@ package org.dllearner.utilities; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -11,7 +10,6 @@ import java.util.TreeSet; import java.util.Map.Entry; -import org.dllearner.Config; import org.dllearner.core.ReasoningMethodUnsupportedException; import org.dllearner.core.ReasoningService; import org.dllearner.core.dl.AssertionalAxiom; @@ -28,121 +26,130 @@ import org.dllearner.core.dl.RoleAssertion; /** - * Die Hilfsmethoden benutzen alle SortedSet, da die Operationen damit schneller sind. + * Die Hilfsmethoden benutzen alle SortedSet, da die Operationen damit schneller + * sind. + * * @author jl - * + * */ public class Helper { - + // findet alle atomaren Konzepte in einem Konzept public static List<AtomicConcept> getAtomicConcepts(Concept concept) { List<AtomicConcept> ret = new LinkedList<AtomicConcept>(); - if(concept instanceof AtomicConcept) { - ret.add((AtomicConcept)concept); + if (concept instanceof AtomicConcept) { + ret.add((AtomicConcept) concept); return ret; } else { - for(Concept child : concept.getChildren()) { + for (Concept child : concept.getChildren()) { ret.addAll(getAtomicConcepts(child)); } return ret; } } - + // findet alle atomaren Rollen in einem Konzept public static List<AtomicRole> getAtomicRoles(Concept concept) { List<AtomicRole> ret = new LinkedList<AtomicRole>(); - - if(concept instanceof Quantification) { - ret.add(new AtomicRole(((Quantification)concept).getRole().getName())); - } else if(concept instanceof NumberRestriction) { - ret.add(new AtomicRole(((NumberRestriction)concept).getRole().getName())); + + if (concept instanceof Quantification) { + ret.add(new AtomicRole(((Quantification) concept).getRole().getName())); + } else if (concept instanceof NumberRestriction) { + ret.add(new AtomicRole(((NumberRestriction) concept).getRole().getName())); } - - // auch NumberRestrictions und Quantifications können weitere Rollen enthalten, + + // auch NumberRestrictions und Quantifications können weitere Rollen + // enthalten, // deshalb hier kein else-Zweig - for(Concept child : concept.getChildren()) { + for (Concept child : concept.getChildren()) { ret.addAll(getAtomicRoles(child)); } return ret; - - } - + + } + // sucht, ob der übergebene String mit einem Prefix beginnt der // versteckt werden soll und gibt diesen zurück, ansonsten wird // null zurück gegeben -// public static String findPrefixToHide(String name) { -// for(String prefix : Config.hidePrefixes) { -// if(name.startsWith(prefix)) -// return prefix; -// } -// return null; -// } - + // public static String findPrefixToHide(String name) { + // for(String prefix : Config.hidePrefixes) { + // if(name.startsWith(prefix)) + // return prefix; + // } + // return null; + // } + /** * * Transforms an URI to an abbreviated version, e.g. if the base URI is - * "http://example.com/" and the uri is "http://example.com/test", then + * "http://example.com/" and the uri is "http://example.com/test", then * "test" is returned. If the the uri is "http://anotherexample.com/test2" * and a prefix "ns1" is given for "http://anotherexample.com", then * "ns1:test2" is returned. If there is no match, uri is returned. * - * @param uri The full uri, which should be transformed to an abbreviated version. - * @param baseURI The base uri (ignored if null). - * @param prefixes A prefix map (ignored if null), where each entry contains a short string e.g. ns1 - * as key and the corresponding uri as value. + * @param uri + * The full uri, which should be transformed to an abbreviated + * version. + * @param baseURI + * The base uri (ignored if null). + * @param prefixes + * A prefix map (ignored if null), where each entry contains a + * short string e.g. ns1 as key and the corresponding uri as + * value. * @return Abbreviated version of the parameter uri. */ - public static String getAbbreviatedString(String uri, String baseURI, Map<String,String> prefixes) { - if(baseURI != null && uri.startsWith(baseURI)) { + public static String getAbbreviatedString(String uri, String baseURI, + Map<String, String> prefixes) { + if (baseURI != null && uri.startsWith(baseURI)) { return uri.substring(baseURI.length()); } else { - if(prefixes != null) { - for(Entry<String,String> prefix : prefixes.entrySet()) { - if(uri.startsWith(prefix.getValue())) + if (prefixes != null) { + for (Entry<String, String> prefix : prefixes.entrySet()) { + if (uri.startsWith(prefix.getValue())) return prefix.getKey() + ":" + uri.substring(prefix.getValue().length()); } } return uri; } } - + public static String prettyPrintNanoSeconds(long nanoSeconds) { return prettyPrintNanoSeconds(nanoSeconds, false, false); } - + // formatiert Nano-Sekunden in einen leserlichen String - public static String prettyPrintNanoSeconds(long nanoSeconds, boolean printMicros, boolean printNanos) { + public static String prettyPrintNanoSeconds(long nanoSeconds, boolean printMicros, + boolean printNanos) { // String str = ""; // long seconds = 0; // long milliSeconds = 0; // long microseconds = 0; - - long seconds = nanoSeconds/1000000000; + + long seconds = nanoSeconds / 1000000000; nanoSeconds = nanoSeconds % 1000000000; - - long milliSeconds = nanoSeconds/1000000; + + long milliSeconds = nanoSeconds / 1000000; nanoSeconds = nanoSeconds % 1000000; // Mikrosekunden werden immer angezeigt, Sekunden nur falls größer 0 String str = ""; - if(seconds > 0) + if (seconds > 0) str = seconds + "s "; str += milliSeconds + "ms"; - - if(printMicros) { - long microSeconds = nanoSeconds/1000; - nanoSeconds = nanoSeconds % 1000; + + if (printMicros) { + long microSeconds = nanoSeconds / 1000; + nanoSeconds = nanoSeconds % 1000; str += " " + microSeconds + "usec"; } - if(printNanos) { + if (printNanos) { str += " " + nanoSeconds + "ns"; } - + return str; } - - public static<T1,T2> void addMapEntry(Map<T1, SortedSet<T2>> map, - T1 keyEntry, T2 setEntry) { + + public static <T1, T2> void addMapEntry(Map<T1, SortedSet<T2>> map, T1 keyEntry, T2 setEntry) { if (map.containsKey(keyEntry)) { map.get(keyEntry).add(setEntry); } else { @@ -150,284 +157,393 @@ newSet.add(setEntry); map.put(keyEntry, newSet); } + } + + /** + * Das ist eine "generic method", d.h. die Methode hat einen bestimmten Typ. + * Ich habe das benutzt um allen beteiligten Mengen den gleichen Typ zu + * geben, denn ansonsten ist es nicht möglich der neu zu erzeugenden Menge + * (union) den gleichen Typ wie den Argumenten zu geben. + * + * Die Methode hat gegenüber addAll den Vorteil, dass sie ein neues Objekt + * erzeugt. + * + * @param <T> + * @param set1 + * @param set2 + * @return + */ + public static <T> Set<T> union(Set<T> set1, Set<T> set2) { + // TODO: effizientere Implementierung (längere Liste klonen und Elemente + // anhängen) + Set<T> union = new TreeSet<T>(); + union.addAll(set1); + union.addAll(set2); + return union; + /* + * Set union; if(set1.size()>set2.size()) { union = set1.clone(); } else { + * } return union; + */ + } + + public static <T> SortedSet<T> union(SortedSet<T> set1, SortedSet<T> set2) { + // Set<T> union = set1.clone(); + // ((Cloneable) set1).clone(); + + // TODO: effizientere Implementierung (längere Liste klonen und Elemente + // anhängen) + + // f�r TreeSet gibt es einen Konstruktor, der eine Collection + // entgegennimmt + // und einen weiteren, der ein SortedSet entgegennimmt; vermutlich ist + // letzterer schneller + + SortedSet<T> union; + if (set1.size() > set2.size()) { + union = new TreeSet<T>(set1); + union.addAll(set2); + } else { + union = new TreeSet<T>(set2); + union.addAll(set1); + } + // SortedSet<T> union = new TreeSet<T>(set1); + // union.addAll(set1); + // union.addAll(set2); + return union; + + } + + public static <T> SortedSet<T> intersection(SortedSet<T> set1, SortedSet<T> set2) { + // TreeSet<T> intersection = (TreeSet<T>) set1.clone(); + // TODO: effizienter implementieren d.h. lange Liste klonen und dann + // retainAll + SortedSet<T> intersection = new TreeSet<T>(set1); + // intersection.addAll(set1); + intersection.retainAll(set2); + return intersection; + } + + public static <T> SortedSet<T> intersectionTuple(SortedSet<T> set, SortedSetTuple<T> tuple) { + SortedSet<T> ret = intersection(set, tuple.getPosSet()); + ret.retainAll(tuple.getNegSet()); + return ret; + } + + public static <T> SortedSet<T> difference(SortedSet<T> set1, SortedSet<T> set2) { + // TODO: effizienter implementieren + SortedSet<T> difference = new TreeSet<T>(set1); + // difference.addAll(set1); + difference.removeAll(set2); + return difference; + } + + public static <T> Set<T> difference(Set<T> set1, Set<T> set2) { + // TODO: effizienter implementieren + SortedSet<T> difference = new TreeSet<T>(set1); + // difference.addAll(set1); + difference.removeAll(set2); + return difference; } - /** - * Das ist eine "generic method", d.h. die Methode hat einen bestimmten Typ. - * Ich habe das benutzt um allen beteiligten Mengen den gleichen Typ zu geben, - * denn ansonsten ist es nicht möglich der neu zu erzeugenden Menge (union) den - * gleichen Typ wie den Argumenten zu geben. - * - * Die Methode hat gegenüber addAll den Vorteil, dass sie ein neues Objekt - * erzeugt. - * - * @param <T> - * @param set1 - * @param set2 - * @return - */ - public static<T> Set<T> union(Set<T> set1, Set<T> set2) { - // TODO: effizientere Implementierung (längere Liste klonen und Elemente - // anhängen) - Set<T> union = new TreeSet<T>(); - union.addAll(set1); - union.addAll(set2); - return union; - /* - Set union; - if(set1.size()>set2.size()) { - union = set1.clone(); - } else { - - } - return union; - */ - } - - public static<T> SortedSet<T> union(SortedSet<T> set1, SortedSet<T> set2) { - //Set<T> union = set1.clone(); - //((Cloneable) set1).clone(); - - // TODO: effizientere Implementierung (längere Liste klonen und Elemente - // anhängen) - - // f�r TreeSet gibt es einen Konstruktor, der eine Collection entgegennimmt - // und einen weiteren, der ein SortedSet entgegennimmt; vermutlich ist - // letzterer schneller - - SortedSet<T> union; - if(set1.size()>set2.size()) { - union = new TreeSet<T>(set1); - union.addAll(set2); - } else { - union = new TreeSet<T>(set2); - union.addAll(set1); - } - // SortedSet<T> union = new TreeSet<T>(set1); - // union.addAll(set1); - // union.addAll(set2); - return union; - - } - - public static<T> SortedSet<T> intersection(SortedSet<T> set1, SortedSet<T> set2) { - // TreeSet<T> intersection = (TreeSet<T>) set1.clone(); - // TODO: effizienter implementieren d.h. lange Liste klonen und dann - // retainAll - SortedSet<T> intersection = new TreeSet<T>(set1); - // intersection.addAll(set1); - intersection.retainAll(set2); - return intersection; - } - - public static<T> SortedSet<T> intersectionTuple(SortedSet<T> set, SortedSetTuple<T> tuple) { - SortedSet<T> ret = intersection(set,tuple.getPosSet()); - ret.retainAll(tuple.getNegSet()); - return ret; - } - - public static<T> SortedSet<T> difference(SortedSet<T> set1, SortedSet<T> set2) { - // TODO: effizienter implementieren - SortedSet<T> difference = new TreeSet<T>(set1); - // difference.addAll(set1); - difference.removeAll(set2); - return difference; - } - // Umwandlung von Menge von Individuals auf Menge von Strings public static SortedSet<Individual> getIndividualSet(Set<String> individuals) { SortedSet<Individual> ret = new TreeSet<Individual>(); - for(String s : individuals) { + for (String s : individuals) { ret.add(new Individual(s)); } return ret; - } - + } + public static SortedSetTuple<Individual> getIndividualTuple(SortedSetTuple<String> tuple) { - return new SortedSetTuple<Individual>(getIndividualSet(tuple.getPosSet()),getIndividualSet(tuple.getNegSet())); + return new SortedSetTuple<Individual>(getIndividualSet(tuple.getPosSet()), + getIndividualSet(tuple.getNegSet())); } - + public static SortedSetTuple<String> getStringTuple(SortedSetTuple<Individual> tuple) { - return new SortedSetTuple<String>(getStringSet(tuple.getPosSet()),getStringSet(tuple.getNegSet())); - } - + return new SortedSetTuple<String>(getStringSet(tuple.getPosSet()), getStringSet(tuple + .getNegSet())); + } + // Umwandlung von Menge von Individuals auf Menge von Strings public static SortedSet<String> getStringSet(Set<Individual> individuals) { SortedSet<String> ret = new TreeSet<String>(); - for(Individual i : individuals) { + for (Individual i : individuals) { ret.add(i.getName()); } return ret; } - - public static Map<String,SortedSet<String>> getStringMap(Map<Individual, SortedSet<Individual>> roleMembers) { - Map<String,SortedSet<String>> ret = new TreeMap<String,SortedSet<String>>(); - for(Individual i : roleMembers.keySet()) { + + public static Map<String, SortedSet<String>> getStringMap( + Map<Individual, SortedSet<Individual>> roleMembers) { + Map<String, SortedSet<String>> ret = new TreeMap<String, SortedSet<String>>(); + for (Individual i : roleMembers.keySet()) { ret.put(i.getName(), getStringSet(roleMembers.get(i))); } return ret; } /** - * TODO: - * split in two methods (one for concepts, one for roles), - * document what exactly the method is doing, - * remove dependencies from old Config class, - * incorporate the new methods in the learning algorithms when appropriate - * (common conf options for allowed concepts/roles and forbidden + * TODO: split in two methods (one for concepts, one for roles), document + * what exactly the method is doing, remove dependencies from old Config + * class, incorporate the new methods in the learning algorithms when + * appropriate (common conf options for allowed concepts/roles and forbidden * concepts/roles need to be created) * - * Computes the set of allowed concepts based on configuration settings (also - * ignores anonymous and standard RDF, RDFS, OWL concept produces by Jena). - * + * Computes the set of allowed concepts based on configuration settings + * (also ignores anonymous and standard RDF, RDFS, OWL concept produces by + * Jena). + * + * DEPRECATED METHOD (RELIED ON OLD CONFIG). + * */ - public static void autoDetectConceptsAndRoles(ReasoningService rs) { - // einige Sachen, die momentan nur vom Refinement-Algorithmus - // unterstützt werden (später ev. auch von anderen Algorithmen) - //if (Config.algorithm == Algorithm.REFINEMENT) { - - // berechnen der verwendbaren Konzepte - if (Config.Refinement.allowedConceptsAutoDetect) { - // TODO: Code aus DIG-Reasoner-Klasse einfügen - - Set<AtomicConcept> allowedConceptsTmp = new TreeSet<AtomicConcept>( - new ConceptComparator()); - allowedConceptsTmp.addAll(rs.getAtomicConcepts()); - Iterator<AtomicConcept> it = allowedConceptsTmp.iterator(); - while (it.hasNext()) { - String conceptName = it.next().getName(); - // System.out.println(conceptName); - // seltsame anon-Konzepte, die von Jena erzeugt werden - // löschen - if (conceptName.startsWith("anon")) { - System.out - .println(" Ignoring concept " - + conceptName - + " (probably an anonymous concept produced by Jena when reading in OWL file)."); - it.remove(); - } else if (conceptName - .startsWith("http://www.w3.org/1999/02/22-rdf-syntax-ns#")) { - System.out - .println(" Ignoring concept " - + conceptName - + " (RDF construct produced by Jena when reading in OWL file)."); - it.remove(); - } else if (conceptName - .startsWith("http://www.w3.org/2000/01/rdf-schema#")) { - System.out - .println(" Ignoring concept " - + conceptName - + " (RDF Schema construct produced by Jena when reading in OWL file)."); - it.remove(); - } else if (conceptName.startsWith("http://www.w3.org/2002/07/owl#")) { - System.out - .println(" Ignoring concept " - + conceptName - + " (OWL construct produced by Jena when reading in OWL file)."); - it.remove(); - } - } +// public static void autoDetectConceptsAndRoles(ReasoningService rs) { +// // einige Sachen, die momentan nur vom Refinement-Algorithmus +// // unterstützt werden (später ev. auch von anderen Algorithmen) +// // if (Config.algorithm == Algorithm.REFINEMENT) { +// +// // berechnen der verwendbaren Konzepte +// if (Config.Refinement.allowedConceptsAutoDetect) { +// // TODO: Code aus DIG-Reasoner-Klasse einfügen +// +// Set<AtomicConcept> allowedConceptsTmp = new TreeSet<AtomicConcept>( +// new ConceptComparator()); +// allowedConceptsTmp.addAll(rs.getAtomicConcepts()); +// Iterator<AtomicConcept> it = allowedConceptsTmp.iterator(); +// while (it.hasNext()) { +// String conceptName = it.next().getName(); +// // System.out.println(conceptName); +// // seltsame anon-Konzepte, die von Jena erzeugt werden +// // löschen +// if (conceptName.startsWith("anon")) { +// System.out +// .println(" Ignoring concept " +// + conceptName +// + " (probably an anonymous concept produced by Jena when reading in OWL file)."); +// it.remove(); +// } else if (conceptName.startsWith("http://www.w3.org/1999/02/22-rdf-syntax-ns#")) { +// System.out.println(" Ignoring concept " + conceptName +// + " (RDF construct produced by Jena when reading in OWL file)."); +// it.remove(); +// } else if (conceptName.startsWith("http://www.w3.org/2000/01/rdf-schema#")) { +// System.out.println(" Ignoring concept " + conceptName +// + " (RDF Schema construct produced by Jena when reading in OWL file)."); +// it.remove(); +// } else if (conceptName.startsWith("http://www.w3.org/2002/07/owl#")) { +// System.out.println(" Ignoring concept " + conceptName +// + " (OWL construct produced by Jena when reading in OWL file)."); +// it.remove(); +// } +// } +// +// // hier werden jetzt noch die zu ignorierenden Konzepte entfernt +// if (Config.Refinement.ignoredConcepts != null) { +// +// for (AtomicConcept ac : Config.Refinement.ignoredConcepts) { +// boolean success = allowedConceptsTmp.remove(ac); +// if (!success) { +// System.out.println("Ignored concept " + ac +// + " does not exist in knowledge base."); +// System.exit(0); +// } +// +// } +// } +// +// Config.Refinement.allowedConcepts = allowedConceptsTmp; +// } else { +// // prüfen, ob nur verfügbare Konzepte vom Nutzer gewählt worden +// Set<AtomicConcept> allowed = new HashSet<AtomicConcept>(); +// allowed.addAll(Config.Refinement.allowedConcepts); +// allowed.removeAll(rs.getAtomicConcepts()); +// if (allowed.size() > 0) { +// System.out +// .println("Some of the concepts you told the learner to use in the definition, " +// + "do not exist in the background knowledge: " + allowed); +// System.out.println("Please correct this problem and restart."); +// System.exit(0); +// } +// } +// +// if (Config.Refinement.allowedRolesAutoDetect) { +// Set<AtomicRole> allowedRolesTmp = rs.getAtomicRoles(); +// +// // hier werden jetzt noch die zu ignorierenden Rollen entfernt +// if (Config.Refinement.ignoredRoles != null) { +// +// for (AtomicRole ar : Config.Refinement.ignoredRoles) { +// boolean success = allowedRolesTmp.remove(ar); +// if (!success) { +// System.out.println("Ignored role " + ar +// + " does not exist in knowledge base."); +// System.exit(0); +// } +// +// } +// } +// +// Config.Refinement.allowedRoles = allowedRolesTmp; +// +// } else { +// Set<AtomicRole> allowedR = new HashSet<AtomicRole>(); +// allowedR.addAll(Config.Refinement.allowedRoles); +// +// Set<AtomicRole> existingR = new TreeSet<AtomicRole>(new RoleComparator()); +// existingR.addAll(rs.getAtomicRoles()); +// +// // allowedR.removeAll(rs.getAtomicRoles()); +// allowedR.removeAll(existingR); +// +// if (allowedR.size() > 0) { +// System.out +// .println("Some of the roles you told the learner to use in the definition, " +// + "do not exist in the background knowledge: " + allowedR); +// System.out.println("Please correct this problem and restart."); +// System.out.println(rs.getAtomicRoles()); +// System.out.println(Config.Refinement.allowedRoles); +// System.exit(0); +// } +// +// } +// } + + /** + * Removes concepts, which should be ignored by the learning algorithm. + * (The main reason to use this method is because Jena introduces such + * concepts when ontologies are converted to DIG.) Currently ignored + * concepts are those having prefix "anon" and concepts belonging to + * the RDF, RDFS, OWL standards. + * + * @param concepts + * @return + */ + public static void removeUninterestingConcepts(Set<AtomicConcept> concepts) { + Iterator<AtomicConcept> it = concepts.iterator(); + while (it.hasNext()) { + String conceptName = it.next().getName(); - // hier werden jetzt noch die zu ignorierenden Konzepte entfernt - if(Config.Refinement.ignoredConcepts != null) { - - - for(AtomicConcept ac : Config.Refinement.ignoredConcepts) { - boolean success = allowedConceptsTmp.remove(ac); - if(!success) { - System.out.println("Ignored concept " + ac + " does not exist in knowledge base."); - System.exit(0); - } - - } + // ignore some concepts (possibly produced by Jena) + if (conceptName.startsWith("anon")) { + System.out + .println(" Ignoring concept " + + conceptName + + " (probably an anonymous concept produced by Jena when reading in OWL file)."); + it.remove(); + } else if (conceptName.startsWith("http://www.w3.org/1999/02/22-rdf-syntax-ns#")) { + System.out.println(" Ignoring concept " + conceptName + + " (RDF construct produced by Jena when reading in OWL file)."); + it.remove(); + } else if (conceptName.startsWith("http://www.w3.org/2000/01/rdf-schema#")) { + System.out.println(" Ignoring concept " + conceptName + + " (RDF Schema construct produced by Jena when reading in OWL file)."); + it.remove(); + } else if (conceptName.startsWith("http://www.w3.org/2002/07/owl#")) { + System.out.println(" Ignoring concept " + conceptName + + " (OWL construct produced by Jena when reading in OWL file)."); + it.remove(); } - - Config.Refinement.allowedConcepts = allowedConceptsTmp; - } else { - // prüfen, ob nur verfügbare Konzepte vom Nutzer gewählt worden - Set<AtomicConcept> allowed = new HashSet<AtomicConcept>(); - allowed.addAll(Config.Refinement.allowedConcepts); - allowed.removeAll(rs.getAtomicConcepts()); - if (allowed.size() > 0) { - System.out - .println("Some of the concepts you told the learner to use in the definition, " - + "do not exist in the background knowledge: " - + allowed); - System.out.println("Please correct this problem and restart."); - System.exit(0); - } } + } - if (Config.Refinement.allowedRolesAutoDetect) { - Set<AtomicRole> allowedRolesTmp = rs.getAtomicRoles(); - - // hier werden jetzt noch die zu ignorierenden Rollen entfernt - if(Config.Refinement.ignoredRoles != null) { - - - for(AtomicRole ar : Config.Refinement.ignoredRoles) { - boolean success = allowedRolesTmp.remove(ar); - if(!success) { - System.out.println("Ignored role " + ar + " does not exist in knowledge base."); - System.exit(0); - } - - } - } - - Config.Refinement.allowedRoles = allowedRolesTmp; - - } else { - Set<AtomicRole> allowedR = new HashSet<AtomicRole>(); - allowedR.addAll(Config.Refinement.allowedRoles); + // concepts case 1: no ignore or allowed list + public static Set<AtomicConcept> computeConcepts(ReasoningService rs) { + // if there is no ignore or allowed list, we just ignore the concepts + // of uninteresting namespaces + Set<AtomicConcept> concepts = rs.getAtomicConcepts(); + Helper.removeUninterestingConcepts(concepts); + return concepts; + } - Set<AtomicRole> existingR = new TreeSet<AtomicRole>(new RoleComparator()); - existingR.addAll(rs.getAtomicRoles()); - - // allowedR.removeAll(rs.getAtomicRoles()); - allowedR.removeAll(existingR); - - if (allowedR.size() > 0) { - System.out - .println("Some of the roles you told the learner to use in the definition, " - + "do not exist in the background knowledge: " - + allowedR); - System.out.println("Please correct this problem and restart."); - System.out.println(rs.getAtomicRoles()); - System.out.println(Config.Refinement.allowedRoles); + // concepts case 2: ignore list + public static Set<AtomicConcept> computeConceptsUsingIgnoreList(ReasoningService rs, Set<AtomicConcept> ignoredConcepts) { + Set<AtomicConcept> concepts = rs.getAtomicConcepts(); + Helper.removeUninterestingConcepts(concepts); + for (AtomicConcept ac : ignoredConcepts) { + boolean success = concepts.remove(ac); + if (!success) { + System.out.println("Warning: Ignored concept " + ac + + " does not exist in knowledge base."); System.exit(0); } + } + return concepts; + } + // concepts case 3: allowed list + // superseeded by checkConcepts() +// public static void checkAllowedList(ReasoningService rs, Set<AtomicConcept> allowedConcepts) { +// // check whether allowed concepts exist in knowledgebase(s) +// Set<AtomicConcept> allowed = new HashSet<AtomicConcept>(); +// allowed.addAll(allowedConcepts); +// allowed.removeAll(rs.getAtomicConcepts()); +// if (allowed.size() > 0) { +// System.out +// .println("Some of the concepts you told the learner to use in the definition, " +// + "do not exist in the background knowledge: " + allowed); +// System.out.println("Please correct this problem and restart."); +// System.exit(0); +// } +// } + + /** + * Checks whether the roles exist in background knowledge + * @param roles The roles to check. + * @return The first non-existing role or null if they are all in the + * background knowledge. + */ + // + public static AtomicRole checkRoles(ReasoningService rs, Set<AtomicRole> roles) { + Set<AtomicRole> existingRoles = rs.getAtomicRoles(); + for (AtomicRole ar : roles) { + if(!existingRoles.contains(ar)) + return ar; } + return null; } + + /** + * Checks whether the roles exist in background knowledge + * @param roles The roles to check. + * @return The first non-existing role or null if they are all in the + * background knowledge. + */ + // + public static AtomicConcept checkConcepts(ReasoningService rs, Set<AtomicConcept> concepts) { + Set<AtomicConcept> existingConcepts = rs.getAtomicConcepts(); + for (AtomicConcept ar : concepts) { + if(!existingConcepts.contains(ar)) + return ar; + } + return null; + } // creates a flat ABox by querying a reasoner public static FlatABox createFlatABox(ReasoningService rs) throws ReasoningMethodUnsupportedException { long dematStartTime = System.currentTimeMillis(); - + FlatABox aBox = new FlatABox(); // FlatABox.getInstance(); for (AtomicConcept atomicConcept : rs.getAtomicConcepts()) { - aBox.atomicConceptsPos.put(atomicConcept.getName(), getStringSet(rs.retrieval(atomicConcept))); + aBox.atomicConceptsPos.put(atomicConcept.getName(), getStringSet(rs + .retrieval(atomicConcept))); Negation negatedAtomicConcept = new Negation(atomicConcept); - aBox.atomicConceptsNeg.put(atomicConcept.getName(), getStringSet(rs.retrieval(negatedAtomicConcept))); + aBox.atomicConceptsNeg.put(atomicConcept.getName(), getStringSet(rs + .retrieval(negatedAtomicConcept))); aBox.concepts.add(atomicConcept.getName()); } - + for (AtomicRole atomicRole : rs.getAtomicRoles()) { - aBox.rolesPos.put(atomicRole.getName(), getStringMap(rs - .getRoleMembers(atomicRole))); + aBox.rolesPos.put(atomicRole.getName(), getStringMap(rs.getRoleMembers(atomicRole))); aBox.roles.add(atomicRole.getName()); } - + aBox.domain = getStringSet(rs.getIndividuals()); aBox.top = aBox.domain; // ab hier keine �nderungen mehr an FlatABox aBox.prepare(); - + // System.out.println(aBox); - + long dematDuration = System.currentTimeMillis() - dematStartTime; System.out.println("OK (" + dematDuration + " ms)"); return aBox; @@ -443,7 +559,7 @@ System.out.println("connected individuals: " + connectedIndividuals); // Individual selbst auch entfernen connectedIndividuals.add(individual); - + // zweiter Schritt: entfernen von Rollen- und Konzeptzusicherungen Set<AssertionalAxiom> abox = kb.getAbox(); Iterator<AssertionalAxiom> it = abox.iterator(); @@ -464,9 +580,9 @@ } else throw new RuntimeException(); } - + Set<Individual> inds = kb.findAllIndividuals(); System.out.println("remaining individuals: " + inds); System.out.println(); - } + } } Modified: trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-10-17 16:54:24 UTC (rev 232) @@ -35,7 +35,6 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasoningMethodUnsupportedException; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; import org.dllearner.kb.OWLFile; @@ -200,17 +199,17 @@ // uses the same reasoning object (e.g. the second algorithm may // have a small advantage if the reasoner cached reasoning requests // of the first algorithm) - Helper.autoDetectConceptsAndRoles(rs); - try { - reasoner.prepareSubsumptionHierarchy(); - reasoner.prepareRoleHierarchy(); - // improving the subsumption hierarchy makes only sense - // for the refinement based algorithm - if(algorithmNr==0) - reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); - } catch (ReasoningMethodUnsupportedException e) { - e.printStackTrace(); - } +// Helper.autoDetectConceptsAndRoles(rs); +// try { +// reasoner.prepareSubsumptionHierarchy(); +// reasoner.prepareRoleHierarchy(); +// // improving the subsumption hierarchy makes only sense +// // for the refinement based algorithm +// if(algorithmNr==0) +// reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); +// } catch (ReasoningMethodUnsupportedException e) { +// e.printStackTrace(); +// } LearningAlgorithm learningAlgorithm = null; if(algorithmNr==0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-17 14:29:01
|
Revision: 231 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=231&view=rev Author: jenslehmann Date: 2007-10-17 07:28:58 -0700 (Wed, 17 Oct 2007) Log Message: ----------- small example for Daimler use case Added Paths: ----------- trunk/examples/daimler/motor.conf trunk/examples/daimler/motor.kb Added: trunk/examples/daimler/motor.conf =================================================================== --- trunk/examples/daimler/motor.conf (rev 0) +++ trunk/examples/daimler/motor.conf 2007-10-17 14:28:58 UTC (rev 231) @@ -0,0 +1,15 @@ +// learn superclass of super + +problem = posNegInclusion; + +import("motor.kb"); + +// pos examples: everything belonging to the superclass ++s1 ++s2 ++b1 ++b2 +// neg. examples: everything else +-d1 +-d2 +-d3 \ No newline at end of file Added: trunk/examples/daimler/motor.kb =================================================================== --- trunk/examples/daimler/motor.kb (rev 0) +++ trunk/examples/daimler/motor.kb 2007-10-17 14:28:58 UTC (rev 231) @@ -0,0 +1,10 @@ +// disjoint classes +(diesel AND benzin) = BOTTOM. + +diesel(d1). +diesel(d2). +diesel(d3). +super(s1). +super(s2). +benzin(b1). +benzin(b2). \ 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: <jen...@us...> - 2007-10-17 10:33:47
|
Revision: 230 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=230&view=rev Author: jenslehmann Date: 2007-10-17 03:33:42 -0700 (Wed, 17 Oct 2007) Log Message: ----------- - implemented generic access to all available components and configuration options in web service interface => this allows to write completely generic clients (e.g. clients could extend themselves automatically once new components and options become available) - demo implemented in testnew.php - improved toString() method for config options Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java trunk/src/dl-learner/org/dllearner/core/ConfigOption.java trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/utilities/Helper.java trunk/src/php-client/testnew.php Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-10-16 15:01:23 UTC (rev 229) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-10-17 10:33:42 UTC (rev 230) @@ -465,6 +465,13 @@ return null; } + public static List<ConfigOption<?>> getConfigOptions(Class<? extends Component> componentClass) { + if (!components.contains(componentClass)) + System.err.println("Warning: component " + componentClass + + " is not a registered component. [ComponentManager.getConfigOptions]"); + return componentOptions.get(componentClass); + } + public ConfigOption<?> getConfigOption(Class<? extends Component> component, String name) { return componentOptionsByName.get(component).get(name); } @@ -473,4 +480,6 @@ return componentNames.get(component); } + + } Modified: trunk/src/dl-learner/org/dllearner/core/ConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ConfigOption.java 2007-10-16 15:01:23 UTC (rev 229) +++ trunk/src/dl-learner/org/dllearner/core/ConfigOption.java 2007-10-17 10:33:42 UTC (rev 230) @@ -76,13 +76,13 @@ public abstract boolean isValidValue(T value); - public static String getRestrictionDescription() { - return "none"; + public String getAllowedValuesDescription() { + return getClass().toString(); } @Override public String toString() { - return "option name: " + name + "\ndescription: " + description + "\nvalues: " + getRestrictionDescription() + "\ndefault value: " + defaultValue + "\n"; + return "option name: " + name + "\ndescription: " + description + "\nvalues: " + getAllowedValuesDescription() + "\ndefault value: " + defaultValue + "\n"; } } Modified: trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java 2007-10-16 15:01:23 UTC (rev 229) +++ trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java 2007-10-17 10:33:42 UTC (rev 230) @@ -85,5 +85,15 @@ public boolean checkType(Object object) { return (object instanceof Double); } + + @Override + public String getAllowedValuesDescription() { + String str = getClass().toString(); + if(lowerLimit != Double.MIN_VALUE) + str += " min " + lowerLimit; + if(upperLimit != Double.MAX_VALUE) + str += " max " + upperLimit; + return str; + } } Modified: trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java 2007-10-16 15:01:23 UTC (rev 229) +++ trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java 2007-10-17 10:33:42 UTC (rev 230) @@ -86,4 +86,14 @@ return (object instanceof Integer); } + @Override + public String getAllowedValuesDescription() { + String str = getClass().toString(); + if(lowerLimit != Integer.MIN_VALUE) + str += " min " + lowerLimit; + if(upperLimit != Integer.MAX_VALUE) + str += " max " + upperLimit; + return str; + } + } Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-16 15:01:23 UTC (rev 229) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-17 10:33:42 UTC (rev 230) @@ -20,6 +20,7 @@ package org.dllearner.server; import java.util.Arrays; +import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; @@ -34,6 +35,7 @@ import org.dllearner.algorithms.refinement.ROLearner; import org.dllearner.core.Component; import org.dllearner.core.ComponentManager; +import org.dllearner.core.ConfigOption; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; @@ -50,6 +52,7 @@ import org.dllearner.parser.ParseException; import org.dllearner.reasoning.DIGReasoner; import org.dllearner.utilities.Datastructures; +import org.dllearner.utilities.Helper; /** * DL-Learner web service interface. @@ -71,6 +74,7 @@ private static Map<String,Class<? extends ReasonerComponent>> reasonerMapping = new TreeMap<String,Class<? extends ReasonerComponent>>(); private static Map<String,Class<? extends LearningProblem>> learningProblemMapping = new TreeMap<String,Class<? extends LearningProblem>>(); private static Map<String,Class<? extends LearningAlgorithm>> learningAlgorithmMapping = new TreeMap<String,Class<? extends LearningAlgorithm>>(); + private static Set<String> components; public DLLearnerWS() { knowledgeSourceMapping.put("owlfile", OWLFile.class); @@ -79,6 +83,9 @@ learningProblemMapping.put("posNegDefinition", PosNegDefinitionLP.class); learningProblemMapping.put("posNegInclusion", PosNegInclusionLP.class); learningAlgorithmMapping.put("refinement", ROLearner.class); + components = Helper.union(knowledgeSourceMapping.keySet(),reasonerMapping.keySet()); + components = Helper.union(components, learningProblemMapping.keySet()); + components = Helper.union(components, learningAlgorithmMapping.keySet()); } /** @@ -107,7 +114,6 @@ } // returns the class which is referred to by the string - @SuppressWarnings({"unused"}) private Class<? extends Component> getComponent(String component) throws UnknownComponentException { if(knowledgeSourceMapping.containsKey(component)) return knowledgeSourceMapping.get(component); @@ -125,6 +131,52 @@ // methods for basic component setup // /////////////////////////////////////// + @WebMethod + public String[] getComponents() { + return components.toArray(new String[components.size()]); + } + + @WebMethod + public String[] getKnowledgeSources() { + Set<String> knowledgeSources = knowledgeSourceMapping.keySet(); + return knowledgeSources.toArray(new String[knowledgeSources.size()]); + } + + @WebMethod + public String[] getReasoners() { + Set<String> reasoners = reasonerMapping.keySet(); + return reasoners.toArray(new String[reasoners.size()]); + } + + @WebMethod + public String[] getLearningProblems() { + Set<String> learningProblems = learningProblemMapping.keySet(); + return learningProblems.toArray(new String[learningProblems.size()]); + } + + @WebMethod + public String[] getLearningAlgorithms() { + Set<String> learningAlgorithms = learningAlgorithmMapping.keySet(); + return learningAlgorithms.toArray(new String[learningAlgorithms.size()]); + } + + @WebMethod + public String[] getConfigOptions(String component, boolean allInfo) throws UnknownComponentException { + Class<? extends Component> componentClass = getComponent(component); + List<ConfigOption<?>> options = ComponentManager.getConfigOptions(componentClass); + String[] optionsString = new String[options.size()]; + for(int i=0; i<options.size(); i++) { + ConfigOption<?> option = options.get(i); + optionsString[i] = option.getName(); + if(allInfo) { + optionsString[i] += "#" + option.getDescription(); + optionsString[i] += "#" + option.getAllowedValuesDescription(); + optionsString[i] += "#" + option.getDefaultValue(); + } + } + return optionsString; + } + /** * Adds a knowledge source. * Modified: trunk/src/dl-learner/org/dllearner/utilities/Helper.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2007-10-16 15:01:23 UTC (rev 229) +++ trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2007-10-17 10:33:42 UTC (rev 230) @@ -166,7 +166,7 @@ * @param set2 * @return */ - public static<T> Set<T> unionAlt(Set<T> set1, Set<T> set2) { + public static<T> Set<T> union(Set<T> set1, Set<T> set2) { // TODO: effizientere Implementierung (längere Liste klonen und Elemente // anhängen) Set<T> union = new TreeSet<T>(); Modified: trunk/src/php-client/testnew.php =================================================================== --- trunk/src/php-client/testnew.php 2007-10-16 15:01:23 UTC (rev 229) +++ trunk/src/php-client/testnew.php 2007-10-17 10:33:42 UTC (rev 230) @@ -20,6 +20,27 @@ // test web service $client = new SoapClient("main.wsdl"); +$print_ws_info = false; + +if($print_ws_info) { + $components = $client->getComponents()->item; + + echo '<h1>Web Service Information</h1>'; + + foreach($components as $component) { + echo '<h2>component '.$component.'</h2>'; + + $options = $client->getConfigOptions($component, true)->item; + if(!is_array($options)) + $options = array($options); + + foreach($options as $option) + echo $option.'<br />'; + } +} + +echo '<h1>Algorithm Run</h1>'; + $id = $client->generateID(); $ksID = $client->addKnowledgeSource($id, "owlfile", $ontology); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-16 15:01:26
|
Revision: 229 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=229&view=rev Author: jenslehmann Date: 2007-10-16 08:01:23 -0700 (Tue, 16 Oct 2007) Log Message: ----------- - created (meta-)methods for accessing applied configuration methods - added getters for all configuration options in web service 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/server/DLLearnerWS.java trunk/src/php-client/testnew.php Added Paths: ----------- trunk/src/dl-learner/org/dllearner/server/ConfigOptionTypeException.java trunk/src/dl-learner/org/dllearner/server/jaxws/ConfigOptionTypeExceptionBean.java Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-10-16 13:24:32 UTC (rev 228) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-10-16 15:01:23 UTC (rev 229) @@ -256,12 +256,14 @@ * @param source A registered knowledge source component. * @return An instance of the given knowledge source class. */ - public KnowledgeSource knowledgeSource(Class<? extends KnowledgeSource> source) { + public <T extends KnowledgeSource> T knowledgeSource(Class<T> source) { if (!knowledgeSources.contains(source)) System.err.println("Warning: knowledge source " + source + " is not a registered knowledge source component."); - return invokeConstructor(source, new Class[] {}, new Object[] {}); + T ks = invokeConstructor(source, new Class[] {}, new Object[] {}); + pool.registerComponent(ks); + return ks; } public <T extends ReasonerComponent> T reasoner(Class<T> reasoner, @@ -277,11 +279,10 @@ System.err.println("Warning: reasoner component " + reasoner + " is not a registered reasoner component."); - return invokeConstructor(reasoner, new Class[] { Set.class }, + T rc = invokeConstructor(reasoner, new Class[] { Set.class }, new Object[] { sources }); -// T reasonerInstance = invokeConstructor(reasoner, new Class[] { Set.class }, -// new Object[] { sources }); -// return new ReasoningService(reasonerInstance); + pool.registerComponent(rc); + return rc; } /** @@ -300,40 +301,70 @@ return new ReasoningService(reasoner); } - public <T extends LearningProblem> T learningProblem(Class<T> lp, ReasoningService reasoner) { - if (!learningProblems.contains(lp)) - System.err.println("Warning: learning problem " + lp + public <T extends LearningProblem> T learningProblem(Class<T> lpClass, ReasoningService reasoner) { + if (!learningProblems.contains(lpClass)) + System.err.println("Warning: learning problem " + lpClass + " is not a registered learning problem component."); - return invokeConstructor(lp, new Class[] { ReasoningService.class }, + T lp = invokeConstructor(lpClass, new Class[] { ReasoningService.class }, new Object[] { reasoner }); + pool.registerComponent(lp); + return lp; } // automagically calls the right constructor for the given learning problem - public <T extends LearningAlgorithm> T learningAlgorithm(Class<T> la, LearningProblem lp, ReasoningService rs) { - if (!learningAlgorithms.contains(la)) - System.err.println("Warning: learning algorithm " + la + public <T extends LearningAlgorithm> T learningAlgorithm(Class<T> laClass, LearningProblem lp, ReasoningService rs) { + if (!learningAlgorithms.contains(laClass)) + System.err.println("Warning: learning algorithm " + laClass + " is not a registered learning algorithm component."); // find the right constructor: use the one that is registered and // has the class of the learning problem as a subclass Class<? extends LearningProblem> constructorArgument = null; - for (Class<? extends LearningProblem> problemClass : algorithmProblemsMapping.get(la)) { + for (Class<? extends LearningProblem> problemClass : algorithmProblemsMapping.get(laClass)) { if (problemClass.isAssignableFrom(lp.getClass())) constructorArgument = problemClass; } if (constructorArgument == null) { System.err.println("Warning: No suitable constructor registered for algorithm " - + la.getName() + " and problem " + lp.getClass().getName() - + ". Registered constructors for " + la.getName() + ": " - + algorithmProblemsMapping.get(la) + "."); + + laClass.getName() + " and problem " + lp.getClass().getName() + + ". Registered constructors for " + laClass.getName() + ": " + + algorithmProblemsMapping.get(laClass) + "."); return null; } - return invokeConstructor(la, new Class[] { constructorArgument, ReasoningService.class }, new Object[] { lp, rs }); + T la = invokeConstructor(laClass, new Class[] { constructorArgument, ReasoningService.class }, new Object[] { lp, rs }); + pool.registerComponent(la); + return la; } + /** + * The <code>ComponentManager</code> factory methods produce component + * instances, which can be freed using this method. Calling the factory + * methods without freeing components when they are not used anymore + * can (in theory) cause memory problems. + * + * @param component The component to free. + */ + public void freeComponent(Component component) { + pool.unregisterComponent(component); + } + + public <T> T getConfigOptionValue(Component component, ConfigOption<T> option) { + T object = pool.getLastValidConfigValue(component, option); + if(object==null) + return option.getDefaultValue(); + else + return object; + } + + public Object getConfigOptionValue(Component component, String optionName) { + ConfigOption<?> option = (ConfigOption<?>) componentOptionsByName.get( + component.getClass()).get(optionName); + return getConfigOptionValue(component, option); + } + public void writeConfigDocumentation(File file) { String doc = ""; doc += "This file contains an automatically generated files of all components and their config options.\n\n"; Modified: trunk/src/dl-learner/org/dllearner/core/ComponentPool.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentPool.java 2007-10-16 13:24:32 UTC (rev 228) +++ trunk/src/dl-learner/org/dllearner/core/ComponentPool.java 2007-10-16 15:01:23 UTC (rev 229) @@ -25,7 +25,8 @@ import java.util.Map; /** - * Stores all live components. + * Stores all live components and the configuration options, which were + * applied to them. * * @author Jens Lehmann * @@ -42,10 +43,6 @@ // complete history of all made config entries for a component private Map<Component,List<ConfigEntry<?>>> configEntryHistory = new HashMap<Component,List<ConfigEntry<?>>>(); - public Object getLastValidConfigEntry(Component component, ConfigOption<?> option) { - return lastValidConfigValue.get(component).get(option); - } - public void registerComponent(Component component) { components.add(component); Map<ConfigOption<?>,Object> emptyMap = new HashMap<ConfigOption<?>,Object>(); @@ -59,10 +56,11 @@ components.remove(component); } - public Object getLastValidConfigValue(Component component, ConfigOption<?> option) { - return lastValidConfigValue.get(component).get(option); + @SuppressWarnings({"unchecked"}) + public <T> T getLastValidConfigValue(Component component, ConfigOption<T> option) { + return (T) lastValidConfigValue.get(component).get(option); } - + public void addConfigEntry(Component component, ConfigEntry<?> entry, boolean valid) { configEntryHistory.get(component).add(entry); if(valid) Added: trunk/src/dl-learner/org/dllearner/server/ConfigOptionTypeException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ConfigOptionTypeException.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/ConfigOptionTypeException.java 2007-10-16 15:01:23 UTC (rev 229) @@ -0,0 +1,37 @@ +/** + * 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.server; + +/** + * Exception for indicating that an operation was performed on + * a wrong type. + * + * @author Jens Lehmann + * + */ +public class ConfigOptionTypeException extends Exception { + + private static final long serialVersionUID = -6856243711006023178L; + + public ConfigOptionTypeException(String optionName, Class<?> correctType, Class<?> wrongType) { + super(optionName + " is of type " + correctType.getName() + ", so you cannot use type " + wrongType.getName() + "."); + } + +} Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-16 13:24:32 UTC (rev 228) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-16 15:01:23 UTC (rev 229) @@ -296,6 +296,46 @@ cm.applyConfigEntry(component, optionName, value); } + @WebMethod + public String[] getConfigOptionValueStringArray(int sessionID, int componentID, String optionName) throws ClientNotKnownException, UnknownComponentException, ConfigOptionTypeException { + return getConfigOptionValue(sessionID, componentID, optionName, String[].class); + } + + @WebMethod + public String getConfigOptionValueString(int sessionID, int componentID, String optionName) throws ClientNotKnownException, UnknownComponentException, ConfigOptionTypeException { + return getConfigOptionValue(sessionID, componentID, optionName, String.class); + } + + @WebMethod + public Double getConfigOptionValueDouble(int sessionID, int componentID, String optionName) throws ClientNotKnownException, UnknownComponentException, ConfigOptionTypeException { + return getConfigOptionValue(sessionID, componentID, optionName, Double.class); + } + + @WebMethod + public Boolean getConfigOptionValueBoolean(int sessionID, int componentID, String optionName) throws ClientNotKnownException, UnknownComponentException, ConfigOptionTypeException { + return getConfigOptionValue(sessionID, componentID, optionName, Boolean.class); + } + + @WebMethod + public Integer getConfigOptionValueInt(int sessionID, int componentID, String optionName) throws ClientNotKnownException, UnknownComponentException, ConfigOptionTypeException { + return getConfigOptionValue(sessionID, componentID, optionName, Integer.class); + } + + @SuppressWarnings({"unchecked"}) + private <T> T getConfigOptionValue(int sessionID, int componentID, String optionName, Class<T> clazz) throws ClientNotKnownException, UnknownComponentException, ConfigOptionTypeException { + Object value = getConfigOptionValue(sessionID, componentID, optionName); + if(clazz.isInstance(value)) + return (T) value; + else + throw new ConfigOptionTypeException(optionName, clazz, value.getClass()); + } + + private Object getConfigOptionValue(int sessionID, int componentID, String optionName) throws ClientNotKnownException, UnknownComponentException { + ClientState state = getState(sessionID); + Component component = state.getComponent(componentID); + return cm.getConfigOptionValue(component, optionName); + } + //////////////////////////////////// // reasoning and querying methods // //////////////////////////////////// Added: trunk/src/dl-learner/org/dllearner/server/jaxws/ConfigOptionTypeExceptionBean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/jaxws/ConfigOptionTypeExceptionBean.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/jaxws/ConfigOptionTypeExceptionBean.java 2007-10-16 15:01:23 UTC (rev 229) @@ -0,0 +1,41 @@ + +package org.dllearner.server.jaxws; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * This class was generated by the JAXWS SI. + * JAX-WS RI 2.0_02-b08-fcs + * Generated source version: 2.0_02 + * + */ +@XmlRootElement(name = "ConfigOptionTypeException", namespace = "http://server.dllearner.org/") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ConfigOptionTypeException", namespace = "http://server.dllearner.org/") +public class ConfigOptionTypeExceptionBean { + + private String message; + + /** + * + * @return + * returns String + */ + public String getMessage() { + return this.message; + } + + /** + * + * @param message + * the value for the message property + */ + public void setMessage(String message) { + this.message = message; + } + +} Modified: trunk/src/php-client/testnew.php =================================================================== --- trunk/src/php-client/testnew.php 2007-10-16 13:24:32 UTC (rev 228) +++ trunk/src/php-client/testnew.php 2007-10-16 15:01:23 UTC (rev 229) @@ -23,6 +23,7 @@ $id = $client->generateID(); $ksID = $client->addKnowledgeSource($id, "owlfile", $ontology); +// echo $client->getConfigOptionValueString($id, $ksID, "url"); $client->setReasoner($id, "dig"); $client->setLearningProblem($id, "posNegDefinition"); $client->setPositiveExamples($id, $posExamples); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-16 13:24:45
|
Revision: 228 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=228&view=rev Author: jenslehmann Date: 2007-10-16 06:24:32 -0700 (Tue, 16 Oct 2007) Log Message: ----------- created component pool for storing all live components (intermediate commit) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java trunk/src/dl-learner/org/dllearner/core/Component.java trunk/src/dl-learner/org/dllearner/core/ComponentManager.java trunk/src/dl-learner/org/dllearner/server/ClientState.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/ComponentPool.java trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2007-10-16 09:32:08 UTC (rev 227) +++ trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2007-10-16 13:24:32 UTC (rev 228) @@ -62,7 +62,7 @@ private Concept bestDefinition; private Score bestScore; - private int maxLength = 7; + private Integer maxLength = 7; private String returnType; // list of all generated concepts sorted by length @@ -97,6 +97,13 @@ returnType = (String) returnType; } +// public Object getConfigValue(String optionName) throws UnknownConfigOptionException { +// if(optionName.equals("maxLength")) +// return maxLength; +// else +// throw new UnknownConfigOptionException(getClass(), optionName); +// } + /* (non-Javadoc) * @see org.dllearner.core.Component#init() */ @@ -264,4 +271,5 @@ @Override public void stop() { } + } Modified: trunk/src/dl-learner/org/dllearner/core/Component.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Component.java 2007-10-16 09:32:08 UTC (rev 227) +++ trunk/src/dl-learner/org/dllearner/core/Component.java 2007-10-16 13:24:32 UTC (rev 228) @@ -23,6 +23,8 @@ import java.util.LinkedList; /** + * General component base class. + * * @author Jens Lehmann * */ @@ -54,4 +56,13 @@ * @param entry A configuration entry. */ public abstract <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException; + + /** + * Gets the value of a configuration option of this component. + * + * @param <T> Option type. + * @param option A configuration option of this component. + * @return Current value of the configuration option. + */ +// public abstract <T> T getConfigValue(ConfigOption<T> option) throws UnknownConfigOptionException; } Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-10-16 09:32:08 UTC (rev 227) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-10-16 13:24:32 UTC (rev 228) @@ -56,6 +56,8 @@ */ public class ComponentManager { + private ComponentPool pool = new ComponentPool(); + // these variables are valid for the complete lifetime of DL-Learner private static String componentsFile = "lib/components.ini"; private static ComponentManager cm = new ComponentManager(); @@ -71,6 +73,9 @@ private static Map<Class<? extends Component>, Map<String, ConfigOption<?>>> componentOptionsByName; private static Map<Class<? extends LearningAlgorithm>, Collection<Class<? extends LearningProblem>>> algorithmProblemsMapping; + // list of default values of config options +// private static Map<ConfigOption<?>,Object> configOptionDefaults; + private Comparator<Class<?>> classComparator = new Comparator<Class<?>>() { public int compare(Class<?> c1, Class<?> c2) { @@ -124,21 +129,24 @@ // read in all configuration options componentOptions = new HashMap<Class<? extends Component>, List<ConfigOption<?>>>(); componentOptionsByName = new HashMap<Class<? extends Component>, Map<String, ConfigOption<?>>>(); - +// configOptionDefaults = new HashMap<ConfigOption<?>,Object>(); + for (Class<? extends Component> component : components) { String name = (String) invokeStaticMethod(component, "getName"); componentNames.put(component, name); + // assign options to components List<ConfigOption<?>> options = (List<ConfigOption<?>>) invokeStaticMethod(component, "createConfigOptions"); componentOptions.put(component, options); + // make config options accessible by name Map<String, ConfigOption<?>> byName = new HashMap<String, ConfigOption<?>>(); for (ConfigOption<?> option : options) byName.put(option.getName(), option); componentOptionsByName.put(component, byName); - + } // System.out.println(components); @@ -186,6 +194,7 @@ * @param optionName * @param value */ + @SuppressWarnings( { "unchecked" }) public <T> void applyConfigEntry(Component component, String optionName, T value) { // first we look whether the component is registered if (components.contains(component.getClass())) { @@ -205,11 +214,13 @@ // we have checked the type, hence it should now be safe to // typecast and // create a ConfigEntry object - try { - @SuppressWarnings( { "unchecked" }) - ConfigEntry<T> entry = new ConfigEntry<T>((ConfigOption<T>) option, value); + ConfigEntry<T> entry = null; + try { + entry = new ConfigEntry<T>((ConfigOption<T>) option, value); component.applyConfigEntry(entry); + pool.addConfigEntry(component, entry, true); } catch (InvalidConfigOptionValueException e) { + pool.addConfigEntry(component, entry, false); System.out.println("Warning: value " + value + " is not valid for option " + optionName + " in component " + component); } @@ -231,9 +242,10 @@ public <T> boolean applyConfigEntry(Component component, ConfigEntry<T> entry) { try { component.applyConfigEntry(entry); + pool.addConfigEntry(component,entry,true); return true; } catch (InvalidConfigOptionValueException e) { - // TODO Auto-generated catch block + pool.addConfigEntry(component,entry,false); e.printStackTrace(); return false; } Added: trunk/src/dl-learner/org/dllearner/core/ComponentPool.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentPool.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/ComponentPool.java 2007-10-16 13:24:32 UTC (rev 228) @@ -0,0 +1,72 @@ +/** + * 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.core; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +/** + * Stores all live components. + * + * @author Jens Lehmann + * + */ +public class ComponentPool { + + // stores all components, which are live (components which are + // no longer used have to be deregistered) + private List<Component> components = new LinkedList<Component>(); + + // stores the last value which was set for a particular + // config option + private Map<Component,Map<ConfigOption<?>,Object>> lastValidConfigValue = new HashMap<Component,Map<ConfigOption<?>,Object>>(); + // complete history of all made config entries for a component + private Map<Component,List<ConfigEntry<?>>> configEntryHistory = new HashMap<Component,List<ConfigEntry<?>>>(); + + public Object getLastValidConfigEntry(Component component, ConfigOption<?> option) { + return lastValidConfigValue.get(component).get(option); + } + + public void registerComponent(Component component) { + components.add(component); + Map<ConfigOption<?>,Object> emptyMap = new HashMap<ConfigOption<?>,Object>(); + lastValidConfigValue.put(component, emptyMap); + configEntryHistory.put(component, new LinkedList<ConfigEntry<?>>()); + } + + public void unregisterComponent(Component component) { + configEntryHistory.remove(component); + lastValidConfigValue.remove(component); + components.remove(component); + } + + public Object getLastValidConfigValue(Component component, ConfigOption<?> option) { + return lastValidConfigValue.get(component).get(option); + } + + public void addConfigEntry(Component component, ConfigEntry<?> entry, boolean valid) { + configEntryHistory.get(component).add(entry); + if(valid) + lastValidConfigValue.get(component).put(entry.getOption(), entry.getValue()); + } + +} Added: trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java 2007-10-16 13:24:32 UTC (rev 228) @@ -0,0 +1,38 @@ +/** + * 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.core; + +/** + * @author Jens Lehmann + * + */ +public class UnknownConfigOptionException extends Exception { + + private static final long serialVersionUID = -7808637210577591687L; + + public UnknownConfigOptionException(Class<? extends Component> componentClass, String optionName) { + super("Option " + optionName + " unknown in component " + ComponentManager.getInstance().getComponentName(componentClass) + "(" + componentClass.getName() + ")"); + } + + public UnknownConfigOptionException(Class<? extends Component> componentClass, ConfigOption<?> option) { + super("Option " + option.getName() + " unknown in component " + ComponentManager.getInstance().getComponentName(componentClass) + "(" + componentClass.getName() + ")"); + } + +} Modified: trunk/src/dl-learner/org/dllearner/server/ClientState.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-10-16 09:32:08 UTC (rev 227) +++ trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-10-16 13:24:32 UTC (rev 228) @@ -45,7 +45,7 @@ // stores the mapping between component IDs and component // (note that this allows us to keep all references to components even - // if they are note used anymore e.g. a deleted knowledge source) + // if they are not used anymore e.g. a deleted knowledge source) private Map<Integer,Component> componentIDs = new HashMap<Integer,Component>(); private Set<KnowledgeSource> knowledgeSources = new HashSet<KnowledgeSource>(); Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-16 09:32:08 UTC (rev 227) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-16 13:24:32 UTC (rev 228) @@ -314,7 +314,7 @@ @WebMethod public String[] retrieval(int id, String conceptString) throws ClientNotKnownException { ClientState state = getState(id); - // call parser to parse atomic concept + // call parser to parse concept Concept concept = null; try { concept = KBParser.parseConcept(conceptString); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |