2

如果我想说某事的标题应该是 rdfs:Literal,我这样做:

example:title a owl:DatatypeProperty ;
    rdfs:range rdfs:Literal .

现在我想表达一些东西有一个有序的标题列表:

example:titles a rdf:List .

如何指定列表的成员应该是什么?我需要继承 rdf:List 吗?

更新:如果可能的话,我想继续使用 rdf:List,根据 Joshua 的回答,我认为以下内容表明任何只有 rdfs:Literal 值的 rdf:List 都是一个示例:ListOfLiterals,然后我可以将其用作范围。

@prefix entity: <http://example.com/stuff/> .
@prefix example: <http://example.com/my/term/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

example:ListOfLiterals a owl:Class ;
    owl:equivalentClass [
        a owl:Class ;
        owl:intersectionOf (
            rdf:List
            [
                a owl:Restriction ;
                owl:allValuesFrom rdfs:Literal ;
                owl:onProperty rdf:first
            ]
            [
                a owl:Restriction ;
                owl:allValuesFrom example:ListOfLiterals ;
                owl:onProperty rdf:rest
            ] )
    ] .

example:Book a owl:Class .

example:titles a owl:DatatypeProperty ;
    rdfs:domain example:Book ;
    rdfs:range example:ListOfLiterals .

entity:somebook a example:Book ;
    example:titles ( "Book Title"@en "Second Book Title"@en ) .

这有什么意义吗,还是我误解了什么?

4

1 回答 1

8

首先,请注意,rdf:List在您的 OWL 代码中使用 s 意味着您将使用 OWL Full,而许多推理器旨在使用 OWL DL。您可能会对此感到满意,如果可以,那就太好了。如果您需要留在 OWL DL 中,那么您将不得不使用您自己的列表词汇表,例如,类warp:List和属性warp:firstand warp:rest,并使用它们而不是它们的 RDF 对应物。

无论如何,一旦你决定了你的List类和你的first属性rest,你就可以定义一个列表类型ListOfElements,它只能包含某个类Element的成员,具有以下限制:

ElementList ⊑ List and (first only Element) and (rest only ElementList)

这意味着 anElementList是: (i) a List;(ii) 该first财产的价值为Element;并且 (iii) has an ElementListas its rest,这意味着其余的东西List也必须是Elements。无论nil对象是什么,都应该已经声明为 a List,但您可能还需要包括:

没有一个元素列表

但这并不一定那么重要。对于您的情况,您希望以TitleList类似的方式定义一个类,然后将您的属性范围声明为TitleList.

这是一个示例本体,其中仅定义了这些类型的List类和一个ElementList类(在人类可读的 Turtle 中):

@prefix :      <http://stackoverflow.com/a/19480798/1281433/code#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

:rest   a            owl:ObjectProperty ;
        rdfs:domain  :List ;
        rdfs:range   :List .

:List   a       owl:Class .

:nil    a       owl:NamedIndividual , :ElementList , :List .

:ElementList  a          owl:Class ;
        rdfs:subClassOf  [ a                   owl:Class ;
                           owl:intersectionOf  ( :List [ a                  owl:Restriction ;
                                                         owl:allValuesFrom  :Element ;
                                                         owl:onProperty     :first
                                                       ] [ a                  owl:Restriction ;
                                                           owl:allValuesFrom  :ElementList ;
                                                           owl:onProperty     :rest
                                                         ] )
                         ] .

:Element  a     owl:Class .

:first  a            owl:ObjectProperty ;
        rdfs:domain  :List .

<http://stackoverflow.com/a/19480798/1281433/code>
        a       owl:Ontology .

[ a                      owl:Axiom ;
  rdfs:comment           "It's probably a good idea to specify that nil is an ElementList.  This could also be inferred, though, if there is a nil-terminated List that is known to be an ElementList." ;
  owl:annotatedProperty  rdf:type ;
  owl:annotatedSource    :nil ;
  owl:annotatedTarget    :ElementList
] .

为全面起见,我定义了新的新List类、first属性rest和个体nil,但如果 OWL Full 对你来说没问题,那么你可以使用rdf:List等。为了完整起见,这里是 RDF/XML 中的相同本体:

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns="http://stackoverflow.com/a/19480798/1281433/code#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
  <owl:Ontology rdf:about="http://stackoverflow.com/a/19480798/1281433/code"/>
  <owl:Class rdf:about="http://stackoverflow.com/a/19480798/1281433/code#List"/>
  <owl:Class rdf:about="http://stackoverflow.com/a/19480798/1281433/code#ElementList">
    <rdfs:subClassOf>
      <owl:Class>
        <owl:intersectionOf rdf:parseType="Collection">
          <owl:Class rdf:about="http://stackoverflow.com/a/19480798/1281433/code#List"/>
          <owl:Restriction>
            <owl:onProperty>
              <owl:ObjectProperty rdf:about="http://stackoverflow.com/a/19480798/1281433/code#first"/>
            </owl:onProperty>
            <owl:allValuesFrom>
              <owl:Class rdf:about="http://stackoverflow.com/a/19480798/1281433/code#Element"/>
            </owl:allValuesFrom>
          </owl:Restriction>
          <owl:Restriction>
            <owl:onProperty>
              <owl:ObjectProperty rdf:about="http://stackoverflow.com/a/19480798/1281433/code#rest"/>
            </owl:onProperty>
            <owl:allValuesFrom rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#ElementList"/>
          </owl:Restriction>
        </owl:intersectionOf>
      </owl:Class>
    </rdfs:subClassOf>
  </owl:Class>
  <owl:ObjectProperty rdf:about="http://stackoverflow.com/a/19480798/1281433/code#rest">
    <rdfs:range rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#List"/>
    <rdfs:domain rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#List"/>
  </owl:ObjectProperty>
  <owl:ObjectProperty rdf:about="http://stackoverflow.com/a/19480798/1281433/code#first">
    <rdfs:domain rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#List"/>
  </owl:ObjectProperty>
  <owl:Axiom>
    <rdfs:comment>It's probably a good idea to specify that nil is an ElementList.  This could also be inferred, though, if there is a nil-terminated List that is known to be an ElementList.</rdfs:comment>
    <owl:annotatedTarget rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#ElementList"/>
    <owl:annotatedSource>
      <owl:NamedIndividual rdf:about="http://stackoverflow.com/a/19480798/1281433/code#nil">
        <rdf:type rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#ElementList"/>
        <rdf:type rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#List"/>
      </owl:NamedIndividual>
    </owl:annotatedSource>
    <owl:annotatedProperty rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"/>
  </owl:Axiom>
</rdf:RDF>
于 2013-10-20T17:54:30.960 回答