是否存在rdf数据/其他格式,可让我获取类别中可能存在的所有属性,例如人,那么我应该返回属性,例如性别,出生日期
Is there an rdf data/other format that allow me to get all the properties that can exist in a category e.g. Person, then I should be returned properties like sex, date of birth
如何在 query.wikidata/上查询此信息?
我想要的是这个 www.wikidata/wiki/Wikidata:List_of_properties/Summary_table 但是,有没有更好的格式呢?我想以编程方式访问
What i want is this www.wikidata/wiki/Wikidata:List_of_properties/Summary_table But is there a better format for this ? I want to access programmatically
更新
此查询太重,导致超时.
This query is too heavy, causes timeout.
SELECT ?p ?attName WHERE { ?q wdt:P31 wd:Q5. ?q ?p ?statement. ?realAtt wikibase:claim ?p. ?realAtt rdfs:label ?attName. FILTER(((LANG(?attName)) = "en") || ((LANG(?attName)) = "")) } GROUP BY ?p ?attName我必须指定实体,例如到巴拉克·奥巴马(Barrack Obama),它就可以了,但这并不能给我所有可能的特性.
I must specify the entity, e.g. to Barrack Obama then it works, but this does not give me the all possible properties.
SELECT ?p ?attName WHERE { BIND(wd:Q76 AS ?q) ?q wdt:P31 wd:Q5. ?q ?p ?statement. ?realAtt wikibase:claim ?p. ?realAtt rdfs:label ?attName. FILTER(((LANG(?attName)) = "en") || ((LANG(?attName)) = "")) } GROUP BY ?p ?attName推荐答案
1
您链接到的页面是由漫游器创建的.如果您需要了解漫游器的工作方式,请与 BetaBot 操作员联系.
The page you have linked to is created by a bot. Contact the BetaBot operator, if you need to know how the bot works.
2
也许该机器人依赖 wd:P1963 属性:
Perhaps the bot relies on the wd:P1963 property:
SELECT ?property ?propertyLabel { VALUES (?class) {(wd:Q5)} ?class wdt:P1963 ?property SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } ORDER BY ASC(xsd:integer(strafter(str(?property), concat(str(wd:), "P"))))上述查询返回 49个结果.
The above query returns 49 results.
3
我建议您依靠属性页中的类型约束:
I'd suggest you rely on type constraints from property pages:
SELECT ?property ?propertyLabel { VALUES (?class) {(wd:Q5)} ?property a wikibase:Property . ?property p:P2302 [ ps:P2302 wd:Q21503250 ; pq:P2309 wd:Q21503252 ; pq:P2308 ?class ] . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } ORDER BY ASC(xsd:integer(strafter(str(?property), concat(str(wd:), "P"))))上述查询返回 700个结果.
The above query returns 700 results.
4
您的问题中的第一个查询适用于相对较小的类,例如e. G. wd:Q6256(国家").在公共端点上,不可能使查询适用于大型类.
The first query from your question works fine for relatively small classes, e. g. wd:Q6256 ('country'). On the public endpoint, it is not possible to make the query work for large classes.
但是,您可以将查询分为几部分.在Python中:
However, you could split the query into small parts. In Python:
from wdqs import Client from time import sleep client = Client() result = client.query("SELECT (count(?p) AS ?c) {?p a wikibase:Property}") count = int(result[0]["c"]) offset = 0 limit = 50 possible = [] while offset <= count: props = client.query(""" SELECT ?property WHERE { hint:Query hint:optimizer "None" . { SELECT ?property { ?property a wikibase:Property . } ORDER BY ?property OFFSET %s LIMIT %s } ?property wikibase:directClaim ?wdt. FILTER EXISTS { ?human ?wdt [] ; wdt:P31 wd:Q5 . hint:Group hint:maxParallel 501 . } hint:Query hint:filterExists "SubQueryLimitOne" . # SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } """ % (offset, limit)) for prop in props: possible.append(prop['property']) offset += limit print (len(possible), min(offset, count)) sleep(0.25)输出的最后一行是:
2156 5154
更多推荐
如何仅获取Wikidata中特定类别的所有属性?
发布评论