嗨,大家好我正在尝试在Virtuoso版本6.1.x上运行SPARQL查询。这是查询:
SPARQL PREFIX fns: <NAMESPACE> SELECT ?birth ?death ?age ?value ?typeId FROM <http://freebaseInc5>
WHERE { fns:m.030pk7c fns:people.person.date_of_birth ?birth; fns:people.deceased_person.date_of_death ?death; BIND(year(?death)-year(?birth) as ?age ) .
OPTIONAL {?mid fns:common.topic.notable_types ?type . ?type fns:type.object.id ?typeId } .
OPTIONAL {?mid fns:type.object.name ?value FILTER langMatches(lang(?value), "en") }}
我收到错误抱怨语法:
> SQLState: 37000
Message: SQ074: Line 4: SP030: SPARQL compiler, line 2: syntax error at 'BIND' before '('
SPARQL PREFIX fns: <NAMESPACE> SELECT ?birth ?death ?age ?value ?typeId FROM <NAMESPACE>
WHERE { fns:m.030pk7c fns:people.person.date_of_birth ?birth; fns:people.deceased_person.date_of_death ?death; BIND(year(?death)-year(?birth) as ?age ) .
OPTIONAL {?mid fns:common.topic.notable_types ?type . ?type fns:type.object.id ?typeId } .
OPTIONAL {?mid fns:type.object.name ?value FILTER langMatches(lang(?value), "en") }}
我不知道错误是什么;我错过了什么?
答案 0 :(得分:0)
这是您的查询,改进了格式,并且从开头删除了“SPARQL”,但没有其他更改:
PREFIX fns: <NAMESPACE>
SELECT ?birth ?death ?age ?value ?typeId
FROM <http://freebaseInc5>
WHERE {
fns:m.030pk7c fns:people.person.date_of_birth ?birth ;
fns:people.deceased_person.date_of_death ?death ;
BIND(year(?death)-year(?birth) as ?age ) .
OPTIONAL {
?mid fns:common.topic.notable_types ?type .
?type fns:type.object.id ?typeId
} .
OPTIONAL {
?mid fns:type.object.name ?value
FILTER langMatches(lang(?value), "en")
}
}
根据sparql.org's query validator,查询结构良好(考虑到;
之后的?death
,实际上让我感到惊讶,但我想这毕竟是可以的。)
但是如果我尝试在运行Virtuoso的DBpedia端点上运行它(以及限制1,只是为了确保它实际上不会在资源方面使用太多),我看到你的错误谈论:
Virtuoso 37000 Error SP030: SPARQL compiler, line 10: syntax error at 'BIND' before '('
SPARQL query:
define sql:big-data-const 0
#output-format:text/html
define sql:signal-void-variables 1 define input:default-graph-uri <http://dbpedia.org> PREFIX fns: <NAMESPACE>
SELECT ?birth ?death ?age ?value ?typeId
FROM <http://freebaseInc5>
WHERE {
fns:m.030pk7c fns:people.person.date_of_birth ?birth ;
fns:people.deceased_person.date_of_death ?death ;
BIND(year(?death)-year(?birth) as ?age ) .
OPTIONAL {
?mid fns:common.topic.notable_types ?type .
?type fns:type.object.id ?typeId
} .
OPTIONAL {
?mid fns:type.object.name ?value
FILTER langMatches(lang(?value), "en")
}
}
LIMIT 1
但是,如果您将;
更改为?death
至.
,或将其完全删除,则会毫无问题地接受查询。