gpt4 book ai didi

rdf - SPARQL 的 CONSTRUCT 模式中的 ORDER BY 解决方案修饰符

转载 作者:行者123 更新时间:2023-12-01 14:30:14 24 4
gpt4 key购买 nike

我遵循了 SPARQL 1.1 部分 10.2 CONSTRUCT并具有以下 SPARQL 查询,该查询返回主题类型为 Homework 并且还具有事件日期的所有三元组。

CONSTRUCT  { ?s ?p ?o } WHERE 
{
GRAPH ?g { ?s ?p ?o } .
{ ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://lod.isi.edu/ontology/syllabus/Homework>
}.

{ ?s <http://lod.isi.edu/ontology/syllabus/hasEventDate> ?date}.
}

现在,我想按事件日期 ?date 的升序/降序检索结果。我尝试添加 order by 修饰符,如下所示,但 OpenRDF 工作台中存在解析错误。

CONSTRUCT  { ?s ?p ?o } WHERE 
{
GRAPH ?g { ?s ?p ?o } .
{ ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://lod.isi.edu/ontology/syllabus/Homework>
}.

{ ?s <http://lod.isi.edu/ontology/syllabus/hasEventDate> ?date}.
ORDER BY DESC(?date)

}
Encountered " "order" "ORDER "" at line 9, column 6. Was expecting one of:
"(" ... "{" ... "}" ... "[" ... <NIL> ... <ANON> ... "optional" ...
"graph" ... "minus" ... "filter" ... "true" ... "false" ... "bind" ...
"service" ... "values" ... <Q_IRI_REF> ... <PNAME_NS> ... <PNAME_LN> ...
<BLANK_NODE_LABEL> ... <VAR1> ... <VAR2> ... <INTEGER> ... <INTEGER_POSITIVE> ...
<INTEGER_NEGATIVE> ... <DECIMAL> ... <DECIMAL_POSITIVE> ...
<DECIMAL_NEGATIVE> ... <DOUBLE> ... <DOUBLE_POSITIVE> ...
<DOUBLE_NEGATIVE> ... <STRING_LITERAL1> ... <STRING_LITERAL2> ...
<STRING_LITERAL_LONG1> ... <STRING_LITERAL_LONG2> ...

最佳答案

问题是您的 ORDER BY 子句在查询中的位置不正确。它应该在结束 WHERE 子句的右括号之后:

CONSTRUCT  { ?s ?p ?o } 
WHERE
{
GRAPH ?g { ?s ?p ?o }
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://lod.isi.edu/ontology/syllabus/Homework> .
?s <http://lod.isi.edu/ontology/syllabus/hasEventDate> ?date .
}
ORDER BY ASC(?date)

另请注意,您的原始查询中的几个大括号虽然不是完全错误,但却是多余的。

关于rdf - SPARQL 的 CONSTRUCT 模式中的 ORDER BY 解决方案修饰符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22029189/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com