获取作为给定项目实例的所有Wikidata项目 [英] Get all Wikidata items that are an instance of a given item

查看:125
本文介绍了获取作为给定项目实例的所有Wikidata项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Wikidata有一个名为智能手机模型的项目.
我想获取它的所有实例.

Wikidata has an item called smartphone model.
I want to get all instances of it.

问题:如何使用实时服务器以编程方式获取实例的标识符?

QUESTION: How to get the identifiers of the instances programmatically, using the live server?

最好不包括出现在WhatLinksHere中但位于"Wikidata:"命名空间而不是主命名空间中的误报.

Preferably not including false positives that show up in WhatLinksHere but are in the "Wikidata:" namespace rather than the main namespace.

推荐答案

您的问题指定了"Mediawiki API",但这是不可能的.

Your question specifies the "Mediawiki API" but this is not possible.

Wikidata在 https://query.wikidata.org

Wikidata has a SPARQL query service at https://query.wikidata.org

您想要的查询是:

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>

SELECT DISTINCT ?item
WHERE {
    ?item wdt:P31/wdt:P279* wd:Q19723451
}

这将列出作为实例"的项目( P31 ) 智能手机型号"( Q19723451 )或实例"或子类"( P279 )'智能手机模型'(

This will list the Items that are an 'instance of'(P31) 'smartphone model'(Q19723451) or an 'instance of' a 'subclass of'(P279) 'smartphone model'(Q19723451).

这篇关于获取作为给定项目实例的所有Wikidata项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