Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
美国国会大厦sparqle查询';美国_Sparql - Fatal编程技术网

美国国会大厦sparqle查询';美国

美国国会大厦sparqle查询';美国,sparql,Sparql,我想对美国各州的国会大厦进行一次简短的询问。我的sparqle查询有什么问题?它一直在失败 # Find US states, their capitals and largest cities PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org

我想对美国各州的国会大厦进行一次简短的询问。我的sparqle查询有什么问题?它一直在失败

# Find US states, their capitals and largest cities
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpr: <http://dbpedia.org/resource/>
PREFIX dbpo: <http://dbpedia.org/ontology/>
PREFIX dbpprop: <http://dbpedia.org/property/>

#for all the capitols in the states
SELECT ?capitol
WHERE {
?capitol dbpo:state ?country .
{ ?capitol a dbpo:capitol } .
{ ?country a dbpprop:country "U.S." } .
}
#查找美国各州、州首府和最大城市
前缀xsd:
前缀rdf:
前缀rdfs:
前缀dbpr:
前缀dbpo:
前缀dbpprop:
#为了所有的国会大厦
选择?国会大厦
在哪里{
?国会大厦dbpo:州?国家。
{?国会大厦a dbpo:国会大厦}。
{?国家a dbpprop:国家“美国”}。
}

您的查询不合法。如果将其粘贴到中,将看到语法错误:

Encountered "  "\"U.S.\" "" at line 14, column 30.
Was expecting one of:
    "values" ...
    "graph" ...
    "optional" ...
    "minus" ...
    "bind" ...
    "service" ...
    "filter" ...
    "{" ...
    "}" ...
    ";" ...
    "," ...
    "." ...
输入:

  1 # Find US states, their capitals and largest cities
  2 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
  3 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
  4 PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  5 PREFIX dbpr: <http://dbpedia.org/resource/>
  6 PREFIX dbpo: <http://dbpedia.org/ontology/>
  7 PREFIX dbpprop: <http://dbpedia.org/property/>
  8 
  9 #for all the capitols in the states
 10 SELECT ?capitol
 11 WHERE {
 12 ?capitol dbpo:state ?country .
 13 { ?capitol a dbpo:capitol } .
 14 { ?country a dbpprop:country "U.S." } .
 15 }
看起来您正在使用DBpedia,如果是这样的话,那么您可以在。(变量
?state
有点用词不当;有56个结果。)


“它一直在失败”-确切地说是如何失败的?您是否得到错误或其他意外结果?另外:您在何处/如何执行此查询?您使用的是公共DBPedia端点还是其他什么?请添加相关详细信息。最有可能的是这一行:
{?国家a dbpprop:country“U.S.”。
是问题所在。字符串“U.S.”在语法上不合法。我假设您使用的任何查询引擎都会给您一个错误,指定了这一点。
select ?state ?capital where { 
  ?state dbpedia-owl:capital ?capital ;
         dbpedia-owl:country dbpedia:United_States .
}