(This page is still under construction.)


Some help (such as sample SPARQL queries) can be found on answers.semanticweb.com and/or Stack Overflow. The most recent 10 posts for each site should be seen in the Feeds section, lower down on this page. Full searches are linked here --


If the information you need cannot be found there, you can:

  1. create a new post on one of the Overflow sites and use the tag “dbpedia”
  2. check the DBpedia support page .

Feeds

(Still not displayed correctly, we are working on aggregating the feed)

answers.semanticweb.com

how to query dbpedia using jena java?

Hello everyone and experts, i am novice user in using sparql query for dbpedia data. what I want to do is to query the Computer Scientist publications DBLP in java: like this following link do http://dbpedia.org/snorql/?query=SELECT+*+WHERE+%7B%0D%0A%3Fsubject+owl%3AsameAs+%3Flink.%0D%0A%3Fsubject+rdf%3Atype+%3Chttp%3A%2F%2Fdbpedia.org%2Fclass%2Fyago%2FProgrammer110481268%3E%0D%0A%7D+LIMIT+20 I use that query in java as follows.

String service = "http://dbpedia.org/sparql";
String query="  PREFIX owl: <http://www.w3.org/2002/07/owl#>"+
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>"+
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"+
"PREFIX foaf: <http://xmlns.com/foaf/0.1/>"+
"PREFIX dc: <http://purl.org/dc/elements/1.1/>"+
"PREFIX : <http://dbpedia.org/resource/>"+
"PREFIX dbpedia2: <http://dbpedia.org/property/>"+
"PREFIX dbpedia: <http://dbpedia.org/>"+
"PREFIX skos: <http://www.w3.org/2004/02/skos/core#>"+
    "SELECT * WHERE {"+
    "?subject owl:sameAs ?link."+
    "?subject rdf:type <http://dbpedia.org/class/yago/Programmer110481268>"+
    "} LIMIT 20";

            QueryExecution qe=QueryExecutionFactory.sparqlService(service, query);
            ResultSet rs=qe.execSelect();
            while(rs.hasNext()){
                System.out.println(rs.next());
            }

///////////////////
that code gave following error

Exception in thread "main" HttpException: java.net.SocketException: Connection reset: java.net.SocketException: Connection reset
at com.hp.hpl.jena.sparql.engine.http.HttpQuery.execCommon(HttpQuery.java:333)
................................

but the other code can link the dbpedia and give the results, but, they are not what I wanted.

String sparqlQueryString = "select distinct ?Concept where {[] a ?Concept } LIMIT 10";
Query query = QueryFactory.create(sparqlQueryString);
QueryExecution qexec = QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);

So, anyone has some idea to query in java like they do in "http://wiki.dbpedia.org/Datasets" Any help is appreciated and thanks you very much in advance.

Query combination using multiple subqueries

I want to count the predicates between two set of entities. Each set has entities of the same DBpedia class (i.e. Person or Organisation). Moreover, each entity E has a certain class C as rdf:type and no other rdf:type x where x is a subclass of C.

Hence, for retrieving one entity set (Person) we can run this query:

PREFIX dbp: <http://dbpedia.org/ontology/>
SELECT ?e1 {
    ?e1 a dbp:Person .
    FILTER NOT EXISTS { 
        ?subclass1 rdfs:subClassOf+ dbp:Person . 
        ?e1 a ?subclass1 .
        FILTER (?subclass1 != dbp:Person ) . 
    }
}

We can do the same thing for the other set (Organisation):

PREFIX dbp: <http://dbpedia.org/ontology/>
SELECT ?e2 {
    ?e2 a dbp:Organisation .
    FILTER NOT EXISTS { 
        ?subclass2 rdfs:subClassOf+ dbp:Organisation . 
        ?e2 a ?subclass2 . 
    }
}

I combined the two queries in this way for achieving the purpose described above:

PREFIX dbp: <http://dbpedia.org/ontology/>
SELECT (COUNT(?p) AS ?cont) {
    ?e1 ?p ?e2 .
    ?e1 a dbp:Person .
    ?e2 a dbp:Organisation .
    FILTER(NOT EXISTS { 
        ?subclass1 rdfs:subClassOf+ dbp:Person . 
        ?e1 a ?subclass1 .
        FILTER (?subclass1 != dbp:Person ) . 
    })
    FILTER(NOT EXISTS { 
        ?subclass2 rdfs:subClassOf+ dbp:Organisation . 
        ?e2 a ?subclass2 . 
        FILTER (?subclass2 != dbp:Organisation ) . 
    })
}

