Wikidata SPARQL:如何包含分组属性的标签
Wikidata SPARQL: how to include labels for grouped-by attributes
我有一个有效的查询:
SELECT ?language (COUNT (?lexeme) as ?lexemeCount) {
?lexeme dct:language ?language .
}
GROUP BY ?language
但是,我想不出如何为语言实体 URI 添加标签(代替或与语言实体 URI 一起添加)。这在维基数据上因超时异常而失败:
SELECT ?languageLabel (COUNT (?lexeme) as ?lexemeCount) {
?lexeme dct:language ?language .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en".
}
}
GROUP BY ?languageLabel
这也是:
SELECT ?languageLabel (COUNT (?lexeme) as ?lexemeCount) {
?lexeme dct:language ?language .
?language rdfs:label ?languageLabel .
FILTER(lang(?languageLabel) = 'en') .
}
GROUP BY ?languageLabel
哪个查询的结果会包含语言 名称,而不是 URI?
将 变成社区维基答案:
SELECT ?languageLabel ?lexemeCount {
{
SELECT ?language (COUNT (?lexeme) AS ?lexemeCount) {
?lexeme dct:language ?language
}
GROUP BY ?language
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en"
}
}
我有一个有效的查询:
SELECT ?language (COUNT (?lexeme) as ?lexemeCount) {
?lexeme dct:language ?language .
}
GROUP BY ?language
但是,我想不出如何为语言实体 URI 添加标签(代替或与语言实体 URI 一起添加)。这在维基数据上因超时异常而失败:
SELECT ?languageLabel (COUNT (?lexeme) as ?lexemeCount) {
?lexeme dct:language ?language .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en".
}
}
GROUP BY ?languageLabel
这也是:
SELECT ?languageLabel (COUNT (?lexeme) as ?lexemeCount) {
?lexeme dct:language ?language .
?language rdfs:label ?languageLabel .
FILTER(lang(?languageLabel) = 'en') .
}
GROUP BY ?languageLabel
哪个查询的结果会包含语言 名称,而不是 URI?
将
SELECT ?languageLabel ?lexemeCount {
{
SELECT ?language (COUNT (?lexeme) AS ?lexemeCount) {
?lexeme dct:language ?language
}
GROUP BY ?language
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en"
}
}