选择查询内的 SPARQL 实体列表
在下面的 DBpedia 查询中,有没有办法将 UNION 合并为单个模式?
PREFIX prop: <http://resedia.org/ontology/>
PREFIX res: <http://resedia.org/resource/>
SELECT DISTINCT ?language ?label
WHERE {
{res:Spain prop:language ?language}
UNION
{res:France prop:language ?language}
UNION
{res:Italy prop:language ?language}
?language rdfs:label ?label .
FILTER langMatches(lang(?label), "en")
}
SPARQL 规范 提到了一些有关 RDF 集合的内容,但我没有真正理解它所描述的内容。看起来以下语法应该有效,但事实并非如此。
PREFIX prop: <http://resedia.org/ontology/>
PREFIX res: <http://resedia.org/resource/>
SELECT DISTINCT ?language ?label
WHERE {
(res:Spain res:France res:Italy) prop:language ?language
?language rdfs:label ?label .
FILTER langMatches(lang(?label), "en")
}
有没有办法在 SELECT 查询中定义像这样的 URI 列表(或“多重集”或“包”)?
In the following DBpedia query, is there a way to consolidate the UNIONs into a single pattern?
PREFIX prop: <http://resedia.org/ontology/>
PREFIX res: <http://resedia.org/resource/>
SELECT DISTINCT ?language ?label
WHERE {
{res:Spain prop:language ?language}
UNION
{res:France prop:language ?language}
UNION
{res:Italy prop:language ?language}
?language rdfs:label ?label .
FILTER langMatches(lang(?label), "en")
}
The SPARQL spec mentions something about RDF collections but I don't really understand what it's describing. It seemed like the following syntax should work, but it didn't.
PREFIX prop: <http://resedia.org/ontology/>
PREFIX res: <http://resedia.org/resource/>
SELECT DISTINCT ?language ?label
WHERE {
(res:Spain res:France res:Italy) prop:language ?language
?language rdfs:label ?label .
FILTER langMatches(lang(?label), "en")
}
Is there a way to define a list (or "multiset", or "bag") of URIs like this inside a SELECT query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在SPARQL 1.1中你可以做
In SPARQL 1.1 you can do
简单的回答:不。
表示“包含西班牙、法国和意大利的列表具有语言的匹配”,即列表本身具有语言。
你可以这样做:
这更短,但可能更慢。
(我感觉 SPARQL 1.1 有一个“IN”功能,但我在草稿中没有看到它)
Simple answer: no.
means 'match where a list containing Spain, France and Italy has a language', i.e. the list itself has a language.
You could do:
which is shorter, but may be slower.
(I had a feeling SPARQL 1.1 had an 'IN' feature, but I don't see it in the drafts)