SPARQL-queries (HELP!)

2019-08-11 05:52发布

So, I have an Ontology and need some help with my SPARQL-queries. The ontology is based on different beer ingredients and equipment for brewing. For instance, it has the class "Ingredients", and a subclass "Malt/Grain", and then a subclass "Dark". Now I have some different, more specific types of dark malts, that are individuals, and members of the class Dark.

If I go into one individual in Protege, for instance "Dark_Crystal", will have "Dark" under its field of "Types"

So, I want to be able to ask queries like: "Show me all dark malts" "Show me the malt "Dark_Crystal", and if not in stock show alternative malts of the same type. I´m not too good with SPARQL as much time have gone un to the ontology. I know a little, but I just don´t know how I would formulate it, or which tags that should define them.

This is my poor shot at a query, I just don´t know how i would formulate it right.

SELECT ?Malt WHERE
{
?malt rdfs:subClassOf [
    owl:someValuesFrom :Dark

}

Thanks a lot guys, hope I explained it well enough and that some of you may have some examples.

1条回答
Juvenile、少年°
2楼-- · 2019-08-11 06:27

I can't test because I do not have your ontology but on the top of my head, that's how I would do it:

If Dark is a literal:

SELECT ?malt WHERE
{
?malt :hasColor "Dark"
}

If Dark is a class:

SELECT ?malt WHERE
{
?malt :hasColor ?color.
?color rdf:type :Dark
}
查看更多
登录 后发表回答