Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.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
SPARQL:查询多种语言的Wikidata标签_Sparql_Wikidata_Blazegraph - Fatal编程技术网

SPARQL:查询多种语言的Wikidata标签

SPARQL:查询多种语言的Wikidata标签,sparql,wikidata,blazegraph,Sparql,Wikidata,Blazegraph,我正在尝试从Wikidata的SPARQL端点获取多种语言的标签。给出了以下示例: 但是,这将返回以下错误: 未知错误:任何组中只能有一个“最后运行”联接 是否有一种解决方案可以使用多种语言获取标签?rdfs:label可以直接使用,无需使用wikibase:label服务: SELECT ?country ?country_en ?country_de ?country_fr WHERE { ?country wdt:P31 wd:Q185441. # member stat

我正在尝试从Wikidata的SPARQL端点获取多种语言的标签。给出了以下示例:

但是,这将返回以下错误:

未知错误:任何组中只能有一个“最后运行”联接


是否有一种解决方案可以使用多种语言获取标签?

rdfs:label
可以直接使用,无需使用
wikibase:label
服务:

SELECT ?country ?country_en ?country_de ?country_fr
   WHERE {
     ?country wdt:P31 wd:Q185441. # member state of the European Union
     OPTIONAL {?country rdfs:label ?country_en filter (lang(?country_en) = "en")}.
     OPTIONAL {?country rdfs:label ?country_de filter (lang(?country_de) = "de")}.
     OPTIONAL {?country rdfs:label ?country_fr filter (lang(?country_fr) = "fr")}.
}

标签服务优化器向标签服务添加一个
提示:先前提示:runLast true
,除非另有明确提示:

LabelServiceUtils.getLabelServiceNodes(op.forEach)(服务->{
if(service.getProperty(QueryHints.RUN_LAST)!=null||
service.getProperty(QueryHints.RUN_FIRST)!=null){
返回;
}
setProperty(QueryHints.RUN_LAST,TRUE);
});
只需在第一次调用之后的所有标签服务调用中添加
hint:previor-hint:runLast-false

您的查询应该是:

选择“国家/地区”\u EN“国家/地区”\u DE“国家/地区”\u FR
在哪里{
?国家wdt:P463 wd:Q458.#欧盟成员国
服务wikibase:label{bd:serviceParam wikibase:language“en”。
?国家/地区RDF:标签?国家/地区。
}
服务wikibase:label{bd:serviceParam wikibase:language“de”。
?国家/地区RDF:标签?国家/地区。
}提示:先前提示:runLast false。
服务wikibase:label{bd:serviceParam wikibase:language“fr”。
?国家RDF:标签?国家/地区。
}提示:先前提示:runLast false。
}

显然,使用常规SPARQL获取多种语言的标签是可能的,这样就不那么冗长了。然而,标签服务提供了语言回退,包括Q-id的最后一个

资料来源:


仅供参考,这不提供Q-id回退。什么是“Q-id回退”?例如,缺少的立陶宛语标签。标签服务将返回
“Q29999”
.SPARQL 1.1
COALESCE
SELECT ?country ?country_en ?country_de ?country_fr
   WHERE {
     ?country wdt:P31 wd:Q185441. # member state of the European Union
     OPTIONAL {?country rdfs:label ?country_en filter (lang(?country_en) = "en")}.
     OPTIONAL {?country rdfs:label ?country_de filter (lang(?country_de) = "de")}.
     OPTIONAL {?country rdfs:label ?country_fr filter (lang(?country_fr) = "fr")}.
}