0

我在本地 GraphDB 三元存储中运行 SPARQL 查询,该查询包含一个 SERVICE 子句,该子句用于 DBPedia Virtuoso。该查询基本上直接从 DBPedia 获取一些 DBPedia URI 的标签(注意首先执行子查询以获取本地结果,然后将这些结果传递给 SERVICE 子句):

SELECT DISTINCT ?uri (STR(?theLabel) AS ?label)
WHERE {
 {
  SELECT DISTINCT ?uri 
  WHERE {
    ?domain a <http://xmlns.com/foaf/0.1/Person> .
    ?domain <http://virtual-assembly.org/pair#hasKeyword> ?uri .
  }
  }

  SERVICE <http://dbpedia.org/sparql> {
    ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?theLabel .
    FILTER(lang(?theLabel) = 'fr')
  }

}
ORDER BY ?label

在评估服务子句Virtuoso S0022 Error SQ200时,我从 Virtuoso 收到以下错误:

Query evaluation error: org.eclipse.rdf4j.query.QueryEvaluationException: Virtuoso S0022 Error SQ200: No column uri.

SPARQL query:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sesame: <http://www.openrdf.org/schema/sesame#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX fn: <http://www.w3.org/2005/xpath-functions#> 

SELECT  ?theLabel ?__rowIdx WHERE {
 ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?theLabel .
 FILTER(lang(?theLabel) = 'fr')
} 
VALUES (?__rowIdx ?uri) {  ("0" <http://dbpedia.org/resource/Semantic_Web> ) ("1" <http://dbpedia.org/resource/Peer-to-peer> ) ("2" <http://dbpedia.org/resource/Collaboration> ) ("3" <http://dbpedia.org/resource/Free_software> ) ("4" <http://dbpedia.org/resource/Social_transformation> ) ("5" <http://dbpedia.org/resource/Social_network> ) ("6" <http://dbpedia.org/resource/Ecology> ) ("7" <http://dbpedia.org/resource/Activism> ) ("8" <http://dbpedia.org/resource/Supernatural> ) ("9" <http://dbpedia.org/resource/Sociology> ) ("10" <http://dbpedia.org/resource/Natural_science> ) ("11" <http://dbpedia.org/resource/Popular_science> ) ("12" <http://dbpedia.org/resource/Cooperation> ) ("13" <http://dbpedia.org/resource/Wikimedia_Commons> ) ("14" <http://dbpedia.org/resource/Musician> ) } 

(HTTP status 500)

发送给 Virtuoso 的 SPARQL 查询在我看来是有效的。

当然,我不知道 GraphDB 如何生成查询,但是有什么办法可以重写原始查询来解决这个问题?

谢谢

4

2 回答 2

1

好的,我在这里得到纠正,因为在 WHERE 子句之后的 VALUES 子句确实是有效的 SPARQL。例如:

PREFIX dc:   <http://purl.org/dc/elements/1.1/> 
PREFIX :     <http://example.org/book/> 
PREFIX ns:   <http://example.org/ns#> 

SELECT ?book ?title ?price
{
   ?book dc:title ?title ;
         ns:price ?price .
}
VALUES (?book ?title)
{ (UNDEF "SPARQL Tutorial")
  (:book2 UNDEF)
}

实时查询结果示例

以下返回一个空结果集,指示不正确的解决方案,即错误:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sesame: <http://www.openrdf.org/schema/sesame#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX fn: <http://www.w3.org/2005/xpath-functions#> 

SELECT  ?theLabel ?rowIdx 
WHERE {
        ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?theLabel .
        FILTER (?uri = <http://dbpedia.org/resource/Semantic_Web>) 
        FILTER (lang(?theLabel) = "en")
      }
VALUES (?rowIdx ?uri) 
      {  ("0" <http://dbpedia.org/resource/Semantic_Web> ) 
         ("1" <http://dbpedia.org/resource/Peer-to-peer> ) 
         ("2" <http://dbpedia.org/resource/Collaboration> ) 
         ("3" <http://dbpedia.org/resource/Free_software> ) 
         ("4" <http://dbpedia.org/resource/Social_transformation> ) 
         ("5" <http://dbpedia.org/resource/Social_network> ) 
         ("6" <http://dbpedia.org/resource/Ecology> ) 
         ("7" <http://dbpedia.org/resource/Activism> ) 
         ("8" <http://dbpedia.org/resource/Supernatural> ) 
         ("9" <http://dbpedia.org/resource/Sociology> ) 
         ("10" <http://dbpedia.org/resource/Natural_science> ) 
         ("11" <http://dbpedia.org/resource/Popular_science> ) 
         ("12" <http://dbpedia.org/resource/Cooperation> ) 
         ("13" <http://dbpedia.org/resource/Wikimedia_Commons> ) 
         ("14" <http://dbpedia.org/resource/Musician> ) 
      } 

实时查询结果链接

于 2020-06-22T16:26:33.893 回答
-1

以下作品揭示了初始示例的结构性问题。

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sesame: <http://www.openrdf.org/schema/sesame#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX fn: <http://www.w3.org/2005/xpath-functions#> 

SELECT  ?theLabel ?__rowIdx
WHERE {
       ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?theLabel .
       FILTER(lang(?theLabel) = 'fr')

       VALUES (?__rowIdx ?uri) {  ("0" <http://dbpedia.org/resource/Semantic_Web> ) ("1" <http://dbpedia.org/resource/Peer-to-peer> ) ("2" <http://dbpedia.org/resource/Collaboration> ) ("3" <http://dbpedia.org/resource/Free_software> ) ("4" <http://dbpedia.org/resource/Social_transformation> ) ("5" <http://dbpedia.org/resource/Social_network> ) ("6" <http://dbpedia.org/resource/Ecology> ) ("7" <http://dbpedia.org/resource/Activism> ) ("8" <http://dbpedia.org/resource/Supernatural> ) ("9" <http://dbpedia.org/resource/Sociology> ) ("10" <http://dbpedia.org/resource/Natural_science> ) ("11" <http://dbpedia.org/resource/Popular_science> ) ("12" <http://dbpedia.org/resource/Cooperation> ) ("13" <http://dbpedia.org/resource/Wikimedia_Commons> ) ("14" <http://dbpedia.org/resource/Musician> ) } 

}

来自 DBpedia 的实时查询结果页面

于 2020-06-16T21:19:57.217 回答