From: <sk...@us...> - 2007-10-08 12:07:12
|
Revision: 181 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=181&view=rev Author: sknappe Date: 2007-10-08 05:07:11 -0700 (Mon, 08 Oct 2007) Log Message: ----------- Sparql Modul in org.dllearner.kb ?\195?\188bertragen 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-08 12:05:59 UTC (rev 180) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-08 12:07:11 UTC (rev 181) @@ -19,12 +19,21 @@ */ package org.dllearner.kb; +import java.io.File; +import java.io.FileWriter; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; +import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedList; +import java.util.Map; import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; import org.dllearner.core.ConfigEntry; import org.dllearner.core.ConfigOption; @@ -32,6 +41,11 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.StringConfigOption; import org.dllearner.core.StringSetConfigOption; +import org.dllearner.core.dl.AtomicConcept; +import org.dllearner.core.dl.Individual; +import org.dllearner.modules.sparql.OntologyCollector; +import org.dllearner.reasoning.OWLAPIDIGConverter; +import org.dllearner.utilities.Datastructures; /** * Represents a SPARQL Endpoint. @@ -85,9 +99,81 @@ */ @Override public void init() { - // TODO add code for downloading data from SPARQL endpoint + // TODO add code for downloading data from SPARQL endpoint + String filename=System.currentTimeMillis()+".nt"; + + int numberOfRecursions=1; + Set<String> predList=new HashSet<String>(); + Set<String> objList=new HashSet<String>(); + Set<String> classList=new HashSet<String>(); + String prefix=""; + int filterMode=0; + Map<AtomicConcept, SortedSet<Individual>> positive=new HashMap<AtomicConcept, SortedSet<Individual>>(); + Map<AtomicConcept, SortedSet<Individual>> negative=new HashMap<AtomicConcept, SortedSet<Individual>>(); + AtomicConcept concept=new AtomicConcept("test"); + Individual ind1=new Individual("http://dbpedia.org/resource/Pythagoras"); + Individual ind2=new Individual("http://dbpedia.org/resource/Socrates"); + SortedSet<Individual> sort1=new TreeSet<Individual>(); + SortedSet<Individual> sort2=new TreeSet<Individual>(); + sort1.add(ind1); + sort2.add(ind2); + positive.put(concept, sort1 ); + negative.put(concept, sort2 ); + + String[] subjectList=makeSubjectList(prefix, positive, negative); + + + try{ + FileWriter fw=new FileWriter(new File("examples/"+filename),true); + System.out.println("SparqlModul: Collecting Ontology"); + OntologyCollector oc=new OntologyCollector(subjectList, numberOfRecursions, + filterMode, Datastructures.setToArray(predList),Datastructures.setToArray( objList),Datastructures.setToArray(classList)); + + String ont=oc.collectOntology(); + fw.write(ont); + fw.flush(); + + System.out.println("SparqlModul: ****Finished"); + + fw.close(); + this.url=(new File("examples/"+filename)).toURI().toURL(); + //System.exit(0); + }catch (Exception e) {e.printStackTrace();} } + private String[] makeSubjectList(String prefix, + Map<AtomicConcept, SortedSet<Individual>> positive, + Map<AtomicConcept, SortedSet<Individual>> negative){ + + //prefix + prefix=""; + + ArrayList<String> al=new ArrayList<String>(); + Iterator<AtomicConcept> it=positive.keySet().iterator(); + while(it.hasNext()){ + SortedSet<Individual> s=positive.get(it.next()); + Iterator<Individual> inner =s.iterator(); + while(inner.hasNext()){ + al.add(inner.next().toString()); + } + } + + it=negative.keySet().iterator(); + while(it.hasNext()){ + SortedSet<Individual> s=negative.get(it.next()); + Iterator<Individual> inner =s.iterator(); + while(inner.hasNext()){ + al.add(inner.next().toString()); + } + } + String[] subjectList=new String[al.size()]; + Object[] o=al.toArray(); + for (int i = 0; i < subjectList.length; i++) { + subjectList[i]=prefix+(String)o[i]; + } + return subjectList; + } + /* * (non-Javadoc) * @@ -95,7 +181,7 @@ */ @Override public String toDIG(URI kbURI) { - return null; + return OWLAPIDIGConverter.getTellsString(url, OntologyFileFormat.N_TRIPLES, kbURI); } public URL getURL() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2007-10-08 13:43:38
|
Revision: 186 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=186&view=rev Author: sknappe Date: 2007-10-08 06:43:15 -0700 (Mon, 08 Oct 2007) Log Message: ----------- 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-08 13:39:55 UTC (rev 185) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-08 13:43:15 UTC (rev 186) @@ -43,6 +43,7 @@ import org.dllearner.core.StringSetConfigOption; import org.dllearner.core.dl.AtomicConcept; import org.dllearner.core.dl.Individual; +import org.dllearner.reasoning.JenaOWLDIGConverter; import org.dllearner.reasoning.OWLAPIDIGConverter; import org.dllearner.utilities.Datastructures; @@ -59,6 +60,8 @@ private URL url; private Set<String> instances; + private URL ntFile; + private int numberOfRecursions; public static String getName() { return "SPARQL Endpoint"; @@ -68,6 +71,7 @@ Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); options.add(new StringConfigOption("url", "URL of SPARQL Endpoint")); options.add(new StringSetConfigOption("instances","relevant instances e.g. positive and negative examples in a learning problem")); + options.add(new StringConfigOption("numberOfRecursions","number of Recursions, the Sparql-Endpoint is asked")); return options; } @@ -90,6 +94,8 @@ //} } else if(option.equals("instances")) { instances = (Set<String>) entry.getValue(); + } else if(option.equals("numberOfRecursions")){ + this.numberOfRecursions=Integer.parseInt((String)entry.getValue()); } } @@ -101,31 +107,20 @@ // TODO add code for downloading data from SPARQL endpoint String filename=System.currentTimeMillis()+".nt"; - int numberOfRecursions=1; Set<String> predList=new HashSet<String>(); Set<String> objList=new HashSet<String>(); Set<String> classList=new HashSet<String>(); String prefix=""; int filterMode=0; - Map<AtomicConcept, SortedSet<Individual>> positive=new HashMap<AtomicConcept, SortedSet<Individual>>(); - Map<AtomicConcept, SortedSet<Individual>> negative=new HashMap<AtomicConcept, SortedSet<Individual>>(); - AtomicConcept concept=new AtomicConcept("test"); + Individual ind1=new Individual("http://dbpedia.org/resource/Pythagoras"); Individual ind2=new Individual("http://dbpedia.org/resource/Socrates"); - SortedSet<Individual> sort1=new TreeSet<Individual>(); - SortedSet<Individual> sort2=new TreeSet<Individual>(); - sort1.add(ind1); - sort2.add(ind2); - positive.put(concept, sort1 ); - negative.put(concept, sort2 ); - String[] subjectList=makeSubjectList(prefix, positive, negative); - - try{ FileWriter fw=new FileWriter(new File("examples/"+filename),true); System.out.println("SparqlModul: Collecting Ontology"); - OntologyCollector oc=new OntologyCollector(subjectList, numberOfRecursions, + String[] a=new String[0]; + OntologyCollector oc=new OntologyCollector(instances.toArray(a), numberOfRecursions, filterMode, Datastructures.setToArray(predList),Datastructures.setToArray( objList),Datastructures.setToArray(classList)); String ont=oc.collectOntology(); @@ -135,44 +130,11 @@ System.out.println("SparqlModul: ****Finished"); fw.close(); - this.url=(new File("examples/"+filename)).toURI().toURL(); + this.ntFile=(new File("examples/"+filename)).toURI().toURL(); //System.exit(0); }catch (Exception e) {e.printStackTrace();} } - private String[] makeSubjectList(String prefix, - Map<AtomicConcept, SortedSet<Individual>> positive, - Map<AtomicConcept, SortedSet<Individual>> negative){ - - //prefix - prefix=""; - - ArrayList<String> al=new ArrayList<String>(); - Iterator<AtomicConcept> it=positive.keySet().iterator(); - while(it.hasNext()){ - SortedSet<Individual> s=positive.get(it.next()); - Iterator<Individual> inner =s.iterator(); - while(inner.hasNext()){ - al.add(inner.next().toString()); - } - } - - it=negative.keySet().iterator(); - while(it.hasNext()){ - SortedSet<Individual> s=negative.get(it.next()); - Iterator<Individual> inner =s.iterator(); - while(inner.hasNext()){ - al.add(inner.next().toString()); - } - } - String[] subjectList=new String[al.size()]; - Object[] o=al.toArray(); - for (int i = 0; i < subjectList.length; i++) { - subjectList[i]=prefix+(String)o[i]; - } - return subjectList; - } - /* * (non-Javadoc) * @@ -180,7 +142,7 @@ */ @Override public String toDIG(URI kbURI) { - return OWLAPIDIGConverter.getTellsString(url, OntologyFileFormat.N_TRIPLES, kbURI); + return JenaOWLDIGConverter.getTellsString(ntFile, OntologyFileFormat.N_TRIPLES, kbURI); } public URL getURL() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2007-10-08 13:54:48
|
Revision: 187 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=187&view=rev Author: sknappe Date: 2007-10-08 06:54:46 -0700 (Mon, 08 Oct 2007) Log Message: ----------- update 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-08 13:43:15 UTC (rev 186) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-08 13:54:46 UTC (rev 187) @@ -37,6 +37,7 @@ import org.dllearner.core.ConfigEntry; import org.dllearner.core.ConfigOption; +import org.dllearner.core.IntegerConfigOption; import org.dllearner.core.InvalidConfigOptionValueException; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.StringConfigOption; @@ -71,7 +72,7 @@ Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); options.add(new StringConfigOption("url", "URL of SPARQL Endpoint")); options.add(new StringSetConfigOption("instances","relevant instances e.g. positive and negative examples in a learning problem")); - options.add(new StringConfigOption("numberOfRecursions","number of Recursions, the Sparql-Endpoint is asked")); + options.add(new IntegerConfigOption("numberOfRecursions","number of Recursions, the Sparql-Endpoint is asked")); return options; } @@ -95,7 +96,8 @@ } else if(option.equals("instances")) { instances = (Set<String>) entry.getValue(); } else if(option.equals("numberOfRecursions")){ - this.numberOfRecursions=Integer.parseInt((String)entry.getValue()); + this.numberOfRecursions=(Integer)entry.getValue(); + System.out.println("test "+numberOfRecursions); } } @@ -113,9 +115,6 @@ String prefix=""; int filterMode=0; - Individual ind1=new Individual("http://dbpedia.org/resource/Pythagoras"); - Individual ind2=new Individual("http://dbpedia.org/resource/Socrates"); - try{ FileWriter fw=new FileWriter(new File("examples/"+filename),true); System.out.println("SparqlModul: Collecting Ontology"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2007-10-08 14:37:27
|
Revision: 189 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=189&view=rev Author: sknappe Date: 2007-10-08 07:37:26 -0700 (Mon, 08 Oct 2007) Log Message: ----------- options added path changed 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-08 14:33:11 UTC (rev 188) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-08 14:37:26 UTC (rev 189) @@ -63,7 +63,11 @@ private Set<String> instances; private URL ntFile; private int numberOfRecursions; - + private int filterMode; + private Set<String> predList; + private Set<String> objList; + private Set<String> classList; + public static String getName() { return "SPARQL Endpoint"; } @@ -73,6 +77,10 @@ options.add(new StringConfigOption("url", "URL of SPARQL Endpoint")); options.add(new StringSetConfigOption("instances","relevant instances e.g. positive and negative examples in a learning problem")); options.add(new IntegerConfigOption("numberOfRecursions","number of Recursions, the Sparql-Endpoint is asked")); + options.add(new IntegerConfigOption("filterMode","the mode of the SPARQL Filter")); + options.add(new StringSetConfigOption("predList","a predicate list")); + options.add(new StringSetConfigOption("objList","an object list")); + options.add(new StringSetConfigOption("classList","a class list")); return options; } @@ -89,15 +97,19 @@ url = new URL(s); } catch (MalformedURLException e) { throw new InvalidConfigOptionValueException(entry.getOption(), entry.getValue(),"malformed URL " + s); - } //catch (URISyntaxException e) { - // TODO Auto-generated catch block - //e.printStackTrace(); - //} + } } else if(option.equals("instances")) { instances = (Set<String>) entry.getValue(); } else if(option.equals("numberOfRecursions")){ - this.numberOfRecursions=(Integer)entry.getValue(); - System.out.println("test "+numberOfRecursions); + numberOfRecursions=(Integer)entry.getValue(); + } else if(option.equals("predList")) { + predList = (Set<String>) entry.getValue(); + } else if(option.equals("objList")) { + objList = (Set<String>) entry.getValue(); + } else if(option.equals("classList")) { + classList = (Set<String>) entry.getValue(); + } else if(option.equals("filterMode")){ + filterMode=(Integer)entry.getValue(); } } @@ -109,14 +121,11 @@ // TODO add code for downloading data from SPARQL endpoint String filename=System.currentTimeMillis()+".nt"; - Set<String> predList=new HashSet<String>(); - Set<String> objList=new HashSet<String>(); - Set<String> classList=new HashSet<String>(); - String prefix=""; - int filterMode=0; - try{ - FileWriter fw=new FileWriter(new File("examples/"+filename),true); + String basedir="cache"+File.separator; + if(!new File(basedir).exists()) + new File(basedir).mkdir(); + FileWriter fw=new FileWriter(new File(basedir+filename),true); System.out.println("SparqlModul: Collecting Ontology"); String[] a=new String[0]; OntologyCollector oc=new OntologyCollector(instances.toArray(a), numberOfRecursions, @@ -129,7 +138,7 @@ System.out.println("SparqlModul: ****Finished"); fw.close(); - this.ntFile=(new File("examples/"+filename)).toURI().toURL(); + this.ntFile=(new File(basedir+filename)).toURI().toURL(); //System.exit(0); }catch (Exception e) {e.printStackTrace();} } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2007-10-08 14:39:20
|
Revision: 191 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=191&view=rev Author: sknappe Date: 2007-10-08 07:39:16 -0700 (Mon, 08 Oct 2007) Log Message: ----------- added author 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-08 14:38:06 UTC (rev 190) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-08 14:39:16 UTC (rev 191) @@ -55,7 +55,7 @@ * TODO: Is it necessary to create a class DBpediaSparqlEndpoint? * * @author Jens Lehmann - * + * @author Sebastian Knappe */ public class SparqlEndpoint extends KnowledgeSource { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2007-10-09 08:46:09
|
Revision: 198 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=198&view=rev Author: sknappe Date: 2007-10-09 01:46:07 -0700 (Tue, 09 Oct 2007) Log Message: ----------- added new options(format, dumpToFile) to choose wether the ontology from DBPedia is stored in a file (in a specific format), adjustet example accordingly 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-08 16:33:30 UTC (rev 197) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-09 08:46:07 UTC (rev 198) @@ -21,6 +21,7 @@ import java.io.File; import java.io.FileWriter; +import java.io.StringReader; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; @@ -28,6 +29,7 @@ import java.util.LinkedList; import java.util.Set; +import org.dllearner.core.BooleanConfigOption; import org.dllearner.core.ConfigEntry; import org.dllearner.core.ConfigOption; import org.dllearner.core.IntegerConfigOption; @@ -35,6 +37,9 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.StringConfigOption; import org.dllearner.core.StringSetConfigOption; +import org.dllearner.core.dl.KB; +import org.dllearner.parser.KBParser; +import org.dllearner.reasoning.DIGConverter; import org.dllearner.reasoning.JenaOWLDIGConverter; import org.dllearner.utilities.Datastructures; @@ -57,6 +62,9 @@ private Set<String> predList; private Set<String> objList; private Set<String> classList; + private KB kb; + private String format; + private boolean dumpToFile; public static String getName() { return "SPARQL Endpoint"; @@ -71,6 +79,8 @@ options.add(new StringSetConfigOption("predList","a predicate list")); options.add(new StringSetConfigOption("objList","an object list")); 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")); return options; } @@ -100,6 +110,10 @@ classList = (Set<String>) entry.getValue(); } else if(option.equals("filterMode")){ filterMode=(Integer)entry.getValue(); + } else if(option.equals("format")){ + format=(String)entry.getValue(); + } else if(option.equals("dumpToFile")){ + dumpToFile=(Boolean)entry.getValue(); } } @@ -108,29 +122,34 @@ */ @Override public void init() { - // TODO add code for downloading data from SPARQL endpoint - String filename=System.currentTimeMillis()+".nt"; + System.out.println("SparqlModul: Collecting Ontology"); + String[] a=new String[0]; + OntologyCollector oc=new OntologyCollector(instances.toArray(a), numberOfRecursions, + filterMode, Datastructures.setToArray(predList),Datastructures.setToArray( objList),Datastructures.setToArray(classList),format); + String ont=oc.collectOntology(); - try{ + if (format.equals("N-TRIPLES")||dumpToFile){ + String filename=System.currentTimeMillis()+".nt"; String basedir="cache"+File.separator; - if(!new File(basedir).exists()) - new File(basedir).mkdir(); - FileWriter fw=new FileWriter(new File(basedir+filename),true); - System.out.println("SparqlModul: Collecting Ontology"); - String[] a=new String[0]; - OntologyCollector oc=new OntologyCollector(instances.toArray(a), numberOfRecursions, - filterMode, Datastructures.setToArray(predList),Datastructures.setToArray( objList),Datastructures.setToArray(classList)); - - String ont=oc.collectOntology(); - fw.write(ont); - fw.flush(); - - System.out.println("SparqlModul: ****Finished"); - - fw.close(); - this.ntFile=(new File(basedir+filename)).toURI().toURL(); - //System.exit(0); - }catch (Exception e) {e.printStackTrace();} + try{ + if(!new File(basedir).exists()) + new File(basedir).mkdir(); + + FileWriter fw=new FileWriter(new File(basedir+filename),true); + fw.write(ont); + fw.flush(); + fw.close(); + + ntFile=(new File(basedir+filename)).toURI().toURL(); + }catch (Exception e) {e.printStackTrace();} + } + if (format.equals("KB")) { + try{ + kb=KBParser.parseKBFile(new StringReader(ont)); + } catch(Exception e) {e.printStackTrace();} + } + + System.out.println("SparqlModul: ****Finished"); } /* @@ -140,7 +159,8 @@ */ @Override public String toDIG(URI kbURI) { - return JenaOWLDIGConverter.getTellsString(ntFile, OntologyFileFormat.N_TRIPLES, kbURI); + if (format.equals("N-TRIPLES")) return JenaOWLDIGConverter.getTellsString(ntFile, OntologyFileFormat.N_TRIPLES, kbURI); + else return DIGConverter.getDIGString(kb, kbURI).toString(); } public URL getURL() { 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: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: <sk...@us...> - 2007-10-29 10:36:38
|
Revision: 266 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=266&view=rev Author: sknappe Date: 2007-10-29 03:36:36 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Modified Sparql Classes to work with all functions of ajax version of dbpedia-navigator 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-29 10:30:25 UTC (rev 265) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-29 10:36:36 UTC (rev 266) @@ -55,7 +55,8 @@ * @author Sebastian Knappe */ public class SparqlEndpoint extends KnowledgeSource { - + + //ConfigOptions private URL url; private Set<String> instances; private URL dumpFile; @@ -64,16 +65,25 @@ private Set<String> predList; private Set<String> objList; private Set<String> classList; - private KB kb; private String format; private boolean dumpToFile; private boolean useLits=false; + + //received ontology as array, used if format=Array(an element of the + //array consists of the subject, predicate and object separated by '<' private String[] ontArray; + //received ontology as KB, the internal format + private KB kb; + public static String getName() { return "SPARQL Endpoint"; } - + + /** + * sets the ConfigOptions for this KnowledgeSource + * @return + */ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); options.add(new StringConfigOption("url", "URL of SPARQL Endpoint")); @@ -130,16 +140,9 @@ @Override public void init() { 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,useLits); - String ont=""; - if (format.equals("Array")){ - ontArray=oc.collectOntologyAsArray(); - } - else{ - ont=oc.collectOntology(); - } + SparqlOntologyCollector oc=new SparqlOntologyCollector(Datastructures.setToArray(instances), numberOfRecursions, filterMode, + Datastructures.setToArray(predList),Datastructures.setToArray( objList),Datastructures.setToArray(classList),format,url,useLits); + String ont=oc.collectOntology(); if (dumpToFile){ String filename=System.currentTimeMillis()+".nt"; @@ -196,9 +199,18 @@ 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); + SparqlOntologyCollector oc=new SparqlOntologyCollector(url); String[] ret=oc.getSubjectsFromLabel(label,limit); System.out.println("SparqlModul: ****Finished"); return ret; } + + public String[] getTriples(){ + System.out.println("SparqlModul: Collecting Triples"); + SparqlOntologyCollector oc=new SparqlOntologyCollector(Datastructures.setToArray(instances), numberOfRecursions, filterMode, + Datastructures.setToArray(predList),Datastructures.setToArray( objList),Datastructures.setToArray(classList),format,url,useLits); + String[] ret=oc.collectTriples(); + System.out.println("SparqlModul: ****Finished"); + return ret; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |