1

让我们以公理为例 SubClassOf( DataAllValuesFrom( <d> xsd:boolean ) ObjectSomeValuesFrom( <o> owl:Thing ) Annotation( rdfs:comment "comm"^^xsd:string ) )

这个公理在 RDF 的形式中应该是什么样子?

如果我正确理解规范,则只有一种方法:

示例 1

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

<o>     a       owl:ObjectProperty .

[ a                      owl:Axiom ;
  rdfs:comment           "comm" ;
  owl:annotatedProperty  rdfs:subClassOf ;
  owl:annotatedSource    [ a                  owl:Restriction ;
                           rdfs:subClassOf    _:c2 ;
                           owl:allValuesFrom  xsd:boolean ;
                           owl:onProperty     <d>
                         ] ;
  owl:annotatedTarget    _:c2
] .

<d>     a       owl:DatatypeProperty .

_:c2    a                   owl:Restriction ;
        owl:onProperty      <o> ;
        owl:someValuesFrom  owl:Thing .

但是,突然发现有些人以不同的方式理解规范。上面的公理可能甚至必须写成如下:

示例 2

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

<o>     a       owl:ObjectProperty .

<d>     a       owl:DatatypeProperty .

[ a                      owl:Axiom ;
  rdfs:comment           "comm" ;
  owl:annotatedProperty  rdfs:subClassOf ;
  owl:annotatedSource    [ a                   owl:Restriction ;
                           rdfs:subClassOf     [ a                  owl:Restriction ;
                                                 owl:allValuesFrom  owl:Thing ;
                                                 owl:onProperty     <o>
                                               ] ;
                           owl:onProperty      <d> ;
                           owl:someValuesFrom  xsd:boolean
                         ] ;
  owl:annotatedTarget    [ a                  owl:Restriction ;
                           owl:allValuesFrom  owl:Thing ;
                           owl:onProperty     <o>
                         ]
] .

那么,问题来了,谁是对的?哪个例子是正确的?

在我看来,第二个 RDF(示例 2)违反了对 RDF 物化和数据连接性的理解。但我无法将这一点传达给对手。我有基于规范的论据(稍后可能会作为答案提供),但这些论据在他眼中是站不住脚的,所以我呼吁这里的广泛专家获得新的论据,或者,也许,改进我自己对这个概念的看法:没有人(除了我)说示例 1 是唯一正确的方法。
因此,如果有规范,获得第一个(或第二个)示例正确的证明,那就太好了。

如果我理解正确,我的对手诉诸规范中的以下短语:
In the mapping, each generated blank node (i.e., each blank node that does not correspond to an anonymous individual) is fresh in each application of a mapping rule.. 他认为,这意味着超类ObjectSomeValuesFrom( <o> owl:Thing )在写入 RDF 时必须两次获得 b 节点。
如何证明这不是真的(或真的)?

谢谢你。

4

1 回答 1

3

所以,由于还没有答案,这里是我自己的,这是基于我对官方规范https://www.w3.org/TR/owl2-mapping-to-rdf/的理解。欢迎任何意见和改进。


一、简介

规范只定义了运算符T(E)and TANN(ann, y), where annis Annotation( AP av ), Eandy是一些对象。该规范还说:The definition of the operator T uses the operator TANN in order to translate annotations. 对于该部分2.1 Translation of Axioms without Annotations 和该部分中描述的操作,2.3 Translation of Axioms with Annotations没有自己的名称。操作符在, sectionTANN中定义,但它是注解的注解,它产生一个根为三元组的 b 节点。使用根三元组创建顶级注释的运算符在 部分中进行了描述,但也没有正确的名称。而且,为了演示,我将为这个“操作员”引入一个新名称:. 注 1:不要将其与本节中的功能混淆Table 22.2 Translation of Annotations_:x rdf:type owl:Annotation_: x rdf: type owl: Axiom2.3.1 Axioms that Generate a Main TripleANNANN3.2.2 Parsing of Annotations- 我们不需要最后一件事;这个答案只是关于映射,而不是解析。注意 2:我不是在写我自己的规范,我只是想用新的缩写来解释我的愿景。在一般情况下,这种注入可能不正确,但出于演示目的,我认为它是可以的。

此外,让我们将公理SubClassOf视为具有两个操作数的运算符。它在Table 1from the section2.1 Translation of Axioms without Annotations这样描述:

SubClassOf( CE1 CE2 ) = T(CE1) rdfs:subClassOf T(CE2) .

SubClassOf让我们还考虑一个具有两个操作数和 vararg 注释的重载运算符。在SubClassOf( CE1 CE2 annotations { n > 1 } )部分中定义2.3.1 Axioms that Generate a Main Triple如下:

s p xlt .
_:x rdf:type owl:Axiom .
_:x owl:annotatedSource s .
_:x owl:annotatedProperty p .
_:x owl:annotatedTarget xlt .
TANN(annotation1, _:x)
...
TANN(annotationm, _:x) 

为简单起见,让我们讨论一种只有一个顶级注释的情况。因此,该运算符是SubClassOf( CE1, CE2, ann),它看起来像这样:

T(CE1) rdfs:subClassOf T(CE2) .
ANN(CE1, CE2, rdfs:subClassOf, ann) .

这是一个 new 运算符ANN,它类似于TANN,但接受两个操作数,注释和常量,用于定义谓词。它产生根三元组_:x rdf:type owl:Axiom,所有其他三元组都类似于TANN上面示例中运算符的三元组,所以ANN(s, xlt, p, ann)是:

_:x rdf:type owl:Axiom .
_:x owl:annotatedSource s .
_:x owl:annotatedProperty p .
_:x owl:annotatedTarget xlt .
TANN(ann, _:x)

2. 没有注释的本体。

现在让我们考虑第一个操作数在哪里,DataAllValuesFrom第二个是ObjectSomeValuesFrom

SubClassOf( DataAllValuesFrom( <d> xsd:boolean ) ObjectSomeValuesFrom( <o> owl:Thing ) ) .

TURTLE中,它看起来像这样:

<d>     a       owl:DatatypeProperty .
<o>     a       owl:ObjectProperty .
[ rdf:type owl:Restriction ;
                        owl:onProperty <d> ;
                        owl:allValuesFrom xsd:boolean ;
                        rdfs:subClassOf [ rdf:type owl:Restriction ;
                                          owl:onProperty <o> ;
                                          owl:someValuesFrom owl:Thing
                                        ]
                      ] ;

或者NTRIPLES语法中的相同本体:

<d> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#DatatypeProperty> .
<o> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#ObjectProperty> .
_:c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> _:c2 .
_:c1 <http://www.w3.org/2002/07/owl#allValuesFrom> <http://www.w3.org/2001/XMLSchema#boolean> .
_:c1 <http://www.w3.org/2002/07/owl#onProperty> <d> .
_:c1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
_:c2 <http://www.w3.org/2002/07/owl#someValuesFrom> <http://www.w3.org/2002/07/owl#Thing> .
_:c2 <http://www.w3.org/2002/07/owl#onProperty> <o> .
_:c2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .

SubClassOf是一个生成主三元组的公理(参见 节2.3.1 Axioms that Generate a Main Triple)。所以,s p xlt这里的主要三元组 () 是_:c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> _:c2,其中s(主语,在示例中DataAllValuesFrom( <d> xsd:boolean )) 是_:c1p(谓词) 是rdfs:subClassOfxlt(xlt代表空白节点、IRI 或文字,这里是宾语,在例子ObjectSomeValuesFrom( <o> owl:Thing ))是_:c2

注意,在ONT-API中,这样的 TURTLE 可以通过以下代码生成:

