温馨提示:本文翻译自stackoverflow.com,查看原文请点击:其他 - How to give a numeric value to an object while writing an rdf triple
rdf rdfs linked-data turtle-rdf triples

其他 - 编写rdf三元组时如何为对象赋予数值

发布于 2020-05-04 05:05:31

我正在尝试为编写rdf三元组 MixedFruitJuice is made of 2 Oranges, 1 Pomegranate and 1 Pineapple

这里MixedFruitJuice是类的一个实例FruitJuiceOrange PomegranatePineapple的实例Fruit

我不明白如何为对象提供数值。如“ 2”个橙子或“ 1”石榴。

查看更多

提问者
Raghav Rathi
被浏览
42
Ivo Velitchkov 2020-02-16 00:24

有多种方法可以实现此目的。例如,使用OWL,您可以申请owl:Restriction定义an rdfs:subClass或an owl:equivalentClass,这取决于您是否认为自己的配方是必要的,也可以是MixedFruitJuice

我建议声明OrangePomegranatePineapple作为rdfs:subClassFruit这样,如果根据配方用混凝土制成的话,就可以制成混凝土汁MixedFruitJuice现在,假设必要但不充分的条件(毕竟他们还需要晃动),a :MixedFruitJuice可以描述为:

:MixedFruitJuice rdf:type owl:Class ;
          rdfs:subClassOf [ owl:intersectionOf ( :Juice
                 [ rdf:type owl:Restriction ;
                 owl:onProperty :hasIngredient ;
                 owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
                 owl:onClass :Pineapple]
                 [ rdf:type owl:Restriction ;
                 owl:onProperty :hasIngredient ;
                 owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
                 owl:onClass :Pomegranate]
                 [ rdf:type owl:Restriction ;
                 owl:onProperty :hasIngredient ;
                 owl:qualifiedCardinality "2"^^xsd:nonNegativeInteger ;
                 owl:onClass :Orange]
                                                          ) ;
                                       rdf:type owl:Class
                                     ] .

除了OWL,在某些情况下也可以使用SHACL来实现,从而带来更好的结果。

如果要保留OrangePomegranatePineapple不是作为的子类而不是作为的子类Fruit,则可以考虑使用RDF规范化或RDF *。

使用规范化会产生问题,总之有一种简单的方法可以表示问题,仅使用RDF就可以了,在建议OWL之前我应该​​想到这一点。这里是:

:MixedFruitJuice
  rdf:type :Juice ;
  :isMadeOf [
      rdf:type :Orange ;
      :numberOfUnits "2"^^xsd:decimal ;
    ] ;
  :isMadeOf [
      rdf:type :Pineapple ;
      :numberOfUnits "1"^^xsd:decimal ;
    ] ;
  :isMadeOf [
      rdf:type :Pomegranate ;
      :numberOfUnits "1"^^xsd:decimal ;
    ] ;
.

因为:numberOfUnits我可以选择一个xsd:int范围,但是我假设果汁中可能需要1.5个苹果。