gpt4 book ai didi

sparql - 此查询的正确 SPARQL 版本是什么?

转载 作者:行者123 更新时间:2023-12-04 00:46:35 26 4
gpt4 key购买 nike

我正在尝试通过 SPARQL 在 DBPedia.org 上运行查询。基本上,这就是我想要做的:

  • 获取 DBPedia 资源链接列表

地点

  • foaf:name (http://xmlns.com/foaf/0.1/name) 等于 PARAMETER1
  • 或者 dbpprop:companyName (http://dbpedia.org/property/companyName) 等于 PARAMETER1
  • 或者 dbpprop:name (http://dbpedia.org/property/name) 等于 PARAMETER1

  • rdf:type (http://www.w3.org/1999/02/22-rdf-syntax-ns#type) 等于 PARAMETER2
  • 或者 dbpedia-owl:type (http://dbpedia.org/ontology/type) 等于 PARAMETER2

我自己尝试过这样做,但完全没有获得任何成功的结果。

我们将不胜感激 - 谢谢!

编辑:这是我一直在处理的查询:

SELECT ?s
WHERE {
{
?s <http://xmlns.com/foaf/0.1/name> "Google Inc." .
} UNION {
?s <http://dbpedia.org/property/companyName> "Google Inc." .
} UNION {
?s <http://dbpedia.org/property/name> "Google Inc." .
}

{
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Company> .
} UNION {
?s <http://dbpedia.org/ontology/type> <http://dbpedia.org/resource/Public_company> .
}
}

最佳答案

您几乎做到了,唯一的问题是 DBPedia 中的属性值使用语言标签,并且您的查询查找具有纯文字值的名称。这个查询对我有用:

SELECT DISTINCT ?s
WHERE {
{
?s <http://xmlns.com/foaf/0.1/name> "Google Inc."@en .
} UNION {
?s <http://dbpedia.org/property/companyName> "Google Inc."@en .
} UNION {
?s <http://dbpedia.org/property/name> "Google Inc."@en .
}

{
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Company> .
} UNION {
?s <http://dbpedia.org/ontology/type> <http://dbpedia.org/resource/Public_company> .
}
}

请注意,我添加了 DISTINCT 以消除当资源具有多个值时出现的重复答案,例如对于 foaf:namedbpprop:companyName

关于sparql - 此查询的正确 SPARQL 版本是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11120344/

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