OntModel m = OntModelFactory.createModel().setNsPrefixes(OntModelFactory.STANDARD);
m.createDataAllValuesFrom(m.createDataProperty("d"), m.getDatatype(XSD.xboolean))
    .addSuperClass(m.createObjectSomeValuesFrom(m.createObjectProperty("o"), 
    m.getOWLThing()));
m.write(System.out, "ttl");

3.操作者的行为T

规范说:In the mapping, each generated blank node (i.e., each blank node that does not correspond to an anonymous individual) is fresh in each application of a mapping rule.。我相信这只是关于运营商T该声明与Parsing OWL, Structure Sharing, OWL1 spec中所说的大致匹配: In practice, this means that blank nodes (i.e. those with no name) which are produced during the transformation and represent arbitrary expressions in the abstract syntax form should not be "re-used".。在一般情况下,ONT-API 和 OWL-API 都不是问题,所有这些事情的行为都相似。以下代码为 OWL-API(默认实现)和 ONT-API(使用 OWL-API 接口)生成相同的 RDF:

OWLOntologyManager m = OntManagers.createONT();
OWLDataFactory df = m.getOWLDataFactory();
OWLClassExpression ce = df.getOWLObjectComplementOf(df.getOWLThing());
OWLOntology o = m.createOntology();            
o.add(df.getOWLSubClassOfAxiom(ce, ce));
o.saveOntology(OntFormat.TURTLE.createOwlFormat(), System.out);

ObjectComplementOf( owl:Thing )对于作为操作数的两个相等的类表达式,SubClassOf( CE1, CE2 )将有两个不同的 b 节点。因此,没有人质疑 OWL中没有对象共享这一事实。
但是,在我看来,这一定不适用于公理和它的注释之间的关系,这是 operator 的情况ANN,见下一段。


4.1 生成主三元组的带注释公理。与SPO.

现在让我们以我认为唯一正确的方式Annotation( rdfs:comment "comm" )SubClassOf( DataAllValuesFrom( <d> xsd:boolean ) ObjectSomeValuesFrom( <o> owl:Thing ) )(参见前面的第2段)添加注释。请记住,操作员会SubClassOf(CE1, CE2, ann)生成以下 ttl:

T(CE1) rdfs:subClassOf T(CE2) .
ANN(CE1, CE2, rdfs:subClassOf, ann) .

或者

s p xlt .
_:x rdf:type owl:Axiom .
_:x owl:annotatedSource s .
_:x owl:annotatedProperty p .
_:x owl:annotatedTarget xlt .
TANN(ann, _:x)

这里,三元组s p xlt是应用 operator 的结果SubClassOf(CE1, CE2)。从Table 2, 部分2.2 Translation of Annotations,运算符TANN(Annotation( AP av ), _:x)forAnnotation( rdfs:comment "comm"^^xsd:string )将给出三元组_:x rdfs:comment "comm"^^xsd:string,所以我们有 ( SubClassOf(CE1, CE2, Annotation( rdfs:comment "comm"^^xsd:string ))):

s p xlt .
_:x rdf:type owl:Axiom .
_:x owl:annotatedSource s .
_:x owl:annotatedProperty p .
_:x owl:annotatedTarget xlt .
_:x rdfs:comment "comm"^^xsd:string .

这里的三元组s p xlt_:c1 rdfs:subClassOf _:c2(见第2段);所以最后我们得到以下带注释的公理:

_:c1 rdfs:subClassOf _:c2 .
_:x rdfs:comment "comm"^^xsd:string .
_:x rdf:type owl:Axiom .
_:x owl:annotatedSource _:c1 .
_:x owl:annotatedProperty rdfs:subClassOf .
_:x owl:annotatedTarget _:c2 .

NTRIPLES语法中的完整本体(没有本体 id)如下所示:

