|
From: <jen...@us...> - 2008-10-11 10:22:13
|
Revision: 1366
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1366&view=rev
Author: jenslehmann
Date: 2008-10-11 10:22:01 +0000 (Sat, 11 Oct 2008)
Log Message:
-----------
bug fix for scrobble.conf
Modified Paths:
--------------
trunk/examples/sparql/scrobble.conf
trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java
Removed Paths:
-------------
trunk/examples/sparql/musicbrainz.conf
Deleted: trunk/examples/sparql/musicbrainz.conf
===================================================================
--- trunk/examples/sparql/musicbrainz.conf 2008-10-11 09:24:11 UTC (rev 1365)
+++ trunk/examples/sparql/musicbrainz.conf 2008-10-11 10:22:01 UTC (rev 1366)
@@ -1,48 +0,0 @@
-
-
-/**
-
- http://www.govtrack.us/sparql.xpd?query=SELECT * WHERE { <http://www.rdfabout.com/rdf/usgov/congress/people/A000360> ?predicate ?object. FILTER( (!isLiteral(?object))).}
-
-**/
-
-sparql.recursionDepth = 4;
-sparql.predefinedEndpoint = "MUSICBRAINZ";
-sparql.predefinedFilter = "YAGO";
-
-sparql.useLits=true;
-
-algorithm = refexamples;
-//reasoner = owlAPIReasoner;
- reasoner = fastInstanceChecker;
-
-
- refexamples.useAllConstructor = false;
- refexamples.useExistsConstructor = true;
- refexamples.useCardinalityRestrictions = false;
-refexamples.useNegation = false;
-
-import("http://dbtune.org/musicbrainz/sparql","SPARQL");
-
-
-/**
-sparql.instances = {
-"http://zitgist.com/music/artist/a066b730-3809-4b39-a091-2297d40b51db",
-"http://zitgist.com/music/artist/cf0f4547-ffbd-4011-98ad-0bec9ba022db"
-};
-
-+"http://zitgist.com/music/artist/a066b730-3809-4b39-a091-2297d40b51db"
--"http://zitgist.com/music/artist/cf0f4547-ffbd-4011-98ad-0bec9ba022db"
-
-
-http://dbtune.org/musicbrainz/resource/track/
-**/
-
-sparql.instances = {
-"http://dbtune.org/musicbrainz/resource/artist/a066b730-3809-4b39-a091-2297d40b51db",
-"http://dbtune.org/musicbrainz/resource/artist/cf0f4547-ffbd-4011-98ad-0bec9ba022db"
-};
-
-+"http://dbtune.org/musicbrainz/resource/artist/a066b730-3809-4b39-a091-2297d40b51db"
--"http://dbtune.org/musicbrainz/resource/artist/cf0f4547-ffbd-4011-98ad-0bec9ba022db"
-
Modified: trunk/examples/sparql/scrobble.conf
===================================================================
--- trunk/examples/sparql/scrobble.conf 2008-10-11 09:24:11 UTC (rev 1365)
+++ trunk/examples/sparql/scrobble.conf 2008-10-11 10:22:01 UTC (rev 1366)
@@ -19,8 +19,6 @@
sparql.recursionDepth = 3;
sparql.predefinedEndpoint = "MUSICBRAINZ";
-// sparql.useLits=true;
-
algorithm = refexamples;
refexamples.useNegation = false;
refexamples.useAllConstructor = false;
Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java
===================================================================
--- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-10-11 09:24:11 UTC (rev 1365)
+++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-10-11 10:22:01 UTC (rev 1366)
@@ -197,6 +197,7 @@
Set<OWLIndividual> owlIndividuals = new TreeSet<OWLIndividual>(namedObjectComparator);
Set<OWLOntology> allImports = new HashSet<OWLOntology>();
+ prefixes = new TreeMap<String,String>();
for(KnowledgeSource source : sources) {
@@ -204,35 +205,18 @@
URL url=null;
if(source instanceof OWLFile){
url = ((OWLFile)source).getURL();
- }
- else if(source instanceof SparqlKnowledgeSource) {
- source = new OWLAPIOntology(((SparqlKnowledgeSource)source).getOWLAPIOntology());
- //url=((SparqlKnowledgeSource)source).getOntologyFragmentURL();
}
try {
- if(source instanceof OWLAPIOntology)
- {
- OWLOntology ontology = ((OWLAPIOntology)source).getOWLOntolgy();
- owlAPIOntologies.add(ontology);
- allImports.addAll(manager.getImportsClosure(ontology));
- classes.addAll(ontology.getReferencedClasses());
- owlObjectProperties.addAll(ontology.getReferencedObjectProperties());
- owlDatatypeProperties.addAll(ontology.getReferencedDataProperties());
- owlIndividuals.addAll(ontology.getReferencedIndividuals());
-
- // TODO: this obviously works only for exactly one knowledge source
- OWLOntologyFormat format = manager.getOntologyFormat(ontology);
- if(format instanceof NamespaceOWLOntologyFormat)
- {
- prefixes = ((NamespaceOWLOntologyFormat)format).getNamespacesByPrefixMap();
- baseURI = prefixes.get("");
- prefixes.remove("");
- }
+ OWLOntology ontology;
+ if(source instanceof OWLAPIOntology) {
+ ontology = ((OWLAPIOntology)source).getOWLOntolgy();
+ } else if (source instanceof SparqlKnowledgeSource) {
+ ontology = ((SparqlKnowledgeSource)source).getOWLAPIOntology();
+ } else {
+ ontology = manager.loadOntologyFromPhysicalURI(url.toURI());
}
- else
- {
- OWLOntology ontology = manager.loadOntologyFromPhysicalURI(url.toURI());
+
owlAPIOntologies.add(ontology);
allImports.addAll(manager.getImportsClosure(ontology));
classes.addAll(ontology.getReferencedClasses());
@@ -240,17 +224,18 @@
owlDatatypeProperties.addAll(ontology.getReferencedDataProperties());
owlIndividuals.addAll(ontology.getReferencedIndividuals());
- // TODO: this obviously works only for exactly one knowledge source
+ // if several knowledge sources are included, then we can only
+ // guarantee that the base URI is from one of those sources (there
+ // can't be more than one); but we will take care that all prefixes are
+ // correctly imported
OWLOntologyFormat format = manager.getOntologyFormat(ontology);
if(format instanceof NamespaceOWLOntologyFormat) {
- prefixes = ((NamespaceOWLOntologyFormat)format).getNamespacesByPrefixMap();
+ prefixes.putAll(((NamespaceOWLOntologyFormat)format).getNamespacesByPrefixMap());
baseURI = prefixes.get("");
prefixes.remove("");
}
- }
- }
- catch (OWLOntologyCreationException e) {
+ } catch (OWLOntologyCreationException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
@@ -315,12 +300,21 @@
boolean inconsistentOntology = false;
try {
reasoner.loadOntologies(allImports);
+
+ // OWL API bug: if we test an ontology for consistency, then
+ // this ontology is automatically used for all subsequent
+ // reasoning tasks (and all others ignored)
+ boolean owlAPIbuggy = true; // remove once this problem has been resolved in OWL API
+ if(!owlAPIbuggy || sources.size() < 2) {
for(OWLOntology ont : owlAPIOntologies) {
+ System.out.println(ont);
if(!reasoner.isConsistent(ont)) {
inconsistentOntology = true;
throw new ComponentInitException("Inconsistent ontologies.");
}
}
+ }
+
if(!inconsistentOntology) {
reasoner.classify();
reasoner.realise();
@@ -364,8 +358,10 @@
}
datatypeProperties.add(dtp);
}
- for(OWLIndividual owlIndividual : owlIndividuals)
+ for(OWLIndividual owlIndividual : owlIndividuals) {
individuals.add(new Individual(owlIndividual.getURI().toString()));
+ }
+
}
/* (non-Javadoc)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|