[英]SPARQL Wikidata - How to combine two queries to retrieve object information
[英]How to retrieve all properties of Wikidata ordered by their usage using SPARQL
我发现一个查询检索 Wikidata 的所有属性以及属性 ID、label、描述和别名
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX schema: <http://schema.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX wikibase: <http://wikiba.se/ontology#>
SELECT ?p ?pt ?pLabel ?d ?aliases WHERE {
{
SELECT ?p ?pt ?d
(GROUP_CONCAT(DISTINCT ?alias; separator="|") as ?aliases)
WHERE {
?p wikibase:propertyType ?pt .
OPTIONAL {?p skos:altLabel ?alias FILTER (LANG (?alias) = "en")}
OPTIONAL {?p schema:description ?d FILTER (LANG (?d) = "en") .}
} GROUP BY ?p ?pt ?d
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
}
}
以及通过语句指向 Q46 的项目使用的查询计数属性
SELECT ?property ?count
WHERE {
SELECT ?property (COUNT(?item) AS ?count)
WHERE {
?item ?statement wd:Q46 . # items pointing to Q46 through a statement
?property wikibase:statementProperty ?statement . # property used for that statement
} GROUP BY ?property # count usage for each property pointing to that entity
} ORDER BY DESC(?count) # show in descending order of uses
我会在不依赖 Q46 的情况下组合它们,但我不知道具体如何。
这样的 SPARQL 查询将花费太多时间导致执行超时。 替代方案是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.