SPARQL-queries (HELP!)

為{幸葍}努か 提交于 2019-12-11 06:13:32

问题


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:


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
}


来源:https://stackoverflow.com/questions/19654416/sparql-queries-help

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!