首页 > 解决方案 > 如何查询 Wikidata 以获取最近一天修改的项目?

问题描述

我正在尝试检索过去 24 小时内已编辑的纬度/经度边界框中的所有 wikidata 项目

我可以通过边界框部分,但我无法确定“修改后”位。

是我能找到的最接近的例子,我试图从中完成这项工作:

SELECT ?place WHERE {
  SERVICE wikibase:box {
    ?place wdt:P625 ?location .
    # looks like cornerwest must be south of cornereast
    # otherwise you go around the globe
    # this is lng lat
    bd:serviceParam wikibase:cornerWest "Point(SW_LNG SW_LAT)"^^geo:wktLiteral .
    bd:serviceParam wikibase:cornerEast "Point(NE_LNG NE_LAT)"^^geo:wktLiteral .
  }
  ?place wdt:P31  ?placeCategory .
  ?place wdt:P625 ?placeCoords   .

  optional{ ?place wdt:P18 ?placePicture . }


  BIND (now() - ?modified as ?date_range)
  FILTER (?date_range > 2)
}

没有结果。

标签: sparqlwikidata

解决方案


使用schema:dateModified. 顺便说一句,Blazegraph 支持日期和时间算法:

SELECT ?place ?placeLabel ?location WHERE {
  BIND ((now() - "P7D"^^xsd:duration) AS ?date_)
  SERVICE wikibase:box {
    ?place wdt:P625 ?location   .
    bd:serviceParam wikibase:cornerSouthWest "Point(55.000 55.000)"^^geo:wktLiteral.
    bd:serviceParam wikibase:cornerNorthEast "Point(65.000 65.000)"^^geo:wktLiteral.
  }
  ?place schema:dateModified ?date .
  # hint:Prior hint:rangeSafe true .
  FILTER (?date >= ?date_)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "ru". }
}

https://w.wiki/3E9Z

还有一个wikibase:timestamp相当辅助的谓词。


推荐阅读