2016-12-01 5 views
1

Ich muss eine Ontologie lesen, mit OWLAPI; Ich benutze diese JAVA-Code:OWLOntology readOntology erstellt AnnotationProperty

public class OwlApi { 

public static void main(String[] args) throws OWLOntologyCreationException, FileNotFoundException { 
     OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); 
     File file = new File("myfile"); 
     InputStream targetStream = new FileInputStream(file); 
     OWLOntology ontology = manager.loadOntologyFromOntologyDocument(targetStream);  
} 
} 

Meine Datei ist eine einfache Schildkröte Datei, wie folgt aus:

@prefix xml: <http://www.w3.org/XML/1998/namespace> . 
@prefix : <platform:/resource/test/OWL/prova#> . 
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . 
@prefix owl: <http://www.w3.org/2002/07/owl#> . 
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . 
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . 

<platform:/resource/test/OWL/prova> a owl:Ontology . 

:proprietao a owl:ObjectProperty ; 
rdfs:domain :classeuno ; 
rdfs:range <http://dbpedia.org/ontology/PopulatedPlace> . 

:proprietad a owl:DatatypeProperty ; 
rdfs:domain <http://dbpedia.org/ontology/PopulatedPlace> ; 
rdfs:range xsd:string . 

:classeuno a owl:Class . 

Die outuput der Laden der Datei ist diese:

Ontology(OntologyID(OntologyIRI(<platform:/resource/test/OWL/prova>) VersionIRI(<null>))) [Axioms: 7 Logical Axioms: 3] First 20 axioms: {DataPropertyRange(<platform:/resource/test/OWL/prova#proprietad> xsd:string) DataPropertyRange(<platform:/resource/test/OWL/prova#proprietao> <http://dbpedia.org/ontology/PopulatedPlace>) Declaration(ObjectProperty(<platform:/resource/test/OWL/prova#proprietao>)) Declaration(DataProperty(<platform:/resource/test/OWL/prova#proprietad>)) Declaration(Class(<platform:/resource/test/OWL/prova#classeuno>)) AnnotationPropertyDomain(<platform:/resource/test/OWL/prova#proprietad> <http://dbpedia.org/ontology/PopulatedPlace>) ObjectPropertyDomain(<platform:/resource/test/OWL/prova#proprietao> <platform:/resource/test/OWL/prova#classeuno>) } 

I don verstehe nicht warum erscheint eine AnnotationPropertyDomain über die DataProperty.

Mache ich etwas falsch? Vielen Dank.

Antwort

2

Das passiert, weil http://dbpedia.org/ontology/PopulatedPlace nicht als owl:Class deklariert ist und der Parser sehr streng ist. In OWL müssen Sie alle Entitäten explizit eingeben.

+0

Danke für Ihre Antwort, Sie haben Recht! Wenn ich also in meiner benutzerdefinierten Ontologie auch owl: ObjectProperty oder owl: DatatypeProperty von externer Ontologie (wie DBpedia) verwenden muss, muss ich das auf die gleiche Weise deklarieren, oder? Was ist stattdessen mit Ontologie importieren? Ist es ausreichend, den Namespace zu deklarieren und Klassen oder Eigenschaften aus importierten Ontologien wiederzuverwenden? –

+0

Ja, für jede Entität wird empfohlen, ihren Typ explizit anzugeben. Wenn Sie eine Ontologie "A" importieren, sollte sie in "A" enthalten sein und daher ausreichen, um sie nur in Ihrer Ontologie zu "verwenden". – AKSW