OWLOntology readOntology创建AnnotationProperty

时间:2016-12-01 16:55:38

标签: java owl semantics owl-api turtle-rdf

我必须使用OWLAPI阅读本体论;我使用这个JAVA代码:

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);      
}
}

我的文件是一个简单的海龟文件,如下所示:

@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 .

加载文件的输出是这样的:

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>) }

我不明白为什么会出现关于DataProperty的 AnnotationPropertyDomain

我做错了吗? 非常感谢。

1 个答案:

答案 0 :(得分:2)

这是因为http://dbpedia.org/ontology/PopulatedPlace未声明为owl:Class且解析器非常严格。在OWL中,您必须明确键入所有实体。