2014-02-20 209 views
2

我是RDF和OWL本體的初學者。uml與RDF和OWL的組合關係

我想把這個圖轉換成OWL語法。

enter image description here

<rdf:RDF 
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
    xmlns:owl="http://www.w3.org/2002/07/owl#" 
    xmlns:dc="http://purl.org/dc/elements/1.1/" 
     > 

    <!-- OWL Class Definition - Robot Position --> 
    <owl:Class rdf:ID="house" /> 
      <owl:Class rdf:ID="room" /> 
      <owl:Class rdf:ID="kitchen" /> 
      <owl:Class rdf:ID="garden" /> 
      <owl:Class rdf:ID="table" /> 
      <owl:Class rdf:ID="chair" /> 

    <owl:ObjectProperty rdf:ID="composedBy"> 
     <rdfs:domain rdf:resource="#house"/> 
     <rdfs:rang rdf:resource="#room" > 
    </owl:ObjectProperty>    
</rdf:RDF> 

我不知道怎麼做才能使由通過關係多次使用。 我想作出的範圍內採取集合類型與

(house)---composedBy---(room, kitchen, garden)

,但是,我想用同樣的關係與

(kitchen)---comoposedBy---(table, chair)

驗證器正在錯誤因爲我用了一次ID作爲ID兩次。 (我現在將其刪除)

我該如何正確翻譯此圖。

:))

+0

要清楚,你是否試圖說「房屋,廚房或花園裏的每一件東西」(unionOf在這裏工作),或者說「a家裏必須有一個房間,必須有一個廚房,並且必須有一個花園「(unionof在這裏不工作)? –

回答

0

事實上這樣的composedBy財產的範圍應該是一個工會。

由於在UML類模型中有兩種不同的組合,因此可能必須定義兩個不同的OWL屬性,如houseComposedBykitchenComposedBy

正如您在您的評論人士建議,在原則上,它也使用XML命名空間讓不同的名稱,這些不同composedBy OWL屬性(如合格的名稱house:composedBykitchen:composedBy)的選項。事實上,這與UML屬性相對應,UML屬性始終位於由它們的(域)類定義的名稱空間中。因此,您必須聲明儘可能多的名稱空間,因爲您擁有屬於composedBy屬性的域的類。

編輯:我會盡量總結約書亞泰勒和我自己的兩個答案。

  1. UML不具有通用的組成的關係,而是類特定isComposedOf(或hasPart)特性,這是在通過(域)類提供的命名空間中定義。因此,可以將這種UML屬性轉換爲相應的OWL屬性,這些屬性可以隱式地將它們的名稱空間編碼到屬性名稱中,也可以用XML命名空間顯式地進行編碼。
  2. Joshua Taylor在答案中指出的第二種方法是基於OWL屬性默認爲通用(不限於特定域類)的事實。這允許定義一個通用的hasPart屬性。但是,爲了獲得與我們的UML類模型相同的範圍約束,我們必須定義相應的allValuesFrom限制我們的通用hasPart屬性。除了這些對於翻譯必不可少的限制之外,我們還可以定義與在我們的UML類模型中定義的多重性約束相對應的基數限制(如果有的話)。
+0

我可以使用命名空間爲例:house:ComposedBy&kitchen:ComposedBy?所以我必須聲明一些實體? – alibenmessaoud

+1

誰沒有在評論中解釋它而低估了我的答案?同一個人已經刪除了他的低票答案? –

+2

這不是我的低估,但是這裏有一個可能性,那就是雖然房產的範圍可能是工會階級,但如果實際的問題是@alibenmessaoud試圖說房子必須有(例如)至少有一個這樣的事情,然後unionof是不是真的會幫助;一些存在的重新調整是需要的。 –

3

如果你想說房屋必須有一個(或至少一個)廚房,並且必須有一個(或至少一個)房間,並且必須有一個(或至少一個)花園,那麼unionOf在這裏並沒有真正解決這個問題。我認爲,如果你有一個更通用的組件屬性,並且通過使用存在限制來表達必須保持的不同關係,它可能會更有幫助。例如,你可以說

House&sqsubseteq; = 1 hasPart.Kitchen
House&sqsubseteq; ≥2hasPart.Room
House&sqsubseteq; ∃ hasPart.Garden

說一個房子有一個廚房,至少有兩個房間,至少有一個花園。同樣的,你可以說有一張桌子和一把椅子

Kitchen&sqsubseteq; ∃ hasPart.Chair
Kitchen&sqsubseteq; ∃ hasPart.Table

在門徒新,這看起來像:

house ontology, kitchen class with axioms

在烏龜和RDF/XML的RDF序列是:

@prefix :  <http://www.example.org/houses#> . 
@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#> . 

<http://www.example.org/houses> 
     a  owl:Ontology . 

:hasPart a  owl:ObjectProperty . 

:Table a  owl:Class . 
:Room a  owl:Class . 
:Garden a  owl:Class . 
:Chair a  owl:Class . 

