SPARQL查询(帮助!) [英] SPARQL-queries (HELP!)

查看:87
本文介绍了SPARQL查询(帮助!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有一个本体论,并且需要一些有关SPARQL查询的帮助. 本体基于不同的啤酒原料和酿造设备. 例如,它具有成分"类和麦芽/谷物"子类,然后具有暗"子类.现在,我有一些不同的,更特定的深色麦芽类型,它们是个人,也是深色类的成员.

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.

如果我进入Protege中的一个人,例如"Dark_Crystal",则在类型"字段下将有暗".

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

因此,我希望能够提出类似的查询:向我展示所有深色麦芽",向我展示麦芽"Dark_Crystal",如果没有现货,则显示相同类型的替代麦芽. 我对SPARQL不太满意,因为本体已经花了很多时间.我知道一点,但是我只是不知道我将如何制定它,或者应该由哪些标签来定义它们.

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.

推荐答案

我无法测试,因为我没有您的本体,但是在我的头顶上,这就是我要这样做的方式:

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:

如果Dark是文字:

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

如果Dark是类:

SELECT ?malt WHERE
{
?malt :hasColor ?color.
?color rdf:type :Dark
}

这篇关于SPARQL查询(帮助!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