2013-10-20 43 views
2

如果我想說的東西的標題應該是一個RDFS:文字,我這樣做:我可以爲rdf:List成員指定一個範圍嗎?

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

現在我想表達的東西有職稱的有序列表:

example:titles a rdf:List . 

如何指定列表的成員應該是什麼?我需要繼承rdf:List嗎?

更新:我想繼續使用rdf:列表,如果可能的話,基於Joshua的答案我認爲以下說任何rdf:只有rdfs:Literal值列表是一個例子: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) . 

這是否有道理,還是我誤解了某些東西?

回答

6

首先,請注意,在您的OWL代碼中使用rdf:List s意味着您將在OWL Full中,而許多reasoners被設計爲與OWL DL一起使用。你可能會這樣做,如果你是,那麼很好。如果您需要留在OWL DL中,那麼您必須使用自己的詞彙表作爲列表,例如類warp:List和屬性warp:firstwarp:rest,並使用它們來代替它們的RDF對應項。

無論如何,一旦你確定了你List類和你firstrest屬性,你可以定義列表類型ListOfElements只能含有一些類Element的成員有下列限制:

ElementList&sqsubseteq;列表(第一元件)(休息元素列表)

這意味着ElementList是:(ⅰ)List; (ii)對first財產的價值爲Element;並且(iii)具有ElementList作爲其rest,這意味着List中的其餘部分也必須是Elements。無論nil對象應該已經被聲明爲List,但你也可能要包括:

一個元素列表

,但這並不一定是很重要的。對於你的情況,你想要以類似的方式定義一個類TitleList,然後聲明你的財產範圍爲TitleList

下面是一個例子本體只包括定義這些類型List類和ElementList類(在人類可讀的龜):

@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類,firstrest屬性,以及個人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> 
+0

謝謝約書亞!這是針對JSON-LD web服務的,大多數客戶端根本不關心RDF位,所以我目前不關心reasoners。 – warp

+1

@warp是的,如果你不關心reasoners,這應該適合你。 (儘管如果你不使用推理器,只是簡單地說明某個列表是,例如,IntegerList不會讓你得到每個成員都是Integer的結果;但是你需要一個推理器)。對於你,請考慮[接受它](http://meta.stackexchange.com/q/5234/225437)。如果沒有,我們可以做些什麼來改善它? :) –

相關問題