<o> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#ObjectProperty> .
<d> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#DatatypeProperty> .
_:x <http://www.w3.org/2000/01/rdf-schema#comment> "comm" .
_:x <http://www.w3.org/2002/07/owl#annotatedTarget> _:c2 .
_:x <http://www.w3.org/2002/07/owl#annotatedProperty> <http://www.w3.org/2000/01/rdf-schema#subClassOf> .
_:x <http://www.w3.org/2002/07/owl#annotatedSource> _:c1 .
_:x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Axiom> .
_:c2 <http://www.w3.org/2002/07/owl#someValuesFrom> <http://www.w3.org/2002/07/owl#Thing> .
_:c2 <http://www.w3.org/2002/07/owl#onProperty> <o> .
_:c2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
_:c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> _:c2 .
_:c1 <http://www.w3.org/2002/07/owl#allValuesFrom> <http://www.w3.org/2001/XMLSchema#boolean> .
_:c1 <http://www.w3.org/2002/07/owl#onProperty> <d> .
_:c1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .

或在TURTLE中相同:

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

<o>     a       owl:ObjectProperty .

[ a                      owl:Axiom ;
  rdfs:comment           "comm" ;
  owl:annotatedProperty  rdfs:subClassOf ;
  owl:annotatedSource    [ a                  owl:Restriction ;
                           rdfs:subClassOf    _:c2 ;
                           owl:allValuesFrom  xsd:boolean ;
                           owl:onProperty     <d>
                         ] ;
  owl:annotatedTarget    _:c2
] .

<d>     a       owl:DatatypeProperty .

_:c2    a                   owl:Restriction ;
        owl:onProperty      <o> ;
        owl:someValuesFrom  owl:Thing .

三元组_:c1 rdfs:subClassOf _:c2( SPO) 出现在图中并有其具体化:

_:x owl:annotatedTarget _:c2 .
_:x owl:annotatedProperty rdfs:subClassOf .
_:x owl:annotatedSource _:c1 .

请注意,此本体可以通过以下代码生成:

OntModel m = OntModelFactory.createModel().setNsPrefixes(OntModelFactory.STANDARD);
m.createDataAllValuesFrom(m.createDataProperty("d"), m.getDatatype(XSD.xboolean))
        .addSubClassOfStatement(m.createObjectSomeValuesFrom(m.createObjectProperty("o"), m.getOWLThing()))
        .annotate(m.getRDFSComment(), "comm");
m.write(System.out, "ttl");
System.out.println(".......");
m.write(System.out, "nt");

4.2 生成主三元组的带注释公理。与(S*)P(O*).

好吧,规范也这么说In the mapping, each generated blank node (i.e., each blank node that does not correspond to an anonymous individual) is fresh in each application of a mapping rule。这与运算符有关,T但与运算符TANN,或无关。但是运算符由and ( ) 组成,因此它们还必须为每个操作数隐式生成一个空白节点。我提醒一下,运营商最初(见第1页)如下所示:ANNSubClassOf(CE1, CE2)SubClassOf(CE1, CE2, ann)SubClassOfTANNTANNSubClassOf(CE1, CE2, ann)

T(CE1) rdfs:subClassOf T(CE2) .
ANN(CE1, CE2, rdfs:subClassOf, ann) .

但它的第二部分 - 操作符实际上应该发生什么仍然不完全清楚ANN(CE1, CE2, rdfs:subClassOf, ann)。让我们采用我的对手的假设(据我所知),即使在包括其所有注释层次树的整个公理中也不得共享类表达式。这对于运营商来说绝对是正确的,对于运营商来说是SubClassOf(CE1, CE2)错误的,对于运营商TANN来说是争议的主题ANN(包括TANN)。但是为了实验,我们假设该规则也必须适用于ANN操作数。所以,SubClassOf(CE1, CE2, ann)现在定义如下:

SubClassOf(CE1, CE2) .
ANN(T(CE1), T(CE2), rdfs:subClassOf, ann) .

或者

