如何计算ARC2 PHP中三元组的数量

时间:2017-02-17 12:17:21

标签: php sparql construct arc2

我在ARC2 PHP中创建了一个CONSTRUCT查询,但是如何计算我收到的三元组数?

$query = '
  PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
  PREFIX owl: <http://www.w3.org/2002/07/owl#>
  PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
   PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
   PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

   CONSTRUCT { ?c rdfs:label ?name }
 WHERE {
   ?c rdf:type dbpedia-owl:City. 
   ?c rdfs:label ?name .
   ?c dbpedia-owl:country <http://dbpedia.org/resource/Italy> .
   OPTIONAL { ?c dbpedia-owl:areaCode ?areacode }
   FILTER ( lang(?name) = "it")
 }';

因为现在查询不会写任何输出。

1 个答案:

答案 0 :(得分:2)

SELECT (COUNT(*) as ?cnt) WHERE { ?s ?p ?o }