2017-11-24 11 views
0

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:institutionOWL 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 *:

+0

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

+0

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

+0

Zuletzt, was erwarten Sie in Ihrem Beispiel? – AKSW

Antwort

2

Ihre ganze Ontologie ist seltsam:

  1. Sie die DBpedia Ontologie Wiederverwendung in der dbo:Place ist bereits als eine Klasse definiert, aber du bist Verwenden Sie es als Objekteigenschaft.
  2. Als Nächstes haben Sie den Bereich dieser Objekteigenschaft als dbo:Event deklariert. Semantisch klingt das auch seltsam.
  3. Sie haben ein Triple, das dbo:Place einer Instanz der Klasse dbo:EducationalInstitution zuweist. Das heißt, am Ende ist dbo:Place eine Klasse, eine Eigenschaft und eine Person. Das ist wirklich schlechtes Modellieren.

Andere Konventionen:

  • Wiederverwendung von Ontologien ist gut, aber man sollte nicht den Namespace wiederverwenden, sondern verwenden einen eigenen Namensraum
  • Namenskonvention:
    • für Klassen Camelcase-Stil
    • für Eigenschaften niedrigerCamelCase Stil

Warum nicht eine geeignetere Modellierung wie folgt verwenden:

@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 owl: <http://www.w3.org/2002/07/owl#> . 

dbo:Event rdf:type owl:Class . 
ex:takesPlaceAt rdf:type owl:ObjectProperty ; 
      rdfs:domain dbo:Event ; 
      rdfs:range dbo:Place . 
ex:Institution rdf:type owl:Class . 
ex:EducationalInstitution rdf:type owl:Class ; 
          rdfs:subClassOf ex:Institution . 
dbo:EducationalInstitution rdfs:subClassOf dbo:Place . 

In Bezug auf die Daten:

_:b0 dbf:Ville     "Rouen" ; 
    rdf:type ex:EducationalInstitution ; 
     foaf:name     "Université du Havre" . 

DBpedia Ontologie hat propertiesThat ist sicher falsch.

  • dbf:Ville ist nicht eine Eigenschaft, sondern ein Individuum. Warum benutzt du es als Eigentum? Die Dbpedia-Ontologie hat eine Eigenschaft dbo:city. Und die Ressource für Rouen existiert bereits.

Vielleicht könnte man es so machen:

@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 dbr: <http://dbpedia.org/resource/> . 
@prefix foaf: <http://xmlns.com/foaf/0.1/> . 

<0762762P> rdf:type dbo:Event ; 
     dbo:status "En cours" ; 
     dbo:Place _:b0 . 

_:b0 dbo:city     http://dbpedia.org/resource/Rouen ; 
    rdf:type ex:EducationalInstitution ; 
     foaf:name     "Université du Havre" . 
Verwandte Themen