T(CE1) rdfs:subClassOf T(CE2) .
ANN(T(CE1), T(CE2), rdfs:subClassOf, ann) .

SubClassOf(CE1, CE2)给出以下NTRIPLES(参见第2页):

<d> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#DatatypeProperty> .
<o> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#ObjectProperty> .
_:c2 <http://www.w3.org/2002/07/owl#someValuesFrom> <http://www.w3.org/2002/07/owl#Thing> .
_:c2 <http://www.w3.org/2002/07/owl#onProperty> <o> .
_:c2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
_:c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> _:c2 .
_:c1 <http://www.w3.org/2002/07/owl#allValuesFrom> <http://www.w3.org/2001/XMLSchema#boolean> .
_:c1 <http://www.w3.org/2002/07/owl#onProperty> <d> .
_:c1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .

这里,b 节点_:c1对应于类表达式DataAllValuesFrom( <d> xsd:boolean ),b 节点_:c2对应于ObjectSomeValuesFrom( <o> owl:Thing )

然后我们TANN主题(第一个操作数T(CE1))做:

_:b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
_:b1 <http://www.w3.org/2002/07/owl#allValuesFrom> <http://www.w3.org/2001/XMLSchema#boolean> .
_:b1 <http://www.w3.org/2002/07/owl#onProperty> <d> .

对于对象(第二个操作数T(CE2)):

_:b2 <http://www.w3.org/2002/07/owl#someValuesFrom> <http://www.w3.org/2002/07/owl#Thing> .
_:b2 <http://www.w3.org/2002/07/owl#onProperty> <o> .
_:b2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .

并打印ANN自己:

_:x <http://www.w3.org/2000/01/rdf-schema#comment> "comm" .
_:x <http://www.w3.org/2002/07/owl#annotatedTarget> _:b2 .
_:x <http://www.w3.org/2002/07/owl#annotatedProperty> <http://www.w3.org/2000/01/rdf-schema#subClassOf> .
_:x <http://www.w3.org/2002/07/owl#annotatedSource> _:b1 .
_:x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Axiom> .

注意,现在我们有新的 b 节点CE1CE2(_:b1_:b2- 分别),并且在注释 ( _:x) 中有这两个节点的引用。在注解图结构内部有_:b1, _:b2, not _:c1, _:c2, 只是因为我们首先将运算符T应用于输入类表达式,然后才将结果进一步传递给运算符ANN

完整的本体如下(只是连接上面的所有部分)(NTRIPLES):

<o> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#ObjectProperty> .
<d> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#DatatypeProperty> .
_:c2 <http://www.w3.org/2002/07/owl#someValuesFrom> <http://www.w3.org/2002/07/owl#Thing> .
_:c2 <http://www.w3.org/2002/07/owl#onProperty> <o> .
_:c2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
_:c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> _:c2 .
_:c1 <http://www.w3.org/2002/07/owl#allValuesFrom> <http://www.w3.org/2001/XMLSchema#boolean> .
_:c1 <http://www.w3.org/2002/07/owl#onProperty> <d> .
_:c1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
_:x <http://www.w3.org/2000/01/rdf-schema#comment> "comm" .
_:x <http://www.w3.org/2002/07/owl#annotatedTarget> _:b2 .
_:x <http://www.w3.org/2002/07/owl#annotatedProperty> <http://www.w3.org/2000/01/rdf-schema#subClassOf> .
_:x <http://www.w3.org/2002/07/owl#annotatedSource> _:b1 .
_:x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Axiom> .
_:b2 <http://www.w3.org/2002/07/owl#someValuesFrom> <http://www.w3.org/2002/07/owl#Thing> .
_:b2 <http://www.w3.org/2002/07/owl#onProperty> <o> .
_:b2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
_:b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
_:b1 <http://www.w3.org/2002/07/owl#allValuesFrom> <http://www.w3.org/2001/XMLSchema#boolean> .
_:b1 <http://www.w3.org/2002/07/owl#onProperty> <d> .

