What RDF templates can you use to represent components and the percentage they constitute?
I would like to inventory my wine collection using RDF, but am not sure how to specify that a wine can contain percentages of multiple grape varieties. Below is an attempt to do it in Turtle syntax using rdf: bag.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix vin: <http://example.org/wine#> .
<http://example.org/wine/id#1001>
a <http://example.org/wine/ns#red> ;
vin:name "Quilceda Creek CVR" ;
vin:vintage "2014"^^xsd:gYear ;
vin:winery "Quilceda Creek"@en ;
vin:alcoholContent "0.15"^^xsd:decimal ;
vin:agedIn "French Oak"@en ;
vin:varietals rdf:_1, rdf:_2, rdf:_3, rdf:_4, [
a rdf:Bag ;
rdf:_1 "Cabernet Sauvignon"@en ;
rdf:_1 "0.76"^^xsd:decimal ;
rdf:_2 "Merlot"@en ;
rdf:_2 "0.20"^^xsd:decimal ;
rdf:_3 "Petit Verdot"@en ;
rdf:_3 "0.03"^^xsd:decimal ;
rdf:_4 "Malbec"@en ;
rdf:_4 "0.01"^^xsd:decimal ;
] .
When I convert this to XML / RDF, the percent triplets are lost. This makes me think that you should not / cannot use bag element predicates (e.g. rdf: _1) more than once.
I also thought about making a bag of sacks, with a bag for each grade containing the name and percentage. This would require creating even more empty nodes, which doesn't seem right to me. In the end, I would like to get all wines containing at least a certain percentage of a certain variety. I'm not sure if I can if the variation of name and percentage pairs does not have any relationship defined other than being in the same bag.
I'm new to this, but feel like I need to look at RDF schemas and ontologies for this problem. However, I also don't want to jump on the ship until I fully understand why I need it.
If possible, how can RDF be used to represent that wine has certain percentages of different varieties?
source to share
Id prefer to use this simple pattern:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix wine: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#> .
@prefix vin: <http://example.org/wine#> .
vin:id1001 vin:varietal [ vin:grape wine:CabernetSauvignonGrape;
vin:percentage "0.76"^^xsd:decimal ] ;
vin:varietal [ vin:grape wine:MerlotGrape ;
vin:percentage "0.20"^^xsd:decimal ] .
Example. SPARQL queries against the template above:
SELECT DISTINCT ?sophistique
WHERE {
?sophistique vin:varietal/vin:percentage ?percentage .
FILTER (?percentage <= "0.05"^^decimal)
}
SELECT DISTINCT ?coupage
WHERE {
?coupage vin:varietal/vin:grape ?grape1.
?coupage vin:varietal/vin:grape ?grape2.
FILTER (?grape1 != ?grape2)
}
SELECT ?id (("1.0"^^xsd:decimal - SUM(?percentage)) AS ?part_des_anges)
WHERE {
?id vin:varietal/vin:percentage ?percentage .
} GROUP BY ?id HAVING ( ?part_des_anges > "0.0"^^xsd:decimal )
Some notes:
-
It is more ideologically correct to use things instead of strings in RDF where possible.
The W3Cs sample ontology can provide URIs for many of these things. -
Why don't you only use a few property occurrences
vin:varietal
insteadrdf:Seq
? With SPARQL, and especially OWL, it will be more difficult to deal withrdfs:Container
s. -
I do not think that these varieties (grape varieties with percentages) need strong URI identification, their "ontological status" is not strong enough. This way I am using empty nodes.
source to share