我正在尝试为MixedFruitJuice is made of 2 Oranges, 1 Pomegranate and 1 Pineapple编写一个RDF三元组。
其中,MixedFruitJuice是FruitJuice类的实例,Orange、Pomegranate和Pineapple是Fruit的实例。
我不明白如何给对象赋予一个数值。比如"2“个橙子或者"1”个石榴子。
发布于 2020-02-15 22:34:30
有不同的方法可以实现这一点。例如,使用OWL,您可以应用owl:Restriction来定义rdfs:subClass或owl:equivalentClass,这取决于您认为您的配方是MixedFruitJuice的必要条件还是充分必要条件。
我建议将Orange、Pomegranate和Pineapple声明为rdfs:subClass of Fruit。这样,一种混凝土果汁,如果根据食谱由混凝土水果制成,就可以是MixedFruitJuice。现在,假设有必要但不充分的条件(毕竟它们也需要一些摇动),: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个苹果。
https://stackoverflow.com/questions/60237468
复制相似问题