The endpoint return this error. So, i rewrite the query using subqueries (I do not perform the count for checking the entity results):

PREFIX dbp: <http://dbpedia.org/ontology/>
SELECT ?e1 ?p ?e2 {
?e1 ?p ?e2 .

{SELECT ?e1 {
    ?e1 a dbp:Person .
    FILTER NOT EXISTS { 
        ?subclass1 rdfs:subClassOf+ dbp:Person . 
        ?e1 a ?subclass1 .
        FILTER (?subclass1 != dbp:Person ) . 
    }
}}

{SELECT ?e2 {
    ?e2 a dbp:Organisation .
    FILTER NOT EXISTS { 
        ?subclass2 rdfs:subClassOf+ dbp:Organisation . 
        ?e2 a ?subclass2 . 
        FILTER (?subclass2 != dbp:Organisation ) . 
    }
}}
}

This are the results. The problem is that while the results of the two subqueries are correct, if executed separately as shown above (first two query of the answer), the results of the combination query have entities like this one. It has rdf:type dbp:Agent and dbp:Person but it has also dbp:Scientist.

Considering that the results of the subqueries (first two query of the answer) are correct, why in the combination query there's this behaviour? Why there are undesired entities that are not included in the previous queries?

I hope the answer is clear. Thank you in advance

DBpedia Entities, rdf:type and Ontology sub-classes

I'm trying to build a query that given a certain ontology class C (like Person) returns the entities that have the rdf:type C and no other rdf:type x where x is a subclass of C (Person) and it belongs to the DBpedia ontology.

Hence if an entity has rdf:type http://dbpedia.org/ontology/Person and rdf:type http://schema.org/Person is accepted. An entity with rdf:type http://dbpedia.org/ontology/Agent and rdf:type http://dbpedia.org/ontology/Person is accepted because Agent is the father of Person in the hierarchy.

I tried to write the query in this way:

PREFIX dbp: <http://dbpedia.org/ontology/>

SELECT DISTINCT ?entity {
    ?subclass rdfs:subClassOf+ dbp:Person .
    ?entity a dbp:Person .
    FILTER NOT EXISTS {?entity a ?subclass}
}

The results contain entities that do not fit my description above. For instance the second entity in the results has rdf:type Person but also Politician and President that are subclasses of Person.

