Get all properties for a DBpedia class

♀尐吖头ヾ 提交于 2019-12-17 23:38:19

问题


How to get a list of properties for a specific class? Consider the class dbpedia-owl:Person. All instances of the Person class have some properties prefixed with dbpprop:. How can I get all the dbpprop: properties that we may find for all the instance of the Person class?


回答1:


The one that works is:

select distinct ?property where { 
   ?property <http://www.w3.org/2000/01/rdf-schema#domain> 
                             <http://dbpedia.org/ontology/Person> . }

In this query you are asking for all the properties that have dbpedia:Person as rdfs:domain. This query requires a schema definition to work and sometime datasets don't really follow perfectly the schemas. For those datasets you would try this other query

select distinct ?property where {
         ?instance a <http://dbpedia.org/ontology/Person> . 
         ?instance ?property ?obj . }

This query looks at every instance of person binding every property that comes out of it. It is much harder than the first one, and in the dbpedia public instance you will get a time out. So you are better off with the first one if you want to use the public endpoint.




回答2:


To get all transitive properties you can ask this query

select distinct ?property where{
{
  ?property rdfs:domain ?class . 
  dbpedia-owl:Person rdfs:subClassOf+ ?class.
} UNION {
  ?property rdfs:domain dbpedia-owl:Person.
}}

The '+' in the 'rdfs:subClassOf' is a property path expression [1] that fetches all uperclasses of Person as well. These properties are also valid for Person.

Also note that the dbprop namespace is not recommended because the data is raw and not normalized to a datatype.

[1] http://www.w3.org/TR/2010/WD-sparql11-property-paths-20100126/

Disclosure: I am a DBpedia developer



来源:https://stackoverflow.com/questions/6943585/get-all-properties-for-a-dbpedia-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!