gpt4 book ai didi

sparql - 在 Wikidata 中使用 SPARQL 获取实体标签数据

转载 作者:行者123 更新时间:2023-12-02 09:24:10 25 4
gpt4 key购买 nike

我正在使用 wikidata 查询服务来获取数据:https://query.wikidata.org/
我已经设法使用 2 种方法来使用实体的标签:

  • 使用 wikibase 标签服务。例如:

  • SELECT ?spouse ?spouseLabel WHERE {
    wd:Q1744 wdt:P26 ?spouse.
    SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
    }
    }

  • 使用 rdfs:label楼盘:

  • SELECT ?spouse ?spouseLabel WHERE {
    wd:Q1744 wdt:P26 ?spouse.
    ?spouse rdfs:label ?spouseLabel. filter(lang(?spouseLabel) = "en").
    }

    然而,对于复杂的查询,第二种方法的执行速度似乎更快,这与 MediaWiki 用户手册的说明相反:

    The service is very helpful when you want to retrieve labels, as itreduces the complexity of SPARQL queries that you would otherwise needto achieve the same effect.


    ( https://www.mediawiki.org/wiki/Wikidata_query_service/User_Manual#Label_service)
    wikibase 添加了哪些我无法仅使用 rdfs:label 实现的功能?
    这似乎很奇怪,因为它们似乎都达到了相同的目的,但 rdfs:label 方法似乎更快(这是合乎逻辑的,因为查询不需要连接来自外部源的数据)。
    谢谢!

    最佳答案

    正如我从文档中了解到的那样,wikibase 标签服务通过消除显式搜索标签的需要来简化查询。在这方面,它在语法方面降低了您需要编写的查询的复杂性。

    我会假设查询随后被扩展为另一种表示形式,可能在您的第二个选项中使用 rdfs 命名空间,然后才真正解决。

    根据第二个选项更快,您是否进行了系统的基准测试?在我的几次尝试中,第一个选项更快。我会假设公共(public)端点的性能无论如何都会受到基于需求、缓存等的波动的影响,因此可能很难就类似查询的性能得出结论。

    关于sparql - 在 Wikidata 中使用 SPARQL 获取实体标签数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39264861/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com