Any hints to improve the query? (I know that the query can be built using a COUNT but I'm wonder if it is possible to write it also using rdfs:subClassOf and FILTER NOT EXISTS)

Thank you in advance

How to know the number of recursions needed in a (rdfs:subClassOf)* for each class found ?

Let's consider, for instance, this query - on DBPedia :

construct { 
    yago:Instrumentality103575240 rdfs:subClassOf ?class
} where {
    yago:Instrumentality103575240 (rdfs:subClassOf)* ?class .
}

Which returns

yago:Instrumentality103575240   rdfs:subClassOf yago:Whole100003553 ,
        yago:PhysicalEntity100001930 ,
        yago:Artifact100021939 ,
        yago:Instrumentality103575240 ,
        yago:Object100002684 .

How can I know, for each class, the number of rdfs:subClassOf (= nb. of recursions) that have been processed to retrieve it ? I.e., how deeply we have to go through each (top)class ? For example : yago:Artifact100021939 == 1 recursion, yago:Whole100003553 == 2 recursion, etc.

Thanks

ps: sorry for this poorly formuled question, I did not know how to explain this clearly

How to understand the use of dcterms:subject in dbpedia?

DBpedia says about Leonardo da Vinci (among other things):

dbpedia:Leonardo_da_Vinci a foaf:Person ;
    dcterms:subject category:Renaissance_painters.
category:Renaissance_painters a skos:Concept .

Since DC defines subject as "The topic of the resource" and of course FOAF defines Person as a person, my question is: How to understand a person having a topic?

Link ontologies from DBpedia to external ones with sameAS

Is there a way in SPARQL to automatically connect instances of one ontology in DBpedia and another in a different database. For example

http://yago-knowledge.org/resource/Daphne_Gere and http://dbpedia.org/page/Daphne_Gere

are similar and connect with the propriety sameAs, but I would like to be able to do it for all instances of the ontologies where they belong

http://yago-knowledge.org/resource/wordnet_actor_109765278 and http://dbpedia.org/ontology/Actor

So for example the result will be a table that has all the instances from one class with their equivalent in the other class.

Why are SPARQL FILTER directives with a Regex ignored in some queries on DBpedia?

I am trying to retrieve property URIs along with their (declared or actual) ranges from DBpedia. I want to restrict the properties to URIs that contain a certain substring.

My first attempt was this:

SELECT DISTINCT ?property ?range WHERE 
{  
   ?s ?property ?object.  
   FILTER(regex(str(?property), 'birth', 'i')).
   BIND(datatype(?object) AS ?range).
   OPTIONAL {?property <http://www.w3.org/2000/01/rdf-schema#range> ?range. }
} LIMIT 10

Upon sending this query, DBpedia returns the following values for ?property:

http://www.w3.org/1999/02/22-rdf-syntax-ns#type     
http://www.w3.org/2002/07/owl#sameAs    
http://purl.org/dc/terms/subject    
http://dbpedia.org/ontology/Person/height
http://dbpedia.org/ontology/PopulatedPlace/areaTotal
http://dbpedia.org/ontology/PopulatedPlace/populationDensity
http://dbpedia.org/ontology/Work/runtime
http://dbpedia.org/ontology/abstract
http://dbpedia.org/ontology/birthPlace
http://dbpedia.org/ontology/birthDate

Evidently, this list contains several URIs that do not contain the substring birth. (The result is the same when using the contains function rather than regex.)

If I remove the lines starting with BIND or OPTIONAL, everything is as expected:

SELECT DISTINCT ?property WHERE 
{  
   ?s ?property ?object.  
   FILTER(regex(str(?property), 'birth', 'i')).
} LIMIT 10

returns

http://dbpedia.org/ontology/birthDate
http://dbpedia.org/ontology/birthPlace
http://dbpedia.org/ontology/birthYear
http://dbpedia.org/property/birthDate
http://dbpedia.org/property/birthPlace
http://dbpedia.org/property/dateOfBirth
http://dbpedia.org/property/placeOfBirth
http://dbpedia.org/ontology/birthName
http://dbpedia.org/property/birthName
http://dbpedia.org/property/birthname

i.e. only properties whose URIs contain the substring birth.

What am I doing wrong?

Which are the DBpedia entities of type Agent that are not of type Thing?

Hi,

I'm trying to extract the DBpedia entities that has "rdf:type Agent" and has not "rdf:type owl:Thing". I wrote this query:

PREFIX dbpedia-owl: http://dbpedia.org/ontology/ SELECT ?entity { ?entity rdf:type dbpedia-owl:Agent . FILTER NOT EXISTS { ?entity rdf:type owl:Thing } }

Something strange happens in the results. The first 8 results, have "rdf:type Agent" and have not "rdf:type owl:Thing". The 9th result, Management, has no rdf:type but in the top of the page there's "An Entity of Type : Thing".

This is quite strange because in the query is specified that ?entity must be of type Agent. Moreover, the query specified to filter the entity with type owl:Thing with the FILTER operator.

How this is possible?

Thanks in advance Fabio

How to find a relationship between two resources on DBpedia?

Hello all,

if a have two resources, for example: http://dbpedia.org/resource/France and http://dbpedia.org/resource/Mitsubishi

[the Two resources : France and Mitsubishi]

How can I get the relations between these two resources using SPARQL queries?? and I mean by relation (is a - has a ) or some thing like that?

DBPedia Local Store and comparing it with other semantic database

Hello, I want to setup a local store which will have all the dbpedia data and similar semantic rdf data. I want to compare the classes and bring a union of the properties matching in all the semantic rdf files. For example if i query about a place in dbpedia and again in openlink then I want to compare the results and give more ratings to only the properties which match. Also i want the dbpedia updates to be synchronized. I also need to know what type of database table structure i will need if i have to integrate this data in my database. I need to know what hardware and software i need to do this. I also need to know whether any paid/free service is available for doing this activity. Sorry if i am not clear by i can give some more explainations.



 
There are no files on this page. [Display files/form]
There is no comment on this page. [Display comments/form]

Information

Last Modification: 2011-07-24 20:04:59 by Sebastian Hellmann