或在TURTLE中相同:

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

<o>     a       owl:ObjectProperty .

[ a                  owl:Restriction ;
  rdfs:subClassOf    [ a                   owl:Restriction ;
                       owl:onProperty      <o> ;
                       owl:someValuesFrom  owl:Thing
                     ] ;
  owl:allValuesFrom  xsd:boolean ;
  owl:onProperty     <d>
] .

<d>     a       owl:DatatypeProperty .

[ a                      owl:Axiom ;
  rdfs:comment           "comm" ;
  owl:annotatedProperty  rdfs:subClassOf ;
  owl:annotatedSource    [ a                  owl:Restriction ;
                           owl:allValuesFrom  xsd:boolean ;
                           owl:onProperty     <d>
                         ] ;
  owl:annotatedTarget    [ a                   owl:Restriction ;
                           owl:onProperty      <o> ;
                           owl:someValuesFrom  owl:Thing
                         ]
] .

如您所见,三元组_:c1 rdfs:subClassOf _:c2( SPO) 出现在图中,但没有具体化。取而代之的是对三元组_:b1 rdfs:subClassOf _:b2( (S*)P(O*)) 的具体化,它实际上并不存在于图中:

_:x owl:annotatedTarget _:b2 .
_:x owl:annotatedProperty rdfs:subClassOf .
_:x owl:annotatedSource _:b1 .

由于三元组_:b1 rdfs:subClassOf _:b2不存在,所以在我看来,这个练习展示了无效的行为。


4.3 通过 OWL-API 生成主三元组的注释公理。与SP(O*).

正如您可能猜到的,我的对手为 OWL-API (v5.1.11) 的当前行为辩护。那么让我们看看 OWL-API 做了什么。要生成的代码:

OWLOntologyManager man = OntManagers.createOWL();
OWLDataFactory df = man.getOWLDataFactory();
OWLAxiom a = df.getOWLSubClassOfAxiom(df.getOWLDataSomeValuesFrom(df.getOWLDataProperty("d"),
        df.getBooleanOWLDatatype()),
        df.getOWLObjectAllValuesFrom(df.getOWLObjectProperty("o"), df.getOWLThing()),
        Collections.singletonList(df.getRDFSComment("comm")));
OWLOntology o = man.createOntology();
o.add(a);
o.saveOntology(new TurtleDocumentFormat(), System.out);

NTRIPLES(省略本体 ID):

<o> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#ObjectProperty> .
<d> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#DatatypeProperty> .
_:u <http://www.w3.org/2002/07/owl#allValuesFrom> <http://www.w3.org/2002/07/owl#Thing> .
_:u <http://www.w3.org/2002/07/owl#onProperty> <o> .
_:u <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
_:x <http://www.w3.org/2000/01/rdf-schema#comment> "comm" .
_:x <http://www.w3.org/2002/07/owl#annotatedTarget> _:u .
_:x <http://www.w3.org/2002/07/owl#annotatedProperty> <http://www.w3.org/2000/01/rdf-schema#subClassOf> .
_:x <http://www.w3.org/2002/07/owl#annotatedSource> _:c1 .
_:x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Axiom> .
_:c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> _:c2 .
_:c1 <http://www.w3.org/2002/07/owl#someValuesFrom> <http://www.w3.org/2001/XMLSchema#boolean> .
_:c1 <http://www.w3.org/2002/07/owl#onProperty> <d> .
_:c1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
_:c2 <http://www.w3.org/2002/07/owl#allValuesFrom> <http://www.w3.org/2002/07/owl#Thing> .
_:c2 <http://www.w3.org/2002/07/owl#onProperty> <o> .
_:c2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .

原来的乌龟

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

[ rdf:type owl:Ontology
 ] .

#################################################################
#    Object Properties
#################################################################

###  o
<o> rdf:type owl:ObjectProperty .


