使用 gas:service或mediawiki:categoryTree。 的服务,是否有可能以某种方式将 mediawiki:pages, mediawiki:subcategories 和 mediawiki:HiddenCategory 属性包含在查询结果中?我在 dumps 中看到了这些属性,但没有运气尝试以编程方式访问它们(使用 SPARQL 或其他 API)... ...
你只需要添加你的条件,例如对页面添加。
?out mediawiki:pages ?pages .
查询结果
{
"out" : {
"type" : "uri",
"value" : "https://en.wikipedia.org/wiki/Category:Fictional_ducks"
},
"depth" : {
"datatype" : "http://www.w3.org/2001/XMLSchema#int",
"type" : "literal",
"value" : "1"
},
"pages" : {
"datatype" : "http://www.w3.org/2001/XMLSchema#integer",
"type" : "literal",
"value" : "113"
}
他们警告说,你不能通过 UI 访问这个,所以你需要对你的查询进行编码,并在 URL 中传递。https:/query.wikidata.orgbigdatanamespacecategoriessparql?query=&format=json。
全面查询。
PREFIX gas: <http://www.bigdata.com/rdf/gas#>
prefix mediawiki: <https://www.mediawiki.org/ontology#>
SELECT * WHERE {
SERVICE gas:service {
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" .
gas:program gas:linkType mediawiki:isInCategory .
gas:program gas:traversalDirection "Reverse" .
gas:program gas:in <https://en.wikipedia.org/wiki/Category:Ducks>. # one or more times, specifies the initial frontier.
gas:program gas:out ?out . # exactly once - will be bound to the visited vertices.
gas:program gas:out1 ?depth . # exactly once - will be bound to the depth of the visited vertices.
gas:program gas:maxIterations 8 . # optional limit on breadth first expansion.
}
?out mediawiki:pages ?pages .
} ORDER BY ASC(?depth)