I am tryin to write an rdf triple for
MixedFruitJuice is made of 2 Oranges, 1 Pomegranate and 1 Pineapple
.
HereMixedFruitJuice
is an instance of class FruitJuice
and Orange
Pomegranate
and Pineapple
are instances of Fruit
.
I don't understand how I can give a numeric value to the objects. Like "2" oranges, or "1" Pomegranate.
There are different ways to achieve this. For example, using OWL, you can apply owl:Restriction
to define either an rdfs:subClass
or an owl:equivalentClass
, depending if you see your recipe as necessary or as necessary and sufficient conditions for a MixedFruitJuice
.
I would suggest declaring Orange
, Pomegranate
and Pineapple
as rdfs:subClass
of Fruit
. This way a concrete juice, if made of concrete fruits according to the recipe, could be MixedFruitJuice
. Now, assuming necessary but insufficient conditions (after all they'd also need some shaking), a :MixedFruitJuice
can be described as:
: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
] .
Apart from OWL, this can be achieved also with SHACL in some cases, bringing better results.
If you want to keep Orange
, Pomegranate
and Pineapple
as instances and not as subclasses of Fruit
, then you may consider using RDF reification or RDF*.
Using reification can create problems and anyway there is a simple way to represent it, using just RDF, which I should've thought of before suggesting OWL. Here it is:
: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 ;
] ;
.
For :numberOfUnits
I could've chosen an xsd:int
range but I assume that in juices might require 1.5 apples for example.