SPARQL 构造子句以包含谓词文字 [英] SPARQL Construct Clause to include predicate literals

查看:47
本文介绍了SPARQL 构造子句以包含谓词文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 SPARQL CONSTRUCT 从 dbpedia 中剥离一组数据 - 我只对一组艺术家感兴趣,我希望 Sesame 尽可能小以提高速度.

I'm trying to use SPARQL CONSTRUCT to strip a set of data from dbpedia - I'm only interested in a set of Artists, and I want Sesame as small as possible for speed.

我认为我可以做的是使用 CONSTRUCT 来获取给定艺术家的每个谓词.我可以让第一个 CONSTRUCT 子句工作以确保我得到类型人",但这只会给我满足该子句的三元组——我想要他们的名字、标签、出生地等.我下面的查询试图在第二个 CONSTRUCT 子句中捕获莫奈的名字?如果我做对了,这会给我三倍的

What I thought I could do is use CONSTRUCT to get every predicate for a given artist. I can get the first CONSTRUCT clause working to make sure I get type "Person", but that only gives me triples satisfying that clause - I want their names, labels, birthPlaces etc to. My query below is trying to capture Monet's name in the second CONSTRUCT clause? If I have it right, this would give me a triple of

<http://dbpedia.org/resource/Claude_Monet>  
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>   
<http://xmlns.com/foaf/0.1/Person>

和这样的三元组

<http://dbpedia.org/resource/Claude_Monet>  
<http://xmlns.com/foaf/0.1/name>
"Claude Monet"@en

如何让我的查询使用 Monet 名称的对象作为变量,以便在我插入空引号的地方使用?这是查询

How do I get my query to use the object of Monet's name as a variable to use where I am inserting empty quotes please? Here's the query

PREFIX purl: <http://purl.org/dc/elements/1.1/>
PREFIX foaf:    <http://xmlns.com/foaf/0.1/>
CONSTRUCT {
  ?s a foaf:Person .
  ?s foaf:name ""
} WHERE { 
  ?s foaf:surname "Monet"@en . 
  ?s purl:description "Painter"@en
} LIMIT 100

非常感谢任何帮助

迈克

推荐答案

我们到了,就是这样.一旦我弄清楚了 CONSTRUCT 和 WHERE 之间的变量绑定,它实际上很简单.

Here we are, this is it. Once I figured the variable bindings between the CONSTRUCT and WHERE it was actually straightforward.

每个 WHERE 语句从 repo 中选择这些值,并且需要引用相同变量的 CONSTRUCT 中的匹配模板语句.该值只是被替换.我想很明显.

Each WHERE statement selects those values from the repo, and requires a matching template statement in the CONSTRUCT referencing the same variable. The value is just replaced. Obvious I suppose.

自我注意 - 必须停止像 RDBMS 那样思考.

Note to self - MUST stop thinking like RDBMS.

PREFIX purl: <http://purl.org/dc/elements/1.1/>
PREFIX foaf:    <http://xmlns.com/foaf/0.1/>
PREFIX dbont:  <http://dbpedia.org/ontology/>
PREFIX w3: <http://www.w3.org/2000/01/rdf-schema#>

CONSTRUCT 
{
    ?s a foaf:Person .
    ?s foaf:name ?a .
    ?s foaf:surname ?b .
    ?s foaf:givenName ?c .
    ?s w3:label ?d .
    ?s purl:description ?e .
    ?s dbont:birthPlace ?f .
    ?s dbont:deathPlace ?g .
    ?s dbont:birthDate ?h .
    ?s dbont:deathDate ?i
}  
WHERE {
    ?s foaf:name ?a .
    ?s foaf:surname ?b .
    ?s foaf:givenName ?c .
    ?s w3:label ?d .
    ?s purl:description ?e .
    ?s dbont:birthPlace ?f .
    ?s dbont:deathPlace ?g .
    ?s dbont:birthDate ?h .
    ?s dbont:deathDate ?i .
    ?s purl:description "Painter"@en
}

这篇关于SPARQL 构造子句以包含谓词文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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