如何形成引用多个资源的SPARQL查询 [英] How to form SPARQL queries that refers to multiple resources
问题描述
我的问题是对我的跟进关于SPARQL的第一个问题在这里。
我对Mountain对象的SPARQL查询结果是此处。
My SPARQL query results for Mountain objects are here.
从这些结果中,我选择了一个对象资源。
现在,我要为此选定的Mountain对象获取 是dbpedia-owl:highestPlace of 记录的值。
From those results I picked a certain object resource. Now I want to get values of "is dbpedia-owl:highestPlace of" records for this chosen Mountain object.
即,此山最高的山脉的名称。
That is, names of mountain ranges for which this mountain is highest place of.
我认为这很复杂。不仅因为我不知道所需的语法,而且在这里我得到了两个对象。
This is, as I figure, complex. Not only because I do not know the required syntax, but also I get two objects here.
- 其中一个是类型为地方的Mont Blank Massif 。
- 另一个是西阿尔卑斯山,其类型为山峰范围-我想要的记录。
- One of them is Mont Blank Massif which is of type "place".
- Another one is Western Alps which is of type "mountain range" - my desired record.
我需要上面的记录#2,但不需要1。我知道1也很重要,但有时它并没有不遵循相同的模式。有时记录似乎是YAGO类型的记录,这可能完全令人误解。为了安全起见,我只想在类型不匹配时就丢弃这些记录。
I need record # 2 above but not 1. I know 1 is also relevant but sometimes it doesn't follow same pattern. Sometimes the records appear to be of YAGO type, which can be totally misleading. To be safe, I simply want to discard those records whenever there is type mismatch.
如何形成我的SPARQL查询以获取这些 是dbpedia-owl :记录的最高位置,并且还具有类型过滤功能?
How can I form my SPARQL query to get these "is dbpedia-owl:highestPlace of" records and also have the type filtering?
推荐答案
您可以使用此查询,但是请注意,在您的示例中, Mont_Blanc_massif 都是 dbpedia-owl:Place
和 dbpedia-owl:MountainRange
you can use this query, note however that Mont_Blanc_massif in your example is both a dbpedia-owl:Place
and a dbpedia-owl:MountainRange
select * where {
?place dbpedia-owl:highestPlace :Mont_Blanc.
?place rdf:type dbpedia-owl:MountainRange.
}
评论后编辑:过滤器
不清楚要过滤的内容(是吗?),从技术上讲,您可以像这样进行过滤:
edit after comment: filter
It is not really clear what you want to filter (yago?), technically you can filter for example like this:
select * where {
?place dbpedia-owl:highestPlace :Mont_Blanc.
?place rdf:type dbpedia-owl:MountainRange.
FILTER NOT EXISTS {
?place ?pred ?obj
Filter (regex(?obj, "yago"))
}
}
这会过滤出结果中包含任何 object
中带有 yago的结果网址。
this filters out results that have any object
with 'yago' in its URL.
这篇关于如何形成引用多个资源的SPARQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!