问题描述
我正在处理一个有趣的查询。在 dbpedia 中,我想查找与年轻男性结婚的女性的记录。或者,也可以是妻子比自己年长的丈夫。
我想出了这个 SPARQL 查询。遗憾的是它返回的记录太少,只有 n = 3。
# I always add these for easier commandline querying
prefix dbo: <http://dbpedia.org/ontology/>
prefix dbp: <http://dbpedia.org/property/>
prefix dbr: <http://dbpedia.org/resource/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-Syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix exo: <http://example.org/ontology/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?husband ?husbandBirthDate ?wife ?wifeBirthDate
WHERE {
# there are 300000 triples that use dbp:spouse
# unfortunately very few have spouses which are also in dbpedia
# and for those partners the birthDate occurs even more rarely in dbpedia
{
?husband dbp:spouse ?wife .
?husband dbp:gender ?husbandGender.
FILTER(str(?husbandGender) = "male")
?husband dbp:birthDate ?husbandBirthDate .
?wife dbp:birthDate ?wifeBirthDate .
?wife dbp:gender ?wifeGender.
FILTER(str(?wifeGender) = "female") .
FILTER (?husbandBirthDate > ?wifeBirthDate)
}
UNION
# there are ~1400 triples that use dbo:husband which means "hasHusband"
{
?wife dbp:husband ?husband .
?husband dbo:birthDate ?husbandBirthDate .
?wife dbo:birthDate ?wifeBirthDate .
FILTER (?husbandBirthDate > ?wifeBirthDate)
}
UNION
# there are ~1300 triples that use dbo:wife which means "hasWife"
{
?husband dbp:wife ?wife .
?husband dbo:birthDate ?husbandBirthDate .
?wife dbo:birthDate ?wifeBirthDate .
FILTER (?husbandBirthDate > ?wifeBirthDate)
}
}
ORDER BY ?husbandBirthDate
遗憾的是它返回的记录太少,这三个,(目前是 2020 年):
老公 | 丈夫出生日期 | 妻子 | 妻子出生日期 |
---|---|---|---|
http://dbpedia.org/resource/Karel_Kosík | 1926-06-26 | http://dbpedia.org/resource/Růžena_Grebeníčková | 1925-11-01 |
http://dbpedia.org/resource/Keiran_Lee | 1984-01-15 | http://dbpedia.org/resource/Puma_Swede | 1976-09-13 |
http://dbpedia.org/resource/Keiran_Lee | 1984-01-15 | http://dbpedia.org/resource/Kirsten_Price_(actress) | 1981-11-13 |
我做错了什么?
我应该切换到foaf
本体吗?我是否必须使用 ^^xsd::date
显式解析日期?
注意:我有自己的 DBpedia docker-image,在 production version of DBpedia 中找到了大约 25 条记录。我想还是太少了。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)