SPARQL:从 DBpedia 中提取唯一实体

发布于 2024-12-22 23:33:38 字数 520 浏览 1 评论 0原文

考虑以下脚本:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゃ懵逼小萝莉 2024-12-29 23:33:38

正如您在运行查询时所看到的,您提到的两行都引用相同的资源:。事实上,您在查询结果中获得多行只是因为此人有多个姓名。

因此,如果您只需要确保应用程序中不会出现重复项,只需确保应用程序将查询结果中“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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文