我正在尝试为编写rdf三元组
MixedFruitJuice is made of 2 Oranges, 1 Pomegranate and 1 Pineapple
。
这里MixedFruitJuice
是类的一个实例FruitJuice
和Orange
Pomegranate
和Pineapple
的实例Fruit
。
我不明白如何为对象提供数值。如“ 2”个橙子或“ 1”石榴。
有多种方法可以实现此目的。例如,使用OWL,您可以申请owl:Restriction
定义an rdfs:subClass
或an owl:equivalentClass
,这取决于您是否认为自己的配方是必要的,也可以是MixedFruitJuice
。
我建议声明Orange
,Pomegranate
并Pineapple
作为rdfs:subClass
的Fruit
。这样,如果根据配方用混凝土制成的话,就可以制成混凝土汁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来实现,从而带来更好的结果。
如果要保留Orange
,Pomegranate
而Pineapple
不是作为的子类而不是作为的子类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个苹果。
谢谢,我真的很想对RDF的修改有所了解。
好吧,这将使类型声明更为重要,但这并不是一个很好的解决方案。实际上,有一个非常简单的RDF解决方案,可以用来更新我的答案。