#################################################################
#    Data properties
#################################################################

###  d
<d> rdf:type owl:DatatypeProperty .


#################################################################
#    General axioms
#################################################################

[ rdf:type owl:Axiom ;
  owl:annotatedSource [ rdf:type owl:Restriction ;
                        owl:onProperty <d> ;
                        owl:someValuesFrom xsd:boolean ;
                        rdfs:subClassOf [ rdf:type owl:Restriction ;
                                          owl:onProperty <o> ;
                                          owl:allValuesFrom owl:Thing
                                        ]
                      ] ;
  owl:annotatedProperty rdfs:subClassOf ;
  owl:annotatedTarget [ rdf:type owl:Restriction ;
                        owl:onProperty <o> ;
                        owl:allValuesFrom owl:Thing
                      ] ;
  rdfs:comment "comm"
] .


###  Generated by the OWL API (version 5.1.11) https://github.com/owlcs/owlapi/

以及重新格式化的TURTLE(同样,没有本体 id):

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

<o>     a       owl:ObjectProperty .

<d>     a       owl:DatatypeProperty .

[ a                      owl:Axiom ;
  rdfs:comment           "comm" ;
  owl:annotatedProperty  rdfs:subClassOf ;
  owl:annotatedSource    [ a                   owl:Restriction ;
                           rdfs:subClassOf     [ a                  owl:Restriction ;
                                                 owl:allValuesFrom  owl:Thing ;
                                                 owl:onProperty     <o>
                                               ] ;
                           owl:onProperty      <d> ;
                           owl:someValuesFrom  xsd:boolean
                         ] ;
  owl:annotatedTarget    [ a                  owl:Restriction ;
                           owl:allValuesFrom  owl:Thing ;
                           owl:onProperty     <o>
                         ]
] .

如您所见,三元组_:c1 rdfs:subClassOf _:c2( SPO) 出现在图中,但没有具体化,就像在上一段 (p 4.2 ) 中一样。取而代之的是对三元组_:c1 rdfs:subClassOf _:u( SP(O*)) 的具体化,它实际上并不存在于图中:

_:x owl:annotatedTarget _:u .
_:x owl:annotatedProperty rdfs:subClassOf .
_:x owl:annotatedSource _:c1 .

另请注意,对于此示例,运算符SubClassOf(CE1, CE2, ann)必须如下:

T(CE1) rdfs:subClassOf T(CE2) .
ANN(CE1, T(CE2), rdfs:subClassOf, ann) .

这里,第一个操作数按原样传递,但第二个操作数有T-transformation,它产生一个新的 b 节点。

_:c1 rdfs:subClassOf _:u由于整个图中不存在三元组,因此该示例也演示了错误行为。因此,在我看来,在 注释公理由匿名表达式组成的情况下,OWL-API (v5.1.11) 不会产生正确的 RDF。


5. 结论和注释。

  • 那么,为什么这两个规范都禁止重用 b 节点进行映射呢?好吧,我看到唯一的一种解释——作者希望公理是原子的。如果某些公理的组件是共享的,那么在推理时就不可能单独关闭/打开所需的公理。
  • 4.1段中的例子是否违反了这一原则?不,注释仍然属于唯一的公理,不能引用另一个公理。
  • 4.24.3段中的例子是错误的:相应的具体化陈述实际上并不存在。但是,据我所知,我的对手为4.3的正确性辩护,给出了导致4.2正确性的论点。我认为,这个奇怪的事实也是正确性的隐含证明4.1
  • SubClassOf(CE1, CE2, ann)示例4.3中的算子是不对称的。规范中没有任何线索可能导致这种不平衡的结果。为什么第二个操作数有转换T,但第一个操作数没有 - 这是一个问题。
  • 来源(github问题中的评论):https ://github.com/owlcs/owlapi/issues/874#issuecomment-527399645
于 2019-09-09T12:31:18.763 回答