SPARQL:查询多种语言的Wikidata标签
我正在尝试从Wikidata的SPARQL端点获取多种语言的标签。给出了以下示例: 但是,这将返回以下错误: 未知错误:任何组中只能有一个“最后运行”联接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
是否有一种解决方案可以使用多种语言获取标签?
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的最后一个
资料来源:
“Q29999”
.SPARQL 1.1COALESCE
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")}.
}