维基数据查询服务类别:分页子类别和隐藏类别属性的数量。

问题描述 投票:1回答:1

使用 gas:service或mediawiki:categoryTree。 的服务,是否有可能以某种方式将 mediawiki:pages, mediawiki:subcategories 和 mediawiki:HiddenCategory 属性包含在查询结果中?我在 dumps 中看到了这些属性,但没有运气尝试以编程方式访问它们(使用 SPARQL 或其他 API)... ...

sparql mediawiki wikipedia wikipedia-api wikidata
1个回答
1
投票

你只需要添加你的条件,例如对页面添加。

  ?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)
© www.soinside.com 2019 - 2024. All rights reserved.