获取DBPedia信息框类别 [英] Getting DBPedia Infobox categories

查看:75
本文介绍了获取DBPedia信息框类别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在寻找一种通过SPARQL端点查询 DBPedia的Infobox本体数据库的方法,以获取类的列表,所选类的子类以及给定类的属性。就我所能找到的而言,您要么需要知道要查找的属性,要么要搜索特定的东西-我发现的所有示例似乎都基于您想搜索特定的东西的想法。 (例如高于某个海拔的城市人口等),而我想构建一些可以有效浏览类别的东西。例如,从此类层次结构图,并向用户显示所选子类的子类列表。似乎可以通过映射Wiki浏览类似的内容,但是最好直接查询SPARQL端点。

I'm currently looking for a way to query DBPedia's Infobox Onyology database via the SPARQL endpoint to get a list of the classes, the subclasses of a selected class, and the properties of a given class. As far as I've been able to find, you either need to know the property that you are looking for or search for something specific - all the examples I've found seem predicated on the idea that you would want to search for something specific (like populations of cities above a certain elevation, etc), whereas I'd like to build something where I can effectively "browse" the categories. For example, starting with the list of subclasses of "owl:Thing" on this class hierarchy chart and presenting the user with the list of subclasses of a selected subclass. It seems possible to browse something like this via the mappings wiki, but it would be preferable to query the SPARQL endpoint directly.

是否有一些简单的SPARQL查询可以返回

Is there some simple SPARQL query that would return the available classes and properties of those classes?

更新:
我想出了一种获取类层次结构的方法通过遍历此查询:

SELECT ?subject WHERE {
     ?subject rdfs:subClassOf owl:Thing
}

返回以下子类的列表owl:Thing,如果我用其中一个子类替换owl:Thing,我将获得该子类的列表,直到没有子类为止,此时我可以选择具有所选子类给定类型的所有资源。不过,我还是不太确定如何获取子类的所有公共属性。

Which returns a list of subclasses of owl:Thing, and if I replace owl:Thing with one of the subclasses, I get the list of subclasses of that, until there are no subclasses, at which point I can select all the resources which have a type given by the chosen subclass. I'm still not quite sure how to get all the properties common to the subclass, though.

更新2
现在。该查询为我提供了所有国家的所有属性(dbpedia:property的子级)及其标题:

Update 2 Getting closer now. This query gets me all the properties (children of dbpedia:property) that are also a country, as well as their titles:

SELECT DISTINCT ?prop ?title WHERE {
     ?country ?prop ?value.
     ?country a <http://dbpedia.org/ontology/Country>.
     ?prop rdf:type rdf:Property.
     ?prop rdfs:label ?title
}

实际上我是谁真的要求。我现在要做的最后一件事是尝试按它们出现的页面数排序(大概最常见的属性将是最感兴趣的属性)。

Which is actually all I really asked for. The last thing I'm trying to do now is to try to order these by the number of pages in which they appear (presumably the most common properties will be the ones of greatest interest).

推荐答案

好,所以我实际上或多或少地确切地知道了如何做到这一点,所以我将其作为答案而不是仅仅进行了编辑。 似乎正是我想要的,首先是使用此查询

OK, so I've actually figured out more or less exactly how to do this, so I'm submitting this as an answer rather than just an edit. What seems to give me exactly what I'm looking for is to start by iterating through the class heirarchy using this query:

SELECT ?class ?label WHERE {
     ?class rdfs:subClassOf owl:Thing.
     ?class rdfs:label ?label. 
     FILTER(lang(?label) = "en")
}

一旦用户选择了他们想要的最低级别的类,就会显示一个owl。属性列表,按其出现的条目数降序排列,我使用此查询

Once the user has selected the lowest-level class that they'd like, to display a list of properties, in descending order by the number of entries in which they appear, I use this query:

SELECT ?prop ?title WHERE {
     ?country ?prop [].
     ?country a <http://dbpedia.org/ontology/Country>.
     ?prop rdf:type rdf:Property.
     ?prop rdfs:label ?title
} ORDER BY DESC(COUNT(DISTINCT ?country))

当然,如果您实际查看这些结果,那么那里会有一些时髦的属性,它们没有非常描述性的标签( s?什么?),但这至少是我想要的首先。

Of course, if you actually look at those results, there are some funky properties there that don't have very descriptive labels ("s"? What?), but this is at least what I was looking for in the first place.

这篇关于获取DBPedia信息框类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