Al *_*Mac 4 properties qualifiers sparql wikidata
我正在尝试为一组担任过政治职务的人(爱丁堡大学校友)返回结果。我想返回所担任职位的标题标签,以及每个职位的开始和结束日期,许多人担任多个职位。如果这个人只担任一个职位,我似乎能够找到其中一个,或者可以让它发挥作用,但无法让两者走到一起,因为有多个办公室。
我当前的查询版本如下。这将为我提供开始和结束日期,但如果政治办公室(例如英国 [x] 议会成员)将返回标签,而不是标签, ?officeLabel 返回一个值,例如:statement/Q4668868-E3734C7D-40F0-4D4A-8208-E3D6B8C944CB
SELECT DISTINCT ?alumni ?fullName ?roleLabel ?officeLabel ?start ?end WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?alumni wdt:P69 wd:Q160302.
?alumni rdfs:label ?fullName.
?alumni wdt:P106 ?role.
#Use Values to separate out politicians - Q82955
VALUES (?role) {
(wd:Q82955)
}
#Select only where position of office is stated but make dates optional
?alumni p:P39 ?office.
OPTIONAL { ?office pq:P580 ?start. }
OPTIONAL { ?office pq:P582 ?end. }
FILTER(LANGMATCHES(LANG(?fullName), "en"))
FILTER(NOT EXISTS { FILTER(LANGMATCHES(LANG(?fullName), "en-ca")) })
FILTER(NOT EXISTS { FILTER(LANGMATCHES(LANG(?fullName), "en-gb")) })
}
ORDER BY ?fullName
LIMIT 10
Run Code Online (Sandbox Code Playgroud)
是的,我仍然被限定符和Wikidata 数据模型绊倒。
迈克尔 F. Schönitzer 的图表 - 自己的作品,基于 File:Rdf mapping.svg,CC BY 4.0,https ://commons.wikimedia.org/w/index.php?curid=63880194
p:
从“物品”走“路线”后,需要“ps:
路线”回到“简单值”。
因此,使用它稍微修改您的查询会给出我认为您想要的结果。
SELECT DISTINCT ?alumni ?fullName ?roleLabel ?officeLabel ?start ?end WHERE {
?alumni wdt:P69 wd:Q160302.
?alumni rdfs:label ?fullName.
?alumni wdt:P106 ?role.
VALUES (?role) {
(wd:Q82955)
}
?alumni p:P39 ?officeStmnt.
?officeStmnt ps:P39 ?office.
OPTIONAL { ?officeStmnt pq:P580 ?start. }
OPTIONAL { ?officeStmnt pq:P582 ?end. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
FILTER(LANGMATCHES(LANG(?fullName), "en"))
FILTER(NOT EXISTS { FILTER(LANGMATCHES(LANG(?fullName), "en-ca")) })
FILTER(NOT EXISTS { FILTER(LANGMATCHES(LANG(?fullName), "en-gb")) })
}
ORDER BY ?fullName
LIMIT 10
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
374 次 |
最近记录: |