dbpedia 上的 SPARQL 查询:查找丈夫比自己年轻的女性

问题描述

我正在处理一个有趣的查询。在 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 年):

我做错了什么?

我应该切换到foaf本体吗?我是否必须使用 ^^xsd::date 显式解析日期?

注意:我有自己的 DBpedia docker-image,在 production version of DBpedia 中找到了大约 25 条记录。我想还是太少了。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...