From: <ku...@us...> - 2008-09-23 23:24:43
|
Revision: 1244 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1244&view=rev Author: kurzum Date: 2008-09-23 23:24:34 +0000 (Tue, 23 Sep 2008) Log Message: ----------- added function getOWLAPIOntology to SparqlKnowledgeSource Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-23 23:06:40 UTC (rev 1243) +++ trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2008-09-23 23:24:34 UTC (rev 1244) @@ -76,6 +76,15 @@ return (String) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "cacheDir") ; } /** +* useCache If true a Cache is used. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getUseCache() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "useCache") ; +} +/** * instances relevant instances e.g. positive and negative examples in a learning problem. * mandatory: true| reinit necessary: true * default value: null @@ -142,60 +151,15 @@ return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "objList") ; } /** -* format N-TRIPLES or KB format. +* saveExtractedFragment Specifies whether the extracted ontology is written to a file or not.. * mandatory: false| reinit necessary: true -* default value: N-TRIPLES -* @return String -**/ -public String getFormat() { -return (String) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "format") ; -} -/** -* dumpToFile Specifies whether the extracted ontology is written to a file or not.. -* mandatory: false| reinit necessary: true * default value: true * @return boolean **/ -public boolean getDumpToFile() { -return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "dumpToFile") ; +public boolean getSaveExtractedFragment() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "saveExtractedFragment") ; } /** -* convertNT2RDF Specifies whether the extracted NTriples are converted to RDF and deleted.. -* mandatory: false| reinit necessary: true -* default value: false -* @return boolean -**/ -public boolean getConvertNT2RDF() { -return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "convertNT2RDF") ; -} -/** -* useLits use Literals in SPARQL query. -* mandatory: false| reinit necessary: true -* default value: true -* @return boolean -**/ -public boolean getUseLits() { -return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "useLits") ; -} -/** -* getAllSuperClasses If true then all superclasses are retrieved until the most general class (owl:Thing) is reached.. -* mandatory: false| reinit necessary: true -* default value: true -* @return boolean -**/ -public boolean getGetAllSuperClasses() { -return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "getAllSuperClasses") ; -} -/** -* useCache If true a Cache is used. -* mandatory: false| reinit necessary: true -* default value: true -* @return boolean -**/ -public boolean getUseCache() { -return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "useCache") ; -} -/** * replacePredicate rule for replacing predicates. * mandatory: false| reinit necessary: true * default value: [] @@ -225,6 +189,24 @@ return (Integer) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "breakSuperClassRetrievalAfter") ; } /** +* useLits use Literals in SPARQL query. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getUseLits() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "useLits") ; +} +/** +* getAllSuperClasses If true then all superclasses are retrieved until the most general class (owl:Thing) is reached.. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getGetAllSuperClasses() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(sparqlKnowledgeSource, "getAllSuperClasses") ; +} +/** * closeAfterRecursion gets all classes for all instances. * mandatory: false| reinit necessary: true * default value: true @@ -291,6 +273,15 @@ reinitNecessary = true; } /** +* @param useCache If true a Cache is used. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setUseCache(boolean useCache) { +ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "useCache", useCache); +reinitNecessary = true; +} +/** * @param instances relevant instances e.g. positive and negative examples in a learning problem. * mandatory: true| reinit necessary: true * default value: null @@ -354,60 +345,15 @@ reinitNecessary = true; } /** -* @param format N-TRIPLES or KB format. +* @param saveExtractedFragment Specifies whether the extracted ontology is written to a file or not.. * mandatory: false| reinit necessary: true -* default value: N-TRIPLES -**/ -public void setFormat(String format) { -ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "format", format); -reinitNecessary = true; -} -/** -* @param dumpToFile Specifies whether the extracted ontology is written to a file or not.. -* mandatory: false| reinit necessary: true * default value: true **/ -public void setDumpToFile(boolean dumpToFile) { -ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "dumpToFile", dumpToFile); +public void setSaveExtractedFragment(boolean saveExtractedFragment) { +ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "saveExtractedFragment", saveExtractedFragment); reinitNecessary = true; } /** -* @param convertNT2RDF Specifies whether the extracted NTriples are converted to RDF and deleted.. -* mandatory: false| reinit necessary: true -* default value: false -**/ -public void setConvertNT2RDF(boolean convertNT2RDF) { -ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "convertNT2RDF", convertNT2RDF); -reinitNecessary = true; -} -/** -* @param useLits use Literals in SPARQL query. -* mandatory: false| reinit necessary: true -* default value: true -**/ -public void setUseLits(boolean useLits) { -ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "useLits", useLits); -reinitNecessary = true; -} -/** -* @param getAllSuperClasses If true then all superclasses are retrieved until the most general class (owl:Thing) is reached.. -* mandatory: false| reinit necessary: true -* default value: true -**/ -public void setGetAllSuperClasses(boolean getAllSuperClasses) { -ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "getAllSuperClasses", getAllSuperClasses); -reinitNecessary = true; -} -/** -* @param useCache If true a Cache is used. -* mandatory: false| reinit necessary: true -* default value: true -**/ -public void setUseCache(boolean useCache) { -ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "useCache", useCache); -reinitNecessary = true; -} -/** * @param replacePredicate rule for replacing predicates. * mandatory: false| reinit necessary: true * default value: [] @@ -435,6 +381,24 @@ reinitNecessary = true; } /** +* @param useLits use Literals in SPARQL query. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setUseLits(boolean useLits) { +ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "useLits", useLits); +reinitNecessary = true; +} +/** +* @param getAllSuperClasses If true then all superclasses are retrieved until the most general class (owl:Thing) is reached.. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setGetAllSuperClasses(boolean getAllSuperClasses) { +ComponentManager.getInstance().applyConfigEntry(sparqlKnowledgeSource, "getAllSuperClasses", getAllSuperClasses); +reinitNecessary = true; +} +/** * @param closeAfterRecursion gets all classes for all instances. * mandatory: false| reinit necessary: true * default value: true Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-23 23:06:40 UTC (rev 1243) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-23 23:24:34 UTC (rev 1244) @@ -96,27 +96,26 @@ this.configurator = new SparqlKnowledgeSourceConfigurator(this); } - // ConfigOptions + // these are saved for further reference private URL url; + private SparqlEndpoint endpoint = null; //private String format = "N-TRIPLES"; - private String format = "RDF/XML"; + //private String format = "RDF/XML"; - private boolean dumpToFile = true; + private URL ontologyFragmentURL; + - - private URL dumpFile; - private OWLOntology fragment; - private SparqlEndpoint endpoint = null; + // 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; + //private String[] ontArray; // received ontology as KB, the internal format - private KB kb; + //private KB kb; // mainly used for statistic private int nrOfExtractedTriples = 0; @@ -140,6 +139,8 @@ null, true, true)); options.add(new StringConfigOption("cacheDir", "dir of cache", "cache", false, true)); + options.add(new BooleanConfigOption("useCache", + "If true a Cache is used", true, false, true)); options .add(new StringSetConfigOption( "instances", @@ -166,27 +167,14 @@ "list of all ignored roles", new TreeSet<String>(), false, true)); options.add(new StringSetConfigOption("objList", "list of all ignored objects", new TreeSet<String>(), false, true)); - options.add(new StringConfigOption("format", "N-TRIPLES or KB format", - "N-TRIPLES", false, true)); options .add(new BooleanConfigOption( - "dumpToFile", + "saveExtractedFragment", "Specifies whether the extracted ontology is written to a file or not.", true, false, true)); - options - .add(new BooleanConfigOption( - "convertNT2RDF", - "Specifies whether the extracted NTriples are converted to RDF and deleted.", - false, false, true)); - options.add(new BooleanConfigOption("useLits", - "use Literals in SPARQL query", true, false, true)); - options - .add(new BooleanConfigOption( - "getAllSuperClasses", - "If true then all superclasses are retrieved until the most general class (owl:Thing) is reached.", - true, false, true)); - options.add(new BooleanConfigOption("useCache", - "If true a Cache is used", true, false, true)); + + + options.add(new StringTupleListConfigOption("replacePredicate", "rule for replacing predicates", new ArrayList<StringTuple>(), false, true)); options.add(new StringTupleListConfigOption("replaceObject", @@ -194,6 +182,14 @@ options.add(new IntegerConfigOption("breakSuperClassRetrievalAfter", "stops a cyclic hierarchy after specified number of classes", 1000, false, true)); + + options.add(new BooleanConfigOption("useLits", + "use Literals in SPARQL query", true, false, true)); + options + .add(new BooleanConfigOption( + "getAllSuperClasses", + "If true then all superclasses are retrieved until the most general class (owl:Thing) is reached.", + true, false, true)); options.add(new BooleanConfigOption("closeAfterRecursion", "gets all classes for all instances", true, false, true)); options.add(new BooleanConfigOption("getPropertyInformation", @@ -264,7 +260,7 @@ extractionTime.printAndSet("extraction needed"); logger.info("Finished collecting Fragment"); - dumpFile = m.getPhysicalOntologyURL(); + ontologyFragmentURL = m.getPhysicalOntologyURL(); /* if (dumpToFile) { @@ -322,12 +318,13 @@ */ @Override public String toDIG(URI kbURI) { - if (format.equals("RDF/XML")){ - return JenaOWLDIGConverter.getTellsString(dumpFile, + //if (format.equals("RDF/XML")){ + return JenaOWLDIGConverter.getTellsString(ontologyFragmentURL, OntologyFormat.RDF_XML, kbURI); - }else { - return DIGConverter.getDIGString(kb, kbURI).toString(); - } + //}else { + //throw new Error("KB Format not supported any more"); + //return DIGConverter.getDIGString(kb, kbURI).toString(); + //} } /* @@ -366,9 +363,9 @@ } - public String[] getOntArray() { + /*public String[] getOntArray() { return ontArray; - } + }*/ public SparqlQuery sparqlQuery(String query) { return new SparqlQuery(query, getSparqlEndpoint()); @@ -456,12 +453,16 @@ @Override public KB toKB() { // TODO Does this work? - return kb; + return new KB(); } - public URL getNTripleURL() { - return dumpFile; + public URL getOntologyFragmentURL() { + return ontologyFragmentURL; } + + public OWLOntology getOWLAPIOntology() { + return fragment; + } public boolean isUseCache() { return configurator.getUseCache(); Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-23 23:06:40 UTC (rev 1243) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-23 23:24:34 UTC (rev 1244) @@ -206,7 +206,7 @@ url = ((OWLFile)source).getURL(); } else if(source instanceof SparqlKnowledgeSource) { - url=((SparqlKnowledgeSource)source).getNTripleURL(); + url=((SparqlKnowledgeSource)source).getOntologyFragmentURL(); } try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |