Ich versuche OWL Rückschlüsse auf Jena zu machen. Als Start, ist mein Ziel, nur, dass zu schließen, wenn eine Bildungseinrichtung vom Typ dbo:EducationalInstitution
, dann auch es dbo:institution
OWL Inferenz mit Jena (Turtle Format)
ist Hier ist der Java-Code (aus dem jena doc angepasst):
package test;
import org.apache.jena.util.FileManager;
import org.apache.jena.util.PrintUtil;
import org.apache.jena.rdf.model.*;
import org.apache.jena.reasoner.Reasoner;
import org.apache.jena.reasoner.ReasonerRegistry;
public class Test {
public static void main(String[] args){
Model schema = FileManager.get().loadModel("file:/home/mica/Downloads/sparql/ontology.ttl");
Model data = FileManager.get().loadModel("file:/home/mica/Downloads/sparql/result.ttl");
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
reasoner = reasoner.bindSchema(schema);
InfModel infmodel = ModelFactory.createInfModel(reasoner, data);
Resource nForce = infmodel.getResource("<0762762P>");
System.out.println(nForce);
System.out.println("nForce *:");
printStatements(infmodel, nForce, null, null);
}
public static void printStatements(Model m, Resource s, Property p, Resource o) {
for (StmtIterator i = m.listStatements(s,p,o); i.hasNext();) {
Statement stmt = i.nextStatement();
System.out.println(" - " + PrintUtil.print(stmt));
}
}
}
Ein Beispiel meiner Daten:
@prefix dbo: <http://dbpedia.org/ontology/> .
@prefix ex: <http://ex.org/a#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dbf: <http://fr.dbpedia.org/resource/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<0762762P> rdf:type dbo:Event ;
dbo:status "En cours" ;
dbo:Place _:b0 .
_:b0 dbf:Ville "Rouen" ;
rdf:type dbo:EducationalInstitution ;
foaf:name "Université du Havre" .
und die folgende Ontologie:
@prefix dbo: <http://dbpedia.org/ontology/> .
@prefix ex: <http://ex.org/a#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#'> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dbf: <http://fr.dbpedia.org/resource/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
dbo:Event rdf:type owl:Class .
dbo:Place rdf:type owl:ObjectProperty ;
rdfs:domain dbo:Event ;
rdfs:range dbo:Event .
dbo:institution rdf:type owl:Class .
dbo:EducationalInstitution rdf:type owl:Class ;
rdfs:subClassOf dbo:institution .
dbo:Place rdf:type dbo:EducationalInstitution .
Ich bin nicht die erwarteten Ergebnisse zu erzielen: nForce *:
Ihr Schema seltsam. 1. 'dbo: Place' als Klasse in der DBpedia-Ontologie. 2.In Ihrer Ontologie haben Sie es als Objekt-Eigenschaft deklariert, ok. Aber dann hast du dieses Triple 'dbo: Place rdf: type dbo: EducationalInstitution 'hinzugefügt. Das macht' dbo: Place 'auch zu einer OWL-Person. Warum? – AKSW
Als nächstes verwenden Sie relative URIs, was eine schlechte Praxis ist, da diese zu absoluten URIs aufgelöst werden, die normalerweise den Dokument-URI als Namespace verwenden. Sie sollten mit absoluten URIs beginnen und prüfen, ob damit Ihr Problem bereits gelöst ist. – AKSW
Zuletzt, was erwarten Sie in Ihrem Beispiel? – AKSW