SPARQL:从 DBpedia 中提取唯一实体
考虑以下脚本:
PREFIX category: <http://dbpedia.org/resource/Category:>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dbpedia: <http://dbpedia.org/ontology/>
SELECT DISTINCT *
WHERE {
?s dcterms:subject category:Living_people .
?s foaf:name ?name
}
LIMIT 10000
运行它时,我得到类似这样的结果:
Sir Alexander Chapman Ferguson
Sir Alex Ferguson
虽然它们是不同的条目,但它们绝对是相同的实体。因此,我想在寻址 SPARQL 端点时减少输出,即我想避免编辑输出数据,因为在这种情况下可能具有挑战性。你能帮我吗?我的查询中应该修复什么?
Consider the following script:
PREFIX category: <http://dbpedia.org/resource/Category:>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dbpedia: <http://dbpedia.org/ontology/>
SELECT DISTINCT *
WHERE {
?s dcterms:subject category:Living_people .
?s foaf:name ?name
}
LIMIT 10000
When running it, I get something like this in result:
Sir Alexander Chapman Ferguson
Sir Alex Ferguson
Though they are different entries, they are definitely the same entities. So I would like to reduce the output when addressing the SPARQL endpoint, i.e. I would like to avoid editing output data because it may be challenging in this case. Could you help me with that? What should be fixed in my query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您在运行查询时所看到的,您提到的两行都引用相同的资源:
。事实上,您在查询结果中获得多行只是因为此人有多个姓名。因此,如果您只需要确保应用程序中不会出现重复项,只需确保应用程序将查询结果中“s”的每个唯一值视为单独的人即可。
另一方面,如果您的问题是您获得一个人的多个名称,您也许可以使用其他一些属性。例如,dbpedia:fullname 仅具有单个条目,属性 dbpedia:surname 和 dbpedia:givenName 也是如此。
As you see when you run your query, both the rows that you mention refer to the same resource:
<http://dbpedia.org/resource/Alex_Ferguson>
. The fact that you get multiple rows in your query result is simply because there are multiple names for this person.So if you just need to ensure that you don't get duplicates in your application, simply make sure that your application treats each unique value for "s" in your query result as a separate person.
On the other hand, if your problem is the fact that you get multiple names for a person, you could perhaps use some other properties. For example, dbpedia:fullname only has a single entry, likewise the properties dbpedia:surname and dbpedia:givenName.