SPARQL 查询 - 类和子类给出类名和命名空间

发布于 2024-07-11 01:10:28 字数 55 浏览 7 评论 0原文

如何使用给定类名和命名空间的 SPARQL 查询从 RDF 数据源获取所有类属性及其子类的属性?

How can i get all the class properties and its sub classes with properties from an RDF datasource using SPARQL query given a class name and namespace?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

记忆之渊 2024-07-18 01:10:28

您是否尝试执行递归 SPARQL 查询? 换句话说,选择一个给定的个体及其所有属性。 当属性的对象是另一个个体时,选择其属性,依此类推。

我不相信 SPARQL 支持这一点。

天真的方法是做这样的事情(并且,假设您指的是个人而不是班级,这实际上符合您的要求,但不处理三元组的下一个“级别”)。

CONSTRUCT {
    ?s ?p ?o .
    ?o ?p2 ?o2 .
} WHERE {
    ?s ?p ?o .
    ?o ?p2 ?o2 .
}

请注意,如果 ?o2 是任何语句的主题,则此查询将不会返回它们。

Are you trying to do a recursive SPARQL query? In other words, select a given individual and all of it's properties. Where the object of the property is another individual, select its properties, and so on.

I don't believe SPARQL supports this.

The naive approach would be to do something like this (and, assuming you mean individuals and not classes, this actually matches your requirements but doesn't handle the next "level" of triples).

CONSTRUCT {
    ?s ?p ?o .
    ?o ?p2 ?o2 .
} WHERE {
    ?s ?p ?o .
    ?o ?p2 ?o2 .
}

Note that if ?o2 is the subjects of any statements, this query will not return them.

小傻瓜 2024-07-18 01:10:28

这个

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?subClass ?predicate 
WHERE {
   ?subClass rdfs:subClassOf <http://dbpedia.org/ontology/Work> .
   ?predicate rdfs:domain ?subClass
}

尝试一下SPARQL 工具,例如 DBPedia 的 SNORQL 接口

How about this:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?subClass ?predicate 
WHERE {
   ?subClass rdfs:subClassOf <http://dbpedia.org/ontology/Work> .
   ?predicate rdfs:domain ?subClass
}

Give it a try on a SPARQL tool such as DBPedia's SNORQL interface.

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