:House a    owl:Class ; 
     rdfs:subClassOf [ a       owl:Restriction ; 
          owl:minQualifiedCardinality "2"^^xsd:nonNegativeInteger ; 
          owl:onClass     :Room ; 
          owl:onProperty    :hasPart 
         ] ; 
     rdfs:subClassOf [ a     owl:Restriction ; 
          owl:onProperty  :hasPart ; 
          owl:someValuesFrom :Garden 
         ] ; 
     rdfs:subClassOf [ a       owl:Restriction ; 
          owl:onClass    :Kitchen ; 
          owl:onProperty   :hasPart ; 
          owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger 
         ] . 


:Kitchen a    owl:Class ; 
     rdfs:subClassOf [ a     owl:Restriction ; 
          owl:onProperty  :hasPart ; 
          owl:someValuesFrom :Table 
         ] ; 
     rdfs:subClassOf [ a     owl:Restriction ; 
          owl:onProperty  :hasPart ; 
          owl:someValuesFrom :Chair 
         ] . 
<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://www.example.org/houses#" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#" 
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> 
    <owl:Ontology rdf:about="http://www.example.org/houses"/> 
    <owl:Class rdf:about="http://www.example.org/houses#Room"/> 
    <owl:Class rdf:about="http://www.example.org/houses#House"> 
    <rdfs:subClassOf> 
     <owl:Restriction> 
     <owl:onProperty> 
      <owl:ObjectProperty rdf:about="http://www.example.org/houses#hasPart"/> 
     </owl:onProperty> 
     <owl:onClass rdf:resource="http://www.example.org/houses#Room"/> 
     <owl:minQualifiedCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" 
     >2</owl:minQualifiedCardinality> 
     </owl:Restriction> 
    </rdfs:subClassOf> 
    <rdfs:subClassOf> 
     <owl:Restriction> 
     <owl:onProperty rdf:resource="http://www.example.org/houses#hasPart"/> 
     <owl:someValuesFrom> 
      <owl:Class rdf:about="http://www.example.org/houses#Garden"/> 
     </owl:someValuesFrom> 
     </owl:Restriction> 
    </rdfs:subClassOf> 
    <rdfs:subClassOf> 
     <owl:Restriction> 
     <owl:onProperty rdf:resource="http://www.example.org/houses#hasPart"/> 
     <owl:onClass> 
      <owl:Class rdf:about="http://www.example.org/houses#Kitchen"/> 
     </owl:onClass> 
     <owl:qualifiedCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger" 
     >1</owl:qualifiedCardinality> 
     </owl:Restriction> 
    </rdfs:subClassOf> 
    </owl:Class> 
    <owl:Class rdf:about="http://www.example.org/houses#Chair"/> 
    <owl:Class rdf:about="http://www.example.org/houses#Table"/> 
    <owl:Class rdf:about="http://www.example.org/houses#Kitchen"> 
    <rdfs:subClassOf> 
     <owl:Restriction> 
     <owl:onProperty rdf:resource="http://www.example.org/houses#hasPart"/> 
     <owl:someValuesFrom rdf:resource="http://www.example.org/houses#Table"/> 
     </owl:Restriction> 
    </rdfs:subClassOf> 
    <rdfs:subClassOf> 
     <owl:Restriction> 
     <owl:onProperty rdf:resource="http://www.example.org/houses#hasPart"/> 
     <owl:someValuesFrom rdf:resource="http://www.example.org/houses#Chair"/> 
     </owl:Restriction> 
    </rdfs:subClassOf> 
    </owl:Class> 
</rdf:RDF> 
+0

你的本體論允許一個房子由其他房屋組成的不直觀的陳述,或者一個由廚房等組成的花園。所以,當你照顧一些沒有被問到的東西(財產基數)時,你不會提供問題的解決方案,但是你更加模糊了一個或多個hasPart屬性的問題。所以,如果你不改善你的答案,它應該是downvoted。 –

+0

@gwag好吧,downvote按鈕的提示說「這個答案沒有用」。我希望這是有用的,即使它沒有完全回答這個問題。在OWL中,有些東西可能與我們沒有預料到的其他東西有關,這並不是直覺,因爲OWL使得開放世界成爲了一種假設。儘管如此,你的觀點是好的,alibenmessaoud可能希望房屋只有部分類型,可以通過「House ** subClassOf **(hasPart ** only **(Kitchen **或* *房間**或**花園))「公理。我會更新我的答案。 –

+0

@gwag通常,OWL本體的用途與UML圖不同。如果我們確實有一個像「House ** subClassOf **(hasPart ** only ** HousePart)」這樣的公理,然後看到像「house73 hasPart house89」這樣的公理,那麼我們不會自動產生不一致。相反,我們推斷house89(除了它可能具有的其他類型)還有HousePart類型。如果我們也有某個地方(宣佈或推斷)的公理和HousePart是不相交的類的公理,我們只會得到一個不一致的結論。你是絕對正確的,我在這裏給答案增加了一些解釋;理由... –