Sparql-如何获得三元组的数量?

Sparql- how to get number of triples?

我正在 sparql 上做一个小练习。使用 Dbpedia Endpoint,我需要计算三元组的数量。

这是我的查询

      // Get the number of triples //


    SELECT (COUNT(*) as ?Triples) WHERE { ?s ?p ?o}
-------------------------------------------------------
    OUTPUT:

    ( ?Triples = 1625382483 )

只是想知道查询和结果是否正确? 这就是你获得三元组数量的方式吗?

您可以通过直接在 SPARQL 端点上执行查询来全面检查很多事情,而不是通过 Jena 或其他中间客户端。例如,your query on the DBpedia form, and its results, which shows all triples in that triplestore (currently 1,625,382,483).

如果您只想在 DBpedia 命名图中计算三元组的数量(currently 438,336,517), you'll need to specify that, either in the SPARQL form Default Data Set Name (Graph IRI), or directly in the query,如 --

SELECT (COUNT(*) as ?Triples) 
WHERE 
  { GRAPH <http://dbpedia.org> 
      { ?s ?p ?o } 
  }

-- 或--

SELECT (COUNT(*) as ?Triples) 
FROM <http://dbpedia.org> 
WHERE { ?s ?p ?o }