选择主题和rdf:在SPARQL查询中键入(Select subjects and rdf:type in a SPARQL query)

编程入门 行业动态 更新时间:2024-10-25 17:22:06
选择主题和rdf:在SPARQL查询中键入(Select subjects and rdf:type in a SPARQL query)

我有一个SPARQL查询,如下所示,选择具有我从DBpedia定义的特定标签的主题。

SELECT ?subject WHERE { ?subject rdfs:label ?label. FILTER ( regex (?label,"^json$", "i") ) }

这个对我有用。

现在我试图通过此查询检索rdf:type每个主题的rdf:type 。

SELECT ?subject ?type WHERE { ?subject rdfs:label ?label; rdf:type ?type. FILTER ( regex (?label,"^json$", "i") ) }

但是我得到了一个空洞的结果。

如果用特定资源替换?subject ,它会再次起作用。

SELECT ?type WHERE { <http://dbpedia.org/resource/JSON> rdf:type ?type. }

无法弄清楚会发生什么。 如何按预期获得结果?

I have a SPARQL query shown below to select subjects having specific labels I defined from DBpedia.

SELECT ?subject WHERE { ?subject rdfs:label ?label. FILTER ( regex (?label,"^json$", "i") ) }

It works for me.

And now I am trying to retrieve rdf:type of each subject by this query.

SELECT ?subject ?type WHERE { ?subject rdfs:label ?label; rdf:type ?type. FILTER ( regex (?label,"^json$", "i") ) }

But I get an empty result from this.

If replacing ?subject with a specific resource, it works again.

SELECT ?type WHERE { <http://dbpedia.org/resource/JSON> rdf:type ?type. }

Cannot figure out what happens. How can I get results as expected?

最满意答案

从语法上讲,您的查询没有任何问题。 我想你看到DbPedia超时了。 尝试添加一个limit子句,看看是否能给你一些结果。

有关DbPedia 在网站上的合理使用政策的更多信息。

Syntactically, there's nothing wrong with your query. I think you're seeing a timeout from DbPedia. Try adding a limit clause, to see if that gives you some results.

There is more information on DbPedia's fair use policy on the web site.

更多推荐

本文发布于:2023-04-27 14:34:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1327134.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:主题   SPARQL   rdf   Select   type

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!