处理未声明的 属性 in load ontology 就像在 Protege 中一样

Handling undeclared property in load ontology like in Protege

如何在 java 中使用 owlapi 重现 Protege 加载 ontology 的方式? 就像我使用时一样:

ontologyBase = ontologyManager.loadOntologyFromOntologyDocument(inFile);

结果:

[main] WARN org.semanticweb.owlapi.rdf.rdfxml.parser.Translators - Property http://www.example.com/individual/prp#keyPA is undeclared at this point in parsing: typing as OWLDataProperty
[main] WARN org.semanticweb.owlapi.rdf.rdfxml.parser.Translators - Property http://www.example.com/individual/prp#keyPB is undeclared at this point in parsing: typing as OWLDataProperty

未声明的 属性 被声明为 OWLDataProperty,但 Protege 加载 ontology 导致将其声明为 OWLAnnotationProperty。

编辑: Ontology:

<http://www.example.com/individual/prp#keyC> <http://www.w3.org/2002/07/owl#hasKey> <http://www.example.com/individual/prp#keyU> .
<http://www.example.com/individual/prp#keyU> <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://www.example.com/individual/prp#keyPA> .
<http://www.example.com/individual/prp#keyU> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.example.com/individual/prp#keyEA> .
<http://www.example.com/individual/prp#keyEA> <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://www.example.com/individual/prp#keyPB> .
<http://www.example.com/individual/prp#keyEA> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
<http://www.example.com/individual/prp#keyX> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.example.com/individual/prp#keyC> .
<http://www.example.com/individual/prp#keyX> <http://www.example.com/individual/prp#keyPA> <http://www.example.com/individual/prp#keyZA> .
<http://www.example.com/individual/prp#keyX> <http://www.example.com/individual/prp#keyPB> <http://www.example.com/individual/prp#keyZB> .
<http://www.example.com/individual/prp#keyY> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.example.com/individual/prp#keyC> .
<http://www.example.com/individual/prp#keyY> <http://www.example.com/individual/prp#keyPA> <http://www.example.com/individual/prp#keyZA> .
<http://www.example.com/individual/prp#keyY> <http://www.example.com/individual/prp#keyPB> <http://www.example.com/individual/prp#keyZB> .

从你的例子ontology解析出的公理如下:

HasKey(<http://www.example.com/individual/prp#keyC> () (<http://www.example.com/individual/prp#keyPA> <http://www.example.com/individual/prp#keyPB> ))
ClassAssertion(<http://www.example.com/individual/prp#keyC> <http://www.example.com/individual/prp#keyX>)
ClassAssertion(<http://www.example.com/individual/prp#keyC> <http://www.example.com/individual/prp#keyY>)
AnnotationAssertion(<http://www.example.com/individual/prp#keyPA> <http://www.example.com/individual/prp#keyY> <http://www.example.com/individual/prp#keyZA>)
AnnotationAssertion(<http://www.example.com/individual/prp#keyPA> <http://www.example.com/individual/prp#keyX> <http://www.example.com/individual/prp#keyZA>)
AnnotationAssertion(<http://www.example.com/individual/prp#keyPB> <http://www.example.com/individual/prp#keyY> <http://www.example.com/individual/prp#keyZB>)
AnnotationAssertion(<http://www.example.com/individual/prp#keyPB> <http://www.example.com/individual/prp#keyX> <http://www.example.com/individual/prp#keyZB>)

警告是关于临时键入为数据属性的未声明属性。解析器猜测,如果没有发现公理反驳类型猜测,则类型将被保留。但在这种情况下并没有发生(使用个人作为 属性 的对象),因此猜测被丢弃。

换句话说,您的代码正在像 Protege 一样解析 ontology。